camframe.cpp

Go to the documentation of this file.
00001 // $Id: camframe.cpp 1769 2007-06-17 19:33:43Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 /*
00099  * This is the top-level window of the application.
00100  */
00101 
00102 #include "camtypes.h"
00103 
00104 #include "camelot.h"
00105 #include "camframe.h"
00106 //#include "camresource.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 
00108 //#include "Res/tbbitmap.h"
00109 
00110 #include "wrkrect.h"
00111 
00112 #include "menuops.h"
00113 #include "qualops.h"
00114 #include "zoomops.h"
00115 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 #include "speedtst.h"
00117 #include "oilmenus.h"
00118 #include "csrstack.h"
00119 
00120 #include "blobby.h"
00121 #include "dbugtree.h"
00122 #include "stdbars.h"
00123 #include "rendwnd.h"
00124 #include "ccolbar.h"
00125 #include "dragmgr.h"
00126 
00127 // Declare smart memory handling in Debug builds
00128 #define new CAM_DEBUG_NEW
00129 
00130 #if defined(USE_WXAUI)
00131 
00132 class CamFrameManager : public wxAuiManager
00133 {
00134 private:
00135     DECLARE_CLASS( CamFrameManager )
00136 
00137 public:
00138     CamFrameManager(wxFrame* frame = NULL, unsigned int /*TYPENOTE: Correct*/ flags = wxAUI_MGR_DEFAULT)
00139            : wxAuiManager(frame, flags)
00140     {
00141     }
00142 
00143     void OnSize(wxSizeEvent &event)
00144     {
00145         if (GetMainFrame())
00146             GetMainFrame()->UpdateWndSize();
00147         event.Skip();
00148     }
00149 
00150     void OnMove(wxMoveEvent &event)
00151     {
00152         if (GetMainFrame())
00153             GetMainFrame()->UpdateWndSize();
00154         event.Skip();
00155     }
00156 
00157     void OnPaneClose(wxAuiManagerEvent& event)
00158     {
00159         // For now just pretend cancel was clicked. This is sufficient to fool
00160         // dialogmanager into closing the window it would seem
00161         wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
00162         wxWindow * pWindow = NULL;
00163         if (event.GetPane() && event.GetPane()->IsOk() )
00164             pWindow = event.GetPane()->window;
00165         if (pWindow && !pWindow->IsBeingDeleted())
00166         {
00167             cancelEvent.SetEventObject( pWindow );
00168             pWindow->GetEventHandler()->AddPendingEvent(cancelEvent);
00169         }
00170     
00171         event.Veto(); // Stop wxAUI doing anything about it
00172     }
00173 
00174     DECLARE_EVENT_TABLE()
00175 };
00176 
00177 IMPLEMENT_CLASS( CamFrameManager, wxAuiManager )
00178 BEGIN_EVENT_TABLE( CamFrameManager, wxAuiManager )
00179     EVT_SIZE(CamFrameManager::OnSize)
00180     EVT_MOVE(CamFrameManager::OnMove)
00181     EVT_AUI_PANE_CLOSE(CamFrameManager::OnPaneClose)
00182 END_EVENT_TABLE()
00183 
00184 #endif
00185 
00186 CCamFrame *CCamFrame::m_pMainFrame = NULL;
00187 
00188 /***************************************************************************************************************************/
00189 
00190 IMPLEMENT_CLASS( CCamFrame, wxDocMDIParentFrame )
00191 BEGIN_EVENT_TABLE( CCamFrame, wxDocMDIParentFrame )
00192 
00193     EVT_MENU_RANGE( AUTO_MENU_ID_MIN, AUTO_MENU_ID_MAX, CCamFrame::OnMenuCommand            )
00194 
00195     EVT_MENU( _R(DOCVIEW_ZOOMIN),                   CCamFrame::OnZoomIn                     )
00196     EVT_MENU( _R(DOCVIEW_ZOOMOUT),                  CCamFrame::OnZoomOut                    )
00197     EVT_MENU( _R(DOCVIEW_ZOOMDRAWING),              CCamFrame::OnZoomDrawing                )
00198     EVT_MENU( _R(DOCVIEW_ZOOMSPREAD),               CCamFrame::OnZoomPage                   )
00199     EVT_MENU( _R(DOCVIEW_ZOOMPREVIOUS),             CCamFrame::OnZoomPrevious               )
00200     EVT_MENU( _R(DOCVIEW_QUALITYOUTLINE),           CCamFrame::OnQualityOutline             )
00201     EVT_MENU( _R(DOCVIEW_QUALITYSIMPLE),            CCamFrame::OnQualitySimple              )
00202     EVT_MENU( _R(DOCVIEW_QUALITYNORMAL),            CCamFrame::OnQualityNormal              )
00203     EVT_MENU( _R(DOCVIEW_QUALITYANTIALIASED),       CCamFrame::OnQualityAntialiased         )
00204     EVT_MENU( _R(DOCVIEW_BACKGROUNDRENDER),         CCamFrame::OnBackgroundRender           )
00205     EVT_MENU( _R(DOCVIEW_CACHING),                  CCamFrame::OnCaching                    )
00206     EVT_MENU( _R(DOCVIEW_DOUBLEBUFFER),             CCamFrame::OnDoubleBuffer               )
00207     EVT_MENU( _R(DOCVIEW_TIMEREDRAW),               CCamFrame::OnTimeRedraw                 )
00208 //#if defined(_DEBUG)
00209     EVT_MENU( _R(DOCVIEW_BLOBBYDLG),                CCamFrame::OnBlobbyDlg                  )
00210     EVT_MENU( _R(DOCVIEW_BLOBBYBAR),                CCamFrame::OnBlobbyBar                  )
00211     EVT_MENU( _R(DEBUG_TREEVIEWDLG),                CCamFrame::OnTreeView                   )
00212 //#endif
00213     // Using the dialog IDs here as menu IDs is a bodge, but should work
00214     EVT_MENU( _R(IDD_BUTTBAR_GENERAL),              CCamFrame::OnStandardBar                )
00215     EVT_MENU( _R(IDD_BUTTBAR_IMAGESETTING),         CCamFrame::OnStandardBar                )
00216     EVT_MENU( _R(IDD_BUTTBAR_WINDOW),               CCamFrame::OnStandardBar                )
00217     EVT_MENU( _R(IDD_BUTTBAR_ARRANGE),              CCamFrame::OnStandardBar                )
00218     EVT_MENU( _R(IDD_BUTTBAR_EDIT),                 CCamFrame::OnStandardBar                )
00219     EVT_MENU( _R(IDD_BUTTBAR_FILE),                 CCamFrame::OnStandardBar                )
00220     EVT_MENU( _R(IDD_BUTTBAR_GALLERIES),            CCamFrame::OnStandardBar                )
00221     EVT_MENU( _R(IDD_BUTTBAR_STANDARD),             CCamFrame::OnStandardBar                )
00222     EVT_MENU( _R(IDD_BUTTBAR_TOOLBAR),              CCamFrame::OnStandardBar                )
00223     EVT_MENU( _R(IDD_BUTTBAR_ANIMATION),            CCamFrame::OnStandardBar                )
00224     EVT_MENU( _R(IDD_BUTTBAR_FEATHER),              CCamFrame::OnStandardBar                )
00225     EVT_MENU( _R(IDD_BUTTBAR_STATUS),               CCamFrame::OnStandardBar                )
00226     
00227     EVT_MENU_OPEN(                                  CCamFrame::OnInitMenuPopup              )
00228 
00229     EVT_UPDATE_UI( _R(IDD_BUTTBAR_GENERAL),         CCamFrame::OnUpdateStandardBar          )
00230     EVT_UPDATE_UI( _R(IDD_BUTTBAR_IMAGESETTING),    CCamFrame::OnUpdateStandardBar          )
00231     EVT_UPDATE_UI( _R(IDD_BUTTBAR_WINDOW),          CCamFrame::OnUpdateStandardBar          )
00232     EVT_UPDATE_UI( _R(IDD_BUTTBAR_ARRANGE),         CCamFrame::OnUpdateStandardBar          )
00233     EVT_UPDATE_UI( _R(IDD_BUTTBAR_EDIT),            CCamFrame::OnUpdateStandardBar          )
00234     EVT_UPDATE_UI( _R(IDD_BUTTBAR_FILE),            CCamFrame::OnUpdateStandardBar          )
00235     EVT_UPDATE_UI( _R(IDD_BUTTBAR_GALLERIES),       CCamFrame::OnUpdateStandardBar          )
00236     EVT_UPDATE_UI( _R(IDD_BUTTBAR_STANDARD),        CCamFrame::OnUpdateStandardBar          )
00237     EVT_UPDATE_UI( _R(IDD_BUTTBAR_TOOLBAR),         CCamFrame::OnUpdateStandardBar          )
00238     EVT_UPDATE_UI( _R(IDD_BUTTBAR_ANIMATION),       CCamFrame::OnUpdateStandardBar          )
00239     EVT_UPDATE_UI( _R(IDD_BUTTBAR_FEATHER),         CCamFrame::OnUpdateStandardBar          )
00240     EVT_UPDATE_UI( _R(IDD_BUTTBAR_STATUS),          CCamFrame::OnUpdateStandardBar          )
00241 
00242     EVT_UPDATE_UI( _R(DOCVIEW_ZOOMPREVIOUS),        CCamFrame::OnUpdateZoomPrevious         )
00243     EVT_UPDATE_UI( _R(DOCVIEW_QUALITYOUTLINE),      CCamFrame::OnUpdateQualityOutline       )
00244     EVT_UPDATE_UI( _R(DOCVIEW_QUALITYSIMPLE),       CCamFrame::OnUpdateQualitySimple        )
00245     EVT_UPDATE_UI( _R(DOCVIEW_QUALITYNORMAL),       CCamFrame::OnUpdateQualityNormal        )
00246     EVT_UPDATE_UI( _R(DOCVIEW_QUALITYANTIALIASED),  CCamFrame::OnUpdateQualityAntialiased   )
00247     EVT_UPDATE_UI( _R(DOCVIEW_BACKGROUNDRENDER),    CCamFrame::OnUpdateBackgroundRender     )
00248     EVT_UPDATE_UI( _R(DOCVIEW_CACHING),             CCamFrame::OnUpdateCaching              )
00249     EVT_UPDATE_UI( _R(DOCVIEW_DOUBLEBUFFER),        CCamFrame::OnUpdateDoubleBuffer         )
00250 #if !defined(USE_WXAUI)
00251     EVT_SIZE(CCamFrame::OnSize)
00252     EVT_MOVE(CCamFrame::OnMove)
00253 #endif
00254 
00255     EVT_CLOSE(CCamFrame::OnCloseWindow)
00256 END_EVENT_TABLE()
00257 
00258 /***************************************************************************************************************************/
00259 
00260 CCamFrame::CCamFrame( wxDocManager *manager, wxFrame *frame, const wxString& title, const wxPoint& pos, 
00261               const wxSize& size, /*TYPENOTE: Correct*/ long type ) : 
00262         wxDocMDIParentFrame( manager, frame, wxID_ANY, title, pos, size, type, wxT("CCamFrame") ),
00263         m_ChangingViewMode( false )
00264 {
00265     wxASSERT( NULL == m_pMainFrame );
00266 
00267     m_pMainFrame = this;
00268     m_editMenu = (wxMenu *)NULL;
00269 
00270 #if defined(USE_WXAUI)
00271     m_pFrameManager = NULL;
00272 #endif
00273     m_pStatusBar = NULL;
00274 
00275     Create( frame, wxID_ANY, title, pos, size, type );
00276     
00277     wxBitmap            bitmapTmp;
00278     CamResource::LoadwxBitmap( bitmapTmp, _T("camelot.png") );
00279     m_iconAppIcon.CopyFromBitmap( bitmapTmp );
00280     SetIcon( m_iconAppIcon );
00281 }
00282 
00283 /***************************************************************************************************************************/
00284 
00285 CCamFrame::~CCamFrame()
00286 {
00287 #if defined(USE_WXAUI)
00288     if (m_pFrameManager)
00289     {
00290         m_pFrameManager->UnInit();
00291         delete m_pFrameManager;
00292     }
00293 #endif
00294 
00295     m_pMainFrame = NULL;
00296 }
00297 
00298 /***************************************************************************************************************************/
00299 /*
00300  * Segment a toolbar image strip into a image list
00301  * @param lstImage      The ImageList to fill
00302  * @param str           The file name of the image file that contains the icons
00303  * @param cPX           The width the of icons (if 0, code will attempt to guess width)
00304  * @return true if successful, else false
00305  **/
00306 #if 0
00307 static bool BuildImageList( std::vector<wxBitmap> &lstImage,  const TCHAR * str, unsigned cPx = 0 )
00308 {
00309     wxImage imageStandard;
00310     CamResource::LoadwxImage(imageStandard, str );
00311 
00312     if( !imageStandard.Ok() )
00313         return false;
00314 
00315     unsigned cpxWidth  = imageStandard.GetWidth();
00316     unsigned cpxHeight = imageStandard.GetHeight();
00317     
00318     // Find width of icons (if not known)
00319     INT32                   ord = 0;
00320     if( 0 == cPx )
00321     {
00322         for( cPx = 1; cPx < cpxWidth; ++cPx )
00323         {
00324             if( 0 != imageStandard.GetAlpha( cPx, 1 ) )
00325                 break;
00326         }
00327         ++cPx;
00328 
00329         ++ord;
00330     }
00331 
00332     // Split icons into an imagelist
00333     INT32                   cImage = cpxWidth / cPx;
00334     for( ; ord < cImage; ++ord )
00335     {
00336         wxImage         image( imageStandard.GetSubImage( wxRect( ord * cPx, 0, cPx, cpxHeight ) ) );
00337 
00338         // GetSubImage doesn't copy alpha, so we do it ourselves
00339         image.SetAlpha( NULL, false );
00340         wxByte         *pSrc = imageStandard.GetAlpha() + ( ord * cPx );
00341         wxByte         *pDst = image.GetAlpha();
00342 
00343         for( unsigned posY = 0; posY < cpxHeight; ++posY, pSrc += cpxWidth, pDst += cPx )
00344         {
00345             memcpy( pDst, pSrc, cPx );
00346         }
00347 
00348         lstImage.push_back( image );
00349     }
00350 
00351     return true;
00352 }
00353 #endif
00354 
00355 /***************************************************************************************************************************/
00356 
00357 bool CCamFrame::Create( wxWindow *pParent, wxWindowID id, const wxString &caption, const wxPoint &pos, 
00358             const wxSize &size, /* TYPENOTE: Correct */ long style )
00359 {
00360 #if defined(USE_WXAUI)
00361     m_pFrameManager = new CamFrameManager;
00362     if (!m_pFrameManager) return FALSE;
00363     m_pFrameManager->SetManagedWindow(this);
00364     
00365     m_pFrameManager->SetFlags(m_pFrameManager->GetFlags() |
00366                             wxAUI_MGR_ALLOW_FLOATING
00367 #if defined(__WXMSW__)
00368                              | wxAUI_MGR_TRANSPARENT_DRAG | wxAUI_MGR_TRANSPARENT_HINT | wxAUI_MGR_TRANSPARENT_HINT_FADE
00369 #endif
00370                             );
00371 #endif
00372     return TRUE;
00373 }
00374 
00375 BOOL CCamFrame::CreateToolbars()
00376 {
00377 #if 0
00378     // Create the status bar
00379     m_pStatusBar = CreateStatusBar();
00380     String_256  strStatus( _R(IDS_NO_OBJECTS_SEL) );
00381     m_pStatusBar->SetStatusText( strStatus );
00382 #endif
00383     
00384     CColourBar* pColourBar = new CColourBar();
00385     if (pColourBar)
00386     {
00387         pColourBar->Create(this, 12345);
00388 
00389         wxAuiPaneInfo paneinfo;
00390         paneinfo.BottomDockable().Bottom();
00391         paneinfo.CaptionVisible(false);
00392         m_pFrameManager->AddPane(pColourBar, paneinfo);
00393 
00394         m_pFrameManager->Update();
00395     }
00396 
00397     // Enable alpha on XP true-color
00398 #if defined(__WXMSW__)
00399     if( wxTheApp->GetComCtl32Version() >= 600 && ::wxDisplayDepth() >= 32 )
00400     {
00401         wxSystemOptions::SetOption( wxT("msw.remap"), 2 );
00402     }
00403 #endif
00404 
00405     wxCommandEvent sbe(wxEVT_COMMAND_MENU_SELECTED, _R(IDD_BUTTBAR_STANDARD));
00406     OnStandardBar(sbe);
00407 
00408     wxCommandEvent tbe(wxEVT_COMMAND_MENU_SELECTED, _R(IDD_BUTTBAR_TOOLBAR));
00409     OnStandardBar(tbe);
00410 
00411     wxCommandEvent sbbe(wxEVT_COMMAND_MENU_SELECTED, _R(IDD_BUTTBAR_STATUS));
00412     OnStandardBar(sbbe);
00413 
00414 //  wxCommandEvent gbe(wxEVT_COMMAND_MENU_SELECTED, _R(IDD_BUTTBAR_GALLERIES));
00415 //  OnStandardBar(gbe);
00416 
00417     return TRUE;
00418 }
00419 
00420 void CCamFrame::UpdateFrameManager()
00421 {
00422 #if defined(USE_WXAUI)
00423     if (m_pFrameManager)
00424         m_pFrameManager->Update();
00425 #endif
00426 }
00427 
00428 /***************************************************************************************************************************/
00429 
00430 bool CCamFrame::Destroy()
00431 {
00432     // Before anything else let's set Document::Current and DocView::Current properly...
00433     // This "event" doesn't refer to any particular doc or view so we'll set them both NULL
00434     Document::SetNoCurrent();
00435     DocView::SetNoCurrent();
00436 
00437     // Update the window position and state preferences
00438     // This doesn't work as well as in Xtreme due to the lack of GetWindowPlacement
00439     // GetRect returns the current size of the window even when maximised or iconised
00440     // so some effort will be needed to correctly save the normal position
00441     bool bMin = IsIconized();
00442     bool bMax = IsMaximized();
00443     wxSize ScreenSize = wxGetDisplaySize();
00444     CCamApp::MainWndPosString._MakeMsg(
00445             _T("#1%d #2%d #3%d #4%d #5%d #6%d"),
00446             m_WndRect.x,
00447             m_WndRect.y,
00448             m_WndRect.width,
00449             m_WndRect.height,
00450             ScreenSize.x,
00451             ScreenSize.y
00452                 );
00453     CCamApp::MainWndMaximized = bMax ? TRUE : FALSE;
00454     CCamApp::MainWndMinimized = bMin ? TRUE : FALSE;
00455 
00456 PORTNOTE("other","Removed WindowPlacement saving")
00457 #if !defined(EXCLUDE_FROM_XARALX)
00458 #ifndef EXCLUDE_FROM_RALPH
00459     // lets write out our non-maximised window position to the .ini file
00460     WINDOWPLACEMENT wPlace;
00461     wPlace.length = sizeof(WINDOWPLACEMENT);
00462     if (GetWindowPlacement( &wPlace ))
00463     {
00464         
00465         // we must save last normal position if in full screen mode 
00466         if (FullScreenMode)
00467         {
00468             wPlace = NormalModePlace;
00469         }
00470 
00471         CCamApp::MainWndPosString._MakeMsg(
00472                 "#1%d #2%d #3%d #4%d #5%d #6%d",
00473                 wPlace.rcNormalPosition.left,
00474                 wPlace.rcNormalPosition.top,
00475                 wPlace.rcNormalPosition.right - wPlace.rcNormalPosition.left,
00476                 wPlace.rcNormalPosition.bottom - wPlace.rcNormalPosition.top,
00477                 GetSystemMetrics( SM_CXSCREEN ),
00478                 GetSystemMetrics( SM_CYSCREEN )
00479                     );
00480         CCamApp::MainWndMaximized = (wPlace.showCmd == SW_SHOWMAXIMIZED) ? TRUE : FALSE;
00481         CCamApp::MainWndMinimized = (wPlace.showCmd == SW_SHOWMINIMIZED) ? TRUE : FALSE;
00482     }
00483     else
00484     {
00485         CCamApp::MainWndPosString = "";                         // so uses default next time
00486         CCamApp::MainWndMaximized = FALSE;
00487         CCamApp::MainWndMinimized = FALSE;
00488 
00489     }
00490 #endif // EXCLUDE_FROM_RALPH
00491 #endif
00492 
00493     // Make sure that the currently selected tool is "de-initialised" before the
00494     // main window is destroyed, or it will try to use a dead info bar.
00495     // NB. Docs say that this function can be safely called more than once.
00496     Tool::DeinitTools();
00497 
00498     // DeathMsg is the last message sent before camelot shuts down
00499     BROADCAST_TO_ALL(DeathMsg());
00500 
00501 PORTNOTE("other","Removed ExternalClipboard usage")
00502 #if !defined(EXCLUDE_FROM_XARALX)
00503 #ifndef EXCLUDE_FROM_RALPH
00504     // And make sure we're no longer on the clipboard viewer chain
00505     ChangeClipboardChain(NextClipboardViewer);
00506 #endif
00507 #endif
00508 
00509     return wxDocMDIParentFrame::Destroy();
00510 }
00511 
00512 /***************************************************************************************************************************/
00513 
00514 CCamFrame *GetMainFrame(void)
00515 {
00516     return CCamFrame::m_pMainFrame;
00517 }
00518 
00519 /***************************************************************************************************************************/
00520 
00521 void CCamFrame::UpdateWndSize()
00522 {
00523     if (!IsIconized() && !IsMaximized())
00524     {
00525         m_WndRect = GetRect();
00526     }
00527 }
00528 
00529 
00530 #if !defined(USE_WXAUI)
00531 void CCamFrame::OnSize(wxSizeEvent &event)
00532 {
00533     // We want to remember the size of the window if we are not maximised or minimised
00534     if (!IsIconized() && !IsMaximized())
00535         m_WndRect = GetRect();
00536 
00537     // We want to skip the event even when we do have a FrameManager
00538     // The FrameManager actually gets the OnSize before us so no need to pass it on
00539 //  event.Skip();
00540 }
00541 
00542 void CCamFrame::OnMove(wxMoveEvent &event)
00543 {
00544     // We want to remember the size of the window if we are not maximised or minimised
00545     if (!IsIconized() && !IsMaximized())
00546         m_WndRect = GetRect();
00547 
00548     // We want to skip the event even when we do have a FrameManager
00549     event.Skip();
00550 }
00551 
00552 #endif
00553 
00554 void CCamFrame::OnCloseWindow(wxCloseEvent& event)
00555 {
00556     Camelot.ShuttingDown(TRUE);
00557 
00558     if (m_docManager->Clear(!event.CanVeto()))
00559     {
00560 PORTNOTE("other","Removed ExternalClipboard usage")
00561 #if !defined(EXCLUDE_FROM_XARALX)
00562         // Put any stuff the user wants to keep on the clipboard before we depart.
00563         // We want this to happen before the window closes and progress displays are lost.
00564         ExternalClipboard::PrepareForShutdown();
00565 #endif
00566         // We must DeInit the dialog manager before any windows are destroyed. 
00567         // This needs to be here because Popup windows (Dialogs/Floating bars) 
00568         // seem to be destroyed before the MainFrame receives an OnDestroy message
00569         DialogManager::DeInit(); 
00570 
00571         this->Destroy();
00572     }
00573     else
00574     {
00575         // We cancelled for some reason.
00576         Camelot.ShuttingDown(FALSE);
00577 
00578         event.Veto();
00579     }
00580 }
00581 
00582 
00583 
00584 /***************************************************************************************************************************/
00585 
00586 void CCamFrame::OnMenuCommand( wxCommandEvent& event )
00587 {
00588     // Before anything else let's set Document::Current and DocView::Current properly...
00589     // Commands which make it up to the main frame will either work on no document or the
00590     // selected document. So the most useful thing to do is to set Current to Selected.
00591     Document::GetSelected()->SetCurrent();
00592     DocView::GetSelected()->SetCurrent();
00593 
00594 #if !defined(EXCLUDE_FROM_XARALX)
00595 #if (_OLE_VER < 0x200) && (_MSVC_VER < 0x300)
00596     if (COleClientItem::InWaitForRelease())
00597     {
00598         AfxMessageBox(_R(IDP_BUSY));
00599         return TRUE;        // handled
00600     }
00601 #endif
00602 #endif
00603 
00604     // Process Menu Commands
00605     if( IsMenuCommand( event ) )
00606     {   
00607         if( PerformMenuCommand( event ) )
00608             return;
00609     }
00610 
00611 #if !defined(EXCLUDE_FROM_XARALX)
00612     // If we get to here then F1 has been pressed over a menu (see comment below).
00613     if (LOWORD(wParam) == _R(ID_HELP))
00614     {
00615         // Apparently this occurs when F1 is pressed at "non-menu times"?!?
00616         if (HIWORD(wParam))
00617         {
00618             TRACEUSER( "Marc", _T("Processing _R(ID_HELP): wParam = 0x%lX, lParam = 0x%lX\n"),
00619                                     (UINT32) wParam, (UINT32) lParam);
00620             return TRUE;
00621         }
00622 
00623         // If we have a valid menu item then run the help engine for it.
00624         if (MenuBeingTracked != NULL)
00625         {
00626             OpDescriptor* pOpDesc = MenuBeingTracked->GetOpDescriptor();
00627             ERROR3IF(pOpDesc == NULL, "Null OpDescriptor* in CMainFrame::OnCommand");
00628             if (pOpDesc != NULL) HelpUser(*pOpDesc);
00629 
00630             // Bug fix: send ourselves a WM_CANCELMODE message here, so that further menu
00631             // processing is cancelled.  Otherwise it is possible for the F1 to run the
00632             // menu item, as well as explaining it.
00633             SendMessage(WM_CANCELMODE);
00634             return TRUE;
00635         }
00636     }
00637 #endif
00638 
00639     // For everything else, pass to the base class for handling.
00640     event.Skip();
00641 }
00642 
00643 
00644 /***************************************************************************************************************************/
00645 //
00646 // These event handlers are probably temporary. They are here just
00647 // to get the program up and running and to add some functionality.
00648 //
00649 
00650 void CCamFrame::OnZoomIn( wxCommandEvent& WXUNUSED(event) )
00651 {
00652     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpZoomIn)); 
00653     if ( pOpDesc )
00654         pOpDesc->Invoke();
00655 }
00656 
00657 void CCamFrame::OnZoomOut( wxCommandEvent& WXUNUSED(event) )
00658 {
00659     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpZoomOut)); 
00660     if ( pOpDesc )
00661         pOpDesc->Invoke();
00662 }
00663 
00664 void CCamFrame::OnZoomDrawing( wxCommandEvent& WXUNUSED(event) )
00665 {
00666     OpZoomDescriptor::FakeInvoke(OPTOKEN_ZOOMDRAWING);
00667 }
00668  
00669 void CCamFrame::OnZoomPage( wxCommandEvent& WXUNUSED(event) )
00670 {
00671     OpZoomDescriptor::FakeInvoke(OPTOKEN_ZOOMSPREAD);
00672 }
00673  
00674 void CCamFrame::OnZoomPrevious( wxCommandEvent& WXUNUSED(event) )
00675 {
00676     OpZoomDescriptor::FakeInvoke(OPTOKEN_ZOOMPREV);
00677 }
00678 
00679 void CCamFrame::OnUpdateZoomPrevious( wxUpdateUIEvent& event )
00680 {
00681     OpZoomDescriptor* pOpDesc = (OpZoomDescriptor*)OpZoomDescriptor::FindOpDescriptor(OPTOKEN_ZOOMPREV); 
00682     event.Enable(pOpDesc && pOpDesc->IsAvailable());
00683 //  event.Enable(!OpZoomPrevZoomDescriptor::GetState(NULL,NULL).Greyed);
00684 }
00685 
00686 /***************************************************************************************************************************/
00687 //
00688 // These event handlers are probably temporary. They are here just
00689 // to get the program up and running and to add some functionality.
00690 //
00691 
00692 void CCamFrame::OnQualityOutline( wxCommandEvent& WXUNUSED(event) )
00693 {
00694     Document::GetSelected()->SetCurrent();
00695     DocView::GetSelected()->SetCurrent();
00696     OpDescriptor* pOpDesc = (OpDescriptor*)OpDescriptor::FindOpDescriptor( OPTOKEN_QUALITYOUTLINE );
00697     if ( pOpDesc )
00698         pOpDesc->Invoke();
00699 }
00700 
00701 void CCamFrame::OnQualitySimple( wxCommandEvent& WXUNUSED(event) )
00702 {
00703     Document::GetSelected()->SetCurrent();
00704     DocView::GetSelected()->SetCurrent();
00705     OpDescriptor* pOpDesc = (OpDescriptor*)OpDescriptor::FindOpDescriptor( OPTOKEN_QUALITYSIMPLE );
00706     if ( pOpDesc )
00707         pOpDesc->Invoke();
00708 }
00709 
00710 void CCamFrame::OnQualityNormal( wxCommandEvent& WXUNUSED(event) )
00711 {
00712     Document::GetSelected()->SetCurrent();
00713     DocView::GetSelected()->SetCurrent();
00714     OpDescriptor* pOpDesc = (OpDescriptor*)OpDescriptor::FindOpDescriptor( OPTOKEN_QUALITYNORMAL );
00715     if ( pOpDesc )
00716         pOpDesc->Invoke();
00717 }
00718 
00719 void CCamFrame::OnQualityAntialiased( wxCommandEvent& WXUNUSED(event) )
00720 {
00721     Document::GetSelected()->SetCurrent();
00722     DocView::GetSelected()->SetCurrent();
00723     OpDescriptor* pOpDesc = (OpDescriptor*)OpDescriptor::FindOpDescriptor( OPTOKEN_QUALITYANTIALIASED );
00724     if ( pOpDesc )
00725         pOpDesc->Invoke();
00726 }
00727 
00728 void CCamFrame::OnUpdateQualitySimple( wxUpdateUIEvent& event )
00729 {
00730     const DocView *pDocView = DocView::GetSelected();
00731     event.Check(pDocView && pDocView->RenderQuality.GetQuality()==QUALITY_LEVEL_SIMPLE);
00732 }
00733 
00734 void CCamFrame::OnUpdateQualityOutline( wxUpdateUIEvent& event )
00735 {
00736     const DocView *pDocView = DocView::GetSelected();
00737     event.Check(pDocView && pDocView->RenderQuality.GetQuality()==QUALITY_LEVEL_OUTLINE);
00738 }
00739 
00740 void CCamFrame::OnUpdateQualityNormal( wxUpdateUIEvent& event )
00741 {
00742     const DocView *pDocView = DocView::GetSelected();
00743     event.Check(pDocView && pDocView->RenderQuality.GetQuality()==QUALITY_LEVEL_NORMAL);
00744 }
00745 
00746 void CCamFrame::OnUpdateQualityAntialiased( wxUpdateUIEvent& event )
00747 {
00748     const DocView *pDocView = DocView::GetSelected();
00749     event.Check(pDocView && pDocView->RenderQuality.GetQuality()==QUALITY_LEVEL_ANTI);
00750 }
00751 
00752 /***************************************************************************************************************************/
00753 //
00754 // These event handlers are probably temporary. They are here just
00755 // to get the program up and running and to add some functionality.
00756 //
00757 
00758 void CCamFrame::OnBackgroundRender( wxCommandEvent& WXUNUSED(event) )
00759 {
00760     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpToggleFore)); 
00761     if ( pOpDesc )
00762         pOpDesc->Invoke();
00763 }
00764 
00765 void CCamFrame::OnUpdateBackgroundRender( wxUpdateUIEvent& event )
00766 {
00767     event.Check(FALSE != OpToggleFore::GetState(NULL,NULL).Ticked);
00768 }
00769 
00770 /***************************************************************************************************************************/
00771 //
00772 // These event handlers are probably temporary. They are here just
00773 // to get the program up and running and to add some functionality.
00774 //
00775 
00776 void CCamFrame::OnCaching( wxCommandEvent& WXUNUSED(event) )
00777 {
00778     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpClearCache)); 
00779     if ( pOpDesc )
00780         pOpDesc->Invoke();
00781 }
00782 
00783 void CCamFrame::OnUpdateCaching( wxUpdateUIEvent& event )
00784 {
00785     event.Check(FALSE != OpClearCache::GetState(NULL,NULL).Ticked);
00786 }
00787 
00788 // We should really do an Op for this
00789 void CCamFrame::OnDoubleBuffer( wxCommandEvent& event )
00790 {
00791     CRenderWnd::SetDoubleBuffer(event.IsChecked());
00792 }
00793 
00794 void CCamFrame::OnUpdateDoubleBuffer( wxUpdateUIEvent& event )
00795 {
00796     event.Check(FALSE != CRenderWnd::GetDoubleBuffer());
00797 }
00798 
00799 
00800 /***************************************************************************************************************************/
00801 //
00802 // These event handlers are probably temporary. They are here just
00803 // to get the program up and running and to add some functionality.
00804 //
00805 
00806 void CCamFrame::OnTimeRedraw( wxCommandEvent& WXUNUSED(event) )
00807 {
00808     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpTimeDraw)); 
00809     if ( pOpDesc )
00810         pOpDesc->Invoke();
00811 }
00812 
00813 /***************************************************************************************************************************/
00814 //
00815 // These event handlers are probably temporary. They are here just
00816 // to get the program up and running and to add some functionality.
00817 //
00818 
00819 //#if defined(_DEBUG)
00820 void CCamFrame::OnBlobbyDlg( wxCommandEvent& WXUNUSED(event) )
00821 {
00822     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(BlobbyDlg)); 
00823     if ( pOpDesc )
00824         pOpDesc->Invoke();
00825 }
00826 
00827 void CCamFrame::OnBlobbyBar( wxCommandEvent& WXUNUSED(event) )
00828 {
00829     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(BlobbyBar)); 
00830     if ( pOpDesc )
00831         pOpDesc->Invoke();
00832 }
00833 
00834 void CCamFrame::OnTreeView( wxCommandEvent& WXUNUSED(event) )
00835 {
00836 //  OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(DebugTreeDlg));
00837     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_DEBUGTREEDLG);
00838     if ( pOpDesc )
00839         pOpDesc->Invoke();
00840 }
00841 
00842 void CCamFrame::OnStandardBar( wxCommandEvent& event)
00843 {
00844     // We can't find by Runtime Class as there are multiple OpDescriptors with the same Class
00845     // So get the resource ID (which also happens to be the dialog ID to use
00846     ResourceID r = (ResourceID)(event.GetId());
00847     // Find the Op Descriptor by name
00848     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor((TCHAR *)(CamResource::GetObjectName(r))); 
00849     // Stick the resource ID in he Op Param
00850 //  OpParam Param(CUniversalParam((INT32)r), CUniversalParam(0));
00851     pOpDesc->Invoke();
00852 }
00853 
00854 void CCamFrame::OnInitMenuPopup( wxMenuEvent& event )
00855 {
00856     // Before anything else let's set Document::Current and DocView::Current properly...
00857     // Menus will either work on no document or the selected document. So the most useful
00858     // thing to do is to set Current to Selected.
00859     Document::GetSelected()->SetCurrent();
00860     DocView::GetSelected()->SetCurrent();
00861 
00862     wxSetCursor( *wxSTANDARD_CURSOR );
00863 
00864 PORTNOTE( "other", "Removed usage of bSysMent from OnInitMenuPopup" )
00865 #if !defined(EXCLUDE_FROM_XARALX)
00866     if (bSysMenu)
00867     {
00868         CMDIFrameWnd::OnInitMenuPopup(pMenu, n, bSysMenu);
00869         // bug fix 2996 
00870         if(FullScreenMode)
00871         {
00872             pMenu->EnableMenuItem(SC_MOVE,MF_GRAYED);
00873             pMenu->EnableMenuItem(SC_SIZE,MF_GRAYED);
00874             pMenu->EnableMenuItem(SC_MAXIMIZE,MF_GRAYED);
00875         }
00876     }
00877     else
00878 #endif
00879     if( !UpdateMenu( event.GetMenu() ) )
00880         event.Skip();
00881 }
00882 
00883 
00884 void CCamFrame::OnUpdateStandardBar( wxUpdateUIEvent& event)
00885 {
00886     // We can't find by Runtime Class as there are multiple OpDescriptors with the same Class
00887     // So get the resource ID (which also happens to be the dialog ID to use
00888     ResourceID r = (ResourceID)(event.GetId());
00889     // Find the Op Descriptor by name
00890     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor((TCHAR *)(CamResource::GetObjectName(r))); 
00891     // Stick the resource ID in he Op Param
00892 //  OpParam Param(CUniversalParam((INT32)r), CUniversalParam(0));
00893     OpParam Param((INT32)r, (INT32)0);
00894     String_256 disable;
00895     OpState opst;
00896     if ( pOpDesc) opst = pOpDesc->GetOpsState(&disable,&Param);
00897     event.Enable(pOpDesc && !opst.Greyed);
00898     event.Check(FALSE != opst.Ticked);
00899 }
00900 
00901 //#endif
00902 
00903 /***************************************************************************************************************************/
00904 
00905 
00906 
00907 
00908 

Generated on Sat Nov 10 03:48:09 2007 for Camelot by  doxygen 1.4.4