OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ConsoleGUI::State Class Reference
Inheritance diagram for C4ConsoleGUI::State:
[legend]
Collaboration diagram for C4ConsoleGUI::State:
[legend]

Public Member Functions

 State (C4ConsoleGUI *console)
 
BOOL RegisterConsoleWindowClass (HINSTANCE hInst)
 
bool AddMenuItem (HMENU hMenu, DWORD dwID, const char *szString, bool fEnabled=true)
 
 State (C4ConsoleGUI *console)
 
 ~State ()
 
void CreateBitmaps (C4AbstractApp *application)
 
void UpdateMenuText (C4ConsoleGUI &console, HMENU hMenu)
 
void PropertyDlgInitLayout ()
 
void PropertyDlgUpdateSize ()
 
void ConsoleInitLayout ()
 
void ConsoleUpdateSize ()
 
class C4ConsoleGUIGetOwner ()
 

Public Attributes

HWND hPropertyDlg
 
HBITMAP hbmMouse
 
HBITMAP hbmMouse2
 
HBITMAP hbmCursor
 
HBITMAP hbmCursor2
 
HBITMAP hbmBrush
 
HBITMAP hbmBrush2
 
HBITMAP hbmPlay
 
HBITMAP hbmPlay2
 
HBITMAP hbmHalt
 
HBITMAP hbmHalt2
 
int MenuIndexFile
 
int MenuIndexPlayer
 
int MenuIndexViewport
 
int MenuIndexNet
 
int MenuIndexHelp
 
int property_dlg_inputarea_height
 
int property_dlg_margin
 
int property_dlg_okbutton_width
 
HWND console_handle
 
int console_default_width
 
int console_default_height
 
int console_margin
 
int console_wide_margin
 
int console_button_height
 
int console_ok_button_width
 
int console_status_width
 

Protected Types

typedef class InternalState
< class C4ConsoleGUI
Super
 

Detailed Description

Definition at line 652 of file C4Console.cpp.

Member Typedef Documentation

typedef class InternalState< class C4ConsoleGUI > C4ConsoleGUI::InternalState< class C4ConsoleGUI >::Super
protectedinherited

Definition at line 42 of file C4ConsoleGUI.h.

Constructor & Destructor Documentation

C4ConsoleGUI::State::State ( C4ConsoleGUI console)
inline

Definition at line 654 of file C4Console.cpp.

654 : State(C4ConsoleGUI *console): Super(console) {}
State(C4ConsoleGUI *console)
Definition: C4Console.cpp:654
class InternalState< class C4ConsoleGUI > Super
Definition: C4ConsoleGUI.h:42
C4ConsoleGUI::State::State ( C4ConsoleGUI console)
inline

Definition at line 94 of file C4ConsoleWin32.cpp.

95  {
96  hbmMouse=nullptr;
97  hbmMouse2=nullptr;
98  hbmCursor=nullptr;
99  hbmCursor2=nullptr;
100  hbmBrush=nullptr;
101  hbmBrush2=nullptr;
102  hbmPlay=nullptr;
103  hbmPlay2=nullptr;
104  hbmHalt=nullptr;
105  hbmHalt2=nullptr;
106  hPropertyDlg=nullptr;
107  MenuIndexFile = 0;
108  MenuIndexPlayer = 1;
109  MenuIndexViewport = 2;
110  MenuIndexNet = -1;
111  MenuIndexHelp = 3;
115  console_handle = nullptr;
118  console_margin = 0;
123  }
C4ConsoleGUI::State::~State ( )
inline

Definition at line 125 of file C4ConsoleWin32.cpp.

126  {
127  if (hbmMouse) DeleteObject(hbmMouse);
128  if (hbmMouse2) DeleteObject(hbmMouse2);
129  if (hbmCursor) DeleteObject(hbmCursor);
130  if (hbmCursor2) DeleteObject(hbmCursor2);
131  if (hbmBrush) DeleteObject(hbmBrush);
132  if (hbmBrush2) DeleteObject(hbmBrush2);
133  if (hbmPlay) DeleteObject(hbmPlay);
134  if (hbmPlay2) DeleteObject(hbmPlay2);
135  if (hbmHalt) DeleteObject(hbmHalt);
136  if (hbmHalt2) DeleteObject(hbmHalt2);
137  }

Member Function Documentation

