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.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
2019-01-07 04:19:20 +00:00
|
|
|
#include "tools/edit_gui_common.h"
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
#include "../../sys/win32/rc/guied_resource.h"
|
|
|
|
#include "../../renderer/tr_local.h"
|
|
|
|
#include "../../sys/win32/win_local.h"
|
|
|
|
#include "../../ui/DeviceContext.h"
|
|
|
|
#include "../../ui/EditWindow.h"
|
|
|
|
#include "../../ui/ListWindow.h"
|
|
|
|
#include "../../ui/BindWindow.h"
|
|
|
|
#include "../../ui/RenderWindow.h"
|
|
|
|
#include "../../ui/ChoiceWindow.h"
|
|
|
|
|
|
|
|
#include "GEApp.h"
|
|
|
|
#include "GEItemPropsDlg.h"
|
|
|
|
#include "GEItemScriptsDlg.h"
|
|
|
|
|
|
|
|
// Modifiers
|
|
|
|
#include "GEModifierGroup.h"
|
|
|
|
#include "GEMoveModifier.h"
|
|
|
|
#include "GESizeModifier.h"
|
|
|
|
#include "GEStateModifier.h"
|
|
|
|
#include "GEZOrderModifier.h"
|
|
|
|
#include "GEInsertModifier.h"
|
|
|
|
#include "GEHideModifier.h"
|
|
|
|
#include "GEDeleteModifier.h"
|
|
|
|
|
|
|
|
static float g_ZoomScales[rvGEWorkspace::ZOOM_MAX] = { 0, 0.25f, 0.33f, 0.50f, 0.66f, 1.0f, 1.5f, 2.0f, 3.0f };
|
|
|
|
|
|
|
|
static const int ID_GUIED_SELECT_FIRST = 9800;
|
|
|
|
static const int ID_GUIED_SELECT_LAST = 9900;
|
|
|
|
|
|
|
|
idList<rvGEClipboardItem*> rvGEWorkspace::mClipboard;
|
|
|
|
|
|
|
|
rvGEWorkspace::rvGEWorkspace ( rvGEApp* app ) : mApplication ( app )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
mWnd = 0;
|
|
|
|
mInterface = 0;
|
|
|
|
mZoom = ZOOM_100;
|
|
|
|
mScrollHorz = false;
|
|
|
|
mScrollVert = false;
|
|
|
|
mModified = false;
|
2011-11-22 21:28:15 +00:00
|
|
|
mNew = false;
|
2011-12-06 18:20:15 +00:00
|
|
|
mDragScroll = false;
|
2011-11-22 21:28:15 +00:00
|
|
|
mSourceControlState = SCS_CHECKEDOUT;
|
2011-12-06 18:20:15 +00:00
|
|
|
mFilename = "guis/Untitled.gui";
|
2011-11-22 21:28:15 +00:00
|
|
|
mDragType = rvGESelectionMgr::HT_NONE;
|
2011-12-06 18:20:15 +00:00
|
|
|
mHandCursor = LoadCursor ( app->GetInstance(), MAKEINTRESOURCE(IDC_GUIED_HAND) );
|
2011-11-22 21:28:15 +00:00
|
|
|
mDontAdd = false;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mSelections.SetWorkspace ( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
rvGEWorkspace::~rvGEWorkspace ( )
|
|
|
|
{
|
|
|
|
// Make sure all the wrappers get cleaned up
|
|
|
|
rvGEWindowWrapper::GetWrapper ( mInterface->GetDesktop ( ) )->EnumChildren ( CleanupEnumProc, NULL );
|
|
|
|
|
|
|
|
DestroyCursor ( mHandCursor );
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
delete mInterface;
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::CleanupEnumProc
|
|
|
|
|
|
|
|
Window enumeration procedure that deletes all the wrapper classes
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
bool rvGEWorkspace::CleanupEnumProc ( rvGEWindowWrapper* wrapper, void* data )
|
|
|
|
{
|
|
|
|
bool result;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( !wrapper )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
result = wrapper->EnumChildren ( CleanupEnumProc, data );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Cleanup the window wrapper
|
|
|
|
delete wrapper;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::GetZoomScale
|
|
|
|
|
|
|
|
Returns the scale of the current zoom level
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
float rvGEWorkspace::GetZoomScale ( void )
|
|
|
|
{
|
|
|
|
return g_ZoomScales [ mZoom ];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::Attach
|
|
|
|
|
|
|
|
Attaches the workspace to the given window. This is usually done after the
|
|
|
|
window is created and the file has been loaded.
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
bool rvGEWorkspace::Attach ( HWND wnd )
|
|
|
|
{
|
|
|
|
assert ( wnd );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mWnd = wnd;
|
|
|
|
|
|
|
|
// Initialize the pixel format for this window
|
|
|
|
SetupPixelFormat ( );
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// Jam the workspace pointer into the userdata window long so
|
2011-11-22 21:28:15 +00:00
|
|
|
// we can retrieve the workspace from the window later
|
2021-05-06 00:07:41 +00:00
|
|
|
SetWindowLongPtr( mWnd, GWLP_USERDATA, ( LONG_PTR ) this );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
UpdateTitle ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::Detach
|
|
|
|
|
|
|
|
Detaches the workspace from the window it is currently attached to
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::Detach ( void )
|
|
|
|
{
|
|
|
|
assert ( mWnd );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2021-05-06 00:07:41 +00:00
|
|
|
SetWindowLongPtr ( mWnd, GWLP_USERDATA, 0 );
|
2011-11-22 21:28:15 +00:00
|
|
|
mWnd = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::SetupPixelFormat
|
|
|
|
|
|
|
|
Setup the pixel format for the opengl context
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
bool rvGEWorkspace::SetupPixelFormat ( void )
|
|
|
|
{
|
|
|
|
HDC hDC = GetDC ( mWnd );
|
|
|
|
bool result = true;
|
|
|
|
|
|
|
|
int pixelFormat = ChoosePixelFormat(hDC, &win32.pfd);
|
2011-12-06 18:20:15 +00:00
|
|
|
if (pixelFormat > 0)
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
if (SetPixelFormat(hDC, pixelFormat, &win32.pfd) == NULL)
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
else
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
ReleaseDC ( mWnd, hDC );
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::RenderGrid
|
|
|
|
|
|
|
|
Renders the grid on top of the user interface
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::RenderGrid ( void )
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float step;
|
|
|
|
idVec4& color = mApplication->GetOptions().GetGridColor ( );
|
|
|
|
|
|
|
|
// See if the grid is off before rendering it
|
|
|
|
if ( !mApplication->GetOptions().GetGridVisible ( ))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
qglEnable(GL_BLEND);
|
|
|
|
qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
qglColor4f ( color[0], color[1], color[2], 0.5f );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
qglBegin ( GL_LINES );
|
|
|
|
step = mApplication->GetOptions().GetGridWidth ( ) * g_ZoomScales[mZoom];
|
|
|
|
for ( x = mRect.x + mRect.w; x >= mRect.x ; x -= step )
|
|
|
|
{
|
|
|
|
qglVertex2f ( x, mRect.y );
|
|
|
|
qglVertex2f ( x, mRect.y + mRect.h );
|
|
|
|
}
|
|
|
|
step = mApplication->GetOptions().GetGridHeight ( ) * g_ZoomScales[mZoom];
|
|
|
|
for ( y = mRect.y + mRect.h; y >= mRect.y ; y -= step )
|
|
|
|
{
|
|
|
|
qglVertex2f ( mRect.x, y );
|
|
|
|
qglVertex2f ( mRect.x + mRect.w, y );
|
|
|
|
}
|
|
|
|
qglEnd ( );
|
|
|
|
|
|
|
|
qglDisable(GL_BLEND);
|
|
|
|
qglColor3f ( color[0], color[1], color[2] );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
qglBegin ( GL_LINES );
|
|
|
|
step = mApplication->GetOptions().GetGridWidth ( ) * g_ZoomScales[mZoom];
|
|
|
|
for ( x = mRect.x + mRect.w; x >= mRect.x ; x -= step * 4 )
|
|
|
|
{
|
|
|
|
qglVertex2f ( x, mRect.y );
|
|
|
|
qglVertex2f ( x, mRect.y + mRect.h );
|
|
|
|
}
|
|
|
|
step = mApplication->GetOptions().GetGridHeight ( ) * g_ZoomScales[mZoom];
|
|
|
|
for ( y = mRect.y + mRect.h; y >= mRect.y ; y -= step * 4 )
|
|
|
|
{
|
|
|
|
qglVertex2f ( mRect.x, y );
|
|
|
|
qglVertex2f ( mRect.x + mRect.w, y );
|
|
|
|
}
|
|
|
|
qglEnd ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::Render
|
|
|
|
|
|
|
|
Renders the workspace to the given DC
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::Render ( HDC hdc )
|
|
|
|
{
|
|
|
|
int front;
|
|
|
|
int back;
|
|
|
|
float scale;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
scale = g_ZoomScales[mZoom];
|
|
|
|
|
|
|
|
// Switch GL contexts to our dc
|
2011-12-06 18:20:15 +00:00
|
|
|
if (!qwglMakeCurrent( hdc, win32.hGLRC ))
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
common->Printf("ERROR: wglMakeCurrent failed.. Error:%i\n", qglGetError());
|
|
|
|
common->Printf("Please restart Q3Radiant if the Map view is not working\n");
|
2011-12-06 18:20:15 +00:00
|
|
|
return;
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare the view and clear it
|
|
|
|
GL_State( GLS_DEFAULT );
|
|
|
|
qglViewport(0, 0, mWindowWidth, mWindowHeight );
|
|
|
|
qglScissor(0, 0, mWindowWidth, mWindowHeight );
|
|
|
|
qglClearColor ( 0.75f, 0.75f, 0.75f, 0 );
|
|
|
|
|
|
|
|
qglDisable(GL_DEPTH_TEST);
|
|
|
|
qglDisable(GL_CULL_FACE);
|
|
|
|
qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
// Render the workspace below
|
2019-01-07 01:42:00 +00:00
|
|
|
qglMatrixMode(GL_PROJECTION);
|
|
|
|
qglLoadIdentity();
|
2011-11-22 21:28:15 +00:00
|
|
|
qglOrtho(0,mWindowWidth, mWindowHeight, 0, -1, 1);
|
2019-01-07 01:42:00 +00:00
|
|
|
qglMatrixMode(GL_MODELVIEW);
|
|
|
|
qglLoadIdentity();
|
2011-11-22 21:28:15 +00:00
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
qglColor3f ( mApplication->GetOptions().GetWorkspaceColor()[0], mApplication->GetOptions().GetWorkspaceColor()[1], mApplication->GetOptions().GetWorkspaceColor()[2] );
|
2011-11-22 21:28:15 +00:00
|
|
|
qglBegin ( GL_QUADS );
|
|
|
|
qglVertex2f ( mRect.x, mRect.y );
|
|
|
|
qglVertex2f ( mRect.x + mRect.w, mRect.y );
|
|
|
|
qglVertex2f ( mRect.x + mRect.w, mRect.y + mRect.h );
|
|
|
|
qglVertex2f ( mRect.x, mRect.y + mRect.h );
|
|
|
|
qglEnd ( );
|
|
|
|
|
|
|
|
// Prepare the renderSystem view to draw the GUI in
|
|
|
|
viewDef_t viewDef;
|
|
|
|
memset ( &viewDef, 0, sizeof(viewDef) );
|
|
|
|
tr.viewDef = &viewDef;
|
|
|
|
tr.viewDef->renderView.x = mRect.x;
|
|
|
|
tr.viewDef->renderView.y = mWindowHeight - mRect.y - mRect.h;
|
|
|
|
tr.viewDef->renderView.width = mRect.w;
|
|
|
|
tr.viewDef->renderView.height = mRect.h;
|
|
|
|
tr.viewDef->scissor.x1 = 0;
|
|
|
|
tr.viewDef->scissor.y1 = 0;
|
|
|
|
tr.viewDef->scissor.x2 = mRect.w;
|
|
|
|
tr.viewDef->scissor.y2 = mRect.h;
|
|
|
|
tr.viewDef->isEditor = true;
|
|
|
|
renderSystem->BeginFrame(mWindowWidth, mWindowHeight );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Draw the gui
|
|
|
|
mInterface->Redraw ( 0 ); // eventLoop->Milliseconds() );
|
|
|
|
|
|
|
|
// We are done using the renderSystem now
|
|
|
|
renderSystem->EndFrame( &front, &back );
|
|
|
|
|
|
|
|
if ( mApplication->GetActiveWorkspace ( ) == this )
|
|
|
|
{
|
|
|
|
mApplication->GetStatusBar().SetTriangles ( backEnd.pc.c_drawIndexes/3 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare the viewport for drawing selections, etc.
|
|
|
|
GL_State( GLS_DEFAULT );
|
|
|
|
qglDisable( GL_TEXTURE_CUBE_MAP_EXT );
|
|
|
|
// qglDisable(GL_BLEND);
|
|
|
|
qglDisable(GL_CULL_FACE);
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
qglViewport(0, 0, mWindowWidth, mWindowHeight );
|
|
|
|
qglScissor(0, 0, mWindowWidth, mWindowHeight );
|
2019-01-07 01:42:00 +00:00
|
|
|
qglMatrixMode(GL_PROJECTION);
|
|
|
|
qglLoadIdentity();
|
2011-11-22 21:28:15 +00:00
|
|
|
qglOrtho(0,mWindowWidth, mWindowHeight, 0, -1, 1);
|
2019-01-07 01:42:00 +00:00
|
|
|
qglMatrixMode(GL_MODELVIEW);
|
|
|
|
qglLoadIdentity();
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
RenderGrid ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mSelections.Render ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
qglFinish ( );
|
|
|
|
qwglSwapBuffers(hdc);
|
|
|
|
|
|
|
|
qglEnable( GL_TEXTURE_CUBE_MAP_EXT );
|
|
|
|
qglEnable( GL_CULL_FACE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::UpdateTitle
|
|
|
|
|
|
|
|
Updates the window title with the name of the file and the zoom level and weither its open or not
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::UpdateTitle ( void )
|
|
|
|
{
|
|
|
|
// Set the window title based on the current filename
|
|
|
|
SetWindowText ( mWnd, va("%s%s (%d%%)", idStr(mFilename).StripPath ( ).c_str( ), mModified?"*":"", (int) (g_ZoomScales[mZoom] * 100)) );
|
|
|
|
|
|
|
|
gApp.GetStatusBar().SetZoom ( (int)(g_ZoomScales[mZoom] * 100.0f) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::UpdateRectangle
|
|
|
|
|
|
|
|
Updates the rectangle (not counting scrolling)
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::UpdateRectangle ( bool useScroll )
|
|
|
|
{
|
|
|
|
RECT rcClient;
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float scale;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
scale = g_ZoomScales[mZoom];
|
|
|
|
|
|
|
|
// Grab the current client rectangle of the window and cache off the width and height
|
|
|
|
GetClientRect ( mWnd, &rcClient );
|
|
|
|
mWindowWidth = rcClient.right - rcClient.left;
|
|
|
|
mWindowHeight = rcClient.bottom - rcClient.top;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// The workspace is always centered in the window
|
|
|
|
x = mRect.x = mWindowWidth / 2 - (SCREEN_WIDTH * scale) / 2;
|
|
|
|
y = mRect.y = mWindowHeight / 2 - (SCREEN_HEIGHT * scale) / 2;
|
|
|
|
mRect.w = (SCREEN_WIDTH * scale);
|
|
|
|
mRect.h = (SCREEN_HEIGHT * scale);
|
|
|
|
|
|
|
|
// When using the scroll position offset the rectangle based on the scrollbar positions
|
|
|
|
if ( useScroll )
|
|
|
|
{
|
|
|
|
// Adjust the start of the rectangle for the scroll positiond
|
|
|
|
mRect.y -= (float)GetScrollPos ( mWnd, SB_VERT ) / 1000.0f;
|
|
|
|
mRect.x -= (float)GetScrollPos ( mWnd, SB_HORZ ) / 1000.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::Scroll
|
|
|
|
|
|
|
|
Adjusts the given scrollbar by the given offset
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::Scroll ( int scrollbar, int offset )
|
|
|
|
{
|
|
|
|
SCROLLINFO si;
|
|
|
|
|
|
|
|
if ( scrollbar == SB_HORZ && !mScrollHorz )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if ( scrollbar == SB_VERT && !mScrollVert )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Get all the vertial scroll bar information
|
|
|
|
si.cbSize = sizeof (si);
|
|
|
|
si.fMask = SIF_ALL;
|
|
|
|
|
|
|
|
// Save the position for comparison later on
|
|
|
|
GetScrollInfo ( mWnd, scrollbar, &si);
|
|
|
|
|
|
|
|
si.nPos += (1000 * offset);
|
|
|
|
if ( si.nPos < si.nMin ) si.nPos = si.nMin;
|
|
|
|
if ( si.nPos > si.nMax ) si.nPos = si.nMax;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
si.fMask = SIF_POS;
|
|
|
|
SetScrollInfo (mWnd, scrollbar, &si, TRUE);
|
|
|
|
GetScrollInfo (mWnd, scrollbar, &si);
|
|
|
|
|
|
|
|
UpdateRectangle ( );
|
|
|
|
}
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
int rvGEWorkspace::HandleScroll ( int scrollbar, WPARAM wParam, LPARAM lParam )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
SCROLLINFO si;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Get all the vertial scroll bar information
|
|
|
|
si.cbSize = sizeof (si);
|
|
|
|
si.fMask = SIF_ALL;
|
|
|
|
|
|
|
|
// Save the position for comparison later on
|
|
|
|
GetScrollInfo ( mWnd, scrollbar, &si);
|
|
|
|
|
|
|
|
switch (LOWORD (wParam))
|
|
|
|
{
|
|
|
|
// user clicked left or up arrow
|
2011-12-06 18:20:15 +00:00
|
|
|
case SB_LINELEFT:
|
2011-11-22 21:28:15 +00:00
|
|
|
si.nPos -= 1000;
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// user clicked right or down arrow
|
2011-12-06 18:20:15 +00:00
|
|
|
case SB_LINERIGHT:
|
2011-11-22 21:28:15 +00:00
|
|
|
si.nPos += 1000;
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// user clicked shaft left of the scroll box
|
|
|
|
case SB_PAGELEFT:
|
|
|
|
si.nPos -= si.nPage;
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// user clicked shaft right of the scroll box
|
|
|
|
case SB_PAGERIGHT:
|
|
|
|
si.nPos += si.nPage;
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// user dragged the scroll box
|
2011-12-06 18:20:15 +00:00
|
|
|
case SB_THUMBTRACK:
|
2011-11-22 21:28:15 +00:00
|
|
|
si.nPos = si.nTrackPos;
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the position and then retrieve it. Due to adjustments
|
|
|
|
// by Windows it may not be the same as the value set.
|
|
|
|
si.fMask = SIF_POS;
|
|
|
|
SetScrollInfo (mWnd, scrollbar, &si, TRUE);
|
|
|
|
GetScrollInfo (mWnd, scrollbar, &si);
|
|
|
|
|
|
|
|
UpdateRectangle ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::UpdateScrollbars
|
|
|
|
|
|
|
|
Updates the states and the ranges of the scrollbars as well as the rectangle
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::UpdateScrollbars ( void )
|
|
|
|
{
|
|
|
|
SCROLLINFO info;
|
|
|
|
|
|
|
|
// First update the rectangle without applying scroll positions so
|
|
|
|
// we know the real sizes and coordinates
|
|
|
|
UpdateRectangle ( false );
|
|
|
|
|
|
|
|
// Setup the veritcal scrollbar
|
|
|
|
info.cbSize = sizeof(info);
|
|
|
|
info.fMask = SIF_RANGE|SIF_PAGE;
|
2011-12-06 18:20:15 +00:00
|
|
|
info.nMax = (mRect.h - mWindowHeight + 10) * 1000 / 2;
|
2011-11-22 21:28:15 +00:00
|
|
|
info.nMin = -info.nMax;
|
|
|
|
info.nPage = (int)((float)info.nMax * (float)((float)mWindowHeight / mRect.h));
|
|
|
|
info.nMax += info.nPage;
|
|
|
|
|
|
|
|
// If there is something to scroll then turn on the vertical scroll bar
|
|
|
|
// if its not on and update the scroll info.
|
|
|
|
if ( info.nMax > 0 )
|
|
|
|
{
|
|
|
|
if ( !mScrollVert )
|
|
|
|
{
|
|
|
|
mScrollVert = true;
|
|
|
|
ShowScrollBar ( mWnd, SB_VERT, mScrollVert );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
SetScrollInfo ( mWnd, SB_VERT, &info, TRUE );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
// Nothing to scroll, turn off the scrollbar if its on.
|
|
|
|
else if ( mScrollVert )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
mScrollVert = false;
|
|
|
|
SetScrollPos ( mWnd, SB_VERT, 0, FALSE );
|
|
|
|
ShowScrollBar ( mWnd, SB_VERT, mScrollVert );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup the horizontal scrollbar
|
2011-12-06 18:20:15 +00:00
|
|
|
info.nMax = (mRect.w - mWindowWidth + 10) * 1000 / 2;
|
2011-11-22 21:28:15 +00:00
|
|
|
info.nMin = -info.nMax;
|
|
|
|
info.nPage = (int)((float)info.nMax * (float)((float)mWindowWidth / mRect.w));
|
|
|
|
info.nMax += info.nPage;
|
|
|
|
|
|
|
|
// If there is something to scroll then turn on the vertical scroll bar
|
|
|
|
// if its not on and update the scroll info.
|
|
|
|
if ( info.nMax > 0 )
|
|
|
|
{
|
|
|
|
if ( !mScrollHorz )
|
|
|
|
{
|
|
|
|
mScrollHorz = true;
|
|
|
|
ShowScrollBar ( mWnd, SB_HORZ, mScrollHorz );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
SetScrollInfo ( mWnd, SB_HORZ, &info, TRUE );
|
|
|
|
}
|
|
|
|
// Nothing to scroll, turn off the scrollbar if its on.
|
|
|
|
else if ( mScrollHorz )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
mScrollHorz = false;
|
|
|
|
SetScrollPos ( mWnd, SB_HORZ, 0, FALSE );
|
|
|
|
ShowScrollBar ( mWnd, SB_HORZ, mScrollHorz );
|
|
|
|
}
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// Need to update the rectangle again to take the scrollbar changes into account
|
2011-11-22 21:28:15 +00:00
|
|
|
UpdateRectangle ( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::UpdateCursor
|
|
|
|
|
|
|
|
Called to update the cursor when the mouse is within the workspace window
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::UpdateCursor ( rvGESelectionMgr::EHitTest type )
|
|
|
|
{
|
|
|
|
switch ( type )
|
|
|
|
{
|
|
|
|
case rvGESelectionMgr::HT_SELECT:
|
|
|
|
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW) ) );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case rvGESelectionMgr::HT_MOVE:
|
|
|
|
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_SIZEALL) ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGESelectionMgr::HT_SIZE_LEFT:
|
|
|
|
case rvGESelectionMgr::HT_SIZE_RIGHT:
|
|
|
|
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_SIZEWE ) ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGESelectionMgr::HT_SIZE_TOP:
|
|
|
|
case rvGESelectionMgr::HT_SIZE_BOTTOM:
|
|
|
|
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_SIZENS ) ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGESelectionMgr::HT_SIZE_TOPRIGHT:
|
|
|
|
case rvGESelectionMgr::HT_SIZE_BOTTOMLEFT:
|
|
|
|
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_SIZENESW ) ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGESelectionMgr::HT_SIZE_BOTTOMRIGHT:
|
|
|
|
case rvGESelectionMgr::HT_SIZE_TOPLEFT:
|
|
|
|
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_SIZENWSE ) ) );
|
|
|
|
break;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
void rvGEWorkspace::UpdateCursor ( float x, float y )
|
|
|
|
{
|
|
|
|
idVec2 point;
|
|
|
|
rvGESelectionMgr::EHitTest type;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// First convert the worspace coord to a window coord
|
|
|
|
point = WorkspaceToWindow ( idVec2( x, y ) );
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// See if it hits anything
|
2011-11-22 21:28:15 +00:00
|
|
|
type = mSelections.HitTest ( point.x, point.y );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// If it hits something then use it to update the cursor
|
|
|
|
if ( rvGESelectionMgr::HT_NONE != type )
|
|
|
|
{
|
|
|
|
UpdateCursor ( type );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW ) ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::UpdateCursor ( void )
|
|
|
|
{
|
|
|
|
if ( mDragType == rvGESelectionMgr::HT_NONE )
|
|
|
|
{
|
|
|
|
POINT point;
|
|
|
|
idVec2 cursor;
|
|
|
|
|
|
|
|
GetCursorPos ( &point );
|
|
|
|
cursor.Set ( point.x, point.y );
|
|
|
|
WindowToWorkspace ( cursor );
|
|
|
|
|
|
|
|
UpdateCursor ( cursor.x, cursor.y );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UpdateCursor ( mDragType );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::HandleMessage
|
|
|
|
|
|
|
|
Handles window messages to the workspace
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::HandleMessage ( UINT msg, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
switch ( msg )
|
|
|
|
{
|
|
|
|
case WM_CLOSE:
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( IsModified ( ) )
|
|
|
|
{
|
|
|
|
if ( IDYES == gApp.MessageBox ( va("Save changes to the document \"%s\" before closing?", GetFilename() ), MB_YESNO|MB_ICONQUESTION ) )
|
|
|
|
{
|
|
|
|
SendMessage ( mApplication->GetMDIFrame(), WM_COMMAND, MAKELONG(ID_GUIED_FILE_SAVE,0), 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
GetApplication ( )->GetNavigator().SetWorkspace(NULL);
|
2011-11-22 21:28:15 +00:00
|
|
|
GetApplication ( )->GetTransformer().SetWorkspace(NULL);
|
|
|
|
GetApplication ( )->GetProperties().SetWorkspace(NULL);
|
|
|
|
break;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_CAPTURECHANGED:
|
|
|
|
if ( (HWND)lParam != mWnd )
|
|
|
|
{
|
|
|
|
mDragScroll = false;
|
|
|
|
mDragType = rvGESelectionMgr::HT_NONE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SETCURSOR:
|
|
|
|
{
|
|
|
|
POINT point;
|
|
|
|
idVec2 cursor;
|
|
|
|
GetCursorPos ( &point );
|
|
|
|
cursor.Set ( point.x, point.y );
|
|
|
|
WindowToWorkspace ( cursor );
|
|
|
|
if ( mDragType == rvGESelectionMgr::HT_NONE )
|
|
|
|
{
|
|
|
|
UpdateCursor ( cursor.x, cursor.y );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UpdateCursor ( mDragType );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_MOUSEWHEEL:
|
|
|
|
if ( (short)HIWORD(wParam) > 0 )
|
|
|
|
{
|
|
|
|
ZoomIn ( );
|
|
|
|
}
|
|
|
|
else if ( (short)HIWORD(wParam) < 0 )
|
|
|
|
{
|
|
|
|
ZoomOut ( );
|
|
|
|
}
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
HandleMouseMove ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
HandleMButtonDown ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_MBUTTONUP:
|
|
|
|
HandleMButtonUp ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
HandleLButtonDown ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_LBUTTONUP:
|
|
|
|
HandleLButtonUp ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
HandleLButtonDblClk ( wParam, lParam );
|
|
|
|
break;
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
case WM_INITMENUPOPUP:
|
2011-11-22 21:28:15 +00:00
|
|
|
SendMessage ( mApplication->GetMDIFrame(), msg, wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
HandleCommand ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
HandleRButtonDown ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_SIZE:
|
|
|
|
UpdateScrollbars();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_VSCROLL:
|
|
|
|
HandleScroll ( SB_VERT, wParam, lParam );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_HSCROLL:
|
|
|
|
HandleScroll ( SB_HORZ, wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_KEYDOWN:
|
|
|
|
HandleKeyDown ( wParam, lParam );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::HandleCommand
|
|
|
|
|
|
|
|
Handles command messages destined for the workspace window. This is for
|
|
|
|
special workspace commands, any unhandled commands are forwarded to the main window
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEWorkspace::HandleCommand ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
// Select command
|
|
|
|
if ( LOWORD(wParam) >= ID_GUIED_SELECT_FIRST && LOWORD(wParam) <= ID_GUIED_SELECT_LAST )
|
|
|
|
{
|
|
|
|
idWindow* window = mSelectMenu[LOWORD(wParam)-ID_GUIED_SELECT_FIRST];
|
|
|
|
rvGEWindowWrapper* wrapper = rvGEWindowWrapper::GetWrapper ( window );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Handle multi select as well
|
|
|
|
if ( GetAsyncKeyState ( VK_SHIFT ) & 0x8000 )
|
|
|
|
{
|
|
|
|
if ( wrapper->IsSelected ( ) )
|
|
|
|
{
|
|
|
|
mSelections.Remove ( window );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mSelections.Add ( window );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
mSelections.Set ( window );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SendMessage ( mApplication->GetMDIFrame(), WM_COMMAND, wParam, lParam );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::HandleMButtonDown
|
|
|
|
|
|
|
|
Handles the middle mouse down message in the workspace
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEWorkspace::HandleMButtonDown ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
if ( mDragType != rvGESelectionMgr::HT_NONE )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mDragPoint.Set ( LOWORD(lParam), HIWORD(lParam) );
|
|
|
|
mDragScroll = true;
|
|
|
|
SetCursor ( mHandCursor );
|
|
|
|
SetCapture ( mWnd );
|
|
|
|
|
|
|
|
WindowToWorkspace ( mDragPoint );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::HandleMButtonUp
|
|
|
|
|
|
|
|
Handles the middle mouse up message in the workspace
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEWorkspace::HandleMButtonUp ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
if ( mDragScroll )
|
|
|
|
{
|
|
|
|
mDragScroll = false;
|
|
|
|
ReleaseCapture ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::HandleRButtonDown
|
|
|
|
|
|
|
|
Handles the left mouse down message in the workspace
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEWorkspace::HandleRButtonDown ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
POINT point = { LOWORD(lParam), HIWORD(lParam) };
|
2011-11-22 21:28:15 +00:00
|
|
|
HMENU menu;
|
|
|
|
|
|
|
|
// Add the select menu
|
|
|
|
mSelectMenu.Clear ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
// Cache where the menu is being brought up so we can
|
2011-11-22 21:28:15 +00:00
|
|
|
// figure out which windows are under the point
|
|
|
|
mSelectMenuPos[0] = point.x;
|
|
|
|
mSelectMenuPos[1] = point.y;
|
2011-12-06 18:20:15 +00:00
|
|
|
WindowToWorkspace ( mSelectMenuPos );
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Build a list of all the windows under the menu point
|
|
|
|
rvGEWindowWrapper::GetWrapper ( mInterface->GetDesktop() )->EnumChildren ( BuildSelectMenuEnumProc, this );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Add the desktop window always
|
|
|
|
mSelectMenu.Append ( mInterface->GetDesktop() );
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
//
|
2011-11-22 21:28:15 +00:00
|
|
|
menu = GetSubMenu ( LoadMenu ( mApplication->GetInstance(), MAKEINTRESOURCE(IDR_GUIED_ITEM_POPUP) ), 0 );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
HMENU popup = CreatePopupMenu ( );
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
int i;
|
|
|
|
for ( i = 0; i < mSelectMenu.Num(); i ++ )
|
|
|
|
{
|
|
|
|
rvGEWindowWrapper* wrapper = rvGEWindowWrapper::GetWrapper ( mSelectMenu[i] );
|
|
|
|
AppendMenu ( popup, MF_STRING|MF_ENABLED|(wrapper->IsSelected()?MF_CHECKED:0), ID_GUIED_SELECT_FIRST + i, mSelectMenu[i]->GetName() );
|
|
|
|
}
|
|
|
|
|
|
|
|
InsertMenu ( menu, 1, MF_POPUP|MF_BYPOSITION, (LONG) popup, "Select" );
|
|
|
|
|
|
|
|
// Bring up the popup menu
|
|
|
|
ClientToScreen ( mWnd, &point );
|
|
|
|
TrackPopupMenu ( menu, TPM_RIGHTBUTTON|TPM_LEFTALIGN, point.x, point.y, 0, mWnd, NULL );
|
|
|
|
|
|
|
|
DestroyMenu ( popup );
|
|
|
|
DestroyMenu ( menu );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::HandleLButtonDown
|
|
|
|
|
|
|
|
Handles the left mouse down message in the workspace
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEWorkspace::HandleLButtonDown ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
if ( mDragScroll )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
idVec2 point ( LOWORD(lParam), HIWORD(lParam) );
|
2011-11-22 21:28:15 +00:00
|
|
|
WindowToWorkspace ( point );
|
|
|
|
|
|
|
|
// Make sure whatever modifications get generated cant be merged into whats already there
|
|
|
|
mModifiers.BlockNextMerge ( );
|
|
|
|
|
|
|
|
mDragPoint.Set ( LOWORD(lParam), HIWORD(lParam) );
|
|
|
|
mDragTime = Sys_Milliseconds ( );
|
|
|
|
mDragX = true;
|
|
|
|
mDragY = true;
|
|
|
|
|
|
|
|
// If we have selections then start a drag
|
|
|
|
if ( mSelections.Num ( ) )
|
|
|
|
{
|
|
|
|
mDragType = mSelections.HitTest ( mDragPoint.x, mDragPoint.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
rvGEWindowWrapper* wrapper;
|
|
|
|
wrapper = rvGEWindowWrapper::GetWrapper ( mInterface->GetDesktop ( ) );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
idWindow* window = wrapper->WindowFromPoint ( point.x, point.y );
|
|
|
|
|
|
|
|
// dissallow selection of the desktop.
|
|
|
|
if ( gApp.GetOptions().GetIgnoreDesktopSelect() && window == mInterface->GetDesktop ( ) )
|
|
|
|
{
|
|
|
|
window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( mDragType == rvGESelectionMgr::HT_MOVE || mDragType == rvGESelectionMgr::HT_NONE )
|
|
|
|
{
|
|
|
|
if ( window )
|
|
|
|
{
|
|
|
|
bool selected;
|
|
|
|
|
|
|
|
selected = mSelections.IsSelected ( window );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( GetAsyncKeyState ( VK_SHIFT ) & 0x8000 )
|
|
|
|
{
|
|
|
|
if ( !selected )
|
|
|
|
{
|
|
|
|
mSelections.Add ( window );
|
|
|
|
mDragType = rvGESelectionMgr::HT_MOVE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mSelections.Remove ( window );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( !selected && mDragType == rvGESelectionMgr::HT_NONE )
|
|
|
|
{
|
|
|
|
mSelections.Set ( window );
|
|
|
|
mDragType = rvGESelectionMgr::HT_MOVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mSelections.Clear ( );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( mSelections.IsExpression ( ) )
|
|
|
|
{
|
|
|
|
mDragType = rvGESelectionMgr::HT_SELECT;
|
|
|
|
}
|
|
|
|
// Windows capture
|
|
|
|
else if ( mDragType != rvGESelectionMgr::HT_NONE )
|
|
|
|
{
|
|
|
|
SetCapture ( mWnd );
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowToWorkspace ( mDragPoint );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::HandleLButtonUp
|
|
|
|
|
|
|
|
Handles the left mouse up message in the workspace
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEWorkspace::HandleLButtonUp ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
if ( mDragType != rvGESelectionMgr::HT_NONE )
|
|
|
|
{
|
|
|
|
ReleaseCapture ( );
|
|
|
|
mModifiers.BlockNextMerge ( );
|
|
|
|
|
|
|
|
// Update the transformer
|
|
|
|
mApplication->GetTransformer().Update ( );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// No more dragging
|
|
|
|
mDragType = rvGESelectionMgr::HT_NONE;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::HandleLButtonDblClk
|
|
|
|
|
|
|
|
Handle a double click by opening properties
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEWorkspace::HandleLButtonDblClk ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
EditSelectedProperties ( );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::HandleMouseMove
|
|
|
|
|
|
|
|
Handles the moving of the mouse for dragging and cursor updating
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEWorkspace::HandleMouseMove ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
idVec2 cursor;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
cursor.Set ( (short)LOWORD(lParam), (short)HIWORD(lParam) );
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// Convert the window point to the workspace before updating the
|
2011-11-22 21:28:15 +00:00
|
|
|
// cursor with the position
|
|
|
|
WindowToWorkspace ( cursor );
|
|
|
|
|
|
|
|
// Scrolling the window around
|
|
|
|
if ( mDragScroll )
|
|
|
|
{
|
|
|
|
Scroll ( SB_HORZ, mDragPoint.x - cursor.x );
|
|
|
|
Scroll ( SB_VERT, mDragPoint.y - cursor.y );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
SetCursor ( mHandCursor );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mDragPoint = cursor;
|
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
|
|
|
|
|
|
|
// If not dragging then just update the cursor and return
|
|
|
|
if ( mDragType == rvGESelectionMgr::HT_NONE )
|
|
|
|
{
|
|
|
|
UpdateCursor ( cursor.x, cursor.y );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dont allow a drag move start until the button has been down for 100 ms or so
|
|
|
|
if ( mDragType == rvGESelectionMgr::HT_MOVE && Sys_Milliseconds() - mDragTime <= 50 )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle grid snapping
|
|
|
|
if ( gApp.GetOptions().GetGridSnap ( ) )
|
|
|
|
{
|
|
|
|
cursor.x = (float)(((int)cursor.x + gApp.GetOptions().GetGridWidth()/2) / gApp.GetOptions().GetGridWidth() * gApp.GetOptions().GetGridWidth());
|
|
|
|
cursor.y = (float)(((int)cursor.y + gApp.GetOptions().GetGridWidth()/2) / gApp.GetOptions().GetGridWidth() * gApp.GetOptions().GetGridWidth());
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// If the cursor hasnt moved then there is nothing to update with the drag
|
|
|
|
if ( (int) cursor.x == (int) mDragPoint.x && (int) cursor.y == (int) mDragPoint.y )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
switch ( mDragType )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
case rvGESelectionMgr::HT_MOVE:
|
|
|
|
AddModifierMove ( "Move", cursor.x - mDragPoint.x, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case rvGESelectionMgr::HT_SIZE_BOTTOM:
|
|
|
|
AddModifierSize ( "Size", 0, 0, 0, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGESelectionMgr::HT_SIZE_TOP:
|
|
|
|
AddModifierSize ( "Size", 0, cursor.y - mDragPoint.y, 0, 0, mApplication->GetOptions().GetGridSnap ( ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGESelectionMgr::HT_SIZE_RIGHT:
|
|
|
|
AddModifierSize ( "Size", 0, 0, cursor.x - mDragPoint.x, 0, mApplication->GetOptions().GetGridSnap ( ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGESelectionMgr::HT_SIZE_LEFT:
|
|
|
|
AddModifierSize ( "Size", cursor.x - mDragPoint.x, 0, 0, 0, mApplication->GetOptions().GetGridSnap ( ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGESelectionMgr::HT_SIZE_TOPLEFT:
|
|
|
|
AddModifierSize ( "Size", cursor.x - mDragPoint.x, cursor.y - mDragPoint.y, 0, 0, mApplication->GetOptions().GetGridSnap ( ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGESelectionMgr::HT_SIZE_TOPRIGHT:
|
|
|
|
AddModifierSize ( "Size", 0, cursor.y - mDragPoint.y, cursor.x - mDragPoint.x, 0, mApplication->GetOptions().GetGridSnap ( ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGESelectionMgr::HT_SIZE_BOTTOMLEFT:
|
|
|
|
AddModifierSize ( "Size", cursor.x - mDragPoint.x, 0, 0, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGESelectionMgr::HT_SIZE_BOTTOMRIGHT:
|
|
|
|
AddModifierSize ( "Size", 0, 0, cursor.x - mDragPoint.x, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateCursor ( mDragType );
|
|
|
|
|
|
|
|
// If the x coordinate has changed then update it
|
|
|
|
if ( (int)cursor.x != (int)mDragPoint.x && mDragX )
|
|
|
|
{
|
|
|
|
mDragPoint.x = cursor.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the y coordinate has changed then update it
|
|
|
|
if ( (int)cursor.y != (int)mDragPoint.y && mDragY )
|
|
|
|
{
|
|
|
|
mDragPoint.y = cursor.y;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::HandleKeyDown
|
|
|
|
|
|
|
|
Handles the the pressing of a key
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvGEWorkspace::HandleKeyDown ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
bool shift = (GetAsyncKeyState ( VK_SHIFT ) & 0x8000) ? true : false;
|
|
|
|
|
|
|
|
switch ( wParam )
|
|
|
|
{
|
|
|
|
case VK_LEFT:
|
|
|
|
if ( shift )
|
|
|
|
{
|
|
|
|
AddModifierSizeNudge ( -1, 0, false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AddModifierMoveNudge ( -1, 0, false );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case VK_RIGHT:
|
|
|
|
if ( shift )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
AddModifierSizeNudge ( 1, 0, false );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
AddModifierMoveNudge ( 1, 0, false );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case VK_DOWN:
|
|
|
|
if ( shift )
|
|
|
|
{
|
|
|
|
AddModifierSizeNudge ( 0, 1, false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AddModifierMoveNudge ( 0, 1, false );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case VK_UP:
|
|
|
|
if ( shift )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
AddModifierSizeNudge ( 0, -1, false );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
AddModifierMoveNudge ( 0, -1, false );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case VK_ESCAPE:
|
|
|
|
mSelections.Clear ( );
|
|
|
|
mApplication->GetNavigator().Update ( );
|
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 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::WindowToWorkspace
|
|
|
|
|
|
|
|
Converts the given coordinates in windows space to the workspace's coordinates.
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
idVec2& rvGEWorkspace::WindowToWorkspace ( idVec2& point )
|
|
|
|
{
|
|
|
|
point.x = (point.x - mRect.x) / mRect.w * SCREEN_WIDTH;
|
|
|
|
point.y = (point.y - mRect.y) / mRect.h * SCREEN_HEIGHT;
|
|
|
|
|
|
|
|
return point;
|
|
|
|
}
|
|
|
|
|
|
|
|
idRectangle& rvGEWorkspace::WindowToWorkspace ( idRectangle& rect )
|
|
|
|
{
|
|
|
|
rect.x = (rect.x - mRect.x) / mRect.w * SCREEN_WIDTH;
|
|
|
|
rect.y = (rect.y - mRect.y) / mRect.h * SCREEN_HEIGHT;
|
|
|
|
rect.w = rect.w / mRect.w * SCREEN_WIDTH;
|
|
|
|
rect.h = rect.h / mRect.h * SCREEN_HEIGHT;
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::WindowToWorkspace
|
|
|
|
|
|
|
|
Converts the given workspace coordinates to the windows coordinates.
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
idVec2& rvGEWorkspace::WorkspaceToWindow ( idVec2& point )
|
|
|
|
{
|
|
|
|
point.x = mRect.x + (point.x / SCREEN_WIDTH * mRect.w);
|
|
|
|
point.y = mRect.y + (point.y / SCREEN_HEIGHT * mRect.h);
|
|
|
|
|
|
|
|
return point;
|
|
|
|
}
|
|
|
|
|
|
|
|
idRectangle& rvGEWorkspace::WorkspaceToWindow ( idRectangle& rect )
|
|
|
|
{
|
|
|
|
rect.x = mRect.x + (rect.x / SCREEN_WIDTH * mRect.w);
|
|
|
|
rect.y = mRect.y + (rect.y / SCREEN_HEIGHT * mRect.h);
|
|
|
|
rect.w = rect.w / SCREEN_WIDTH * mRect.w;
|
|
|
|
rect.h = rect.h / SCREEN_HEIGHT * mRect.h;
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::ZoomIn
|
|
|
|
|
|
|
|
Zooms the workspace in by one zoom level
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
rvGEWorkspace::EZoomLevel rvGEWorkspace::ZoomIn ( void )
|
|
|
|
{
|
|
|
|
mZoom = mZoom + 1;
|
|
|
|
if ( mZoom >= ZOOM_MAX )
|
|
|
|
{
|
|
|
|
mZoom = ZOOM_MAX - 1;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
UpdateScrollbars ( );
|
|
|
|
UpdateTitle ( );
|
|
|
|
|
|
|
|
InvalidateRect ( mWnd, NULL, FALSE );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return (EZoomLevel)mZoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::ZoomOut
|
|
|
|
|
|
|
|
Zooms the workspace out by one level
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
rvGEWorkspace::EZoomLevel rvGEWorkspace::ZoomOut ( void )
|
|
|
|
{
|
|
|
|
mZoom--;
|
|
|
|
if ( mZoom <= ZOOM_MIN )
|
|
|
|
{
|
|
|
|
mZoom = ZOOM_MIN + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateScrollbars ( );
|
|
|
|
UpdateTitle ( );
|
|
|
|
|
|
|
|
InvalidateRect ( mWnd, NULL, FALSE );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return (EZoomLevel)mZoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::CreateModifier
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
Creates a new modifier of the given type for the given window. This function is called
|
2011-11-22 21:28:15 +00:00
|
|
|
specifically from the add modifiers function with the variable args list forwarded.
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
rvGEModifier* rvGEWorkspace::CreateModifier ( EModifierType type, idWindow* window, va_list args )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
rvGEModifier* mod;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
switch ( type )
|
|
|
|
{
|
|
|
|
case MOD_DELETE:
|
|
|
|
mod = new rvGEDeleteModifier ( "Delete", window );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case MOD_HIDE:
|
|
|
|
mod = new rvGEHideModifier ( "Hide", window, true );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case MOD_UNHIDE:
|
|
|
|
mod = new rvGEHideModifier ( "Hide", window, false );
|
2011-12-06 18:20:15 +00:00
|
|
|
break;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
case MOD_SEND_BACKWARD:
|
|
|
|
mod = new rvGEZOrderModifier ( "Send Backward", window, rvGEZOrderModifier::ZO_BACKWARD );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case MOD_SEND_BACK:
|
|
|
|
mod = new rvGEZOrderModifier ( "Send to Back", window, rvGEZOrderModifier::ZO_BACK );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MOD_BRING_FORWARD:
|
|
|
|
mod = new rvGEZOrderModifier ( "Bring Forward", window, rvGEZOrderModifier::ZO_FORWARD );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MOD_BRING_FRONT:
|
|
|
|
mod = new rvGEZOrderModifier ( "Bring to Front", window, rvGEZOrderModifier::ZO_FRONT );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
default:
|
|
|
|
mod = NULL;
|
|
|
|
break;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return mod;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::AddModifiers
|
|
|
|
|
|
|
|
Add the specific modifier for the given window
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::AddModifiers ( idWindow* window, EModifierType type, ... )
|
|
|
|
{
|
|
|
|
va_list args;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
va_start(args,type) ;
|
|
|
|
mModifiers.Append ( CreateModifier ( type, window, args ) );
|
|
|
|
va_end (args) ;
|
|
|
|
|
|
|
|
SetModified ( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::AddModifiers ( EModifierType type, ... )
|
|
|
|
{
|
|
|
|
va_list args;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Nothing to move if there is no selection
|
|
|
|
if ( !mSelections.Num ( ) )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// More than one selection requires a modifier group
|
|
|
|
else if ( mSelections.Num ( ) > 1 )
|
|
|
|
{
|
|
|
|
rvGEModifierGroup* group = new rvGEModifierGroup;
|
|
|
|
int i;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
for ( i = 0; i < mSelections.Num(); i ++ )
|
|
|
|
{
|
|
|
|
va_start(args,type);
|
|
|
|
group->Append ( CreateModifier ( type, mSelections[i], args ) );
|
|
|
|
va_end (args);
|
|
|
|
}
|
|
|
|
|
|
|
|
mModifiers.Append ( group );
|
|
|
|
}
|
|
|
|
// Single modifier
|
|
|
|
else
|
|
|
|
{
|
|
|
|
va_start(args,type) ;
|
|
|
|
mModifiers.Append ( CreateModifier ( type, mSelections[0], args ) );
|
|
|
|
va_end (args) ;
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
SetModified ( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rvGEWorkspace::BuildSelectMenuEnumProc ( rvGEWindowWrapper* wrapper, void* data )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
rvGEWorkspace* workspace;
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
workspace = (rvGEWorkspace*) data;
|
|
|
|
assert ( workspace );
|
|
|
|
|
|
|
|
if ( !wrapper )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
wrapper->EnumChildren ( BuildSelectMenuEnumProc, data );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( wrapper->IsDeleted ( ) || wrapper->IsHidden ( ) )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( wrapper->GetScreenRect ( ).Contains ( workspace->mSelectMenuPos[0], workspace->mSelectMenuPos[1] ) )
|
|
|
|
{
|
|
|
|
workspace->mSelectMenu.Append ( wrapper->GetWindow ( ));
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rvGEWorkspace::ShowAllEnumProc ( rvGEWindowWrapper* wrapper, void* data )
|
|
|
|
{
|
|
|
|
rvGEModifierGroup* group = (rvGEModifierGroup*) data;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
wrapper->EnumChildren ( ShowAllEnumProc, data );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( wrapper->IsHidden ( ) )
|
|
|
|
{
|
|
|
|
group->Append ( new rvGEHideModifier ( "Show Hidden", wrapper->GetWindow ( ), false ) );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::AddModifierShowAll ( void )
|
|
|
|
{
|
|
|
|
rvGEModifierGroup* group = new rvGEModifierGroup;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
rvGEWindowWrapper::GetWrapper( mInterface->GetDesktop ( ) )->EnumChildren ( ShowAllEnumProc, group );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( !group->GetCount ( ) )
|
|
|
|
{
|
|
|
|
delete group;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mModifiers.Append ( group );
|
|
|
|
}
|
|
|
|
|
|
|
|
mApplication->GetNavigator().Refresh ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::DeleteSelected ( void )
|
|
|
|
{
|
|
|
|
AddModifiers ( MOD_DELETE );
|
|
|
|
mSelections.Clear ( );
|
|
|
|
mApplication->GetNavigator().Update ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::NewWindow
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
Create a new window
|
2011-11-22 21:28:15 +00:00
|
|
|
================
|
|
|
|
*/
|
|
|
|
idWindow* rvGEWorkspace::NewWindow ( idDict* state, rvGEWindowWrapper::EWindowType type )
|
|
|
|
{
|
|
|
|
idWindow* window = new idWindow ( mInterface->GetDesktop()->GetDC(), mInterface );
|
|
|
|
rvGEWindowWrapper* wrapper;
|
|
|
|
int count;
|
|
|
|
idStr baseName;
|
|
|
|
|
|
|
|
switch ( type )
|
|
|
|
{
|
|
|
|
case rvGEWindowWrapper::WT_NORMAL:
|
|
|
|
window = new idWindow ( mInterface->GetDesktop()->GetDC(), mInterface );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case rvGEWindowWrapper::WT_BIND:
|
|
|
|
window = new idBindWindow ( mInterface->GetDesktop()->GetDC(), mInterface );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGEWindowWrapper::WT_RENDER:
|
|
|
|
window = new idRenderWindow ( mInterface->GetDesktop()->GetDC(), mInterface );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case rvGEWindowWrapper::WT_CHOICE:
|
|
|
|
window = new idChoiceWindow ( mInterface->GetDesktop()->GetDC(), mInterface );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rvGEWindowWrapper::WT_EDIT:
|
|
|
|
window = new idEditWindow ( mInterface->GetDesktop()->GetDC(), mInterface );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
default:
|
|
|
|
assert ( false );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
baseName = state ? state->GetString("name","unnamed") : "unnamed";
|
|
|
|
baseName.StripQuotes ( );
|
|
|
|
|
|
|
|
count = 0;
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( mInterface->GetDesktop()->FindChildByName ( baseName ) )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
count = 1;
|
|
|
|
while ( 1 )
|
|
|
|
{
|
|
|
|
drawWin_t* dw = mInterface->GetDesktop()->FindChildByName ( va("%s%d",baseName.c_str(),count) );
|
|
|
|
if ( !dw )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
assert ( dw->win );
|
|
|
|
wrapper = rvGEWindowWrapper::GetWrapper ( dw->win );
|
|
|
|
if ( wrapper && wrapper->IsDeleted ( ) )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
idStr winName;
|
|
|
|
idStr winTemplate;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( count )
|
|
|
|
{
|
|
|
|
winName = va("%s%d", baseName.c_str(), count );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
winName = baseName;
|
|
|
|
}
|
|
|
|
winTemplate = winName + " { }";
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
idParser src( winTemplate, winTemplate.Length(), "", LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
|
|
|
|
window->Parse ( &src );
|
|
|
|
|
|
|
|
wrapper = rvGEWindowWrapper::GetWrapper ( window );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( state )
|
|
|
|
{
|
|
|
|
wrapper->SetState ( *state );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
wrapper->SetStateKey ( "name", winName );
|
|
|
|
wrapper->Finish ( );
|
|
|
|
|
|
|
|
SetModified ( true );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
idWindow* rvGEWorkspace::AddWindow ( rvGEWindowWrapper::EWindowType type )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
idWindow* window;
|
2011-11-22 21:28:15 +00:00
|
|
|
idDict state;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
state.Set ( "rect", "0,0,100,100" );
|
|
|
|
state.Set ( "visible", "1" );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
window = NewWindow ( &state, type );
|
|
|
|
assert ( window );
|
|
|
|
|
|
|
|
mModifiers.Append ( new rvGEInsertModifier ( "New", window, mInterface->GetDesktop(), NULL ) );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mSelections.Set ( window );
|
|
|
|
mApplication->GetNavigator().Update ( );
|
|
|
|
mApplication->GetTransformer().Update ( );
|
|
|
|
mApplication->GetProperties().Update ( );
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rvGEWorkspace::EditSelectedProperties ( void )
|
|
|
|
{
|
|
|
|
if ( !mSelections.Num ( ) || mSelections.Num() > 1 )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
idDict dict;
|
|
|
|
if ( GEItemPropsDlg_DoModal ( mWnd, mSelections[0], dict ) )
|
|
|
|
{
|
|
|
|
mModifiers.Append ( new rvGEStateModifier ( "Item Properties", mSelections[0], dict ) );
|
|
|
|
SetModified ( true );
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mApplication->GetNavigator().Update ( );
|
2011-11-22 21:28:15 +00:00
|
|
|
mApplication->GetTransformer().Update ( );
|
|
|
|
mApplication->GetProperties().Update ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rvGEWorkspace::EditSelectedScripts ( void )
|
|
|
|
{
|
|
|
|
if ( GEItemScriptsDlg_DoModal ( mWnd, mSelections[0] ) )
|
|
|
|
{
|
|
|
|
gApp.GetNavigator().Refresh ( );
|
|
|
|
SetModified ( true );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return true;
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
void rvGEWorkspace::BringSelectedForward ( void )
|
|
|
|
{
|
|
|
|
AddModifiers ( MOD_BRING_FORWARD );
|
2011-12-06 18:20:15 +00:00
|
|
|
mApplication->GetNavigator().Update ( );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::BringSelectedToFront ( void )
|
|
|
|
{
|
|
|
|
AddModifiers ( MOD_BRING_FRONT );
|
2011-12-06 18:20:15 +00:00
|
|
|
mApplication->GetNavigator().Update ( );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::SendSelectedToBack ( void )
|
|
|
|
{
|
|
|
|
AddModifiers ( MOD_SEND_BACK );
|
2011-12-06 18:20:15 +00:00
|
|
|
mApplication->GetNavigator().Update ( );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::SendSelectedBackward ( void )
|
|
|
|
{
|
|
|
|
AddModifiers ( MOD_SEND_BACKWARD );
|
2011-12-06 18:20:15 +00:00
|
|
|
mApplication->GetNavigator().Update ( );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::MakeSelectedSameSize
|
|
|
|
|
|
|
|
Align the selected items to the first one using the given align type
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::MakeSelectedSameSize ( bool changeWidth, bool changeHeight )
|
|
|
|
{
|
|
|
|
rvGEModifierGroup* group;
|
|
|
|
idRectangle rectTo;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
group = new rvGEModifierGroup ( );
|
|
|
|
|
|
|
|
rectTo = rvGEWindowWrapper::GetWrapper ( mSelections[0] )->GetClientRect ( );
|
|
|
|
|
|
|
|
for ( i = 1; i < mSelections.Num(); i ++ )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
idRectangle rectFrom;
|
|
|
|
float width = 0;
|
|
|
|
float height = 0;
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
rectFrom = rvGEWindowWrapper::GetWrapper(mSelections[i])->GetClientRect ();
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( changeWidth )
|
|
|
|
{
|
|
|
|
width = rectTo.w - rectFrom.w;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( changeHeight )
|
|
|
|
{
|
|
|
|
height = rectTo.h - rectFrom.h;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
group->Append ( new rvGESizeModifier ( "Make Same Size", mSelections[i], 0, 0, width, height ) );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mModifiers.Append ( group );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Cant merge alignments
|
|
|
|
mModifiers.BlockNextMerge ( );
|
|
|
|
|
|
|
|
SetModified ( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::AlignSelected
|
|
|
|
|
|
|
|
Align the selected items to the first one using the given align type
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::AlignSelected ( EItemAlign align )
|
|
|
|
{
|
|
|
|
static const char* alignNames[]={"Lefts","Centers","Rights","Tops","Middles","Bottoms" };
|
|
|
|
int i;
|
|
|
|
idStr modName;
|
|
|
|
rvGEModifierGroup* group;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
assert ( mSelections.Num() > 1 );
|
|
|
|
|
|
|
|
modName = "Align " + idStr(alignNames[align]);
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
group = new rvGEModifierGroup ( );
|
|
|
|
|
|
|
|
idRectangle rectTo;
|
|
|
|
rectTo = rvGEWindowWrapper::GetWrapper ( mSelections[0] )->GetScreenRect ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Everything gets aligned to the first selection so run
|
|
|
|
// through all other selections and move them.
|
|
|
|
for ( i = 1; i < mSelections.Num(); i ++ )
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
idRectangle rectFrom;
|
|
|
|
|
|
|
|
rectFrom = rvGEWindowWrapper::GetWrapper ( mSelections[i] )->GetScreenRect ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
switch ( align )
|
|
|
|
{
|
|
|
|
case ALIGN_LEFTS:
|
|
|
|
x = rectTo[0] - rectFrom[0];
|
|
|
|
y = 0;
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ALIGN_RIGHTS:
|
|
|
|
x = (rectTo[0]+rectTo[2]) - (rectFrom[0]+rectFrom[2]);
|
|
|
|
y = 0;
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ALIGN_CENTERS:
|
|
|
|
x = (rectTo[0]+rectTo[2]/2) - (rectFrom[0]+rectFrom[2]/2);
|
|
|
|
y = 0;
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ALIGN_TOPS:
|
|
|
|
y = rectTo[1] - rectFrom[1];
|
|
|
|
x = 0;
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ALIGN_BOTTOMS:
|
|
|
|
x = 0;
|
|
|
|
y = (rectTo[1]+rectTo[3]) - (rectFrom[1]+rectFrom[3]);
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case ALIGN_MIDDLES:
|
|
|
|
x = 0;
|
|
|
|
y = (rectTo[1]+rectTo[3]/2) - (rectFrom[1]+rectFrom[3]/2);
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
default:
|
|
|
|
assert ( false );
|
|
|
|
break;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
group->Append ( new rvGEMoveModifier ( modName, mSelections[i], x, y ) );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mModifiers.Append ( group );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Cant merge alignments
|
|
|
|
mModifiers.BlockNextMerge ( );
|
|
|
|
|
|
|
|
SetModified ( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::AddModifierMove
|
|
|
|
|
|
|
|
Adds a move modifier with the given offsets
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::AddModifierMove ( const char* modName, float x, float y, bool snap )
|
|
|
|
{
|
|
|
|
idRectangle scaleRect;
|
|
|
|
idRectangle newRect;
|
|
|
|
|
|
|
|
scaleRect = mSelections.GetRect ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
WindowToWorkspace ( scaleRect );
|
2011-11-22 21:28:15 +00:00
|
|
|
newRect = scaleRect;
|
|
|
|
newRect.x += x;
|
|
|
|
newRect.y += y;
|
|
|
|
|
|
|
|
if ( snap )
|
|
|
|
{
|
|
|
|
gApp.GetOptions ().SnapRectToGrid ( newRect, true, true, false, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
rvGEModifierGroup* group = new rvGEModifierGroup;
|
|
|
|
for ( int i = 0; i < mSelections.Num(); i ++ )
|
|
|
|
{
|
|
|
|
if ( !mSelections[i]->GetParent ( ) )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// IF the parent window is being moved around as well then dont move this one.
|
|
|
|
if ( rvGEWindowWrapper::GetWrapper ( mSelections[i]->GetParent ( ) )->IsSelected ( ) )
|
|
|
|
{
|
|
|
|
// We still need the modifier there so the selection can be restored and
|
|
|
|
// so the rectangle gets updated
|
|
|
|
group->Append ( new rvGEMoveModifier ( modName, mSelections[i], 0, 0 ) );
|
|
|
|
continue;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
group->Append ( new rvGEMoveModifier ( modName, mSelections[i], newRect.x-scaleRect.x, newRect.y-scaleRect.y ) );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mModifiers.Append ( group );
|
|
|
|
|
|
|
|
SetModified ( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::AddModifierSize
|
|
|
|
|
|
|
|
Adds a size modifier with the given offsets
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::AddModifierSize ( const char* modName, float l, float t, float r, float b, bool snap )
|
|
|
|
{
|
|
|
|
idRectangle scaleRect;
|
|
|
|
idRectangle sizeRect;
|
|
|
|
idRectangle newRect;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
scaleRect = mSelections.GetRect ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
WindowToWorkspace ( scaleRect );
|
2011-11-22 21:28:15 +00:00
|
|
|
newRect = scaleRect;
|
|
|
|
newRect.x += l;
|
|
|
|
newRect.y += t;
|
|
|
|
newRect.w += (r - l);
|
|
|
|
newRect.h += (b - t);
|
|
|
|
|
|
|
|
// Restrict sizing below 1 width
|
|
|
|
if ( newRect.w <= 1 )
|
|
|
|
{
|
|
|
|
newRect.x = newRect.x - (l ? (1 - newRect.w) : 0);
|
|
|
|
mDragPoint.x = newRect.x;
|
|
|
|
newRect.w = 1;
|
|
|
|
mDragX = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mDragX = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restrict sizing below 1 height
|
|
|
|
if ( newRect.h <= 1 )
|
|
|
|
{
|
|
|
|
newRect.y = newRect.y - (t ? (1 - newRect.h) : 0);
|
|
|
|
mDragPoint.y = newRect.y;
|
|
|
|
newRect.h = 1;
|
|
|
|
mDragY = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mDragY = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( snap )
|
|
|
|
{
|
|
|
|
gApp.GetOptions ().SnapRectToGrid ( newRect, l != 0.0f, t != 0.0f, r != 0.0f, b != 0.0f );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
rvGEModifierGroup* group = new rvGEModifierGroup;
|
|
|
|
for ( int i = 0; i < mSelections.Num(); i ++ )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
sizeRect = rvGEWindowWrapper::GetWrapper ( mSelections[i] )->GetScreenRect ( );
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
l = (newRect.x + ((sizeRect.x - scaleRect.x) / scaleRect.w) * newRect.w) - sizeRect.x;
|
|
|
|
t = (newRect.y + ((sizeRect.y - scaleRect.y) / scaleRect.h) * newRect.h) - sizeRect.y;
|
|
|
|
r = (sizeRect.w / scaleRect.w * newRect.w) - sizeRect.w + l;
|
|
|
|
b = (sizeRect.h / scaleRect.h * newRect.h) - sizeRect.h + t;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// This is sorta crufty but needs to be done. When a parent is being sized at the same
|
|
|
|
// time as a child you will get double movement because the child is relative to the parent. Therefore
|
|
|
|
// we need to subtract out the closest parents sizing.
|
|
|
|
idWindow* parent = mSelections[i];
|
|
|
|
while ( NULL != (parent = parent->GetParent ( ) ) )
|
|
|
|
{
|
|
|
|
rvGEWindowWrapper* pwrapper = rvGEWindowWrapper::GetWrapper ( parent );
|
|
|
|
float offset;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( !pwrapper->IsSelected ( ) )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
sizeRect = pwrapper->GetScreenRect ( );
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Subtract out the left and right modifications
|
|
|
|
offset = ((newRect.x + ((sizeRect.x - scaleRect.x) / scaleRect.w) * newRect.w) - sizeRect.x);
|
|
|
|
l -= offset;
|
|
|
|
r -= offset;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Subtract out the top and bottom modifications
|
|
|
|
offset = ((newRect.y + ((sizeRect.y - scaleRect.y) / scaleRect.h) * newRect.h) - sizeRect.y);
|
|
|
|
t -= offset;
|
|
|
|
b -= offset;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
group->Append ( new rvGESizeModifier ( modName, mSelections[i], l, t, r, b ) );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
mModifiers.Append ( group );
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
SetModified ( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::MakeSelectedAChild
|
|
|
|
|
|
|
|
Makes the selected windows a child of the first selected window
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::MakeSelectedAChild ( void )
|
|
|
|
{
|
|
|
|
rvGEModifierGroup* group;
|
|
|
|
int i;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( !rvGEWindowWrapper::GetWrapper ( mSelections[0] )->CanHaveChildren ( ) )
|
|
|
|
{
|
|
|
|
gApp.MessageBox ( "Cannot add children to an htmlDef item", MB_OK|MB_ICONERROR );
|
|
|
|
return;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
group = new rvGEModifierGroup;
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
for ( i = 1; i < mSelections.Num(); i ++ )
|
|
|
|
{
|
|
|
|
if ( mSelections[i]->GetParent ( ) == mSelections[0] )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( !mSelections[i]->GetParent ( ) )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
continue;
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
group->Append ( new rvGEInsertModifier ( "Make Child", mSelections[i], mSelections[0], NULL ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
mModifiers.Append ( group );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Navigator needs an update since the ordering has changed
|
|
|
|
gApp.GetNavigator().Update ( );
|
|
|
|
|
|
|
|
SetModified ( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::Copy ( void )
|
|
|
|
{
|
|
|
|
int i;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
// Clear the current clipboard
|
2011-11-22 21:28:15 +00:00
|
|
|
for ( i = 0; i < mClipboard.Num(); i ++ )
|
|
|
|
{
|
|
|
|
delete mClipboard[i];
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mClipboard.Clear ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
for ( i = 0; i < mSelections.Num(); i ++ )
|
|
|
|
{
|
|
|
|
rvGEWindowWrapper* wrapper = rvGEWindowWrapper::GetWrapper ( mSelections[i] );
|
|
|
|
assert ( wrapper );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
rvGEClipboardItem* item = new rvGEClipboardItem;
|
|
|
|
item->mStateDict = wrapper->GetStateDict ( );
|
|
|
|
item->mScriptDict = wrapper->GetScriptDict ( );
|
|
|
|
item->mVarDict = wrapper->GetVariableDict ( );
|
|
|
|
|
|
|
|
item->mStateDict.Set ( "windowType", rvGEWindowWrapper::WindowTypeToString ( wrapper->GetWindowType ( ) ) );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mClipboard.Append ( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::Paste ( void )
|
|
|
|
{
|
|
|
|
int i;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
rvGEModifierGroup* group = new rvGEModifierGroup;
|
|
|
|
|
|
|
|
mSelections.Clear ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
for ( i = 0; i < mClipboard.Num(); i ++ )
|
|
|
|
{
|
|
|
|
idDict state;
|
|
|
|
rvGEWindowWrapper::EWindowType type;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
state.Copy ( mClipboard[i]->mStateDict );
|
|
|
|
type = rvGEWindowWrapper::StringToWindowType ( state.GetString ( "windowType", "windowDef" ) );
|
|
|
|
state.Delete ( "windowType" );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
idWindow* window = NewWindow ( &state, type );
|
|
|
|
group->Append ( new rvGEInsertModifier ( "Paste", window, mInterface->GetDesktop(), NULL ) );
|
|
|
|
mSelections.Add ( window );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
rvGEWindowWrapper::GetWrapper ( window )->GetScriptDict ( ) = mClipboard[i]->mScriptDict;
|
|
|
|
rvGEWindowWrapper::GetWrapper ( window )->GetVariableDict ( ) = mClipboard[i]->mVarDict;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mModifiers.Append ( group );
|
|
|
|
|
|
|
|
mApplication->GetNavigator().Update ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
SetModified ( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::HideSelected ( void )
|
|
|
|
{
|
|
|
|
AddModifiers ( MOD_HIDE );
|
|
|
|
mSelections.Clear ( );
|
|
|
|
mApplication->GetNavigator().Refresh ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::UnhideSelected ( void )
|
|
|
|
{
|
|
|
|
AddModifiers ( MOD_UNHIDE );
|
|
|
|
mApplication->GetNavigator().Refresh ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::HideWindow ( idWindow* window )
|
|
|
|
{
|
|
|
|
AddModifiers ( window, MOD_HIDE );
|
|
|
|
mApplication->GetNavigator().Refresh ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
void rvGEWorkspace::UnhideWindow ( idWindow* window )
|
|
|
|
{
|
|
|
|
AddModifiers ( window, MOD_UNHIDE );
|
|
|
|
mApplication->GetNavigator().Refresh ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvGEWorkspace::SetModified
|
|
|
|
|
|
|
|
Sets the modified state of the window and if source control is enabled it
|
|
|
|
will attempt to check out the file
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvGEWorkspace::SetModified ( bool mod )
|
|
|
|
{
|
|
|
|
if ( mModified != mod )
|
|
|
|
{
|
|
|
|
|
|
|
|
mModified = mod;
|
|
|
|
UpdateTitle ( );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|