forked from Mirrors/openclonk
win32: Move C4GUI::DialogWindow platform code to C4WindowWin32.cpp
parent
52e0b52ba9
commit
15ebf70ab1
|
@ -58,7 +58,8 @@ C4FullScreen::~C4FullScreen()
|
|||
|
||||
C4Window * C4FullScreen::Init(C4AbstractApp * pApp)
|
||||
{
|
||||
return Init(C4Window::W_Fullscreen, pApp, C4ENGINECAPTION);
|
||||
C4Rect r(0, 0, Config.Graphics.ResX, Config.Graphics.ResY);
|
||||
return Init(C4Window::W_Fullscreen, pApp, C4ENGINECAPTION, &r);
|
||||
}
|
||||
|
||||
void C4FullScreen::Close()
|
||||
|
|
|
@ -312,7 +312,8 @@ void C4ConsoleGUI::State::OnScriptActivate(GtkWidget* widget, gpointer data)
|
|||
|
||||
C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp* pApp)
|
||||
{
|
||||
C4Window* retval = C4Window::Init(C4Window::W_Console, pApp, LoadResStr("IDS_CNS_CONSOLE"));
|
||||
C4Rect r(0, 0, 320, 320);
|
||||
C4Window* retval = C4Window::Init(C4Window::W_Console, pApp, LoadResStr("IDS_CNS_CONSOLE"), &r);
|
||||
state->InitGUI();
|
||||
UpdateHaltCtrls(true);
|
||||
EnableControls(fGameOpen);
|
||||
|
@ -475,8 +476,6 @@ void C4ConsoleGUI::State::InitGUI()
|
|||
gtk_box_pack_start(GTK_BOX(box), txtScript, false, false, 3);
|
||||
gtk_box_pack_start(GTK_BOX(box), status_frame, false, false, 0);
|
||||
|
||||
gtk_window_set_default_size(GTK_WINDOW(GetOwner()->window), 320, 320);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(GetOwner()->window), box);
|
||||
gtk_widget_show_all(GTK_WIDGET(GetOwner()->window));
|
||||
|
||||
|
|
|
@ -32,9 +32,6 @@
|
|||
#ifndef INC_C4Gui
|
||||
#define INC_C4Gui
|
||||
|
||||
#define ConsoleDlgClassName L"C4GUIdlg"
|
||||
#define ConsoleDlgWindowStyle (WS_VISIBLE | WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX)
|
||||
|
||||
#include "C4Rect.h"
|
||||
#include "C4Shape.h"
|
||||
#include "C4FacetEx.h"
|
||||
|
@ -1952,7 +1949,7 @@ namespace C4GUI
|
|||
Dialog* pDialog;
|
||||
DialogWindow(): C4Window(), pDialog(NULL) {}
|
||||
using C4Window::Init;
|
||||
C4Window * Init(C4AbstractApp * pApp, const char * Title, C4Window * pParent, const C4Rect &rcBounds, const char *szID);
|
||||
C4Window * Init(C4AbstractApp * pApp, const char * Title, const C4Rect &rcBounds, const char *szID);
|
||||
virtual void Close();
|
||||
virtual void PerformUpdate();
|
||||
};
|
||||
|
|
|
@ -194,131 +194,25 @@ namespace C4GUI
|
|||
// DialogWindow
|
||||
|
||||
#ifdef USE_WIN32_WINDOWS
|
||||
C4Window * DialogWindow::Init(C4AbstractApp * pApp, const char * Title, C4Window * pParent, const C4Rect &rcBounds, const char *szID)
|
||||
|
||||
C4Window * DialogWindow::Init(C4AbstractApp * pApp, const char * Title, const C4Rect &rcBounds, const char *szID)
|
||||
{
|
||||
Active = true;
|
||||
// calculate required size
|
||||
RECT rtSize;
|
||||
rtSize.left = 0;
|
||||
rtSize.top = 0;
|
||||
rtSize.right = rcBounds.Wdt;
|
||||
rtSize.bottom = rcBounds.Hgt;
|
||||
if (!::AdjustWindowRectEx(&rtSize, ConsoleDlgWindowStyle, false, 0)) return false;
|
||||
// create it!
|
||||
if (!Title || !*Title) Title = "???";
|
||||
hWindow = ::CreateWindowExW (
|
||||
0,
|
||||
ConsoleDlgClassName, GetWideChar(Title),
|
||||
ConsoleDlgWindowStyle,
|
||||
CW_USEDEFAULT,CW_USEDEFAULT,rtSize.right-rtSize.left,rtSize.bottom-rtSize.top,
|
||||
pParent->hWindow,NULL,pApp->GetInstance(),NULL);
|
||||
if (hWindow)
|
||||
C4Window * result = C4Window::Init(C4Window::W_GuiWindow, pApp, Title, &rcBounds);
|
||||
if (result)
|
||||
{
|
||||
hRenderWindow = hWindow;
|
||||
// update pos
|
||||
if (szID && *szID)
|
||||
RestoreWindowPosition(hWindow, FormatString("ConsoleGUI_%s", szID).getData(), Config.GetSubkeyPath("Console"), false);
|
||||
// and show
|
||||
::ShowWindow(hWindow, SW_SHOW);
|
||||
}
|
||||
return hWindow ? this : 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
// Dialog
|
||||
LRESULT APIENTRY DialogWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// Determine dialog
|
||||
Dialog *pDlg = ::pGUI->GetDialog(hwnd);
|
||||
if (!pDlg) return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
|
||||
// Process message
|
||||
switch (uMsg)
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_KEYDOWN:
|
||||
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), !!(lParam & 0x40000000), pDlg)) return 0;
|
||||
break;
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_KEYUP:
|
||||
if (Game.DoKeyboardInput(wParam, KEYEV_Up, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), false, pDlg)) return 0;
|
||||
break;
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case WM_SYSKEYDOWN:
|
||||
if (wParam == 18) break;
|
||||
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), !!(lParam & 0x40000000), pDlg)) return 0;
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_DESTROY:
|
||||
{
|
||||
const char *szID = pDlg->GetID();
|
||||
if (szID && *szID)
|
||||
StoreWindowPosition(hwnd, FormatString("ConsoleGUI_%s", szID).getData(), Config.GetSubkeyPath("Console"), false);
|
||||
}
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_CLOSE:
|
||||
pDlg->Close(false);
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_SIZE:
|
||||
// UpdateOutputSize
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_PAINT:
|
||||
// 2do: only draw specific dlg?
|
||||
//::GraphicsSystem.Execute();
|
||||
break;
|
||||
return 0;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_LBUTTONDOWN: ::pGUI->MouseInput(C4MC_Button_LeftDown,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_LBUTTONUP: ::pGUI->MouseInput(C4MC_Button_LeftUp,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_RBUTTONDOWN: ::pGUI->MouseInput(C4MC_Button_RightDown,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_RBUTTONUP: ::pGUI->MouseInput(C4MC_Button_RightUp,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_LBUTTONDBLCLK: ::pGUI->MouseInput(C4MC_Button_LeftDouble,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_RBUTTONDBLCLK: ::pGUI->MouseInput(C4MC_Button_RightDouble,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_MOUSEMOVE:
|
||||
//SetCursor(NULL);
|
||||
::pGUI->MouseInput(C4MC_Button_None,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL);
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_MOUSEWHEEL:
|
||||
::pGUI->MouseInput(C4MC_Button_Wheel,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL);
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
bool Dialog::RegisterWindowClass(HINSTANCE hInst)
|
||||
{
|
||||
// register landscape viewport class
|
||||
WNDCLASSEXW WndClass;
|
||||
WndClass.cbSize=sizeof(WNDCLASSEX);
|
||||
WndClass.style = CS_DBLCLKS | CS_BYTEALIGNCLIENT;
|
||||
WndClass.lpfnWndProc = DialogWinProc;
|
||||
WndClass.cbClsExtra = 0;
|
||||
WndClass.cbWndExtra = 0;
|
||||
WndClass.hInstance = hInst;
|
||||
WndClass.hCursor = LoadCursor (NULL, IDC_ARROW); // - always use normal hw cursor
|
||||
WndClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
|
||||
WndClass.lpszMenuName = NULL;
|
||||
WndClass.lpszClassName = ConsoleDlgClassName;
|
||||
WndClass.hIcon = LoadIcon (hInst, MAKEINTRESOURCE (IDI_00_C4X) );
|
||||
WndClass.hIconSm = LoadIcon (hInst, MAKEINTRESOURCE (IDI_00_C4X) );
|
||||
return !!RegisterClassExW(&WndClass);
|
||||
}
|
||||
#else
|
||||
C4Window * DialogWindow::Init(C4AbstractApp * pApp, const char * Title, C4Window * pParent, const C4Rect &rcBounds, const char *szID)
|
||||
C4Window * DialogWindow::Init(C4AbstractApp * pApp, const char * Title, const C4Rect &rcBounds, const char *szID)
|
||||
{
|
||||
C4Window *result = C4Window::Init(C4Window::W_GuiWindow, pApp, Title, pParent, false);
|
||||
C4Window * result = C4Window::Init(C4Window::W_GuiWindow, pApp, Title, &rcBounds);
|
||||
if (result)
|
||||
{
|
||||
// update pos
|
||||
|
@ -364,7 +258,7 @@ namespace C4GUI
|
|||
if (pWindow) return true;
|
||||
// create it!
|
||||
pWindow = new DialogWindow();
|
||||
if (!pWindow->Init(&Application, TitleString.getData(), &Console, rcBounds, GetID()))
|
||||
if (!pWindow->Init(&Application, TitleString.getData(), rcBounds, GetID()))
|
||||
{
|
||||
delete pWindow;
|
||||
pWindow = NULL;
|
||||
|
|
|
@ -87,7 +87,10 @@ bool C4AbstractApp::GetIndexedDisplayMode(int32_t iIndex, int32_t *piXRes, int32
|
|||
|
||||
void C4AbstractApp::RestoreVideoMode() {}
|
||||
|
||||
bool C4AbstractApp::SetVideoMode(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, bool) {}
|
||||
bool C4AbstractApp::SetVideoMode(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, bool)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Copy the text to the clipboard or the primary selection
|
||||
bool C4AbstractApp::Copy(const StdStrBuf & text, bool fClipboard)
|
||||
|
@ -204,7 +207,7 @@ C4Window::~C4Window() {}
|
|||
void C4Window::EnumerateMultiSamples(std::vector<int, std::allocator<int> >&) const {}
|
||||
void C4Window::FlashWindow() {}
|
||||
bool C4Window::GetSize(C4Rect*) {return 0;}
|
||||
C4Window* C4Window::Init(C4Window::WindowKind, C4AbstractApp*, char const*, C4Window*, bool) {return this;}
|
||||
C4Window* C4Window::Init(C4Window::WindowKind, C4AbstractApp*, char const*, const C4Rect *) {return this;}
|
||||
bool C4Window::ReInit(C4AbstractApp*) {return 0;}
|
||||
bool C4Window::RestorePosition(char const*, char const*, bool) {return 0;}
|
||||
void C4Window::RequestUpdate() {}
|
||||
|
|
|
@ -217,8 +217,8 @@ C4Window * C4ViewportWindow::Init(int32_t Player)
|
|||
{
|
||||
C4Window* result;
|
||||
const char * Title = Player == NO_OWNER ? LoadResStr("IDS_CNS_VIEWPORT") : ::Players.Get(Player)->GetName();
|
||||
|
||||
result = C4Window::Init(C4Window::W_Viewport, &Application, Title);
|
||||
C4Rect r(0,0,400,250);
|
||||
result = C4Window::Init(C4Window::W_Viewport, &Application, Title, &r);
|
||||
|
||||
if (!result) return result;
|
||||
|
||||
|
|
|
@ -274,7 +274,6 @@ public:
|
|||
virtual void Close() = 0;
|
||||
// Keypress(es) translated to a char
|
||||
virtual void CharIn(const char *) { }
|
||||
virtual C4Window * Init(WindowKind windowKind, C4AbstractApp * pApp, const char * Title, C4Window * pParent = 0, bool HideCursor = true);
|
||||
|
||||
// Reinitialize the window with updated configuration settings.
|
||||
// Keep window kind, title and size as they are. Currently the only point
|
||||
|
@ -329,6 +328,7 @@ public:
|
|||
/*ClonkWindowController*/void* GetController() {return controller;}
|
||||
#endif
|
||||
protected:
|
||||
virtual C4Window * Init(WindowKind windowKind, C4AbstractApp * pApp, const char * Title, const C4Rect * size);
|
||||
friend class C4Draw;
|
||||
friend class CStdGL;
|
||||
friend class CStdGLCtx;
|
||||
|
|
|
@ -709,7 +709,7 @@ void C4Window::FlashWindow()
|
|||
//FIXME - how is this reset? gtk_window_set_urgency_hint(window, true);
|
||||
}
|
||||
|
||||
C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char * Title, C4Window * pParent, bool HideCursor)
|
||||
C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char * Title, const C4Rect * size)
|
||||
{
|
||||
Active = true;
|
||||
|
||||
|
@ -727,7 +727,6 @@ C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char
|
|||
if (windowKind == W_Viewport)
|
||||
{
|
||||
C4ViewportWindow * vw = static_cast<C4ViewportWindow *>(this);
|
||||
gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
|
||||
|
||||
// Cannot just use ScrolledWindow because this would just move
|
||||
// the GdkWindow of the DrawingArea.
|
||||
|
@ -831,6 +830,7 @@ C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char
|
|||
assert(render_widget);
|
||||
// Override gtk's default to match name/class of the XLib windows
|
||||
gtk_window_set_wmclass(GTK_WINDOW(window), C4ENGINENAME, C4ENGINENAME);
|
||||
gtk_window_set_default_size(GTK_WINDOW(window), size->Wdt, size->Hgt);
|
||||
|
||||
g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(OnDelete), this);
|
||||
handlerDestroy = g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(OnDestroyStatic), this);
|
||||
|
|
|
@ -53,7 +53,7 @@ static NSString* windowNibNameForWindowKind(C4Window::WindowKind kind)
|
|||
}
|
||||
}
|
||||
|
||||
C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, const char * Title, C4Window * pParent, bool HideCursor)
|
||||
C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, const char * Title, const C4Rect * size)
|
||||
{
|
||||
Active = true;
|
||||
|
||||
|
@ -186,4 +186,4 @@ int MK_SHIFT = NSShiftKeyMask;
|
|||
int MK_CONTROL = NSControlKeyMask;
|
||||
int MK_ALT = NSAlternateKeyMask;
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -46,8 +46,10 @@ C4Window::~C4Window ()
|
|||
Clear();
|
||||
}
|
||||
|
||||
C4Window * C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char * Title, C4Window * pParent, bool HideCursor)
|
||||
C4Window * C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char * Title, const C4Rect * size)
|
||||
{
|
||||
if (windowKind != W_Fullscreen)
|
||||
return NULL;
|
||||
Active = true;
|
||||
// SDL doesn't support multiple monitors.
|
||||
if (!SDL_SetVideoMode(Config.Graphics.ResX, Config.Graphics.ResY, Config.Graphics.BitDepth, SDL_OPENGL | (Config.Graphics.Windowed ? 0 : SDL_FULLSCREEN)))
|
||||
|
@ -55,7 +57,7 @@ C4Window * C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const cha
|
|||
Log(SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
SDL_ShowCursor(HideCursor ? SDL_DISABLE : SDL_ENABLE);
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
SetSize(Config.Graphics.ResX, Config.Graphics.ResY);
|
||||
SetTitle(Title);
|
||||
return this;
|
||||
|
|
|
@ -68,6 +68,8 @@
|
|||
|
||||
#define C4ViewportClassName L"C4Viewport"
|
||||
#define C4FullScreenClassName L"C4FullScreen"
|
||||
#define ConsoleDlgClassName L"C4GUIdlg"
|
||||
#define ConsoleDlgWindowStyle (WS_VISIBLE | WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX)
|
||||
|
||||
LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
@ -387,6 +389,77 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
LRESULT APIENTRY DialogWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// Determine dialog
|
||||
Dialog *pDlg = ::pGUI->GetDialog(hwnd);
|
||||
if (!pDlg) return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
|
||||
// Process message
|
||||
switch (uMsg)
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_KEYDOWN:
|
||||
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), !!(lParam & 0x40000000), pDlg)) return 0;
|
||||
break;
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_KEYUP:
|
||||
if (Game.DoKeyboardInput(wParam, KEYEV_Up, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), false, pDlg)) return 0;
|
||||
break;
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case WM_SYSKEYDOWN:
|
||||
if (wParam == 18) break;
|
||||
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), !!(lParam & 0x40000000), pDlg)) return 0;
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_DESTROY:
|
||||
{
|
||||
const char *szID = pDlg->GetID();
|
||||
if (szID && *szID)
|
||||
StoreWindowPosition(hwnd, FormatString("ConsoleGUI_%s", szID).getData(), Config.GetSubkeyPath("Console"), false);
|
||||
}
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_CLOSE:
|
||||
pDlg->Close(false);
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_SIZE:
|
||||
// UpdateOutputSize
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_PAINT:
|
||||
// 2do: only draw specific dlg?
|
||||
//::GraphicsSystem.Execute();
|
||||
break;
|
||||
return 0;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_LBUTTONDOWN: ::pGUI->MouseInput(C4MC_Button_LeftDown,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_LBUTTONUP: ::pGUI->MouseInput(C4MC_Button_LeftUp,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_RBUTTONDOWN: ::pGUI->MouseInput(C4MC_Button_RightDown,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_RBUTTONUP: ::pGUI->MouseInput(C4MC_Button_RightUp,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_LBUTTONDBLCLK: ::pGUI->MouseInput(C4MC_Button_LeftDouble,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_RBUTTONDBLCLK: ::pGUI->MouseInput(C4MC_Button_RightDouble,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL); break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_MOUSEMOVE:
|
||||
//SetCursor(NULL);
|
||||
::pGUI->MouseInput(C4MC_Button_None,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL);
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
case WM_MOUSEWHEEL:
|
||||
::pGUI->MouseInput(C4MC_Button_Wheel,LOWORD(lParam),HIWORD(lParam),wParam, pDlg, NULL);
|
||||
break;
|
||||
//----------------------------------------------------------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
C4Window::C4Window (): Active(false), pSurface(0), hWindow(0)
|
||||
{
|
||||
}
|
||||
|
@ -394,7 +467,7 @@ C4Window::~C4Window ()
|
|||
{
|
||||
}
|
||||
|
||||
C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, const char * Title, C4Window * pParent, bool HideCursor)
|
||||
C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, const char * Title, const C4Rect * size)
|
||||
{
|
||||
Active = true;
|
||||
if (windowKind == W_Viewport)
|
||||
|
@ -423,7 +496,7 @@ C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp,
|
|||
hWindow = CreateWindowExW (
|
||||
WS_EX_ACCEPTFILES,
|
||||
C4ViewportClassName, GetWideChar(Title), C4ViewportWindowStyle,
|
||||
CW_USEDEFAULT,CW_USEDEFAULT,400,250,
|
||||
CW_USEDEFAULT,CW_USEDEFAULT, size->Wdt, size->Hgt,
|
||||
Console.hWindow,NULL,pApp->GetInstance(),NULL);
|
||||
if(!hWindow) return NULL;
|
||||
|
||||
|
@ -451,7 +524,7 @@ C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp,
|
|||
C4FullScreenClassName,
|
||||
GetWideChar(Title),
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT,CW_USEDEFAULT, Config.Graphics.ResX, Config.Graphics.ResY,
|
||||
CW_USEDEFAULT,CW_USEDEFAULT, size->Wdt, size->Hgt,
|
||||
NULL,NULL,pApp->GetInstance(),NULL);
|
||||
if(!hWindow) return NULL;
|
||||
|
||||
|
@ -469,6 +542,48 @@ C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp,
|
|||
SetFocus(hWindow);
|
||||
#endif
|
||||
}
|
||||
else if (windowKind == W_GuiWindow)
|
||||
{
|
||||
static bool fDialogClassRegistered = false;
|
||||
if (!fDialogClassRegistered)
|
||||
{
|
||||
// register landscape viewport class
|
||||
WNDCLASSEXW WndClass;
|
||||
WndClass.cbSize=sizeof(WNDCLASSEX);
|
||||
WndClass.style = CS_DBLCLKS | CS_BYTEALIGNCLIENT;
|
||||
WndClass.lpfnWndProc = DialogWinProc;
|
||||
WndClass.cbClsExtra = 0;
|
||||
WndClass.cbWndExtra = 0;
|
||||
WndClass.hInstance = hInst;
|
||||
WndClass.hCursor = LoadCursor (NULL, IDC_ARROW); // - always use normal hw cursor
|
||||
WndClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
|
||||
WndClass.lpszMenuName = NULL;
|
||||
WndClass.lpszClassName = ConsoleDlgClassName;
|
||||
WndClass.hIcon = LoadIcon (hInst, MAKEINTRESOURCE (IDI_00_C4X) );
|
||||
WndClass.hIconSm = LoadIcon (hInst, MAKEINTRESOURCE (IDI_00_C4X) );
|
||||
if (!RegisterClassExW(&WndClass))
|
||||
return NULL;
|
||||
}
|
||||
Active = true;
|
||||
// calculate required size
|
||||
RECT rtSize;
|
||||
rtSize.left = 0;
|
||||
rtSize.top = 0;
|
||||
rtSize.right = size->Wdt;
|
||||
rtSize.bottom = size->Hgt;
|
||||
if (!::AdjustWindowRectEx(&rtSize, ConsoleDlgWindowStyle, false, 0))
|
||||
return NULL;
|
||||
// create it!
|
||||
if (!Title || !*Title) Title = "???";
|
||||
hWindow = ::CreateWindowExW(
|
||||
0,
|
||||
ConsoleDlgClassName, GetWideChar(Title),
|
||||
ConsoleDlgWindowStyle,
|
||||
CW_USEDEFAULT,CW_USEDEFAULT,rtSize.right-rtSize.left,rtSize.bottom-rtSize.top,
|
||||
pParent->hWindow,NULL,pApp->GetInstance(),NULL);
|
||||
hRenderWindow = hWindow;
|
||||
return hWindow ? this : 0;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue