OpenClonk
C4WindowWin32.cpp File Reference
#include "C4Include.h"
#include "C4ForbidLibraryCompilation.h"
#include "platform/C4Window.h"
#include "C4Version.h"
#include "editor/C4Console.h"
#include "editor/C4ViewportWindow.h"
#include "game/C4Application.h"
#include "game/C4FullScreen.h"
#include "game/C4GraphicsSystem.h"
#include "game/C4Viewport.h"
#include "graphics/C4DrawGL.h"
#include "gui/C4MouseControl.h"
#include "lib/C4Rect.h"
#include "platform/C4AppWin32Impl.h"
#include "platform/StdRegistry.h"
#include "res/resource.h"
#include "platform/C4windowswrapper.h"
#include <mmsystem.h>
#include <shellapi.h>
Include dependency graph for C4WindowWin32.cpp:

Go to the source code of this file.

Macros

#define C4ViewportClassName   L"C4Viewport"
 
#define C4FullScreenClassName   L"C4FullScreen"
 
#define ConsoleDlgClassName   L"C4GUIdlg"
 
#define ConsoleDlgWindowStyle   (WS_VISIBLE | WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX)
 
#define CDSE_ERROR(error)   case error: sLastError = LoadResStr("IDS_ERR_" #error); break
 

Functions

LRESULT APIENTRY FullScreenWinProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
bool ConsoleHandleWin32KeyboardMessage (MSG *msg)
 
LRESULT APIENTRY ViewportWinProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
LRESULT APIENTRY DialogWinProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

int GLMonitorInfoEnumCount
 

Macro Definition Documentation

◆ C4FullScreenClassName

#define C4FullScreenClassName   L"C4FullScreen"

Definition at line 43 of file C4WindowWin32.cpp.

◆ C4ViewportClassName

#define C4ViewportClassName   L"C4Viewport"

Definition at line 42 of file C4WindowWin32.cpp.

◆ CDSE_ERROR

#define CDSE_ERROR (   error)    case error: sLastError = LoadResStr("IDS_ERR_" #error); break

◆ ConsoleDlgClassName

#define ConsoleDlgClassName   L"C4GUIdlg"

Definition at line 44 of file C4WindowWin32.cpp.

◆ ConsoleDlgWindowStyle

#define ConsoleDlgWindowStyle   (WS_VISIBLE | WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX)

Definition at line 45 of file C4WindowWin32.cpp.

Function Documentation

◆ ConsoleHandleWin32KeyboardMessage()

bool ConsoleHandleWin32KeyboardMessage ( MSG *  msg)

Definition at line 252 of file C4WindowWin32.cpp.

