cgv
Loading...
Searching...
No Matches
console.cxx
1#include "console.h"
2#include <cgv/type/variant.h>
3
4using namespace cgv::type;
5
6#ifdef _WIN32
7#include <windows.h>
8#endif
9
10namespace cgv {
11 namespace base {
12
14console::console()
15{
16}
19{
20 static console_ptr cp(new console);
21 return cp;
22}
23
25std::string console::get_type_name() const
26{
27 return "console";
28}
29
31{
32 return "x:int32;y:int32;w:int32;h:int32;show:bool;title:string";
33}
34
35bool console::set_void(const std::string& property, const std::string& value_type, const void* value_ptr)
36{
37#if defined(_MSC_VER)
38 if (property == "x") {
39 int32_type x;
40 get_variant(x, value_type, value_ptr);
41 HWND console = GetConsoleWindow();
42 RECT rect;
43 GetWindowRect(console, &rect);
44 SetWindowPos(console,HWND_BOTTOM,x,rect.top,0,0,SWP_NOSIZE|SWP_NOZORDER);
45 return true;
46 }
47 if (property == "y") {
48 int32_type y;
49 get_variant(y, value_type, value_ptr);
50 HWND console = GetConsoleWindow();
51 RECT rect;
52 GetWindowRect(console, &rect);
53 SetWindowPos(console, HWND_BOTTOM, rect.left, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
54 return true;
55 }
56 if (property == "w") {
57 int32_type w;
58 get_variant(w, value_type, value_ptr);
59 HWND console = GetConsoleWindow();
60 RECT rect;
61 GetWindowRect(console, &rect);
62 SetWindowPos(console, HWND_BOTTOM, 0, 0, w, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER);
63 return true;
64 }
65 if (property == "h") {
66 int32_type h;
67 get_variant(h, value_type, value_ptr);
68 HWND console = GetConsoleWindow();
69 RECT rect;
70 GetWindowRect(console, &rect);
71 SetWindowPos(console, HWND_BOTTOM, 0, 0, rect.right - rect.left, h, SWP_NOMOVE | SWP_NOZORDER);
72 return true;
73 }
74#endif
75 return false;
76}
77
78bool console::get_void(const std::string& property, const std::string& value_type, void* value_ptr)
79{
80 return false;
81}
82 }
83}
bool get_void(const std::string &property, const std::string &value_type, void *value_ptr)
abstract interface for the getter of a dynamic property.
Definition console.cxx:78
std::string get_type_name() const
return "console"
Definition console.cxx:25
std::string get_property_declarations()
supported properties are x:int32;y:int32;w:int32;h:int32;show:bool;title:string
Definition console.cxx:30
bool set_void(const std::string &property, const std::string &value_type, const void *value_ptr)
abstract interface for the setter of a dynamic property.
Definition console.cxx:35
static console_ptr get_console()
return console singleton
Definition console.cxx:18
the base namespace holds the base hierarchy, support for plugin registration and signals
Definition action.cxx:4
cgv::data::ref_ptr< console, true > console_ptr
pointer to console
Definition console.h:14
namespace for compile time type information
Definition bool32_t.h:7
int int32_type
this type provides an 32 bit signed integer type
this header is dependency free
Definition print.h:11