2011-11-22 21:28:15 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 GPL Source Code
|
2011-12-06 18:20:15 +00:00
|
|
|
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
|
2011-11-22 21:28:15 +00:00
|
|
|
|
2011-12-06 16:14:59 +00:00
|
|
|
This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
Doom 3 Source Code is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Doom 3 Source Code is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
|
|
|
|
|
|
|
|
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../../idlib/precompiled.h"
|
|
|
|
#pragma hdrstop
|
|
|
|
|
|
|
|
#include <io.h>
|
|
|
|
|
|
|
|
#include "../../sys/win32/rc/guied_resource.h"
|
|
|
|
#include "../../ui/DeviceContext.h"
|
|
|
|
|
|
|
|
#include "GEApp.h"
|
|
|
|
#include "GEOptionsDlg.h"
|
|
|
|
#include "GEViewer.h"
|
|
|
|
|
|
|
|
static const int IDM_WINDOWCHILD = 1000;
|
|
|
|
static const int ID_GUIED_FILE_MRU1 = 10000;
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK AboutDlg_WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
switch ( msg )
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
|
|
|
EndDialog ( hwnd, 1 );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rvGEApp::rvGEApp ( )
|
|
|
|
{
|
|
|
|
mMDIFrame = NULL;
|
|
|
|
mMDIClient = NULL;
|
|
|
|
mRecentFileMenu = NULL;
|
|
|
|
mViewer = NULL;
|
|
|
|
mRecentFileInsertPos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
rvGEApp::~rvGEApp ( )
|
|
|
|
{
|
|
|
|
DestroyAcceleratorTable ( mAccelerators );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::Initialize
|
|
|
|
|
|
|
|
Initialize the gui editor application
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
bool rvGEApp::Initialize ( void )
|
|
|
|
{
|
|
|
|
mOptions.Init();
|
|
|
|
|
|
|
|
// Mutually exclusive
|
|
|
|
com_editors = EDITOR_GUI;
|
|
|
|
|
|
|
|
Sys_GrabMouseCursor( false );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Load the options
|
2011-12-06 18:20:15 +00:00
|
|
|
mOptions.Load ( );
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
mInstance = win32.hInstance;
|
|
|
|
|
|
|
|
// Create the accelerators
|
|
|
|
mAccelerators = LoadAccelerators ( mInstance, MAKEINTRESOURCE(IDR_GUIED_ACCELERATORS) );
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// Register the window classes for the main frame and the mdi child window
|
2011-11-22 21:28:15 +00:00
|
|
|
WNDCLASSEX wndClass;
|
|
|
|
memset ( &wndClass, 0, sizeof(wndClass) );
|
|
|
|
wndClass.cbSize = sizeof(WNDCLASSEX);
|
2011-12-06 18:20:15 +00:00
|
|
|
wndClass.lpszClassName = "QUAKE4_GUIEDITOR_CLASS";
|
2011-11-22 21:28:15 +00:00
|
|
|
wndClass.lpfnWndProc = FrameWndProc;
|
2011-12-06 18:20:15 +00:00
|
|
|
wndClass.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE + 1);
|
|
|
|
wndClass.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
2011-11-22 21:28:15 +00:00
|
|
|
wndClass.lpszMenuName = MAKEINTRESOURCE(IDR_GUIED_MAIN);
|
2011-12-06 18:20:15 +00:00
|
|
|
wndClass.hInstance = mInstance;
|
2011-11-22 21:28:15 +00:00
|
|
|
RegisterClassEx ( &wndClass );
|
|
|
|
|
|
|
|
wndClass.lpszMenuName = NULL;
|
|
|
|
wndClass.lpfnWndProc = MDIChildProc;
|
|
|
|
wndClass.lpszClassName = "QUAKE4_GUIEDITOR_CHILD_CLASS";
|
|
|
|
wndClass.style = CS_OWNDC|CS_DBLCLKS|CS_BYTEALIGNWINDOW|CS_VREDRAW|CS_HREDRAW;
|
2011-12-06 18:20:15 +00:00
|
|
|
wndClass.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
|
2011-11-22 21:28:15 +00:00
|
|
|
RegisterClassEx ( &wndClass );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Create the main window
|
2011-12-06 18:20:15 +00:00
|
|
|
mMDIFrame = CreateWindow ( "QUAKE4_GUIEDITOR_CLASS",
|
|
|
|
"Quake IV GUI Editor",
|
|
|
|
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
2011-11-22 21:28:15 +00:00
|
|
|
NULL, NULL, mInstance, (LPVOID)this );
|
|
|
|
|
|
|
|
if ( !mMDIFrame )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetClassLong( mMDIFrame, GCL_HICON, ( LONG )LoadIcon( win32.hInstance, MAKEINTRESOURCE( IDI_GUIED ) ) );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Create the MDI window
|
|
|
|
CLIENTCREATESTRUCT ccs;
|
|
|
|
ccs.hWindowMenu = GetSubMenu ( GetMenu ( mMDIFrame ), 5 );
|
|
|
|
ccs.idFirstChild = IDM_WINDOWCHILD;
|
2011-12-06 18:20:15 +00:00
|
|
|
mMDIClient = CreateWindow ( "MDICLIENT", NULL,
|
|
|
|
WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
|
|
|
0, 0, 1000, 1000,
|
|
|
|
mMDIFrame, NULL,
|
2011-11-22 21:28:15 +00:00
|
|
|
mInstance, &ccs );
|
|
|
|
|
|
|
|
if ( !mMDIClient )
|
|
|
|
{
|
|
|
|
DestroyWindow ( mMDIFrame );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// hide the doom window by default
|
|
|
|
::ShowWindow ( win32.hWnd, SW_HIDE );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Show both windows
|
|
|
|
mOptions.GetWindowPlacement ( "mdiframe", mMDIFrame );
|
2011-12-06 18:20:15 +00:00
|
|
|
ShowWindow ( mMDIFrame, SW_SHOW );
|
2011-11-22 21:28:15 +00:00
|
|
|
UpdateWindow ( mMDIFrame );
|
|
|
|
|
|
|
|
ShowWindow ( mMDIClient, SW_SHOW );
|
|
|
|
UpdateWindow ( mMDIClient );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::GetActiveWorkspace
|
|
|
|
|
|
|
|
Retrieves the workspace pointer for the active workspace. If there is no active
|
|
|
|
workspace then it will return NULL
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
rvGEWorkspace* rvGEApp::GetActiveWorkspace ( HWND* ret )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
rvGEWorkspace* workspace;
|
|
|
|
HWND active;
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
workspace = NULL;
|
|
|
|
active = (HWND)SendMessage ( mMDIClient, WM_MDIGETACTIVE, 0, NULL );
|
|
|
|
|
|
|
|
// Return the window handle if requested
|
|
|
|
if ( ret )
|
|
|
|
{
|
|
|
|
*ret = active;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !active )
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return rvGEWorkspace::GetWorkspace ( active );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::TranslateAccelerator
|
|
|
|
|
|
|
|
Translate any accelerators destined for this window
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
bool rvGEApp::TranslateAccelerator ( LPMSG msg )
|
|
|
|
{
|
|
|
|
HWND focus;
|
|
|
|
|
|
|
|
if ( msg->message == WM_SYSCHAR )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
SetFocus ( GetMDIClient ( ) );
|
|
|
|
msg->hwnd = GetMDIClient ( );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( mViewer )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
focus = GetActiveWindow ( );
|
|
|
|
|
|
|
|
// Only use accelerators when on the main window or navigator window
|
|
|
|
if ( focus == mMDIClient || focus == mMDIFrame ||
|
|
|
|
focus == GetNavigator().GetWindow ( ) )
|
|
|
|
{
|
|
|
|
if ( ::TranslateAccelerator ( mMDIFrame, mAccelerators, msg ) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( TranslateMDISysAccel ( mMDIClient, msg ) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::RunFrame
|
|
|
|
|
|
|
|
Runs the current frame which causes the active window to be redrawn
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEApp::RunFrame ( void )
|
|
|
|
{
|
|
|
|
HWND wnd;
|
|
|
|
rvGEWorkspace* workspace = GetActiveWorkspace ( &wnd );
|
|
|
|
|
|
|
|
if ( workspace )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
// Render the workspace using a temp DC
|
2011-12-06 18:20:15 +00:00
|
|
|
HDC hDC = GetDC ( wnd );
|
|
|
|
workspace->Render ( hDC );
|
|
|
|
ReleaseDC ( wnd, hDC );
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( mViewer )
|
|
|
|
{
|
|
|
|
mViewer->RunFrame ( );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::FrameWndProc
|
|
|
|
|
|
|
|
Main frame window procedure
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
LRESULT CALLBACK rvGEApp::FrameWndProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
rvGEApp* app = (rvGEApp*) GetWindowLong ( hWnd, GWL_USERDATA );
|
|
|
|
|
|
|
|
switch ( uMsg )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_SIZE:
|
|
|
|
{
|
|
|
|
RECT rStatus;
|
|
|
|
RECT rClient;
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// Tell the status bar to resize
|
2011-11-22 21:28:15 +00:00
|
|
|
app->mStatusBar.Resize ( LOWORD(lParam), HIWORD(lParam) );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Calculate the new client window rectangle (minus the status bar)
|
|
|
|
GetWindowRect ( app->mStatusBar.GetWindow ( ), &rStatus );
|
|
|
|
GetClientRect ( hWnd, &rClient );
|
|
|
|
|
|
|
|
if ( app->mOptions.GetStatusBarVisible ( ) )
|
|
|
|
{
|
|
|
|
rClient.bottom -= (rStatus.bottom-rStatus.top);
|
|
|
|
}
|
|
|
|
MoveWindow ( app->mMDIClient, 0, 0, rClient.right-rClient.left, rClient.bottom-rClient.top, FALSE );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_ENABLE:
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
int i;
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// Synchronise all toolwindows to the same state.
|
2011-11-22 21:28:15 +00:00
|
|
|
for(i = 0; i < app->mToolWindows.Num(); i++)
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
if(app->mToolWindows[i] != hWnd)
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
EnableWindow(app->mToolWindows[i], wParam);
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case WM_NCACTIVATE:
|
|
|
|
return app->ToolWindowActivate ( hWnd, uMsg, wParam, lParam );
|
|
|
|
|
|
|
|
case WM_ACTIVATE:
|
|
|
|
common->ActivateTool( LOWORD( wParam ) != WA_INACTIVE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_INITMENUPOPUP:
|
|
|
|
app->HandleInitMenu ( wParam, lParam );
|
|
|
|
break;
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
case WM_CLOSE:
|
2011-11-22 21:28:15 +00:00
|
|
|
while ( app->mWorkspaces.Num ( ) )
|
|
|
|
{
|
|
|
|
SendMessage ( app->mWorkspaces[0]->GetWindow ( ), WM_CLOSE, 0, 0 );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
app->mOptions.SetWindowPlacement ( "mdiframe", hWnd );
|
2011-12-06 18:20:15 +00:00
|
|
|
app->mOptions.Save ( );
|
2011-11-22 21:28:15 +00:00
|
|
|
ExitProcess(0);
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
assert ( app );
|
|
|
|
result = app->HandleCommand ( wParam, lParam );
|
|
|
|
if ( -1 != result )
|
|
|
|
{
|
|
|
|
return result;
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_CREATE:
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
LPCREATESTRUCT cs;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
cs = (LPCREATESTRUCT) lParam;
|
|
|
|
app = (rvGEApp*)cs->lpCreateParams;
|
|
|
|
|
|
|
|
assert ( app );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
SetWindowLong ( hWnd, GWL_USERDATA, (LONG)app );
|
|
|
|
|
|
|
|
app->mMDIFrame = hWnd;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
app->InitRecentFiles ( );
|
|
|
|
app->UpdateRecentFiles ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
app->mNavigator.Create ( hWnd, gApp.mOptions.GetNavigatorVisible ( ) );
|
2011-11-22 21:28:15 +00:00
|
|
|
app->mTransformer.Create ( hWnd, gApp.mOptions.GetTransformerVisible ( ) );
|
|
|
|
app->mStatusBar.Create ( hWnd, 9999, gApp.mOptions.GetStatusBarVisible ( ) );
|
|
|
|
app->mProperties.Create ( hWnd, gApp.mOptions.GetPropertiesVisible ( ) );
|
|
|
|
|
|
|
|
// add all the tool windows to the tool window array
|
|
|
|
app->mToolWindows.Append ( app->mMDIFrame );
|
|
|
|
app->mToolWindows.Append ( app->mNavigator.GetWindow ( ) );
|
|
|
|
app->mToolWindows.Append ( app->mProperties.GetWindow ( ) );
|
|
|
|
app->mToolWindows.Append ( app->mTransformer.GetWindow ( ) );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
SendMessage ( app->mNavigator.GetWindow ( ), WM_NCACTIVATE, true, (LONG)-1 );
|
|
|
|
SendMessage ( app->mProperties.GetWindow ( ), WM_NCACTIVATE, true, (LONG)-1 );
|
2011-12-06 18:20:15 +00:00
|
|
|
SendMessage ( app->mTransformer.GetWindow ( ), WM_NCACTIVATE, true, (LONG)-1 );
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefFrameProc ( hWnd, app?app->mMDIClient:NULL, uMsg, wParam, lParam );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::MDIChildProc
|
|
|
|
|
|
|
|
MDI Child window procedure
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
LRESULT CALLBACK rvGEApp::MDIChildProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
rvGEWorkspace* workspace = (rvGEWorkspace*)GetWindowLong ( hWnd, GWL_USERDATA );
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
// Give the active workspace a chance to play with it
|
|
|
|
if ( workspace )
|
|
|
|
{
|
|
|
|
workspace->HandleMessage ( uMsg, wParam, lParam );
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ( uMsg )
|
|
|
|
{
|
|
|
|
case WM_CLOSE:
|
|
|
|
workspace->GetApplication ( )->mWorkspaces.Remove ( workspace );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_CREATE:
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
LPMDICREATESTRUCT mdics;
|
|
|
|
LPCREATESTRUCT cs;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// MDI windows have their creation params buried two levels deep, extract
|
|
|
|
// that param since it is the workspace pointer
|
|
|
|
cs = (LPCREATESTRUCT) lParam;
|
|
|
|
mdics = (LPMDICREATESTRUCT) cs->lpCreateParams;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Attach the workspace to the window
|
|
|
|
workspace = (rvGEWorkspace*) mdics->lParam;
|
2011-12-06 18:20:15 +00:00
|
|
|
workspace->Attach ( hWnd );
|
|
|
|
|
|
|
|
workspace->GetApplication ( )->mWorkspaces.Append ( workspace );
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_MDIACTIVATE:
|
|
|
|
assert ( workspace );
|
|
|
|
if ( (HWND)lParam == hWnd )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
workspace->GetApplication ( )->GetNavigator().SetWorkspace(workspace);
|
|
|
|
workspace->GetApplication ( )->GetTransformer().SetWorkspace(workspace);
|
|
|
|
workspace->GetApplication ( )->GetProperties().SetWorkspace(workspace);
|
|
|
|
gApp.GetStatusBar ( ).SetSimple ( false );
|
|
|
|
}
|
|
|
|
else if ( lParam == NULL )
|
|
|
|
{
|
|
|
|
gApp.GetStatusBar ( ).SetSimple ( true );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->Detach ( );
|
|
|
|
delete workspace;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SETCURSOR:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case WM_ERASEBKGND:
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_PAINT:
|
|
|
|
{
|
|
|
|
HDC dc;
|
|
|
|
PAINTSTRUCT ps;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
dc = BeginPaint(hWnd, &ps);
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( workspace )
|
|
|
|
{
|
|
|
|
workspace->Render ( dc );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return DefMDIChildProc ( hWnd, uMsg, wParam, lParam );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::HandleCommandSave
|
|
|
|
|
|
|
|
Handles the ID_GUIED_FILE_SAVE and ID_GUIED_FILE_SAVEAS commands
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEApp::HandleCommandSave ( rvGEWorkspace* workspace, const char* filename )
|
|
|
|
{
|
|
|
|
idStr realFilename;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// See if we need to browse for a filename
|
|
|
|
if ( workspace->IsNew ( ) || filename == NULL )
|
|
|
|
{
|
|
|
|
OPENFILENAME ofn;
|
|
|
|
char szFile[MAX_PATH];
|
|
|
|
|
|
|
|
strcpy ( szFile, workspace->GetFilename ( ) );
|
|
|
|
|
|
|
|
// Initialize OPENFILENAME
|
|
|
|
ZeroMemory(&ofn, sizeof(OPENFILENAME));
|
|
|
|
ofn.lStructSize = sizeof(OPENFILENAME);
|
|
|
|
ofn.hwndOwner = mMDIFrame;
|
|
|
|
ofn.lpstrFile = szFile;
|
|
|
|
ofn.nMaxFile = sizeof(szFile);
|
|
|
|
ofn.lpstrFilter = "GUI Files\0*.GUI\0All Files\0*.*\0";
|
|
|
|
ofn.nFilterIndex = 1;
|
|
|
|
ofn.Flags = OFN_PATHMUSTEXIST;
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// Display the save dialog box.
|
|
|
|
if ( !GetSaveFileName(&ofn) )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
realFilename = ofn.lpstrFile;
|
|
|
|
realFilename.StripFileExtension ( );
|
|
|
|
realFilename.Append ( ".gui" );
|
|
|
|
|
|
|
|
// If the file already exists then warn about overwriting it
|
|
|
|
if ( _taccess ( realFilename, 0 ) == 0 )
|
|
|
|
{
|
|
|
|
if ( IDNO == MessageBox ( va("File '%s' already exists. Do you want to replace it?", realFilename.c_str()), MB_YESNO|MB_ICONQUESTION ) )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
realFilename = filename;
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
// Now performe the file save
|
|
|
|
if ( workspace->SaveFile ( realFilename ) )
|
|
|
|
{
|
|
|
|
mOptions.AddRecentFile ( workspace->GetFilename ( ) );
|
|
|
|
UpdateRecentFiles ( );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MessageBox ( va("Could not write file '%s'", workspace->GetFilename()), MB_OK|MB_ICONERROR );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::HandleCommand
|
|
|
|
|
|
|
|
Handles the WM_COMMAND message
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEApp::HandleCommand ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
HWND active;
|
|
|
|
rvGEWorkspace* workspace = GetActiveWorkspace ( &active );
|
|
|
|
|
|
|
|
// The recent file list needs to be handled specially
|
|
|
|
if ( LOWORD(wParam) >= ID_GUIED_FILE_MRU1 && LOWORD(wParam) < ID_GUIED_FILE_MRU1 + rvGEOptions::MAX_MRU_SIZE )
|
|
|
|
{
|
|
|
|
OpenFile ( mOptions.GetRecentFile ( mOptions.GetRecentFileCount() - (LOWORD(wParam)-ID_GUIED_FILE_MRU1) - 1 ) );
|
|
|
|
return 0;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
switch ( LOWORD ( wParam ) )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_SOURCECONTROL_CHECKIN:
|
|
|
|
assert ( workspace );
|
|
|
|
HandleCommandSave ( workspace, workspace->GetFilename ( ) );
|
|
|
|
workspace->CheckIn ( );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_SOURCECONTROL_CHECKOUT:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->CheckOut ( );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_SOURCECONTROL_UNDOCHECKOUT:
|
|
|
|
assert ( workspace );
|
|
|
|
if ( IDYES == MessageBox ( va("Are you sure you want to undo the checkout of the file '%s'?",workspace->GetFilename()), MB_YESNO|MB_ICONQUESTION) )
|
|
|
|
{
|
|
|
|
workspace->UndoCheckout ( );
|
|
|
|
}
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_TOOLS_RELOADMATERIALS:
|
|
|
|
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_WAIT) ) );
|
|
|
|
cmdSystem->BufferCommandText( CMD_EXEC_NOW, "reloadImages\n" );
|
|
|
|
cmdSystem->BufferCommandText( CMD_EXEC_NOW, "reloadMaterials\n" );
|
|
|
|
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW) ) );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_EDIT_COPY:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->Copy ( );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_EDIT_PASTE:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->Paste ( );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_HELP_ABOUT:
|
|
|
|
DialogBox ( GetInstance(), MAKEINTRESOURCE(IDD_GUIED_ABOUT), mMDIFrame, AboutDlg_WndProc );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_TOOLS_VIEWER:
|
|
|
|
{
|
|
|
|
if ( mViewer )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mViewer = new rvGEViewer;
|
|
|
|
if ( !mViewer->Create ( mMDIFrame ) )
|
|
|
|
{
|
|
|
|
delete mViewer;
|
|
|
|
mViewer = NULL;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( workspace )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( !workspace->IsModified () || HandleCommand ( MAKELONG(ID_GUIED_FILE_SAVE,0), 0 ) )
|
|
|
|
{
|
|
|
|
mViewer->OpenFile ( workspace->GetFilename ( ) );
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
SetActiveWindow ( mViewer->GetWindow ( ) );
|
|
|
|
break;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_ITEM_MAKESAMESIZEWIDTH:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->MakeSelectedSameSize ( true, false );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_MAKESAMESIZEBOTH:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->MakeSelectedSameSize ( true, true );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_MAKESAMESIZEHEIGHT:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->MakeSelectedSameSize ( false, true );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_ITEM_ALIGNLEFTS:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AlignSelected ( rvGEWorkspace::ALIGN_LEFTS );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_ALIGNCENTERS:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AlignSelected ( rvGEWorkspace::ALIGN_CENTERS );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_ALIGNRIGHTS:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AlignSelected ( rvGEWorkspace::ALIGN_RIGHTS );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_ALIGNTOPS:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AlignSelected ( rvGEWorkspace::ALIGN_TOPS );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_ALIGNMIDDLES:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AlignSelected ( rvGEWorkspace::ALIGN_MIDDLES );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_ALIGNBOTTOMS:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AlignSelected ( rvGEWorkspace::ALIGN_BOTTOMS );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_ITEM_ARRANGESENDBACKWARD:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->SendSelectedBackward ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case ID_GUIED_ITEM_ARRANGESENDTOBACK:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->SendSelectedToBack( );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case ID_GUIED_ITEM_ARRANGEBRINGFORWARD:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->BringSelectedForward ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case ID_GUIED_ITEM_ARRANGEBRINGTOFRONT:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->BringSelectedToFront ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_ITEM_ARRANGEMAKECHILD:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->MakeSelectedAChild ( );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_ITEM_PROPERTIES:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->EditSelectedProperties ( );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_SCRIPTS:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->EditSelectedScripts ( );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_ITEM_NEWWINDOWDEF:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AddWindow ( rvGEWindowWrapper::WT_NORMAL );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_NEWEDITDEF:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AddWindow ( rvGEWindowWrapper::WT_EDIT );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_NEWHTMLDEF:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AddWindow ( rvGEWindowWrapper::WT_HTML );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_NEWCHOICEDEF:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AddWindow ( rvGEWindowWrapper::WT_CHOICE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_NEWSLIDERDEF:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AddWindow ( rvGEWindowWrapper::WT_SLIDER );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_NEWLISTDEF:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AddWindow ( rvGEWindowWrapper::WT_LIST );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_NEWBINDDEF:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AddWindow ( rvGEWindowWrapper::WT_BIND );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_ITEM_NEWRENDERDEF:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->AddWindow ( rvGEWindowWrapper::WT_RENDER );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_WINDOW_TILE:
|
|
|
|
SendMessage ( mMDIClient, WM_MDITILE, 0, 0 );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case ID_GUIED_WINDOW_CASCADE:
|
|
|
|
SendMessage ( mMDIClient, WM_MDICASCADE, 0, 0 );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case ID_GUIED_VIEW_STATUSBAR:
|
|
|
|
{
|
|
|
|
RECT rWindow;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mStatusBar.Show ( mOptions.GetStatusBarVisible()?false:true );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
GetWindowRect ( mMDIFrame, &rWindow );
|
2011-12-06 18:20:15 +00:00
|
|
|
SendMessage ( mMDIFrame, WM_SIZE, 0, MAKELONG ( rWindow.right-rWindow.left, rWindow.bottom-rWindow.top ) );
|
2011-11-22 21:28:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ID_GUIED_WINDOW_SHOWNAVIGATOR:
|
|
|
|
mNavigator.Show ( mOptions.GetNavigatorVisible()?false:true );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_WINDOW_SHOWPROPERTIES:
|
|
|
|
mProperties.Show ( mOptions.GetPropertiesVisible()?false:true );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_WINDOW_SHOWTRANSFORMER:
|
|
|
|
mTransformer.Show ( mOptions.GetTransformerVisible()?false:true );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_EDIT_DELETE:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->DeleteSelected ( );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_VIEW_HIDESELECTED:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->HideSelected ( );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_VIEW_UNHIDESELECTED:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->UnhideSelected ( );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_VIEW_SHOWHIDDEN:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->ShowHidden ( );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_EDIT_UNDO:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->GetModifierStack().Undo ( );
|
|
|
|
mNavigator.Update ( );
|
|
|
|
mTransformer.Update ( );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_EDIT_REDO:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->GetModifierStack().Redo ( );
|
|
|
|
mNavigator.Update ( );
|
|
|
|
mTransformer.Update ( );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_VIEW_OPTIONS:
|
|
|
|
GEOptionsDlg_DoModal ( mMDIFrame );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_VIEW_SHOWGRID:
|
2011-12-06 18:20:15 +00:00
|
|
|
mOptions.SetGridVisible ( mOptions.GetGridVisible()?false:true );
|
2011-11-22 21:28:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_VIEW_SNAPTOGRID:
|
2011-12-06 18:20:15 +00:00
|
|
|
mOptions.SetGridSnap ( mOptions.GetGridSnap ()?false:true );
|
2011-11-22 21:28:15 +00:00
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_VIEW_ZOOMIN:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->ZoomIn ( );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_VIEW_ZOOMOUT:
|
|
|
|
assert ( workspace );
|
|
|
|
workspace->ZoomOut ( );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_FILE_EXIT:
|
|
|
|
DestroyWindow ( mMDIFrame );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_FILE_CLOSE:
|
|
|
|
if ( active )
|
|
|
|
{
|
|
|
|
assert ( workspace );
|
|
|
|
SendMessage ( active, WM_CLOSE, 0, 0 );
|
|
|
|
}
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_FILE_NEW:
|
|
|
|
NewFile ( );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_FILE_SAVE:
|
|
|
|
assert ( workspace );
|
|
|
|
HandleCommandSave ( workspace, workspace->GetFilename ( ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_FILE_SAVEAS:
|
|
|
|
assert ( workspace );
|
|
|
|
HandleCommandSave ( workspace, NULL );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_FILE_OPEN:
|
|
|
|
{
|
|
|
|
OPENFILENAME ofn;
|
|
|
|
char szFile[MAX_PATH] = "";
|
|
|
|
|
|
|
|
// Initialize OPENFILENAME
|
|
|
|
ZeroMemory(&ofn, sizeof(OPENFILENAME));
|
|
|
|
ofn.lStructSize = sizeof(OPENFILENAME);
|
|
|
|
ofn.hwndOwner = mMDIFrame;
|
|
|
|
ofn.lpstrFile = szFile;
|
|
|
|
ofn.nMaxFile = sizeof(szFile);
|
|
|
|
ofn.lpstrFilter = "GUI Files\0*.GUI\0All Files\0*.*\0";
|
|
|
|
ofn.nFilterIndex = 1;
|
|
|
|
ofn.lpstrFileTitle = NULL;
|
|
|
|
ofn.nMaxFileTitle = 0;
|
|
|
|
ofn.lpstrInitialDir = NULL;
|
|
|
|
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// Display the Open dialog box.
|
|
|
|
if (GetOpenFileName(&ofn)==TRUE)
|
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
OpenFile ( ofn.lpstrFile );
|
|
|
|
}
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::HandleInitMenu
|
|
|
|
|
|
|
|
Handles the initialization of the main menu
|
|
|
|
================
|
|
|
|
*/
|
2011-12-06 18:20:15 +00:00
|
|
|
int rvGEApp::HandleInitMenu ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
int cMenuItems = GetMenuItemCount((HMENU)wParam);
|
|
|
|
int nPos;
|
|
|
|
int id;
|
|
|
|
UINT flags;
|
|
|
|
rvGEWorkspace* workspace;
|
|
|
|
HMENU hmenu;
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
hmenu = (HMENU) wParam;
|
|
|
|
workspace = GetActiveWorkspace ( );
|
|
|
|
|
|
|
|
// Run through all the menu items in the menu and see if any of them need
|
|
|
|
// modification in any way
|
2011-12-06 18:20:15 +00:00
|
|
|
for (nPos = 0; nPos < cMenuItems; nPos++)
|
|
|
|
{
|
|
|
|
id = GetMenuItemID(hmenu, nPos);
|
|
|
|
flags = 0;
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Handle popup menus too
|
|
|
|
if ( id < 0 )
|
|
|
|
{
|
|
|
|
HMENU sub = GetSubMenu ( hmenu, nPos );
|
|
|
|
if ( sub )
|
|
|
|
{
|
|
|
|
HandleInitMenu ( (WPARAM) sub, 0 );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Menu items that are completely unrelated to the workspace
|
|
|
|
switch ( id )
|
|
|
|
{
|
|
|
|
case ID_GUIED_VIEW_STATUSBAR:
|
|
|
|
flags = MF_BYCOMMAND | (mOptions.GetStatusBarVisible()?MF_CHECKED:MF_UNCHECKED);
|
|
|
|
CheckMenuItem ( hmenu, id, flags );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case ID_GUIED_WINDOW_SHOWNAVIGATOR:
|
|
|
|
flags = MF_BYCOMMAND | (mOptions.GetNavigatorVisible()?MF_CHECKED:MF_UNCHECKED);
|
|
|
|
CheckMenuItem ( hmenu, id, flags );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_WINDOW_SHOWPROPERTIES:
|
|
|
|
flags = MF_BYCOMMAND | (mOptions.GetPropertiesVisible()?MF_CHECKED:MF_UNCHECKED);
|
|
|
|
CheckMenuItem ( hmenu, id, flags );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case ID_GUIED_WINDOW_SHOWTRANSFORMER:
|
|
|
|
flags = MF_BYCOMMAND | (mOptions.GetTransformerVisible()?MF_CHECKED:MF_UNCHECKED);
|
|
|
|
CheckMenuItem ( hmenu, id, flags );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Handle the basic case where an item is disabled because
|
|
|
|
// there is no workspace available
|
|
|
|
if ( !workspace )
|
|
|
|
{
|
|
|
|
switch ( id )
|
|
|
|
{
|
|
|
|
case ID_GUIED_EDIT_UNDO:
|
|
|
|
case ID_GUIED_EDIT_REDO:
|
|
|
|
case ID_GUIED_VIEW_SHOWGRID:
|
|
|
|
case ID_GUIED_VIEW_SNAPTOGRID:
|
|
|
|
case ID_GUIED_VIEW_HIDESELECTED:
|
|
|
|
case ID_GUIED_VIEW_UNHIDESELECTED:
|
|
|
|
case ID_GUIED_EDIT_DELETE:
|
|
|
|
case ID_GUIED_WINDOW_TILE:
|
|
|
|
case ID_GUIED_WINDOW_CASCADE:
|
|
|
|
case ID_GUIED_ITEM_NEWWINDOWDEF:
|
|
|
|
case ID_GUIED_ITEM_NEWEDITDEF:
|
|
|
|
case ID_GUIED_ITEM_NEWHTMLDEF:
|
|
|
|
case ID_GUIED_ITEM_ARRANGEBRINGTOFRONT:
|
|
|
|
case ID_GUIED_ITEM_ARRANGEBRINGFORWARD:
|
|
|
|
case ID_GUIED_ITEM_ARRANGESENDTOBACK:
|
|
|
|
case ID_GUIED_ITEM_ARRANGESENDBACKWARD:
|
|
|
|
case ID_GUIED_ITEM_PROPERTIES:
|
|
|
|
case ID_GUIED_ITEM_SCRIPTS:
|
|
|
|
case ID_GUIED_VIEW_ZOOMIN:
|
|
|
|
case ID_GUIED_VIEW_ZOOMOUT:
|
|
|
|
case ID_GUIED_ITEM_ALIGNLEFTS:
|
|
|
|
case ID_GUIED_ITEM_ALIGNCENTERS:
|
|
|
|
case ID_GUIED_ITEM_ALIGNRIGHTS:
|
|
|
|
case ID_GUIED_ITEM_ALIGNBOTTOMS:
|
|
|
|
case ID_GUIED_ITEM_ALIGNMIDDLES:
|
|
|
|
case ID_GUIED_ITEM_ALIGNTOPS:
|
|
|
|
case ID_GUIED_ITEM_MAKESAMESIZEHEIGHT:
|
|
|
|
case ID_GUIED_ITEM_MAKESAMESIZEWIDTH:
|
|
|
|
case ID_GUIED_ITEM_MAKESAMESIZEBOTH:
|
|
|
|
case ID_GUIED_FILE_SAVE:
|
|
|
|
case ID_GUIED_FILE_SAVEAS:
|
|
|
|
case ID_GUIED_EDIT_COPY:
|
2011-12-06 18:20:15 +00:00
|
|
|
case ID_GUIED_EDIT_PASTE:
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_ITEM_ARRANGEMAKECHILD:
|
|
|
|
case ID_GUIED_SOURCECONTROL_GETLATESTVERSION:
|
|
|
|
case ID_GUIED_SOURCECONTROL_CHECKIN:
|
|
|
|
case ID_GUIED_SOURCECONTROL_CHECKOUT:
|
|
|
|
case ID_GUIED_SOURCECONTROL_UNDOCHECKOUT:
|
|
|
|
case ID_GUIED_FILE_CLOSE:
|
|
|
|
EnableMenuItem ( hmenu, nPos, MF_GRAYED|MF_BYPOSITION );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
switch (id)
|
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
// Undo is greyed out when there is noting to undo and the text is
|
|
|
|
// modified to include the name of the modifier that will be undone
|
|
|
|
case ID_GUIED_EDIT_UNDO:
|
|
|
|
{
|
|
|
|
MENUITEMINFO info;
|
|
|
|
idStr undo;
|
|
|
|
|
|
|
|
info.cbSize = sizeof(info);
|
|
|
|
info.fMask = MIIM_STATE|MIIM_TYPE;
|
|
|
|
info.fType = MFT_STRING;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( !workspace->GetModifierStack().CanUndo ( ) )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
undo = "Undo\tCtrl+Z";
|
|
|
|
info.fState = MFS_GRAYED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
undo = "Undo ";
|
|
|
|
undo.Append ( workspace->GetModifierStack().GetUndoModifier()->GetName ( ) );
|
|
|
|
undo.Append ( "\tCtrl+Z" );
|
|
|
|
info.fState = MFS_ENABLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
info.dwTypeData = (LPSTR)undo.c_str();
|
|
|
|
info.cch = undo.Length ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
SetMenuItemInfo ( hmenu, id, FALSE, &info );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ID_GUIED_EDIT_REDO:
|
|
|
|
{
|
|
|
|
MENUITEMINFO info;
|
|
|
|
idStr undo;
|
|
|
|
|
|
|
|
info.cbSize = sizeof(info);
|
|
|
|
info.fMask = MIIM_STATE|MIIM_TYPE;
|
|
|
|
info.fType = MFT_STRING;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( !workspace || !workspace->GetModifierStack().CanRedo ( ) )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
undo = "Redo\tCtrl+Y";
|
|
|
|
info.fState = MFS_GRAYED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
undo = "Redo ";
|
|
|
|
undo.Append ( workspace->GetModifierStack().GetRedoModifier()->GetName ( ) );
|
|
|
|
undo.Append ( "\tCtrl+Y" );
|
|
|
|
info.fState = MFS_ENABLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
info.dwTypeData = (LPSTR)undo.c_str();
|
|
|
|
info.cch = undo.Length ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
SetMenuItemInfo ( hmenu, id, FALSE, &info );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ID_GUIED_VIEW_SHOWGRID:
|
|
|
|
flags = MF_BYCOMMAND | (mOptions.GetGridVisible()?MF_CHECKED:MF_UNCHECKED);
|
|
|
|
CheckMenuItem ( hmenu, id, flags );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case ID_GUIED_VIEW_SNAPTOGRID:
|
|
|
|
flags = MF_BYCOMMAND | (mOptions.GetGridSnap()?MF_CHECKED:MF_UNCHECKED);
|
|
|
|
CheckMenuItem ( hmenu, id, flags );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// All menu items that are greyed out when there is no workspace
|
|
|
|
case ID_GUIED_WINDOW_TILE:
|
|
|
|
case ID_GUIED_WINDOW_CASCADE:
|
|
|
|
case ID_GUIED_ITEM_NEWWINDOWDEF:
|
|
|
|
case ID_GUIED_ITEM_NEWEDITDEF:
|
|
|
|
case ID_GUIED_ITEM_NEWHTMLDEF:
|
|
|
|
case ID_GUIED_VIEW_ZOOMIN:
|
|
|
|
case ID_GUIED_VIEW_ZOOMOUT:
|
|
|
|
case ID_GUIED_FILE_SAVE:
|
|
|
|
case ID_GUIED_FILE_SAVEAS:
|
|
|
|
case ID_GUIED_FILE_CLOSE:
|
|
|
|
EnableMenuItem ( hmenu, nPos, MF_ENABLED|MF_BYPOSITION);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// All menu items that are greyed out unless an item is selected
|
|
|
|
case ID_GUIED_VIEW_HIDESELECTED:
|
|
|
|
case ID_GUIED_VIEW_UNHIDESELECTED:
|
|
|
|
case ID_GUIED_EDIT_DELETE:
|
|
|
|
case ID_GUIED_EDIT_COPY:
|
|
|
|
EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->GetSelectionMgr().Num()>0?MF_ENABLED:MF_GRAYED) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Enable paste if the clipboard has something in it
|
2011-12-06 18:20:15 +00:00
|
|
|
case ID_GUIED_EDIT_PASTE:
|
2011-11-22 21:28:15 +00:00
|
|
|
EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->GetClipboard().Num()>0?MF_ENABLED:MF_GRAYED) );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// All menu items that are greyed out unless a single item is selected
|
|
|
|
case ID_GUIED_ITEM_ARRANGEBRINGTOFRONT:
|
|
|
|
case ID_GUIED_ITEM_ARRANGEBRINGFORWARD:
|
|
|
|
case ID_GUIED_ITEM_ARRANGESENDTOBACK:
|
|
|
|
case ID_GUIED_ITEM_ARRANGESENDBACKWARD:
|
|
|
|
case ID_GUIED_ITEM_PROPERTIES:
|
|
|
|
case ID_GUIED_ITEM_SCRIPTS:
|
|
|
|
EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->GetSelectionMgr().Num()==1?MF_ENABLED:MF_GRAYED) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
// All menu items that are greyed out unless multiple itmes are selected
|
|
|
|
case ID_GUIED_ITEM_ALIGNLEFTS:
|
|
|
|
case ID_GUIED_ITEM_ALIGNCENTERS:
|
|
|
|
case ID_GUIED_ITEM_ALIGNRIGHTS:
|
|
|
|
case ID_GUIED_ITEM_ALIGNBOTTOMS:
|
|
|
|
case ID_GUIED_ITEM_ALIGNMIDDLES:
|
|
|
|
case ID_GUIED_ITEM_ALIGNTOPS:
|
|
|
|
case ID_GUIED_ITEM_MAKESAMESIZEHEIGHT:
|
|
|
|
case ID_GUIED_ITEM_MAKESAMESIZEBOTH:
|
|
|
|
case ID_GUIED_ITEM_MAKESAMESIZEWIDTH:
|
|
|
|
case ID_GUIED_ITEM_ARRANGEMAKECHILD:
|
|
|
|
EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->GetSelectionMgr().Num()>1?MF_ENABLED:MF_GRAYED) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_SOURCECONTROL_CHECKIN:
|
|
|
|
case ID_GUIED_SOURCECONTROL_UNDOCHECKOUT:
|
|
|
|
EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|((workspace->GetSourceControlState()==rvGEWorkspace::SCS_CHECKEDOUT)?MF_ENABLED:MF_GRAYED) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GUIED_SOURCECONTROL_CHECKOUT:
|
|
|
|
EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|((workspace->GetSourceControlState()==rvGEWorkspace::SCS_CHECKEDIN)?MF_ENABLED:MF_GRAYED) );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
default:
|
|
|
|
continue;
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return 0;
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::NewFile
|
|
|
|
|
|
|
|
Creates a new file and opens a window for it
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
bool rvGEApp::NewFile ( void )
|
|
|
|
{
|
|
|
|
rvGEWorkspace* workspace = new rvGEWorkspace ( this );
|
|
|
|
if ( workspace->NewFile ( ) )
|
|
|
|
{
|
|
|
|
HWND child;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
child = CreateMDIWindow("QUAKE4_GUIEDITOR_CHILD_CLASS",
|
|
|
|
"Untitled.gui",
|
|
|
|
WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_HSCROLL|WS_VSCROLL|WS_MAXIMIZE,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
640,
|
|
|
|
480,
|
|
|
|
mMDIClient,
|
|
|
|
mInstance,
|
|
|
|
(LONG)workspace );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
ShowWindow ( child, SW_SHOW );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::OpenFile
|
|
|
|
|
|
|
|
Opens the given file and will fail if its already open or could not
|
|
|
|
be opened for some reason
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
bool rvGEApp::OpenFile ( const char* filename )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
bool result = false;
|
|
|
|
idStr error;
|
|
|
|
|
|
|
|
// See if the file is already open and if so just make it active
|
|
|
|
for ( i = 0; i < mWorkspaces.Num(); i ++ )
|
|
|
|
{
|
|
|
|
if ( !idStr::Icmp ( mWorkspaces[i]->GetFilename(), filename ) )
|
|
|
|
{
|
|
|
|
SendMessage ( mMDIClient, WM_MDIACTIVATE, (WPARAM)mWorkspaces[i]->GetWindow ( ), 0 );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_WAIT ) ) );
|
|
|
|
|
|
|
|
// Setup the default error.
|
|
|
|
error = va("Failed to parse '%s'", filename );
|
|
|
|
|
|
|
|
rvGEWorkspace* workspace = new rvGEWorkspace ( this );
|
|
|
|
if ( workspace->LoadFile ( filename, &error ) )
|
|
|
|
{
|
|
|
|
HWND child;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
child = CreateMDIWindow("QUAKE4_GUIEDITOR_CHILD_CLASS",
|
|
|
|
"Unamed.gui",
|
|
|
|
WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_HSCROLL|WS_VSCROLL|WS_MAXIMIZE,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
640,
|
|
|
|
480,
|
|
|
|
mMDIClient,
|
|
|
|
mInstance,
|
|
|
|
(LONG)workspace );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
ShowWindow ( child, SW_SHOW );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
mOptions.AddRecentFile ( filename );
|
2011-11-22 21:28:15 +00:00
|
|
|
UpdateRecentFiles ( );
|
|
|
|
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MessageBox ( error, MB_OK|MB_ICONERROR );
|
|
|
|
}
|
|
|
|
|
|
|
|
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW ) ) );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return result;;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::InitRecentFiles
|
|
|
|
|
|
|
|
Finds the file menu and the location within it where the MRU should
|
|
|
|
be added.
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
bool rvGEApp::InitRecentFiles ( void )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
mRecentFileMenu = GetSubMenu ( GetMenu(mMDIFrame), 0 );
|
|
|
|
count = GetMenuItemCount ( mRecentFileMenu );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
for ( i = 0; i < count; i ++ )
|
|
|
|
{
|
|
|
|
if ( GetMenuItemID ( mRecentFileMenu, i ) == ID_GUIED_FILE_MRU )
|
|
|
|
{
|
|
|
|
mRecentFileInsertPos = i;
|
|
|
|
DeleteMenu ( mRecentFileMenu, mRecentFileInsertPos, MF_BYPOSITION );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::UpdateRecentFiles
|
|
|
|
|
|
|
|
Updates the mru in the menu
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEApp::UpdateRecentFiles ( void )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
// Make sure everything is initialized
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( !mRecentFileMenu )
|
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
InitRecentFiles ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete all the old recent files from the menu's
|
|
|
|
for ( i = 0; i < rvGEOptions::MAX_MRU_SIZE; i ++ )
|
|
|
|
{
|
|
|
|
DeleteMenu ( mRecentFileMenu, ID_GUIED_FILE_MRU1 + i, MF_BYCOMMAND );
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
// Make sure there is a separator after the recent files
|
|
|
|
if ( mOptions.GetRecentFileCount() )
|
|
|
|
{
|
|
|
|
MENUITEMINFO info;
|
|
|
|
ZeroMemory ( &info, sizeof(info) );
|
|
|
|
info.cbSize = sizeof(info);
|
|
|
|
info.fMask = MIIM_FTYPE;
|
|
|
|
GetMenuItemInfo ( mRecentFileMenu, mRecentFileInsertPos+1,TRUE, &info );
|
|
|
|
if ( !(info.fType & MFT_SEPARATOR ) )
|
|
|
|
{
|
|
|
|
InsertMenu ( mRecentFileMenu, mRecentFileInsertPos, MF_BYPOSITION|MF_SEPARATOR|MF_ENABLED, 0, NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the recent files to the menu now
|
|
|
|
for ( j = 0, i = mOptions.GetRecentFileCount ( ) - 1; i >= 0; i --, j++ )
|
|
|
|
{
|
|
|
|
UINT id = ID_GUIED_FILE_MRU1 + j;
|
|
|
|
idStr str = va("&%d ", j+1);
|
|
|
|
str.Append ( mOptions.GetRecentFile ( i ) );
|
|
|
|
InsertMenu ( mRecentFileMenu, mRecentFileInsertPos+j+1, MF_BYPOSITION|MF_STRING|MF_ENABLED, id, str );
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::CloseViewer
|
|
|
|
|
|
|
|
Closes the gui viewer
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEApp::CloseViewer ( void )
|
|
|
|
{
|
|
|
|
if ( !mViewer )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mViewer->Destroy ( );
|
|
|
|
delete mViewer;
|
|
|
|
mViewer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::ToolWindowActivate
|
|
|
|
|
|
|
|
Handles the nc activate message for all tool windows
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEApp::ToolWindowActivate ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
bool keepActive;
|
|
|
|
bool syncOthers;
|
|
|
|
int i;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
keepActive = ( wParam != 0 );
|
|
|
|
syncOthers = true;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
for ( i = 0; i < mToolWindows.Num (); i ++ )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( (HWND)lParam == mToolWindows[i] )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
keepActive = true;
|
|
|
|
syncOthers = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( lParam == -1 )
|
|
|
|
{
|
|
|
|
return DefWindowProc ( hwnd, WM_NCACTIVATE, keepActive, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( syncOthers )
|
|
|
|
{
|
|
|
|
for ( i = 0; i < mToolWindows.Num(); i ++ )
|
|
|
|
{
|
|
|
|
if ( mToolWindows[i] != hwnd && mToolWindows[i] != (HWND) lParam )
|
|
|
|
{
|
|
|
|
SendMessage ( mToolWindows[i], WM_NCACTIVATE, keepActive, (LONG)-1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return DefWindowProc ( hwnd, WM_NCACTIVATE, keepActive, lParam );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEApp::MessageBox
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
Displays a modal message box
|
2011-11-22 21:28:15 +00:00
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEApp::MessageBox ( const char* text, int flags )
|
|
|
|
{
|
|
|
|
return ::MessageBox ( mMDIFrame, text, "Quake 4 GUI Editor", flags );
|
|
|
|
}
|