bool C4ConsoleGUI::State::AddMenuItem ( HMENU  hMenu,
DWORD  dwID,
const char *  szString,
bool  fEnabled = true 
)
void C4ConsoleGUI::State::ConsoleInitLayout ( )
inline

Definition at line 227 of file C4ConsoleWin32.cpp.

References IDC_STATICTIME.

228  {
229  // Find out desired sizes and margins of elements used in console dialogue.
230  // Just remember initial layout.
231  // This is easier than getting all values from Windows metrics definitions.
232  RECT console_rc = { 0,0,356,252 };
233  ::GetWindowRect(console_handle, &console_rc);
234  console_default_width = console_rc.right - console_rc.left;
235  console_default_height = console_rc.bottom - console_rc.top;
236  console_margin = 1; // hardcoded margins
238  RECT button_rc = { 288,180,350,200 };
239  ::GetWindowRect(::GetDlgItem(console_handle, IDOK), &button_rc);
240  console_button_height = button_rc.bottom - button_rc.top;
241  console_ok_button_width = button_rc.right - button_rc.left;
242  RECT status_rc = { 222,205,350,223 };
243  ::GetWindowRect(::GetDlgItem(console_handle, IDC_STATICTIME), &status_rc);
244  console_status_width = status_rc.right - status_rc.left;
245  }
#define IDC_STATICTIME
Definition: resource.h:51
void C4ConsoleGUI::State::ConsoleUpdateSize ( )
inline

Definition at line 247 of file C4ConsoleWin32.cpp.

References console_button_height, IDC_BUTTONHALT, IDC_BUTTONMODEDRAW, IDC_BUTTONMODEEDIT, IDC_BUTTONMODEPLAY, IDC_BUTTONPLAY, IDC_COMBOINPUT, IDC_EDITOUTPUT, IDC_STATICCURSOR, IDC_STATICFRAME, and IDC_STATICTIME.

248  {
249  // Positions unknown?
250  if (!console_default_width) return;
251  // Reposition all child elements after size of console dialogue has changed
252  RECT rc = { 0,0,0,0 };
253  if (!::GetClientRect(console_handle, &rc)) return;
254  int y0 = rc.bottom - console_margin * 3 - console_button_height * 3;
255  int y1 = rc.bottom - console_margin * 2 - console_button_height * 2;
256  int y2 = rc.bottom - console_margin * 1 - console_button_height * 1;
257  int x0 = rc.right - console_margin - console_button_height;
258  // Output text box
259  ::SetWindowPos(::GetDlgItem(console_handle, IDC_EDITOUTPUT), nullptr,
261  0,
263  y0 - console_margin,
264  SWP_NOOWNERZORDER | SWP_NOZORDER);
265  // Input ComboBox
266  ::SetWindowPos(::GetDlgItem(console_handle, IDC_COMBOINPUT), nullptr,
268  y0,
269  rc.right - console_ok_button_width - console_margin * 3,
270  console_button_height,
271  SWP_NOOWNERZORDER | SWP_NOZORDER);
272  // Input OK button
273  ::SetWindowPos(::GetDlgItem(console_handle, IDOK), nullptr,
275  y0,
277  console_button_height,
278  SWP_NOOWNERZORDER | SWP_NOZORDER);
279  // Frame status bar
280  ::SetWindowPos(::GetDlgItem(console_handle, IDC_STATICFRAME), nullptr,
282  y1,
284  console_button_height,
285  SWP_NOOWNERZORDER | SWP_NOZORDER);
286  // Play button
287  ::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONPLAY), nullptr,
289  y1,
290  console_button_height,
291  console_button_height,
292  SWP_NOOWNERZORDER | SWP_NOZORDER);
293  // Halt button
294  ::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONHALT), nullptr,
295  console_margin + console_status_width + console_wide_margin * 2 + console_button_height,
296  y1,
297  console_button_height,
298  console_button_height,
299  SWP_NOOWNERZORDER | SWP_NOZORDER);
300  // Time/FPS status bar
301  ::SetWindowPos(::GetDlgItem(console_handle, IDC_STATICTIME), nullptr,
303  y1,
305  console_button_height,
306  SWP_NOOWNERZORDER | SWP_NOZORDER);
307  // Main status bar
308  ::SetWindowPos(::GetDlgItem(console_handle, IDC_STATICCURSOR), nullptr,
310  y2,
311  rc.right - 2* console_margin,
312  console_button_height,
313  SWP_NOOWNERZORDER | SWP_NOZORDER);
314  // Tool buttons
315  ::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONMODEPLAY), nullptr,
316  x0,
318  console_button_height,
319  console_button_height,
320  SWP_NOOWNERZORDER | SWP_NOZORDER);
321  ::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONMODEEDIT), nullptr,
322  x0,
323  console_margin * 2 + console_button_height,
324  console_button_height,
325  console_button_height,
326  SWP_NOOWNERZORDER | SWP_NOZORDER);
327  ::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONMODEDRAW), nullptr,
328  x0,
329  console_margin * 3 + console_button_height * 2,
330  console_button_height,
331  console_button_height,
332  SWP_NOOWNERZORDER | SWP_NOZORDER);
333  }
#define IDC_BUTTONPLAY
Definition: resource.h:37
#define IDC_STATICTIME
Definition: resource.h:51
#define IDC_EDITOUTPUT
Definition: resource.h:44
#define IDC_STATICCURSOR
Definition: resource.h:47
#define IDC_BUTTONMODEDRAW
Definition: resource.h:30
#define IDC_STATICFRAME
Definition: resource.h:48
#define IDC_BUTTONMODEEDIT
Definition: resource.h:32
#define IDC_COMBOINPUT
Definition: resource.h:40
#define IDC_BUTTONHALT
Definition: resource.h:28
#define IDC_BUTTONMODEPLAY
Definition: resource.h:34
void C4ConsoleGUI::State::CreateBitmaps ( C4AbstractApp application)
inline

Definition at line 139 of file C4ConsoleWin32.cpp.

References IDB_BRUSH, IDB_BRUSH2, IDB_CURSOR, IDB_CURSOR2, IDB_HALT, IDB_HALT2, IDB_MOUSE, IDB_MOUSE2, IDB_PLAY, and IDB_PLAY2.

140  {
141  HINSTANCE instance = application->GetInstance();
142  hbmMouse=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_MOUSE));
143  hbmMouse2=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_MOUSE2));
144  hbmCursor=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_CURSOR));
145  hbmCursor2=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_CURSOR2));
146  hbmBrush=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_BRUSH));
147  hbmBrush2=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_BRUSH2));
148  hbmPlay=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_PLAY));
149  hbmPlay2=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_PLAY2));
150  hbmHalt=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_HALT));
151  hbmHalt2=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_HALT2));
152  }
#define IDB_HALT2
Definition: resource.h:14
#define IDB_MOUSE
Definition: resource.h:17
#define IDB_PLAY2
Definition: resource.h:22
#define IDB_MOUSE2
Definition: resource.h:18
#define IDB_CURSOR2
Definition: resource.h:8
#define IDB_BRUSH
Definition: resource.h:5
#define IDB_HALT
Definition: resource.h:13
#define IDB_CURSOR
Definition: resource.h:7
#define IDB_PLAY
Definition: resource.h:21
#define IDB_BRUSH2
Definition: resource.h:6
class C4ConsoleGUI * C4ConsoleGUI::InternalState< class C4ConsoleGUI >::GetOwner ( )
inlineinherited

Definition at line 47 of file C4ConsoleGUI.h.

47 {return owner;}
void C4ConsoleGUI::State::PropertyDlgInitLayout ( )
inline

Definition at line 182 of file C4ConsoleWin32.cpp.

183  {
184  // Find out desired sizes and margins of elements used in property dialogue.
185  // Just remember initial layout.
186  // This is easier than getting all values from Windows metrics definitions.
187  RECT client_rc = { 0,0,252,101 }, button_rc = { 207,182,254,202 };
188  ::GetClientRect(hPropertyDlg, &client_rc);
189  HWND button = ::GetDlgItem(hPropertyDlg, IDOK);
190  ::GetWindowRect(button, &button_rc);
191  property_dlg_inputarea_height = button_rc.bottom - button_rc.top;
192  property_dlg_margin = 1; // hardcoded. The elements are actually placed quite poorly in the .rc, cannot derive from it
193  property_dlg_okbutton_width = button_rc.right - button_rc.left;
194  }
void C4ConsoleGUI::State::PropertyDlgUpdateSize ( )
inline

Definition at line 196 of file C4ConsoleWin32.cpp.

References IDC_COMBOINPUT, IDC_EDITOUTPUT, and property_dlg_inputarea_height.

197  {
198  // Positions unknown?
199  if (!property_dlg_inputarea_height) return;
200  // Reposition all child elements after size of property dialogue has changed
201  RECT rc = { 0,0,0,0 };
202  if (!::GetClientRect(hPropertyDlg, &rc)) return;
203  int y0 = rc.bottom - property_dlg_margin - property_dlg_inputarea_height;
204  // Output text box
205  ::SetWindowPos(::GetDlgItem(hPropertyDlg, IDC_EDITOUTPUT), nullptr,
208  rc.right - 2* property_dlg_margin,
209  y0 - 2* property_dlg_margin,
210  SWP_NOOWNERZORDER | SWP_NOZORDER);
211  // Input ComboBox
212  ::SetWindowPos(::GetDlgItem(hPropertyDlg, IDC_COMBOINPUT), nullptr,
214  y0,
216  property_dlg_inputarea_height,
217  SWP_NOOWNERZORDER | SWP_NOZORDER);
218  // OK button
219  ::SetWindowPos(::GetDlgItem(hPropertyDlg, IDOK), nullptr,
221  y0,
223  property_dlg_inputarea_height,
224  SWP_NOOWNERZORDER | SWP_NOZORDER);
225  }
#define IDC_EDITOUTPUT
Definition: resource.h:44
#define IDC_COMBOINPUT
Definition: resource.h:40
BOOL C4ConsoleGUI::State::RegisterConsoleWindowClass ( HINSTANCE  hInst)
void C4ConsoleGUI::State::UpdateMenuText ( C4ConsoleGUI console,
HMENU  hMenu 
)
inline

Definition at line 154 of file C4ConsoleWin32.cpp.

References C4Window::Active, IDM_FILE_CLOSE, IDM_FILE_OPEN, IDM_FILE_OPENWPLRS, IDM_FILE_QUIT, IDM_FILE_RECORD, IDM_FILE_SAVE, IDM_FILE_SAVEAS, IDM_FILE_SAVEGAMEAS, IDM_HELP_ABOUT, IDM_PLAYER_JOIN, IDM_VIEWPORT_NEW, LoadResStr(), LoadResStrW(), and SetMenuItemText().

155  {
156  HMENU hSubMenu;
157  if (!console.Active) return;
158  // File
159  ModifyMenuW(hMenu,MenuIndexFile,MF_BYPOSITION | MF_STRING,0,LoadResStrW("IDS_MNU_FILE"));
160  hSubMenu = GetSubMenu(hMenu,MenuIndexFile);
161  SetMenuItemText(hSubMenu,IDM_FILE_OPEN,LoadResStr("IDS_MNU_OPEN"));
162  SetMenuItemText(hSubMenu,IDM_FILE_OPENWPLRS,LoadResStr("IDS_MNU_OPENWPLRS"));
163  SetMenuItemText(hSubMenu,IDM_FILE_RECORD,LoadResStr("IDS_MNU_RECORD"));
164  SetMenuItemText(hSubMenu,IDM_FILE_SAVE,LoadResStr("IDS_MNU_SAVESCENARIO"));
165  SetMenuItemText(hSubMenu,IDM_FILE_SAVEAS,LoadResStr("IDS_MNU_SAVESCENARIOAS"));
166  SetMenuItemText(hSubMenu,IDM_FILE_SAVEGAMEAS,LoadResStr("IDS_MNU_SAVEGAMEAS"));
167  SetMenuItemText(hSubMenu,IDM_FILE_CLOSE,LoadResStr("IDS_MNU_CLOSE"));
168  SetMenuItemText(hSubMenu,IDM_FILE_QUIT,LoadResStr("IDS_MNU_QUIT"));
169  // Player
170  ModifyMenuW(hMenu,MenuIndexPlayer,MF_BYPOSITION | MF_STRING,0,LoadResStrW("IDS_MNU_PLAYER"));
171  hSubMenu = GetSubMenu(hMenu,MenuIndexPlayer);
172  SetMenuItemText(hSubMenu,IDM_PLAYER_JOIN,LoadResStr("IDS_MNU_JOIN"));
173  // Viewport
174  ModifyMenuW(hMenu,MenuIndexViewport,MF_BYPOSITION | MF_STRING,0,LoadResStrW("IDS_MNU_VIEWPORT"));
175  hSubMenu = GetSubMenu(hMenu,MenuIndexViewport);
176  SetMenuItemText(hSubMenu,IDM_VIEWPORT_NEW,LoadResStr("IDS_MNU_NEW"));
177  // Help
178  hSubMenu = GetSubMenu(hMenu,MenuIndexHelp);
179  SetMenuItemText(hSubMenu,IDM_HELP_ABOUT,LoadResStr("IDS_MENU_ABOUT"));
180  }
#define IDM_FILE_QUIT
Definition: resource.h:84
#define IDM_FILE_SAVEGAMEAS
Definition: resource.h:87
#define IDM_PLAYER_JOIN
Definition: resource.h:89
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
#define IDM_FILE_OPEN
Definition: resource.h:82
#define IDM_VIEWPORT_NEW
Definition: resource.h:93
#define IDM_FILE_OPENWPLRS
Definition: resource.h:83
bool SetMenuItemText(HMENU hMenu, WORD id, const char *szText)
#define IDM_HELP_ABOUT
Definition: resource.h:88
#define IDM_FILE_SAVE
Definition: resource.h:85
#define IDM_FILE_SAVEAS
Definition: resource.h:86
bool Active
Definition: C4Window.h:273
StdStrBuf::wchar_t_holder LoadResStrW(const char *id)
#define IDM_FILE_CLOSE
Definition: resource.h:81
#define IDM_FILE_RECORD
Definition: resource.h:98

Here is the call graph for this function:

Member Data Documentation

int C4ConsoleGUI::State::console_button_height

Definition at line 90 of file C4ConsoleWin32.cpp.

Referenced by ConsoleUpdateSize().

int C4ConsoleGUI::State::console_default_height

Definition at line 87 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::console_default_width

Definition at line 87 of file C4ConsoleWin32.cpp.

HWND C4ConsoleGUI::State::console_handle

Definition at line 86 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::console_margin

Definition at line 88 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::console_ok_button_width

Definition at line 91 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::console_status_width

Definition at line 92 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::console_wide_margin

Definition at line 89 of file C4ConsoleWin32.cpp.

HBITMAP C4ConsoleGUI::State::hbmBrush

Definition at line 72 of file C4ConsoleWin32.cpp.

HBITMAP C4ConsoleGUI::State::hbmBrush2

Definition at line 73 of file C4ConsoleWin32.cpp.

HBITMAP C4ConsoleGUI::State::hbmCursor

Definition at line 70 of file C4ConsoleWin32.cpp.

HBITMAP C4ConsoleGUI::State::hbmCursor2

Definition at line 71 of file C4ConsoleWin32.cpp.

HBITMAP C4ConsoleGUI::State::hbmHalt

Definition at line 76 of file C4ConsoleWin32.cpp.

HBITMAP C4ConsoleGUI::State::hbmHalt2

Definition at line 77 of file C4ConsoleWin32.cpp.

HBITMAP C4ConsoleGUI::State::hbmMouse

Definition at line 68 of file C4ConsoleWin32.cpp.

HBITMAP C4ConsoleGUI::State::hbmMouse2

Definition at line 69 of file C4ConsoleWin32.cpp.

HBITMAP C4ConsoleGUI::State::hbmPlay

Definition at line 74 of file C4ConsoleWin32.cpp.

HBITMAP C4ConsoleGUI::State::hbmPlay2

Definition at line 75 of file C4ConsoleWin32.cpp.

HWND C4ConsoleGUI::State::hPropertyDlg

Definition at line 67 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::MenuIndexFile

Definition at line 78 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::MenuIndexHelp

Definition at line 82 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::MenuIndexNet

Definition at line 81 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::MenuIndexPlayer

Definition at line 79 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::MenuIndexViewport

Definition at line 80 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::property_dlg_inputarea_height

Definition at line 83 of file C4ConsoleWin32.cpp.

Referenced by PropertyDlgUpdateSize().

int C4ConsoleGUI::State::property_dlg_margin

Definition at line 84 of file C4ConsoleWin32.cpp.

int C4ConsoleGUI::State::property_dlg_okbutton_width

Definition at line 85 of file C4ConsoleWin32.cpp.


The documentation for this class was generated from the following files: