Scope
Windows.cpp
1 #include "stdafx.h"
2 #include "Windows.h"
3 
4 namespace scope {
5  namespace parameters {
6 
7 Window::Window(void)
8  : type(L"None", L"WindowType")
9  , area(0, 0, 1024, L"Area")
10  , top(0, 0, 10000, L"Top")
11  , left(0, 0, 10000, L"Left")
12  , bottom(100, 0, 10000, L"Bottom")
13  , right(100, 0, 10000, L"Right") {
14 }
15 
16 void Window::Load(const wptree& pt) {
23 }
24 
25 void Window::Save(wptree& pt) const {
32 }
33 
34 WindowCollection::WindowCollection(void)
35  : collection(0) {
36 }
37 
38 void WindowCollection::AddWindow(const std::wstring& _type, const uint32_t& _area,HWND _hwnd) {
39  Window wnd;
40  wnd.type = _type;
41  wnd.area = _area;
42  RECT rect;
43  GetWindowRect(_hwnd, &rect);
44  wnd.top = rect.top;
45  wnd.left = rect.left;
46  wnd.bottom = rect.bottom;
47  wnd.right = rect.right;
48  collection.push_back(wnd);
49 }
50 
51 void WindowCollection::Load(const wptree& pt) {
52  try {
53  // Load until get_child throws
54  for ( uint32_t w = 0 ; w < 100 ; w++ ) {
55  Window wnd;
56  wnd.Load(pt.get_child(boost::str(boost::wformat(L"Window%d") % w)));
57  collection.push_back(wnd);
58  }
59  }
60  catch (...) { }
61 }
62 
63 void WindowCollection::Save(wptree& pt) const {
64  for ( uint32_t w = 0 ; w < collection.size() ; w++ ) {
65  wptree wt;
66  collection[w].Save(wt);
67  pt.add_child(boost::str(boost::wformat(L"Window%d") % w), wt);
68  }
69 }
70 
71 
72 }
73 }
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Windows.cpp:63
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Windows.cpp:16
ScopeNumber< uint32_t > right
right coordinate
Definition: Windows.h:32
void AddToPropertyTree(boost::property_tree::wptree &pt) const
Adds the value to a Boost property tree, using its name and value.
Definition: ScopeValue.h:103
Parameters for all frames/windows on screen.
Definition: Windows.h:12
ScopeNumber< uint32_t > bottom
bottom coordinate
Definition: Windows.h:29
ScopeNumber< uint32_t > top
top coordinate
Definition: Windows.h:23
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Windows.cpp:25
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Windows.cpp:51
void AddWindow(const std::wstring &_type, const uint32_t &_area, HWND _hwnd)
Add a window to the collection.
Definition: Windows.cpp:38
This is the include file for standard system include files, or project specific include files that ar...
ScopeString type
Type of window, e.g.
Definition: Windows.h:17
ScopeNumber< uint32_t > left
left coordinate
Definition: Windows.h:26
std::vector< Window > collection
Vector with Window.
Definition: Windows.h:48
void SetFromPropertyTree(const boost::property_tree::wptree &pt)
Set value from a Boost property, using its name as a key.
Definition: ScopeValue.h:108
ScopeNumber< uint32_t > area
For which area that window is.
Definition: Windows.h:20