29 #include "../../idlib/precompiled.h"
34 #include "../../sys/win32/rc/guied_resource.h"
35 #include "../../ui/DeviceContext.h"
41 static const int IDM_WINDOWCHILD = 1000;
42 static const int ID_GUIED_FILE_MRU1 = 10000;
44 static INT_PTR CALLBACK AboutDlg_WndProc ( HWND hwnd,
UINT msg, WPARAM wParam,
LPARAM lParam )
49 EndDialog ( hwnd, 1 );
97 memset ( &wndClass, 0,
sizeof(wndClass) );
98 wndClass.cbSize =
sizeof(WNDCLASSEX);
99 wndClass.lpszClassName =
"QUAKE4_GUIEDITOR_CLASS";
101 wndClass.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE + 1);
102 wndClass.hCursor = LoadCursor((HINSTANCE)
NULL, IDC_ARROW);
105 RegisterClassEx ( &wndClass );
107 wndClass.lpszMenuName =
NULL;
109 wndClass.lpszClassName =
"QUAKE4_GUIEDITOR_CHILD_CLASS";
110 wndClass.style = CS_OWNDC|CS_DBLCLKS|CS_BYTEALIGNWINDOW|CS_VREDRAW|CS_HREDRAW;
111 wndClass.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
112 RegisterClassEx ( &wndClass );
115 mMDIFrame = CreateWindow (
"QUAKE4_GUIEDITOR_CLASS",
116 "Quake IV GUI Editor",
117 WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS,
118 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
129 CLIENTCREATESTRUCT ccs;
130 ccs.hWindowMenu = GetSubMenu ( GetMenu (
mMDIFrame ), 5 );
131 ccs.idFirstChild = IDM_WINDOWCHILD;
132 mMDIClient = CreateWindow (
"MDICLIENT", NULL,
133 WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
173 active = (HWND)SendMessage (
mMDIClient, WM_MDIGETACTIVE, 0,
NULL );
200 if ( msg->message == WM_SYSCHAR )
211 focus = GetActiveWindow ( );
223 if ( TranslateMDISysAccel (
mMDIClient, msg ) )
247 workspace->
Render ( hDC );
248 ReleaseDC ( wnd, hDC );
280 GetClientRect ( hWnd, &rClient );
284 rClient.bottom -= (rStatus.bottom-rStatus.top);
286 MoveWindow ( app->
mMDIClient, 0, 0, rClient.right-rClient.left, rClient.bottom-rClient.top,
FALSE );
313 case WM_INITMENUPOPUP:
320 SendMessage ( app->
mWorkspaces[0]->GetWindow ( ), WM_CLOSE, 0, 0 );
346 cs = (LPCREATESTRUCT) lParam;
347 app = (
rvGEApp*)cs->lpCreateParams;
351 SetWindowLong ( hWnd, GWL_USERDATA, (
LONG)app );
353 app->mMDIFrame = hWnd;
355 app->InitRecentFiles ( );
356 app->UpdateRecentFiles ( );
363 app->mToolWindows.Append ( app->mMDIFrame );
364 app->mToolWindows.Append ( app->mNavigator.GetWindow ( ) );
365 app->mToolWindows.Append ( app->mProperties.GetWindow ( ) );
366 app->mToolWindows.Append ( app->mTransformer.GetWindow ( ) );
368 SendMessage ( app->mNavigator.GetWindow ( ), WM_NCACTIVATE,
true, (
LONG)-1 );
369 SendMessage ( app->mProperties.GetWindow ( ), WM_NCACTIVATE,
true, (
LONG)-1 );
370 SendMessage ( app->mTransformer.GetWindow ( ), WM_NCACTIVATE,
true, (
LONG)-1 );
376 return DefFrameProc ( hWnd, app?app->
mMDIClient:
NULL, uMsg, wParam, lParam );
404 LPMDICREATESTRUCT mdics;
409 cs = (LPCREATESTRUCT) lParam;
410 mdics = (LPMDICREATESTRUCT) cs->lpCreateParams;
414 workspace->
Attach ( hWnd );
423 if ( (HWND)lParam == hWnd )
430 else if ( lParam ==
NULL )
453 dc = BeginPaint(hWnd, &ps);
466 return DefMDIChildProc ( hWnd, uMsg, wParam, lParam );
481 if ( workspace->
IsNew ( ) || filename ==
NULL )
484 char szFile[MAX_PATH];
489 ZeroMemory(&ofn,
sizeof(OPENFILENAME));
490 ofn.lStructSize =
sizeof(OPENFILENAME);
492 ofn.lpstrFile = szFile;
493 ofn.nMaxFile =
sizeof(szFile);
494 ofn.lpstrFilter =
"GUI Files\0*.GUI\0All Files\0*.*\0";
495 ofn.nFilterIndex = 1;
496 ofn.Flags = OFN_PATHMUSTEXIST;
499 if ( !GetSaveFileName(&ofn) )
504 realFilename = ofn.lpstrFile;
506 realFilename.
Append (
".gui" );
509 if ( _taccess ( realFilename, 0 ) == 0 )
511 if ( IDNO ==
MessageBox (
va(
"File '%s' already exists. Do you want to replace it?", realFilename.
c_str()), MB_YESNO|MB_ICONQUESTION ) )
519 realFilename = filename;
523 if ( workspace->
SaveFile ( realFilename ) )
553 switch ( LOWORD ( wParam ) )
568 if ( IDYES ==
MessageBox (
va(
"Are you sure you want to undo the checkout of the file '%s'?",workspace->
GetFilename()), MB_YESNO|MB_ICONQUESTION) )
575 SetCursor ( LoadCursor (
NULL, MAKEINTRESOURCE(IDC_WAIT) ) );
578 SetCursor ( LoadCursor (
NULL, MAKEINTRESOURCE(IDC_ARROW) ) );
588 workspace->
Paste ( );
746 SendMessage (
mMDIClient, WM_MDICASCADE, 0, 0 );
756 SendMessage (
mMDIFrame, WM_SIZE, 0, MAKELONG ( rWindow.right-rWindow.left, rWindow.bottom-rWindow.top ) );
836 SendMessage ( active, WM_CLOSE, 0, 0 );
857 char szFile[MAX_PATH] =
"";
860 ZeroMemory(&ofn,
sizeof(OPENFILENAME));
861 ofn.lStructSize =
sizeof(OPENFILENAME);
863 ofn.lpstrFile = szFile;
864 ofn.nMaxFile =
sizeof(szFile);
865 ofn.lpstrFilter =
"GUI Files\0*.GUI\0All Files\0*.*\0";
866 ofn.nFilterIndex = 1;
867 ofn.lpstrFileTitle =
NULL;
868 ofn.nMaxFileTitle = 0;
869 ofn.lpstrInitialDir =
NULL;
870 ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
873 if (GetOpenFileName(&ofn)==
TRUE)
893 int cMenuItems = GetMenuItemCount((HMENU)wParam);
900 hmenu = (HMENU) wParam;
905 for (nPos = 0; nPos < cMenuItems; nPos++)
907 id = GetMenuItemID(hmenu, nPos);
913 HMENU sub = GetSubMenu ( hmenu, nPos );
926 CheckMenuItem ( hmenu,
id, flags );
931 CheckMenuItem ( hmenu,
id, flags );
936 CheckMenuItem ( hmenu,
id, flags );
941 CheckMenuItem ( hmenu,
id, flags );
990 EnableMenuItem ( hmenu, nPos, MF_GRAYED|MF_BYPOSITION );
1006 info.cbSize =
sizeof(info);
1007 info.fMask = MIIM_STATE|MIIM_TYPE;
1008 info.fType = MFT_STRING;
1012 undo =
"Undo\tCtrl+Z";
1013 info.fState = MFS_GRAYED;
1019 undo.
Append (
"\tCtrl+Z" );
1020 info.fState = MFS_ENABLED;
1023 info.dwTypeData = (LPSTR)undo.
c_str();
1024 info.cch = undo.
Length ( );
1026 SetMenuItemInfo ( hmenu,
id,
FALSE, &info );
1036 info.cbSize =
sizeof(info);
1037 info.fMask = MIIM_STATE|MIIM_TYPE;
1038 info.fType = MFT_STRING;
1042 undo =
"Redo\tCtrl+Y";
1043 info.fState = MFS_GRAYED;
1049 undo.
Append (
"\tCtrl+Y" );
1050 info.fState = MFS_ENABLED;
1053 info.dwTypeData = (LPSTR)undo.
c_str();
1054 info.cch = undo.
Length ( );
1056 SetMenuItemInfo ( hmenu,
id,
FALSE, &info );
1063 CheckMenuItem ( hmenu,
id, flags );
1068 CheckMenuItem ( hmenu,
id, flags );
1082 EnableMenuItem ( hmenu, nPos, MF_ENABLED|MF_BYPOSITION);
1090 EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->
GetSelectionMgr().
Num()>0?MF_ENABLED:MF_GRAYED) );
1095 EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->
GetClipboard().
Num()>0?MF_ENABLED:MF_GRAYED) );
1105 EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->
GetSelectionMgr().
Num()==1?MF_ENABLED:MF_GRAYED) );
1119 EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->
GetSelectionMgr().
Num()>1?MF_ENABLED:MF_GRAYED) );
1153 child = CreateMDIWindow(
"QUAKE4_GUIEDITOR_CHILD_CLASS",
1155 WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_HSCROLL|WS_VSCROLL|WS_MAXIMIZE,
1164 ShowWindow ( child, SW_SHOW );
1194 SetCursor ( LoadCursor (
NULL, MAKEINTRESOURCE(IDC_WAIT ) ) );
1197 error =
va(
"Failed to parse '%s'", filename );
1200 if ( workspace->
LoadFile ( filename, &error ) )
1204 child = CreateMDIWindow(
"QUAKE4_GUIEDITOR_CHILD_CLASS",
1206 WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_HSCROLL|WS_VSCROLL|WS_MAXIMIZE,
1215 ShowWindow ( child, SW_SHOW );
1227 SetCursor ( LoadCursor (
NULL, MAKEINTRESOURCE(IDC_ARROW ) ) );
1248 for ( i = 0; i <
count; i ++ )
1289 ZeroMemory ( &info,
sizeof(info) );
1290 info.cbSize =
sizeof(info);
1291 info.fMask = MIIM_FTYPE;
1293 if ( !(info.fType & MFT_SEPARATOR ) )
1302 UINT id = ID_GUIED_FILE_MRU1 +
j;
1341 keepActive = ( wParam != 0 );
1356 return DefWindowProc ( hwnd, WM_NCACTIVATE, keepActive, 0 );
1370 return DefWindowProc ( hwnd, WM_NCACTIVATE, keepActive, lParam );
1382 return ::MessageBox (
mMDIFrame, text,
"Quake 4 GUI Editor", flags );
bool GEOptionsDlg_DoModal(HWND parent)
void Resize(int width, int height)
idList< rvGEClipboardItem * > GetClipboard(void)
rvGEProperties mProperties
#define ID_GUIED_ITEM_ALIGNMIDDLES
#define ID_GUIED_FILE_SAVEAS
#define ID_GUIED_ITEM_NEWCHOICEDEF
#define ID_GUIED_ITEM_ARRANGESENDBACKWARD
#define ID_GUIED_ITEM_PROPERTIES
bool GetNavigatorVisible(void)
#define IDR_GUIED_ACCELERATORS
#define ID_GUIED_ITEM_ALIGNCENTERS
#define ID_GUIED_ITEM_NEWLISTDEF
assert(prefInfo.fullscreenBtn)
virtual const char * GetName(void)
#define ID_GUIED_HELP_ABOUT
#define ID_GUIED_FILE_EXIT
#define ID_GUIED_SOURCECONTROL_CHECKOUT
#define ID_GUIED_ITEM_NEWBINDDEF
bool EditSelectedScripts(void)
bool GetPropertiesVisible(void)
#define ID_GUIED_TOOLS_VIEWER
bool SaveFile(const char *filename)
#define ID_GUIED_ITEM_ARRANGEMAKECHILD
CONST PIXELFORMATDESCRIPTOR UINT
#define ID_GUIED_ITEM_NEWHTMLDEF
bool LoadFile(const char *filename, idStr *error=NULL)
void HandleMessage(UINT msg, WPARAM wParam, LPARAM lParam)
ESourceControlState GetSourceControlState(void)
void SetWindowPlacement(const char *name, HWND hwnd)
#define ID_GUIED_ITEM_ALIGNTOPS
static LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
idList< rvGEWorkspace * > mWorkspaces
#define ID_GUIED_VIEW_STATUSBAR
void SendSelectedToBack(void)
#define ID_GUIED_SOURCECONTROL_GETLATESTVERSION
#define ID_GUIED_FILE_SAVE
#define ID_GUIED_ITEM_ALIGNRIGHTS
#define ID_GUIED_EDIT_REDO
#define ID_GUIED_VIEW_SHOWHIDDEN
void SendSelectedBackward(void)
rvGEProperties & GetProperties(void)
const char * GetFilename(void)
#define ID_GUIED_ITEM_MAKESAMESIZEHEIGHT
bool GetTransformerVisible(void)
bool TranslateAccelerator(LPMSG msg)
bool GetWindowPlacement(const char *name, HWND hwnd)
rvGEWorkspace * GetActiveWorkspace(HWND *retwnd=NULL)
HINSTANCE GetInstance(void)
#define ID_GUIED_SOURCECONTROL_UNDOCHECKOUT
int Icmp(const char *text) const
#define ID_GUIED_ITEM_ARRANGEBRINGFORWARD
rvGETransformer & GetTransformer(void)
void BringSelectedForward(void)
#define ID_GUIED_ITEM_SCRIPTS
void SetWorkspace(rvGEWorkspace *workspace)
#define ID_GUIED_FILE_NEW
virtual void BufferCommandText(cmdExecution_t exec, const char *text)=0
void UpdateRecentFiles(void)
#define ID_GUIED_VIEW_ZOOMOUT
#define ID_GUIED_VIEW_ZOOMIN
GLuint GLuint GLsizei count
rvGEModifierStack & GetModifierStack(void)
#define ID_GUIED_FILE_CLOSE
#define ID_GUIED_VIEW_UNHIDESELECTED
#define ID_GUIED_WINDOW_CASCADE
idStr & StripFileExtension(void)
#define ID_GUIED_WINDOW_SHOWNAVIGATOR
rvGEApp * GetApplication(void)
#define ID_GUIED_ITEM_MAKESAMESIZEBOTH
#define ID_GUIED_VIEW_SNAPTOGRID
#define ID_GUIED_VIEW_HIDESELECTED
#define ID_GUIED_WINDOW_TILE
void SetGridSnap(bool snap)
void DeleteSelected(void)
void AddRecentFile(const char *filename)
bool GetGridVisible(void)
void SetGridVisible(bool vis)
#define ID_GUIED_WINDOW_SHOWTRANSFORMER
int MessageBox(const char *text, int flags)
rvGESelectionMgr & GetSelectionMgr(void)
const char * GetRecentFile(int index)
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
#define ID_GUIED_EDIT_COPY
#define ID_GUIED_TOOLS_RELOADMATERIALS
#define ID_GUIED_FILE_MRU
void SetWorkspace(rvGEWorkspace *workspace)
rvGEModifier * GetUndoModifier(void)
static rvGEWorkspace * GetWorkspace(HWND wnd)
#define ID_GUIED_ITEM_NEWRENDERDEF
#define ID_GUIED_ITEM_ARRANGESENDTOBACK
int ToolWindowActivate(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
#define ID_GUIED_EDIT_DELETE
void MakeSelectedAChild(void)
void BringSelectedToFront(void)
int Append(const type &obj)
rvGENavigator & GetNavigator(void)
bool OpenFile(const char *filename)
idList< HWND > mToolWindows
void AlignSelected(EItemAlign align)
void Append(const char a)
bool GetStatusBarVisible(void)
void UnhideSelected(void)
#define ID_GUIED_ITEM_ALIGNBOTTOMS
#define ID_GUIED_EDIT_UNDO
bool OpenFile(const char *filename)
#define ID_GUIED_SOURCECONTROL_CHECKIN
rvGEStatusBar & GetStatusBar(void)
typedef LPVOID(WINAPI *PFNWGLCREATEIMAGEBUFFERI3DPROC)(HDC hDC
void MakeSelectedSameSize(bool width, bool height)
void HandleCommandSave(rvGEWorkspace *workspace, const char *filename)
const char * c_str(void) const
#define ID_GUIED_ITEM_ALIGNLEFTS
void SetSimple(bool simple)
#define ID_GUIED_WINDOW_SHOWPROPERTIES
#define ID_GUIED_ITEM_MAKESAMESIZEWIDTH
rvGETransformer mTransformer
char * va(const char *fmt,...)
bool InitRecentFiles(void)
static LRESULT CALLBACK MDIChildProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define ID_GUIED_VIEW_SHOWGRID
bool EditSelectedProperties(void)
rvGEModifier * GetRedoModifier(void)
#define ID_GUIED_ITEM_NEWEDITDEF
#define ID_GUIED_FILE_OPEN
#define ID_GUIED_ITEM_NEWWINDOWDEF
#define ID_GUIED_VIEW_OPTIONS
idWindow * AddWindow(rvGEWindowWrapper::EWindowType type)
virtual void ActivateTool(bool active)=0
int HandleCommand(WPARAM wParam, LPARAM lParam)
bool Remove(const type &obj)
#define ID_GUIED_EDIT_PASTE
int GetRecentFileCount(void)
int HandleInitMenu(WPARAM wParam, LPARAM lParam)
#define ID_GUIED_ITEM_ARRANGEBRINGTOFRONT
static const int MAX_MRU_SIZE
void Sys_GrabMouseCursor(bool)
#define ID_GUIED_ITEM_NEWSLIDERDEF