253 {
254  switch (msg->message)
255  {
256  case WM_KEYDOWN:
257  if (Game.DoKeyboardInput(msg2scancode(msg), KEYEV_Down, !!(msg->lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(msg->lParam & 0x40000000), nullptr)) return true;
258  break;
259  case WM_KEYUP:
260  if (Game.DoKeyboardInput(msg2scancode(msg), KEYEV_Up, !!(msg->lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, nullptr)) return false;
261  break;
262  case WM_SYSKEYDOWN:
263  if (msg->wParam == 18) break; // VK_MENU (Alt)
264  if (Game.DoKeyboardInput(msg2scancode(msg), KEYEV_Down, !!(msg->lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(msg->lParam & 0x40000000), nullptr)) return false;
265  break;
266  }
267  return false;
268 
269 }
C4Game Game
Definition: C4Globals.cpp:52
@ KEYEV_Up
@ KEYEV_Down
bool DoKeyboardInput(C4KeyCode vk_code, C4KeyEventType event_type, bool alt, bool ctrl, bool shift, bool repeated, class C4GUI::Dialog *for_dialog=nullptr, bool fPlrCtrlOnly=false, int32_t strength=-1)
Definition: C4Game.cpp:2288

References C4Game::DoKeyboardInput(), and Game.

Here is the call graph for this function:

◆ DialogWinProc()

LRESULT APIENTRY DialogWinProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 494 of file C4WindowWin32.cpp.

495 {
496  // Determine dialog
497  C4GUI::Dialog *pDlg = ::pGUI->GetDialog(hwnd);
498  if (!pDlg) return DefWindowProc(hwnd, uMsg, wParam, lParam);
499 
500  POINT p;
501  p.x = GET_X_LPARAM(lParam);
502  p.y = GET_Y_LPARAM(lParam);
503 
504  // compute scancode
505  C4KeyCode scancode = (((unsigned int)lParam) >> 16) & 0xFF;
506  bool extended = ((lParam & 0x01000000) != 0);
507  ConvertToUnixScancode(wParam, &scancode, extended);
508 
509  // Process message
510  switch (uMsg)
511  {
512  //---------------------------------------------------------------------------------------------------------------------------
513  case WM_KEYDOWN:
514  if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), pDlg)) return 0;
515  break;
516  //---------------------------------------------------------------------------------------------------------------------------
517  case WM_KEYUP:
518  if (Game.DoKeyboardInput(scancode, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, pDlg)) return 0;
519  break;
520  //------------------------------------------------------------------------------------------------------------
521  case WM_SYSKEYDOWN:
522  if (wParam == 18) break;
523  if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), pDlg)) return 0;
524  break;
525  //----------------------------------------------------------------------------------------------------------------------------------
526  case WM_DESTROY:
527  {
528  const char *szID = pDlg->GetID();
529  if (szID && *szID)
530  StoreWindowPosition(hwnd, FormatString("ConsoleGUI_%s", szID).getData(), Config.GetSubkeyPath("Console"), false);
531  }
532  break;
533  //----------------------------------------------------------------------------------------------------------------------------------
534  case WM_CLOSE:
535  pDlg->Close(false);
536  break;
537  //----------------------------------------------------------------------------------------------------------------------------------
538  case WM_SIZE:
539  // UpdateOutputSize
540  break;
541  //----------------------------------------------------------------------------------------------------------------------------------
542  case WM_PAINT:
543  // 2do: only draw specific dlg?
544  break;
545  return 0;
546  //----------------------------------------------------------------------------------------------------------------------------------
547  case WM_LBUTTONDOWN: ::pGUI->MouseInput(C4MC_Button_LeftDown, p.x, p.y, wParam, pDlg, nullptr); break;
548  //----------------------------------------------------------------------------------------------------------------------------------
549  case WM_LBUTTONUP: ::pGUI->MouseInput(C4MC_Button_LeftUp, p.x, p.y, wParam, pDlg, nullptr); break;
550  //----------------------------------------------------------------------------------------------------------------------------------
551  case WM_RBUTTONDOWN: ::pGUI->MouseInput(C4MC_Button_RightDown, p.x, p.y, wParam, pDlg, nullptr); break;
552  //----------------------------------------------------------------------------------------------------------------------------------
553  case WM_RBUTTONUP: ::pGUI->MouseInput(C4MC_Button_RightUp, p.x, p.y, wParam, pDlg, nullptr); break;
554  //----------------------------------------------------------------------------------------------------------------------------------
555  case WM_LBUTTONDBLCLK: ::pGUI->MouseInput(C4MC_Button_LeftDouble, p.x, p.y, wParam, pDlg, nullptr); break;
556  //----------------------------------------------------------------------------------------------------------------------------------
557  case WM_RBUTTONDBLCLK: ::pGUI->MouseInput(C4MC_Button_RightDouble, p.x, p.y, wParam, pDlg, nullptr); break;
558  //----------------------------------------------------------------------------------------------------------------------------------
559  case WM_MOUSEMOVE:
560  ::pGUI->MouseInput(C4MC_Button_None, p.x, p.y, wParam, pDlg, nullptr);
561  break;
562  //----------------------------------------------------------------------------------------------------------------------------------
563  case WM_MOUSEWHEEL:
564  ScreenToClient(hwnd, &p);
565  ::pGUI->MouseInput(C4MC_Button_Wheel, p.x, p.y, wParam, pDlg, nullptr);
566  break;
567  //----------------------------------------------------------------------------------------------------------------------------------
568  }
569 
570  return DefWindowProc(hwnd, uMsg, wParam, lParam);
571 }
C4Config Config
Definition: C4Config.cpp:930
C4GUIScreen * pGUI
Definition: C4Gui.cpp:1191
unsigned long C4KeyCode
const int32_t C4MC_Button_None
const int32_t C4MC_Button_RightDown
const int32_t C4MC_Button_RightUp
const int32_t C4MC_Button_RightDouble
const int32_t C4MC_Button_LeftUp
const int32_t C4MC_Button_LeftDown
const int32_t C4MC_Button_LeftDouble
const int32_t C4MC_Button_Wheel
#define GET_Y_LPARAM(lp)
#define GET_X_LPARAM(lp)
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
const char * GetSubkeyPath(const char *subkey)
Definition: C4Config.cpp:806
void Close(bool fOK)
virtual const char * GetID()
Definition: C4Gui.h:2108
bool MouseInput(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam, Dialog *pDlg, class C4Viewport *pVP)
Definition: C4Gui.cpp:837
Dialog * GetDialog(C4Window *pWindow)
Definition: C4Gui.cpp:720

References GET_X_LPARAM, GET_Y_LPARAM, C4GUI::Screen::GetDialog(), and pGUI.

Here is the call graph for this function:

◆ FullScreenWinProc()

LRESULT APIENTRY FullScreenWinProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 86 of file C4WindowWin32.cpp.

87 {
88  static bool NativeCursorShown = true;
89 
90  POINT p;
91  p.x = GET_X_LPARAM(lParam);
92  p.y = GET_Y_LPARAM(lParam);
93 
94  // compute scancode
95  C4KeyCode scancode = (((unsigned int)lParam) >> 16) & 0xFF;
96  bool extended = ((lParam & 0x01000000) != 0);
97  ConvertToUnixScancode(wParam, &scancode, extended);
98 
99  // Process message
100  switch (uMsg)
101  {
102  case WM_ACTIVATE:
103  wParam = (LOWORD(wParam)==WA_ACTIVE || LOWORD(wParam)==WA_CLICKACTIVE);
104  // fall through to next case
105  case WM_ACTIVATEAPP:
106  Application.Active = wParam != 0;
107 #ifndef USE_CONSOLE
108  if (pGL)
109  {
110  if (Application.Active)
111  {
112  // restore textures
114  {
116  }
117  }
118  else
119  {
121  {
122  ::ChangeDisplaySettings(nullptr, 0);
123  ::ShowWindow(hwnd, SW_MINIMIZE);
124  }
125  }
126  }
127 #endif
128  // redraw background
130  // Redraw after task switch
131  if (Application.Active)
133  // update cursor clip
135  return false;
136  case WM_PAINT:
137  // Redraw after task switch
138  if (Application.Active)
140  break;
141  case WM_DESTROY:
142  Application.Quit();
143  return 0;
144  case WM_CLOSE:
145  FullScreen.Close();
146  return 0;
147  case MM_MCINOTIFY:
148  if (wParam == MCI_NOTIFY_SUCCESSFUL)
150  return true;
151  case WM_KEYUP:
152  if (Game.DoKeyboardInput(scancode, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, nullptr))
153  return 0;
154  break;
155  case WM_KEYDOWN:
156  if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), nullptr))
157  return 0;
158  break;
159  case WM_SYSKEYDOWN:
160  if (wParam == 18) break;
161  if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), nullptr))
162  {
163  // Remove handled message from queue to prevent Windows "standard" sound for unprocessed system message
164  MSG msg;
165  PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE);
166  return 0;
167  }
168  break;
169  case WM_CHAR:
170  {
171  // UTF-8 has 1 to 4 data bytes, and we need a terminating \0
172  char c[5] = {0,0,0,0,0};
173  if(!WideCharToMultiByte(CP_UTF8, 0L, reinterpret_cast<LPCWSTR>(&wParam), 1, c, 4, nullptr, nullptr))
174  return 0;
175  // GUI: forward
176  if (::pGUI->CharIn(c))
177  return 0;
178  return false;
179  }
180  case WM_USER_LOG:
181  if (SEqual2((const char *)lParam, "IDS_"))
182  Log(LoadResStr((const char *)lParam));
183  else
184  Log((const char *)lParam);
185  return false;
186  case WM_LBUTTONDOWN:
187  C4GUI::MouseMove(C4MC_Button_LeftDown,p.x,p.y,wParam, nullptr);
188  break;
189  case WM_LBUTTONUP: C4GUI::MouseMove(C4MC_Button_LeftUp, p.x, p.y, wParam, nullptr); break;
190  case WM_RBUTTONDOWN: C4GUI::MouseMove(C4MC_Button_RightDown, p.x, p.y, wParam, nullptr); break;
191  case WM_RBUTTONUP: C4GUI::MouseMove(C4MC_Button_RightUp, p.x, p.y, wParam, nullptr); break;
192  case WM_LBUTTONDBLCLK: C4GUI::MouseMove(C4MC_Button_LeftDouble, p.x, p.y, wParam, nullptr); break;
193  case WM_RBUTTONDBLCLK: C4GUI::MouseMove(C4MC_Button_RightDouble, p.x, p.y, wParam, nullptr); break;
194  case WM_MOUSEWHEEL:
195  // the coordinates are screen-coordinates here (but only on this uMsg),
196  // we need to convert them to client area coordinates
197  ScreenToClient(hwnd, &p);
198  C4GUI::MouseMove(C4MC_Button_Wheel, p.x, p.y, wParam, nullptr);
199  break;
200  case WM_MOUSEMOVE:
201  C4GUI::MouseMove(C4MC_Button_None, p.x, p.y, wParam, nullptr);
202  // Hide cursor in client area
203  if (NativeCursorShown)
204  {
205  NativeCursorShown = false;
206  ShowCursor(FALSE);
207  }
208  break;
209  case WM_NCMOUSEMOVE:
210  // Show cursor on window frame
211  if (!NativeCursorShown)
212  {
213  NativeCursorShown = true;
214  ShowCursor(TRUE);
215  }
216  break;
217  case WM_SIZE:
218  // Notify app about render window size change
219  switch (wParam)
220  {
221  case SIZE_RESTORED:
222  case SIZE_MAXIMIZED:
224  if(Application.pWindow) // this might be called from C4Window::Init in which case Application.pWindow is not yet set
225  ::SetWindowPos(Application.pWindow->renderwnd, nullptr, 0, 0, p.x, p.y, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOZORDER);
226  break;
227  }
228  break;
229  case WM_INPUTLANGCHANGE:
231  break;
232  case WM_SYSCOMMAND:
233  // The user pressed Alt to open the system menu. This enters a modal
234  // loop which stops us from event processing, so prevent it. Users
235  // can still open the system menu by clicking the window's icon.
236  if ((wParam & 0xFFF0) == SC_KEYMENU && lParam == 0)
237  return 0;
238  break;
239  }
240  return DefWindowProcW(hwnd, uMsg, wParam, lParam);
241 }
#define WM_USER_LOG
CStdGL * pGL
Definition: C4DrawGL.cpp:907
C4Application Application
Definition: C4Globals.cpp:44
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool Log(const char *szMessage)
Definition: C4Log.cpp:204
bool SEqual2(const char *szStr1, const char *szStr2)
Definition: Standard.cpp:204
bool SetVideoMode(int iXRes, int iYRes, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen)
Definition: C4AppSDL.cpp:354
bool Active
Definition: C4App.h:63
C4Window * pWindow
Definition: C4App.h:80
void OnKeyboardLayoutChanged() override
C4MusicSystem MusicSystem
Definition: C4Application.h:41
int GetConfigWidth()
Definition: C4Application.h:83
int GetConfigHeight()
Definition: C4Application.h:84
void OnResolutionChanged(unsigned int iXRes, unsigned int iYRes) override
void Quit() override
int32_t RefreshRate
Definition: C4Config.h:106
int32_t Monitor
Definition: C4Config.h:112
C4ConfigGraphics Graphics
Definition: C4Config.h:257
void Close() override
virtual bool CharIn(const char *c)
Definition: C4Gui.cpp:779
void MouseMove(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam, class C4Viewport *pVP)
Definition: C4Gui.h:2832

References GET_X_LPARAM, and GET_Y_LPARAM.

◆ ViewportWinProc()

LRESULT APIENTRY ViewportWinProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 271 of file C4WindowWin32.cpp.

272 {
273  // Determine viewport
274  C4Viewport *cvp;
275  if (!(cvp=::Viewports.GetViewport(hwnd)))
276  return DefWindowProcW(hwnd, uMsg, wParam, lParam);
277 
278  // compute scancode
279  C4KeyCode scancode = (((unsigned int)lParam) >> 16) & 0xFF;
280  bool extended = ((lParam & 0x01000000) != 0);
281  ConvertToUnixScancode(wParam, &scancode, extended);
282 
283  // Process message
284  switch (uMsg)
285  {
286  //---------------------------------------------------------------------------------------------------------------------------
287  case WM_KEYDOWN:
288  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
289  switch (wParam)
290  {
291  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
292  case VK_SCROLL:
293  // key bound to this specific viewport. Don't want to pass this through C4Game...
294  cvp->TogglePlayerLock();
295  break;
296  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
297  default:
298  if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), nullptr)) return 0;
299  break;
300  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
301  }
302  break;
303  //---------------------------------------------------------------------------------------------------------------------------
304  case WM_KEYUP:
305  if (Game.DoKeyboardInput(scancode, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, nullptr)) return 0;
306  break;
307  //------------------------------------------------------------------------------------------------------------
308  case WM_SYSKEYDOWN:
309  if (wParam == 18) break;
310  if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), nullptr)) return 0;
311  break;
312  //----------------------------------------------------------------------------------------------------------------------------------
313  case WM_DESTROY:
314  StoreWindowPosition(hwnd, FormatString("Viewport%i",cvp->Player+1).getData(), Config.GetSubkeyPath("Console"));
315  break;
316  //----------------------------------------------------------------------------------------------------------------------------------
317  case WM_CREATE:
318  DragAcceptFiles(hwnd, TRUE);
319  break;
320  case WM_CLOSE:
321  cvp->pWindow->Close();
322  break;
323 
324  //----------------------------------------------------------------------------------------------------------------------------------
325  case WM_DROPFILES:
326  {
327  HDROP hDrop = (HDROP)(HANDLE) wParam;
328  if (!Console.Editing) { Console.Message(LoadResStr("IDS_CNS_NONETEDIT")); return false; }
329 
330  int32_t iFileNum = DragQueryFile(hDrop,0xFFFFFFFF,nullptr,0);
331  POINT pntPoint;
332  DragQueryPoint(hDrop,&pntPoint);
333  wchar_t szFilename[500+1];
334  for (int32_t cnt=0; cnt<iFileNum; cnt++)
335  {
336  DragQueryFileW(hDrop,cnt,szFilename,500);
337  cvp->DropFile(StdStrBuf(szFilename).getData(), (float)pntPoint.x, (float)pntPoint.y);
338  }
339  DragFinish(hDrop);
340  break;
341  }
342  //----------------------------------------------------------------------------------------------------------------------------------
343  case WM_USER_DROPDEF:
344  Game.DropDef(C4ID(lParam),cvp->GetViewX()+float(LOWORD(wParam))/cvp->Zoom,cvp->GetViewY()+float(HIWORD(wParam)/cvp->Zoom));
345  break;
346  //----------------------------------------------------------------------------------------------------------------------------------
347  case WM_SIZE:
348  case WM_SIZING:
349  cvp->UpdateOutputSize();
350  break;
351  //----------------------------------------------------------------------------------------------------------------------------------
352  case WM_PAINT:
354  break;
355  //----------------------------------------------------------------------------------------------------------------------------------
356  case WM_HSCROLL:
357  switch (LOWORD(wParam))
358  {
359  case SB_THUMBTRACK:
360  case SB_THUMBPOSITION: cvp->SetViewX(float(HIWORD(wParam))/cvp->Zoom); break;
361  case SB_LINELEFT: cvp->ScrollView(-ViewportScrollSpeed, 0.0f); break;
362  case SB_LINERIGHT: cvp->ScrollView(+ViewportScrollSpeed, 0.0f); break;
363  case SB_PAGELEFT: cvp->ScrollView(-cvp->ViewWdt/cvp->Zoom, 0.0f); break;
364  case SB_PAGERIGHT: cvp->ScrollView(+cvp->ViewWdt/cvp->Zoom, 0.0f); break;
365  }
366  cvp->Execute();
368  return 0;
369  //----------------------------------------------------------------------------------------------------------------------------------
370  case WM_VSCROLL:
371  switch (LOWORD(wParam))
372  {
373  case SB_THUMBTRACK:
374  case SB_THUMBPOSITION: cvp->SetViewY(float(HIWORD(wParam))/cvp->Zoom); break;
375  case SB_LINEUP: cvp->ScrollView(0.0f,-ViewportScrollSpeed); break;
376  case SB_LINEDOWN: cvp->ScrollView(0.0f,+ViewportScrollSpeed); break;
377  case SB_PAGEUP: cvp->ScrollView(0.0f,-cvp->ViewWdt/cvp->Zoom); break;
378  case SB_PAGEDOWN: cvp->ScrollView(0.0f,+cvp->ViewWdt/cvp->Zoom); break;
379  }
380  cvp->Execute();
382  return 0;
383  //----------------------------------------------------------------------------------------------------------------------------------
384  case WM_ACTIVATE:
385  // Keep editing dialogs on top of the current viewport, but don't make them
386  // float on other windows (i.e., no HWND_TOPMOST).
387  // Also, don't use SetParent, since that activates the window, which in turn
388  // posts a new WM_ACTIVATE to us, and so on, ultimately leading to a hang.
389  if (LOWORD(wParam) == WA_INACTIVE)
390  {
391  Console.Win32KeepDialogsFloating();
392  }
393  else
394  {
395  // FALLTHROUGH
396  case WM_MOUSEACTIVATE:
397  // WM_MOUSEACTIVATE is emitted when the user hovers over a window and pushes a mouse button.
398  // Setting the window owner here avoids z-order flickering.
399  Console.Win32KeepDialogsFloating(hwnd);
400  }
401  break;
402  //----------------------------------------------------------------------------------------------------------------------------------
403  case WM_SYSCOMMAND:
404  // The user pressed Alt to open the system menu. This enters a modal
405  // loop which stops us from event processing, so prevent it. Users
406  // can still open the system menu by clicking the window's icon.
407  if ((wParam & 0xFFF0) == SC_KEYMENU && lParam == 0)
408  return 0;
409  break;
410  }
411 
412  POINT p;
413  p.x = GET_X_LPARAM(lParam);
414  p.y = GET_Y_LPARAM(lParam);
415 
416  // Viewport mouse control
418  {
419  switch (uMsg)
420  {
421  //----------------------------------------------------------------------------------------------------------------------------------
422  case WM_LBUTTONDOWN: C4GUI::MouseMove(C4MC_Button_LeftDown, p.x, p.y, wParam, cvp); break;
423  //----------------------------------------------------------------------------------------------------------------------------------
424  case WM_LBUTTONUP: C4GUI::MouseMove(C4MC_Button_LeftUp, p.x, p.y, wParam, cvp); break;
425  //----------------------------------------------------------------------------------------------------------------------------------
426  case WM_RBUTTONDOWN: C4GUI::MouseMove(C4MC_Button_RightDown, p.x, p.y, wParam, cvp); break;
427  //----------------------------------------------------------------------------------------------------------------------------------
428  case WM_RBUTTONUP: C4GUI::MouseMove(C4MC_Button_RightUp, p.x, p.y, wParam, cvp); break;
429  //----------------------------------------------------------------------------------------------------------------------------------
430  case WM_LBUTTONDBLCLK: C4GUI::MouseMove(C4MC_Button_LeftDouble, p.x, p.y, wParam, cvp); break;
431  //----------------------------------------------------------------------------------------------------------------------------------
432  case WM_RBUTTONDBLCLK: C4GUI::MouseMove(C4MC_Button_RightDouble, p.x, p.y, wParam, cvp); break;
433  //----------------------------------------------------------------------------------------------------------------------------------
434  case WM_MOUSEMOVE:
435  if ( Inside<int32_t>(p.x-cvp->DrawX,0,cvp->ViewWdt-1)
436  && Inside<int32_t>(p.y-cvp->DrawY,0,cvp->ViewHgt-1) )
437  SetCursor(nullptr);
438  C4GUI::MouseMove(C4MC_Button_None, p.x, p.y, wParam, cvp);
439  break;
440  //----------------------------------------------------------------------------------------------------------------------------------
441  case WM_MOUSEWHEEL:
442  ScreenToClient(hwnd, &p);
443  C4GUI::MouseMove(C4MC_Button_Wheel, p.x, p.y, wParam, cvp);
444  break;
445  //----------------------------------------------------------------------------------------------------------------------------------
446 
447  }
448  }
449  // Console edit cursor control
450  else
451  {
452  // The state of the ALT key is not reported in wParam for mouse messages,
453  // and for keyboard messages the key states are hidden in lParam. It's a mess. Let's just
454  // query GetKeyState().
455  DWORD dwKeyState = 0;
456  if(GetKeyState(VK_CONTROL) < 0) dwKeyState |= MK_CONTROL;
457  if(GetKeyState(VK_SHIFT) < 0) dwKeyState |= MK_SHIFT;
458  if(GetKeyState(VK_MENU) < 0) dwKeyState |= MK_ALT;
459 
460  switch (uMsg)
461  {
462  case WM_KEYDOWN:
463  Console.EditCursor.KeyDown(scancode, dwKeyState);
464  break;
465  case WM_KEYUP:
466  Console.EditCursor.KeyUp(scancode, dwKeyState);
467  break;
468  case WM_SYSKEYDOWN:
469  Console.EditCursor.KeyDown(scancode, dwKeyState);
470  break;
471  case WM_SYSKEYUP:
472  Console.EditCursor.KeyUp(scancode, dwKeyState);
473  break;
474  //----------------------------------------------------------------------------------------------------------------------------------
475  case WM_LBUTTONDOWN:
476  // movement update needed before, so target is always up-to-date
477  cvp->pWindow->EditCursorMove(p.x, p.y, dwKeyState);
478  Console.EditCursor.LeftButtonDown(dwKeyState); break;
479  //----------------------------------------------------------------------------------------------------------------------------------
480  case WM_LBUTTONUP: Console.EditCursor.LeftButtonUp(dwKeyState); break;
481  //----------------------------------------------------------------------------------------------------------------------------------
482  case WM_RBUTTONDOWN: Console.EditCursor.RightButtonDown(dwKeyState); break;
483  //----------------------------------------------------------------------------------------------------------------------------------
484  case WM_RBUTTONUP: Console.EditCursor.RightButtonUp(dwKeyState); break;
485  //----------------------------------------------------------------------------------------------------------------------------------
486  case WM_MOUSEMOVE: cvp->pWindow->EditCursorMove(p.x, p.y, dwKeyState); break;
487  //----------------------------------------------------------------------------------------------------------------------------------
488  }
489  }
490 
491  return DefWindowProcW(hwnd, uMsg, wParam, lParam);
492 }
#define WM_USER_DROPDEF
const int C4CNS_ModePlay
Definition: C4Console.h:30
C4Console Console
Definition: C4Globals.cpp:45
C4ViewportList Viewports
@ ViewportScrollSpeed
uint32_t DWORD
bool Message(const char *szMessage, bool fQuery=false)
Definition: C4Console.cpp:292
C4EditCursor EditCursor
Definition: C4Console.h:90
bool LeftButtonDown(DWORD dwKeyState)
int32_t GetMode()
bool KeyDown(C4KeyCode KeyCode, DWORD dwKeyState)
bool RightButtonDown(DWORD dwKeyState)
bool RightButtonUp(DWORD dwKeyState)
bool LeftButtonUp(DWORD dwKeyState)
bool KeyUp(C4KeyCode KeyCode, DWORD dwKeyState)
bool DropDef(C4ID id, float x, float y)
Definition: C4Game.cpp:1746
Definition: C4Id.h:26
bool IsViewport(C4Viewport *pViewport)
float Zoom
Definition: C4Viewport.h:104
int32_t ViewWdt
Definition: C4Viewport.h:36
bool UpdateOutputSize(int32_t new_width=0, int32_t new_height=0)
Definition: C4Viewport.cpp:52
std::unique_ptr< C4ViewportWindow > pWindow
Definition: C4Viewport.h:113
float GetViewY()
Definition: C4Viewport.h:78
void SetViewX(float x)
Definition: C4Viewport.cpp:888
int32_t ViewHgt
Definition: C4Viewport.h:37
bool ScrollBarsByViewPosition()
Definition: C4Console.cpp:710
void ScrollView(float by_x, float by_y)
Definition: C4Viewport.cpp:882
void SetViewY(float y)
Definition: C4Viewport.cpp:907
float GetViewX()
Definition: C4Viewport.h:76
bool TogglePlayerLock()
Definition: C4Console.cpp:711
void DropFile(const char *filename, float x, float y)
Definition: C4Viewport.cpp:47
int32_t DrawY
Definition: C4Viewport.h:41
void Execute()
Definition: C4Viewport.cpp:443
int32_t Player
Definition: C4Viewport.h:108
int32_t DrawX
Definition: C4Viewport.h:40
C4Viewport * GetViewport(int32_t player_nr, C4Viewport *prev=nullptr)
const char * getData() const
Definition: StdBuf.h:442

References C4ViewportList::GetViewport(), and Viewports.

Here is the call graph for this function:

Variable Documentation

◆ GLMonitorInfoEnumCount

int GLMonitorInfoEnumCount

Definition at line 888 of file C4WindowWin32.cpp.