00001 // $Id: scrvw.cpp 1354 2006-06-23 20:23:25Z 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 // The ScreenView class - subclass of CamView used for screen display. 00100 00101 /* 00102 */ 00103 00104 #include "camtypes.h" 00105 00106 00107 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00108 #include "scrvw.h" 00109 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00110 #include "camelot.h" 00111 #include "camdoc.h" 00112 //#include "ccmdikid.h" 00113 #include "vstate.h" 00114 #include "rendwnd.h" 00115 //#include "scroller.h" 00116 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00117 //#include "ops.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00118 //#include "oiltool.h" 00119 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00120 //#include "justin.h" 00121 //#include "ensure.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00122 #include "ccdc.h" 00123 #include "csrstack.h" 00124 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00125 #include "camframe.h" 00126 //#include "oilkeys.h" 00127 //#include "monotime.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00128 #include "pen.h" 00129 //#include "bars.h" 00130 #include "impexpop.h" // Import/Export ops 00131 //#include "resource.h" 00132 #include "statline.h" 00133 #include "prntview.h" 00134 //#include "prncamvw.h" 00135 #include "page.h" 00136 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00137 //#include "dragmgr.h" 00138 //#include "dragcol.h" 00139 //#include "viewrc.h" 00140 //#include "printdlg.h" 00141 //#include "prdlgctl.h" 00142 #include "princomp.h" 00143 #include "printctl.h" 00144 #include "psrndrgn.h" 00145 //#include "markn.h" 00146 //#include "oilruler.h" 00147 //#include "rulers.h" 00148 #include "keypress.h" 00149 #include "localenv.h" 00150 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00151 //#include "mario.h" //For _R(IDE_NOMORE_MEMORY) - Matt 26/10/2000 00152 00153 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00154 #include "zoomops.h" 00155 00156 //#include "redraw.h" 00157 //#include "custmsg.h" 00158 #include "brushmsg.h" // for ScreenChanged message 00159 //#include <winuser.h> 00160 00161 //#include <mmsystem.h> // Needed by MFC 3 00162 //#include <limits.h> 00163 00164 #if (_OLE_VER >= 0x200) 00165 // Extra OLE 2.0 stuff in MFC 2.5 00166 #include "cntritem.h" 00167 #include "ole2id.h" 00168 #endif 00169 00170 DECLARE_SOURCE("$Revision: 1354 $"); 00171 00172 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 00173 CC_IMPLEMENT_DYNCREATE(PageDropInfo, CCObject) 00174 CC_IMPLEMENT_DYNAMIC(ViewDragTarget, WinoilDragTarget) 00175 #endif 00176 00178 // ScreenCanvas the message map. 00179 00180 BEGIN_EVENT_TABLE( ScreenView::ScreenCanvas, CCamView::CCamCanvas ) 00181 EVT_SIZE( ScreenView::ScreenCanvas::OnSize ) 00182 EVT_LEFT_DOWN( ScreenView::ScreenCanvas::OnLButtonDown ) 00183 EVT_LEFT_DCLICK( ScreenView::ScreenCanvas::OnLButtonDblClk ) 00184 EVT_LEFT_UP( ScreenView::ScreenCanvas::OnLButtonUp ) 00185 EVT_MIDDLE_DOWN( ScreenView::ScreenCanvas::OnMButtonDown ) 00186 EVT_MIDDLE_DCLICK( ScreenView::ScreenCanvas::OnMButtonDblClk ) 00187 EVT_MIDDLE_UP( ScreenView::ScreenCanvas::OnMButtonUp ) 00188 EVT_RIGHT_DOWN( ScreenView::ScreenCanvas::OnRButtonDown ) 00189 EVT_RIGHT_DCLICK( ScreenView::ScreenCanvas::OnRButtonDblClk ) 00190 EVT_RIGHT_UP( ScreenView::ScreenCanvas::OnRButtonUp ) 00191 EVT_MOTION( ScreenView::ScreenCanvas::OnMouseMove ) 00192 EVT_MOUSEWHEEL( ScreenView::ScreenCanvas::OnMouseWheel ) 00193 END_EVENT_TABLE() 00194 00195 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnSize, wxSizeEvent ) 00196 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnLButtonDown, wxMouseEvent ) 00197 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnLButtonDblClk, wxMouseEvent ) 00198 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnLButtonUp, wxMouseEvent ) 00199 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnMButtonDown, wxMouseEvent ) 00200 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnMButtonDblClk, wxMouseEvent ) 00201 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnMButtonUp, wxMouseEvent ) 00202 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnRButtonDown, wxMouseEvent ) 00203 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnRButtonDblClk, wxMouseEvent ) 00204 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnRButtonUp, wxMouseEvent ) 00205 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnMouseMove, wxMouseEvent ) 00206 ReflectIntoView( ScreenView::ScreenCanvas, ScreenView, OnMouseWheel, wxMouseEvent ) 00207 00209 // ScreenView serialization & the message map. 00210 00211 IMPLEMENT_DYNAMIC_CLASS( ScreenView, CCamView ) 00212 00213 BEGIN_EVENT_TABLE( ScreenView, CCamView ) 00214 END_EVENT_TABLE() 00215 00216 PORTNOTE("other","Removed MessageMap - hopefully very temporarily") 00217 #ifndef EXCLUDE_FROM_XARALX 00218 BEGIN_MESSAGE_MAP(ScreenView, CCamView) 00219 //{{AFX_MSG_MAP(ScreenView) 00220 ON_WM_DROPFILES() 00221 ON_WM_CREATE() 00222 ON_WM_SIZE() 00223 ON_WM_TIMER() 00224 ON_WM_CANCELMODE() 00225 ON_WM_PAINT() 00226 ON_WM_SETCURSOR() 00227 ON_MESSAGE(WM_RENDERVIEW, OnRenderView) 00228 ON_MESSAGE(WM_SCROLLEREVENT, OnScrollerEvent) 00229 ON_WM_MOUSEWHEEL() 00230 ON_WM_VSCROLL() 00231 ON_WM_HSCROLL() 00232 00233 #ifdef WIN32 00234 ON_MESSAGE(MM_JOY1MOVE, OnJoystickMove) 00235 #endif 00236 00237 ON_COMMAND(_R(ID_OLE_INSERT_NEW), OnInsertObject) 00238 #if (_OLE_VER >= 0x200) 00239 ON_WM_SETFOCUS() 00240 ON_COMMAND(_R(ID_CANCEL_EDIT), OnCancelEdit) 00241 #endif 00242 00243 #ifdef _DEBUG 00244 ON_MESSAGE(WM_DESCRIBEVIEW, OnDescribeView) 00245 #endif 00246 //}}AFX_MSG_MAP 00247 00248 // WEBSTER-ranbirr-27/03/97 00249 #ifndef WEBSTER 00250 // Standard print commands:- 00251 #ifndef STANDALONE 00252 ON_COMMAND(_R(ID_FILE_PRINT), OnFilePrint) 00253 #endif 00254 #endif //webster 00255 00256 ON_COMMAND(_R(ID_FILE_PRINT_PREVIEW), OnFilePrintPreview) 00257 00258 END_MESSAGE_MAP() 00259 #endif 00260 00261 // WEBSTER-ranbirr-27/03/97 00262 #ifndef WEBSTER 00263 00264 #ifdef STANDALONE 00265 void ScreenView::OnFilePrint() {} 00266 #endif 00267 #endif //webster 00268 00270 // ScreenView construction, attachment, and destruction. 00271 00272 INT32 ScreenView::PopCount = 0; 00273 ViewState* ScreenView::pReadyMadeViewState = NULL; 00274 //static INT32 TimerCount = 0; 00275 00276 00277 /********************************************************************************************* 00278 > ScreenView::ScreenView() 00279 00280 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00281 Created: ages ago 00282 Inputs: - 00283 Outputs: - 00284 Returns: - 00285 Purpose: Default constructor for a ScreenView window. Sets the pointers to the 00286 child windows to null, so that an incomplete construction of the view 00287 that is later destroyed won't try to delete invalid pointers. The 00288 Windows side of construction is done later, in the OnCreate() message 00289 handler. 00290 00291 Updates the ScreenView population counter. Called from somewhere deep 00292 inside MFC. 00293 Errors: - 00294 Scope: Protected. 00295 SeeAlso: ScreenView::OnCreate(); ScreenView::~ScreenView() 00296 00297 **********************************************************************************************/ 00298 00299 ScreenView::ScreenView() 00300 { 00301 // TRACEUSER( "Richard", _T("ScreenView::ScreenView()\n")); 00302 00303 // No child windows or connections yet. 00304 // RenderWindow = NULL; 00305 HScrollBar = NULL; 00306 VScrollBar = NULL; 00307 00308 PORTNOTE("other","Removed CScrollerCorner usage") 00309 #ifndef EXCLUDE_FROM_XARALX 00310 Corner = NULL; 00311 #endif 00312 00313 // WEBSTER - markn 15/1/97 00314 // No rulers in Webster 00315 #ifndef WEBSTER 00316 HRuler = NULL; 00317 VRuler = NULL; 00318 OGadget= NULL; 00319 #endif // WEBSTER 00320 00321 00322 // Set/clear these internal flags. 00323 fSetupDone = FALSE; 00324 fInitialUpdate = false; 00325 00326 // Not dragging or scrolling either. 00327 ScrollerStyle = TRUE; 00328 pCurrentDragOp = NULL; 00329 00330 OLERecaptureMouse = FALSE; 00331 00332 // Set up click event variables 00333 LastClickType = CLICKTYPE_NONE; 00334 LastClickButton = 0; 00335 LastClickPoint.x = 0; 00336 LastClickPoint.y = 0; 00337 CurrentMousePos.x = 0; 00338 CurrentMousePos.y = 0; 00339 FirstClickButton = 0; 00340 DragKeepAccuracy = TRUE; 00341 AutoScrollExcludeRulers = FALSE; 00342 00343 // Bump the population. 00344 PopCount++; 00345 00346 // Vars used by InvokeDragOp() mechanism 00347 DragOpToken = ""; 00348 pDragOpParam = NULL; 00349 DragOpInvoke = FALSE; 00350 00351 // Triple and quad click support 00352 LastDoubleClickPos = wxPoint( 0, 0 ); 00353 ThisSingleIsTriple = FALSE; 00354 ThisDoubleIsQuad = FALSE; 00355 00356 // Set this flag until we have been through OnActivateView once, after which we can 00357 // include this view in the eat-activating-click system. 00358 fJustCreated = TRUE; 00359 } 00360 00361 00362 00363 /********************************************************************************************* 00364 > virtual ScreenView::~ScreenView() 00365 00366 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00367 Created: ages ago 00368 Inputs: - 00369 Outputs: - 00370 Returns: - 00371 Purpose: Destroys a ScreenView window. Deletes child windows first. 00372 Updates the ScreenView population counter. 00373 Errors: - 00374 Scope: Public 00375 SeeAlso: ScreenView::ScreenView() 00376 00377 **********************************************************************************************/ 00378 00379 ScreenView::~ScreenView() 00380 { 00381 TRACEUSER( "Richard", _T("ScreenView::~ScreenView()\n")); 00382 // Deregister for WM_DROPFILES messages 00383 // VC2 Beta 1 asserts with a zero handle here so we check 00384 PORTNOTE("other","Removed DragAcceptFiles usage") 00385 #ifndef EXCLUDE_FROM_XARALX 00386 if (m_hWnd) DragAcceptFiles(TRUE); 00387 #endif 00388 00389 // delete RenderWindow; GetCanvas()? 00390 PORTNOTE("other","Removed CWinScroller usage") 00391 #ifndef EXCLUDE_FROM_XARALX 00392 delete HScrollBar; 00393 delete VScrollBar; 00394 #endif 00395 PORTNOTE("other","Removed CScrollerCorner usage") 00396 #ifndef EXCLUDE_FROM_XARALX 00397 delete Corner; 00398 #endif 00399 00400 // WEBSTER - markn 15/1/97 00401 // No rulers in Webster 00402 #ifndef WEBSTER 00403 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 00404 delete HRuler; 00405 delete VRuler; 00406 delete OGadget; 00407 #endif 00408 #endif // WEBSTER 00409 00410 PopCount--; // one less ScreenView in the world, sigh 00411 } 00412 00413 00414 /********************************************************************************************* 00415 > virtual BOOL ScreenView::Create(LPCTSTR, LPCTSTR lpszWindowName, DWORD dwStyle, 00416 const RECT& rect, wxWindow* parent, UINT32 id, 00417 CCreateContext* ctxt = 0) 00418 00419 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00420 Created: ages ago 00421 Inputs: A long pointer to a constant character string (can be NULL, not used); a 00422 long pointer to the view window's title; the Windows instance-style flags; 00423 a rectangle describing the extent of the view; a pointer to the view's 00424 parent window; a numeric identifier; possibly a pointer to a CCreateContext. 00425 Outputs: - 00426 Returns: TRUE if the view is successfully created (attached to a Windows object). 00427 Purpose: Calls CCamView::Create() to attach a Windows object to the previously 00428 constructed C++ object. The view has a standard arrow cursor and 00429 a custom icon (_R(IDR_CAMTYPE)). The view is responsible for painting 00430 its background itself. The view is initially hidden, until its size and 00431 position have been properly set. 00432 Errors: - 00433 Scope: Public 00434 SeeAlso: ScreenView::ScreenView(); ScreenView::OnCreate() 00435 00436 **********************************************************************************************/ 00437 00438 /*BOOL ScreenView::Create(LPCTSTR, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, 00439 wxWindow *parent, UINT32 id, CCreateContext* ctxt) 00440 { 00441 TRACEUSER( "Richard", _T("ScreenView::Create\n")); 00442 00443 return CCamView::Create(AfxRegisterWndClass(CS_DBLCLKS, 00444 0, 00445 0, 00446 AfxGetApp()->LoadIcon(_R(IDR_CAMTYPE))), 00447 lpszWindowName, 00448 dwStyle | WS_CLIPCHILDREN, // NB. *NOT* WS_VISIBLE!!! 00449 rect, 00450 parent, 00451 id, 00452 ctxt); 00453 } */ 00454 00455 /******************************************************************************************** 00456 > static void ScreenView::SetReadyMadeViewState(ViewState* pvs) 00457 00458 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00459 Created: 27/9/95 00460 Inputs: pvs pointer to a ViewState object 00461 Purpose: Call this to set up a view-state object that ScreenView::OnInitialUpdate 00462 will use in preference to the one the ScreenView has got already. This 00463 is a nasty little "back-door" to changing the creation state of a 00464 ScreenView, used by the code that restores docs and views when the app 00465 starts. The reason we have to use code like this is that the Camelot doc/view 00466 architecture is NOT MFC. 00467 SeeAlso: ScreenView::OnInitialUpdate; LoadAppWindowState 00468 ********************************************************************************************/ 00469 00470 void ScreenView::SetReadyMadeViewState(ViewState* pvs) 00471 { 00472 pReadyMadeViewState = pvs; 00473 } 00474 00475 /******************************************************************************************** 00476 > static BOOL ScreenView::ReadViewPrefs() 00477 00478 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00479 Created: 26/11/93 00480 Inputs: - 00481 Outputs: - 00482 Returns: TRUE if the .INI file settings were loaded (or created) successfully. 00483 Purpose: Tries to load preferences for ScreenView, creating them with default values 00484 if they don't exist. 00485 Errors: - 00486 SeeAlso: Application::DeclareSection; Application::DeclarePref 00487 ********************************************************************************************/ 00488 00489 BOOL ScreenView::ReadViewPrefs() 00490 { 00491 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 00492 // Declare and load the .INI file settings. 00493 BOOL ok = Camelot.DeclareSection(TEXT("Mouse"), 10) && 00494 Camelot.DeclarePref(TEXT("Mouse"), TEXT("DragLatency"), 00495 &ScreenView::DragLatency, 1, 10) && 00496 Camelot.DeclarePref(TEXT("Mouse"), TEXT("DragDelay"), 00497 &DragDelay, 100, 2000) 00498 00499 && Camelot.DeclareSection(TEXT("WindowFurniture"), 10) && 00500 Camelot.DeclarePref(TEXT("WindowFurniture"), TEXT("PropScrollers"), 00501 &ScreenView::PropScrollersOn, FALSE, TRUE) && 00502 Camelot.DeclarePref(TEXT("WindowFurniture"), TEXT("Scrollers Visibilty State"), 00503 &ScreenView::DefaultScrollersState, FALSE, TRUE)&& 00504 Camelot.DeclarePref(TEXT("WindowFurniture"), TEXT("Rulers Visibilty State"), 00505 &ScreenView::DefaultRulersState, FALSE, TRUE) 00506 00507 && Camelot.DeclareSection(TEXT("Windows"), 10) && 00508 Camelot.DeclarePref(TEXT("Windows"), TEXT("UnzoomOnNewView"), 00509 &ScreenView::UnzoomOnNewView, FALSE, TRUE) && 00510 Camelot.DeclarePref(TEXT("Windows"), TEXT("ZoomSingleView"), 00511 &ScreenView::ZoomSingleView, FALSE, TRUE); 00512 00513 return ok; 00514 #else 00515 return TRUE; 00516 #endif 00517 } 00518 00519 00520 00521 /********************************************************************************************* 00522 > static INT32 ScreenView::HowMany() 00523 00524 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00525 Created: ages ago 00526 Inputs: - 00527 Outputs: - 00528 Returns: The number of ScreenViews existing at the moment. 00529 Purpose: None immediately springs to mind, although one day - who knows? 00530 Errors: - 00531 Scope: Public 00532 SeeAlso: ScreenView::ScreenView(); ScreenView::~ScreenView(); 00533 00534 **********************************************************************************************/ 00535 00536 INT32 ScreenView::HowMany() 00537 { 00538 return PopCount; 00539 } 00540 00541 00542 00543 /********************************************************************************************* 00544 > BOOL ScreenView::AreRulersVisible() 00545 00546 Author: Chris_Snook (Xara Group Ltd) <camelotdev@xara.com> 00547 Created: ages ago 00548 Inputs: - 00549 Outputs: - 00550 Returns: Ruler Visible state. 00551 Purpose: - 00552 Errors: - 00553 Scope: Public 00554 00555 **********************************************************************************************/ 00556 00557 BOOL ScreenView::AreRulersVisible() 00558 { 00559 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 00560 if(Status) 00561 return Status->RulersVisible; 00562 #endif 00563 return FALSE; 00564 }; 00565 00566 /********************************************************************************************* 00567 > BOOL ScreenView::AreScrollersVisible() 00568 00569 Author: Chris_Snook (Xara Group Ltd) <camelotdev@xara.com> 00570 Created: ages ago 00571 Inputs: - 00572 Outputs: - 00573 Returns: Scroller Visible state. 00574 Purpose: - 00575 Errors: - 00576 Scope: Public 00577 00578 **********************************************************************************************/ 00579 00580 BOOL ScreenView::AreScrollersVisible() 00581 { 00582 if(Status) 00583 return Status->ScrollersVisible; 00584 return FALSE; 00585 } 00586 00587 00588 /********************************************************************************************* 00589 > BOOL ScreenView::IsMouseOverRuler() 00590 00591 Author: Chris_Snook (Xara Group Ltd) <camelotdev@xara.com> 00592 Created: 1/10/95 00593 Inputs: - 00594 Outputs: - 00595 Returns: enum MouseOverRulerHit can be OVER_NO_RULERS, 00596 OVER_HORIZONTAL, 00597 OVER_VERTICAL, 00598 OVER_ORIGIN_GADGET. 00599 Purpose: - 00600 Errors: - 00601 Scope: Public 00602 00603 **********************************************************************************************/ 00604 00605 MouseOverRulerHit ScreenView::IsMouseOverRuler() 00606 { 00607 // WEBSTER - markn 15/1/97 00608 // No rulers in Webster 00609 #ifndef WEBSTER 00610 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 00611 // check that we have some rulers 00612 if(!HRuler||!VRuler||!OGadget) 00613 return OVER_NO_RULERS; 00614 // get the mouse position in screen coords 00615 wxPoint ScrMousePos; 00616 ::GetCursorPos(&ScrMousePos); 00617 00618 // get the HWND under the mouse 00619 HWND ThisControl = ::WindowFromPoint(ScrMousePos); 00620 00621 // check the HWND against the rulers 00622 if(ThisControl == HRuler->GetSafeHwnd()) 00623 return OVER_HORIZONTAL; 00624 else if(ThisControl == VRuler->GetSafeHwnd()) 00625 return OVER_VERTICAL; 00626 else if(ThisControl == OGadget->GetSafeHwnd()) 00627 return OVER_ORIGIN_GADGET; 00628 00629 00630 #endif 00631 #endif // WEBSTER 00632 return OVER_NO_RULERS; 00633 }; 00634 00635 00636 00637 00638 /********************************************************************************************* 00639 > BOOL ScreenView::CreateDragTarget(DragInformation * DragInfo) 00640 00641 Author: Chris_Parks (Xara Group Ltd) <camelotdev@xara.com> 00642 Created: 21/1/95 00643 Inputs: DragInfo : details about the current drag 00644 Outputs: - 00645 Purpose: will create drag targets for appropriate drags 00646 Errors: - 00647 00648 **********************************************************************************************/ 00649 00650 BOOL ScreenView::CreateDragTarget(DragInformation * DragInfo) 00651 { 00652 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 00653 // TEMPORARY - only create drag targets for the selected (frontmost/input-focus) 00654 // DocView. This stops us allowing colour drags to go into the wrong document 00655 // if the user ctrl-tabs to a different window during the drag. 00656 // Ideally, drags will be allowed, but the colour will be copied to the destination 00657 // document before being applied, but currently we don't have time to implement all that 00658 if (pDocView != DocView::GetSelected()) 00659 return FALSE; 00660 00661 if (DragInfo->CanDropOnPage()) 00662 { 00663 // If the drag can be dropped onto an object or the page, then we will accept it 00664 ViewDragTarget * NewTarget; 00665 NewTarget = new ViewDragTarget(RenderWindow->m_hWnd,NULL,DragInfo); 00666 return TRUE; 00667 } 00668 #endif 00669 00670 return FALSE; 00671 } 00672 00673 00674 00675 /******************************************************************************************** 00676 > static DocView* ScreenView::GetDocViewFromHwnd(HWND hwnd) 00677 00678 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00679 Created: 28/7/94 00680 Inputs: The handle of the render window to find. 00681 Outputs: - 00682 Returns: A pointer to the DocView associated with a render window, or NULL if 00683 there isn't one. 00684 Purpose: Given a window handle of a ScreenView render window, this function will 00685 return a pointer to the kernel DocView object that renders into that 00686 window, or NULL if there isn't one. 00687 Errors: - 00688 SeeAlso: - 00689 ********************************************************************************************/ 00690 00691 DocView *ScreenView::GetDocViewFromHwnd( wxWindow *hwnd ) 00692 { 00693 PORTNOTETRACE("other","ScreenView::GetDocViewFromHwnd - do nothing"); 00694 #ifndef EXCLUDE_FROM_XARALX 00695 // For all kernel documents in existence . . . 00696 List* pDocList = &(GetApplication()->Documents); 00697 for (Document* pKernelDoc = (Document*) pDocList->GetHead(); 00698 pKernelDoc != NULL; 00699 pKernelDoc = (Document*) pDocList->GetNext(pKernelDoc)) 00700 { 00701 00702 if(pKernelDoc->IsARalphDoc()) 00703 { 00704 // a bit unpleasent - only works because Ralph Docs have only one view.. 00705 // get the first (and only) docview 00706 DocView * pDocView = pKernelDoc->GetFirstDocView(); 00707 // check handles 00708 if(pDocView) 00709 if( pDocView->GetRenderWindow() == hwnd ) 00710 return pDocView; 00711 } 00712 else 00713 { 00714 00715 // Convert from a kernel document to an OIL document. 00716 CCamDoc* pCamDoc = pKernelDoc->GetOilDoc(); 00717 00718 // For all views onto the OIL document . . . 00719 POSITION pos = pCamDoc->GetFirstViewPosition(); 00720 while (pos != NULL) 00721 { 00722 // Compare the handle of the view's render window to the given handle, 00723 // returning the associated DocView if they match. 00724 ScreenView* pCamView = (ScreenView*) pCamDoc->GetNextView(pos); 00725 00726 // Not interested unless it is a ScreenView (it could be a print preview view) 00727 if (pCamView->IsKindOf(RUNTIME_CLASS(ScreenView))) 00728 { 00729 if (pCamView->RenderWindow->m_hWnd == hwnd) 00730 { 00731 return pCamView->pDocView; 00732 } 00733 } 00734 } 00735 } 00736 } 00737 #endif 00738 // Couldn't find the handle, so return nothing. 00739 return NULL; 00740 } 00741 00742 00743 /******************************************************************************************** 00744 > static DocView* ScreenView::GetDocViewFromWindowID(CWindowID WinID) 00745 00746 Author: Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com> 00747 Created: 15/1/95 00748 Inputs: Window ID 00749 Returns: A pointer to the DocView associated with the window ID, else NULL 00750 Also See: GetDocViewFromHwnd() 00751 ********************************************************************************************/ 00752 00753 DocView* ScreenView::GetDocViewFromWindowID(CWindowID WinID) 00754 { 00755 return GetDocViewFromHwnd( (wxWindow *)WinID ); 00756 } 00757 00758 00759 00761 // Position & Z-order management. 00762 00763 BOOL ScreenView::ZoomSingleView = TRUE; // if only a single view, maximise it 00764 BOOL ScreenView::UnzoomOnNewView = FALSE; // a new view unmaximises a maximised view 00765 00766 00767 00768 00769 00770 /********************************************************************************************* 00771 > void ScreenView::SetViewStateFromThis() const 00772 00773 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00774 Created: ages ago 00775 Inputs: - 00776 Outputs: - 00777 Returns: - 00778 Purpose: Called by a virgin ScreenView, ie. a view onto a new, unedited 00779 document. The function reads the attributes of the view window 00780 from the operating system, converts them into a device- 00781 independent form, and stores them in the ViewState. 00782 Errors: - 00783 Scope: Private 00784 SeeAlso: ScreenView::OnInitialUpdate; ScreenView::SetThisFromViewState(); 00785 DocView::ViewStateChanged(); class ViewState 00786 00787 **********************************************************************************************/ 00788 00789 void ScreenView::SetViewStateFromThis() const 00790 { 00791 // Set the current docview. 00792 pDocView->SetCurrent(); 00793 00794 // Set most of the ViewState according to the current state (the default) of this 00795 // ScreenView. 00796 UpdateViewPosition(); 00797 00798 // Make sure the scale factor is accurate. 00799 FIXED16 scale = pDocView->GetViewScale(); 00800 if (scale != Status->ViewScale) Status->ViewScale = scale; 00801 00802 // Record the current scroller position. 00803 WorkCoord temp; 00804 GetScrollOffset(&temp); 00805 Status->SetScrollPos(temp); 00806 00807 if( NULL != GetParentFrame() ) 00808 { 00809 // Record the top-most attribute of the frame window. 00810 PORTNOTE("other","Removed WM_TOPMOSTENQUIRY usage - is this really needed?") 00811 #ifndef EXCLUDE_FROM_XARALX 00812 Status->AlwaysOnTop = m_pFrame->SendMessage( WM_TOPMOSTENQUIRY ); 00813 #endif 00814 } 00815 } 00816 00817 00818 00819 00820 /********************************************************************************************* 00821 > void ScreenView::SetThisFromViewState() 00822 00823 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00824 Created: ages ago 00825 Inputs: - 00826 Outputs: - 00827 Returns: - 00828 Purpose: Move and resize the ScreenView according to the (device-independent) 00829 settings of a ViewState object. This typically happens when a new 00830 view is opened on a saved document. 00831 Errors: - 00832 Scope: Private 00833 SeeAlso: ScreenView::SetViewStateFromThis(); ScreenView::OnInitialUpdate() 00834 00835 **********************************************************************************************/ 00836 00837 void ScreenView::SetThisFromViewState() 00838 { 00839 PORTNOTETRACE("other","ScreenView::SetThisFromViewState - do nothing"); 00840 #ifndef EXCLUDE_FROM_XARALX 00841 // Get a pointer to this view's frame window. 00842 wxMDIChildFrame *pframewnd = (wxMDIChildFrame *)GetParentFrame(); 00843 //ENSURE(pframewnd != NULL, "Found a ScreenView without a frame window?!?"); 00844 00845 // Fill in a Windows placement structure with some converted positions from the 00846 // ViewState object, and set the placement of the parent frame window accordingly. 00847 WINDOWPLACEMENT wp; 00848 wp.length = sizeof(wp); 00849 wp.flags = WPF_SETMINPOSITION; 00850 wp.ptMaxPosition.x = wp.ptMaxPosition.y = 0; 00851 00852 // Work out how to display the window, either as an icon, maximised, or just normal. 00853 // Note that it is possible for a maximised window to be iconised without being 00854 // restore first. 00855 if (Status->IsMinimised) 00856 { 00857 wp.showCmd = SW_SHOWMINIMIZED; // display as an icon 00858 if (Status->IsMaximised) 00859 { 00860 wp.flags |= WPF_RESTORETOMAXIMIZED; // go from icon to maximised 00861 } 00862 } 00863 else if (Status->IsMaximised) 00864 { 00865 wp.showCmd = SW_SHOWMAXIMIZED; // display maximised 00866 } 00867 else 00868 { 00869 wp.showCmd = SW_SHOWNORMAL; // display normally 00870 } 00871 00872 Coord2POINT(Status->IconPoint, &wp.ptMinPosition); 00873 Rect2RECT(Status->ViewRect, &wp.rcNormalPosition); 00874 00875 //RALPH 00876 if(pframewnd) 00877 pframewnd->SetWindowPlacement(&wp); 00878 00879 // Set the scroll offset. 00880 OldOffset = Status->GetScrollPos(); 00881 SetScrollOffset(OldOffset); 00882 00883 // Set the scale factor. 00884 pDocView->SetViewScale(Status->ViewScale); 00885 00886 // If the view was "always on top" then fake a user selection of the appropriate 00887 // menu option. 00888 // RALPH 00889 if (Status->AlwaysOnTop && GetParentFrame()) 00890 { 00891 GetParentFrame()->PostMessage(WM_SYSCOMMAND, _R(IDM_ALWAYSONTOP)); 00892 } 00893 #endif 00894 } 00895 00896 00897 00898 /******************************************************************************************** 00899 > void ScreenView::UpdateViewPosition() const 00900 00901 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00902 Created: 12/4/94 00903 Inputs: - 00904 Outputs: - 00905 Returns: - 00906 Purpose: Updates the ViewState object shared between this ScreenView and its 00907 associated DocView with the new size of the view etc. 00908 Errors: - 00909 SeeAlso: - 00910 ********************************************************************************************/ 00911 00912 void ScreenView::UpdateViewPosition() const 00913 { 00914 PORTNOTETRACE("other","ScreenView::UpdateViewPosition - do nothing"); 00915 #ifndef EXCLUDE_FROM_XARALX 00916 ENSURE(Status != NULL, "No ViewState object in ScreenView::UpdateViewPosition!"); 00917 00918 // Get the size of the screen. We don't use this for anything, but I'm afraid to 00919 // take it out in case something breaks! 00920 // LH 31/08/2005 - Removed, if something breaks I'll revisit! 00921 wxRect rc; 00922 // GetDesktopWindow()->GetWindowRect( &rc ); 00923 // RECT2Rect(rc, &Status->ScreenRect); 00924 00925 wxFrame *pframewnd = GetParentFrame(); 00926 00927 if(pframewnd) 00928 { 00929 // Get the rectangle of the parent's MDICLIENT window. All child window sizes and 00930 // positions are calculated as relative to this. This is more accurate than just 00931 // taking the size of the main frame window as a whole, including menus, title bar etc. 00932 GetMainFrame()->GetClientSize( &rc.width, &rc.height ); 00933 RECT2Rect(rc, &Status->ParentRect); 00934 } 00935 00936 // Get the placement information for this view (MDI child) window. Note 00937 // that because it is a child window, the position is taken relative to the 00938 // client area of its parent. 00939 WINDOWPLACEMENT wp; 00940 wp.length = sizeof(wp); 00941 00942 00943 //ENSURE(pframewnd != NULL, "Found a ScreenView without a frame window?!?"); 00944 if(pframewnd) 00945 pframewnd->GetWindowPlacement(&wp); 00946 00947 // Fill in the ViewState with the position of the normal and iconised 00948 // window. The maximised position of the window does not need to be 00949 // stored as it always fills the whole MDI client area of its parent. 00950 RECT2Rect(wp.rcNormalPosition, &Status->ViewRect); 00951 POINT2Coord(wp.ptMinPosition, &Status->IconPoint); 00952 00953 // Update the mini/maxi flags. Note that it is possible for IsMinised and IsMaximised 00954 // to both be TRUE, if a maximised window has been iconised (but NOT if an iconised 00955 // window has been maximised!). 00956 if (wp.showCmd == SW_SHOWMINIMIZED) 00957 { 00958 Status->IsMinimised = TRUE; 00959 } 00960 else if (wp.showCmd == SW_SHOWMAXIMIZED) 00961 { 00962 Status->IsMinimised = FALSE; 00963 Status->IsMaximised = TRUE; 00964 } 00965 else // must be SW_SHOWNORMAL, ie. "restored" 00966 { 00967 Status->IsMinimised = Status->IsMaximised = FALSE; 00968 } 00969 #endif 00970 } 00971 00972 00973 00974 /********************************************************************************************* 00975 > virtual void ScreenView::OnInitialUpdate() 00976 00977 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00978 Created: 19 Jan 1994 00979 Inputs: - 00980 Outputs: - 00981 Returns: - 00982 Purpose: Called when the view must first display the document. Moves this 00983 view/frame to the position given in the ViewState object. 00984 Errors: - 00985 Scope: Protected 00986 SeeAlso: ScreenView::SetThisFromViewState; ScreenView::SetViewStateFromThis; 00987 DocView::ViewStateChanged 00988 **********************************************************************************************/ 00989 00990 void ScreenView::OnUpdate(wxView* sender, wxObject* hint) 00991 { 00992 if ( sender==NULL && !fInitialUpdate ) 00993 { 00994 OnInitialUpdate(); 00995 fInitialUpdate = true; 00996 } 00997 CCamView::OnUpdate(sender,hint); 00998 } 00999 01000 01001 // 01002 // OnIntialUpdate is no longer called automatically, so we call it instead 01003 // just once from OnUpdate. 01004 // 01005 void ScreenView::OnInitialUpdate() 01006 { 01007 // Set up current etc. 01008 SetCurrentStates(); 01009 01010 // Check if this view is being created by LoadAppWindowState at the start. If it is 01011 // then pick up the ViewState object ready-made by LoadAppWindowState and set 01012 // this view according to that. 01013 if (pReadyMadeViewState != NULL) 01014 { 01015 // Set the flags saved in temp. storage in the ViewState in the corresponding 01016 // DocView. 01017 DocView* pdv = GetDocViewPtr(); 01018 ERROR3IF(pdv == NULL, "Null DocView* in ScreenView::OnInitialUpdate"); 01019 01020 // Deallocate the old ViewState and set the new. 01021 delete SetViewState(pReadyMadeViewState); 01022 01023 // Set these flags as well in the DocView. 01024 pdv->ViewFlags.GridShow = pReadyMadeViewState->_GridShow; 01025 pdv->ViewFlags.GridSnap = pReadyMadeViewState->_GridSnap; 01026 pdv->ViewFlags.ObjectsSnap = pReadyMadeViewState->_ObjectsSnap; 01027 pdv->ViewFlags.MagObjectsSnap = pReadyMadeViewState->_MagObjectsSnap; 01028 pdv->ViewFlags.PrintBorderShow = pReadyMadeViewState->_PrintBorderShow; 01029 pdv->ViewFlags.LogicalView = pReadyMadeViewState->_LogicalView; 01030 pdv->ViewFlags.GuidesSnap = pReadyMadeViewState->_GuidesSnap; 01031 pdv->ViewFlags.GuidesShow = pReadyMadeViewState->_GuidesShow; 01032 01033 // Make sure we set this view from the view-state, not the other way around. 01034 pReadyMadeViewState = NULL; 01035 Status->IsNewView = FALSE; 01036 } 01037 01038 // Force the DocView to set the work area extent. 01039 pDocView->ViewStateChanged(); 01040 PORTNOTETRACE("other","ScreenView::OnInitialUpdate - code removed"); 01041 #ifndef EXCLUDE_FROM_XARALX 01042 if(HScrollBar&&VScrollBar) 01043 { 01044 01045 // Calculate the scroller page & line sizes, and its range, and make sure the 01046 // work area extent is updated. 01047 FIXED16 PixelWidth, PixelHeight; 01048 pDocView->GetPixelSize(&PixelWidth, &PixelHeight); 01049 XLONG x1 = CurrentSize.GetWidth() * PixelWidth; 01050 XLONG x2 = CurrentSize.GetHeight() * PixelHeight; 01051 HScrollBar->SetPageSize(x1); 01052 VScrollBar->SetPageSize(x2); 01053 HScrollBar->SetLineSize(x1 / xlong(10) + xlong(1)); 01054 VScrollBar->SetLineSize(x2 / xlong(10) + xlong(1)); 01055 } 01056 #endif 01057 // Either make this view conform to the ViewState, or update the ViewState with 01058 // information about this view, depending on whether the view is new or (re)loaded. 01059 if (Status->IsNewView) 01060 { 01061 SetViewStateFromThis(); 01062 pDocView->OnNewView(); // give the DocView a shot 01063 } 01064 else 01065 { 01066 SetThisFromViewState(); 01067 pDocView->OnLoadedView(); // let kernel have its say 01068 } 01069 01070 PORTNOTE("other","ScreenView::OnInitialUpdate - code removed") 01071 #ifndef EXCLUDE_FROM_XARALX 01072 // RALPH 01073 if (GetParentFrame()) 01074 { 01075 #if (_OLE_VER >= 0x200) 01076 // In OLE builds only do this for non-embedded docs, as OnShowDocument will handle it 01077 // for embedded docs. 01078 if (!GetDocument()->IsServer()) 01079 #endif 01080 { 01081 // Apply preferences. To begin, maximise this view if it is the only one around. 01082 BOOL fAppIsIcon = GetMainFrame()->IsIconic(); 01083 if (HowMany() == 1) 01084 { 01085 // This flag is TRUE during workspace restoration of more than one doc. We don't 01086 // want to maximise any views if its TRUE. 01087 extern BOOL fDontMaximiseViews; 01088 if (ZoomSingleView && !fAppIsIcon && !fDontMaximiseViews) 01089 ((CMDIChildWnd*) GetParentFrame())->MDIMaximize(); 01090 } 01091 else 01092 { 01093 // Otherwise, if a view is already maximised, un-maximise it so that this 01094 // view is visible. 01095 if (UnzoomOnNewView || fAppIsIcon) 01096 { 01097 // Find out the active view, which must be the one maximised, if any are. 01098 BOOL fIsMaxed; 01099 CMDIFrameWnd* pMainWnd = ((CMDIChildWnd*) GetParentFrame())->GetMDIFrame(); 01100 ENSURE(pMainWnd, "No MDI frame window in ScreenView::OnShowWindow!"); 01101 CMDIChildWnd* pMaxiWnd = pMainWnd->MDIGetActive(&fIsMaxed); 01102 01103 // If it is maximised then restore it. 01104 if (fIsMaxed && pMaxiWnd != NULL) 01105 { 01106 wxView* pv = pMaxiWnd->GetActiveView(); 01107 if (pv && pv->GetDocument() && 01108 ((CCamDoc*) pv->GetDocument())->IsUntouched()) 01109 { 01110 TRACEUSER( "JustinF", _T("MDI Restore in ScreenView::OnInitialUpdate\n")); 01111 pMaxiWnd->MDIRestore(); 01112 } 01113 } 01114 } 01115 } 01116 } 01117 } 01118 #ifdef _DEBUG 01119 else 01120 { 01121 TRACEUSER( "JustinF", _T("\t- no parent frame in ScreenView::OnInitialUpdate\n")); 01122 } 01123 #endif 01124 #endif 01125 // Initialise the OLE selection (TODO: remove this when selection model code 01126 // is written). 01127 #if (_OLE_VER >= 0x200) 01128 m_pSelection = 0; 01129 #endif 01130 01131 // Make sure the render window is repainted and inform the kernel that something 01132 // has happened. 01133 // InvalidateView(); 01134 pDocView->ViewStateChanged(); 01135 01136 // Allow the base class to do it's OnInitialUpdate stuff last, because it just 01137 // calls OnUpdate. 01138 // CCamView::OnInitialUpdate(); 01139 01140 // Indicate that we have set the position, size, focus etc so OnActivateView is safe 01141 // to update the HasFocus fields of ViewStates. 01142 fSetupDone = TRUE; 01143 01144 #if (_OLE_VER >= 0x200) 01145 01146 // Check if the document wants to zoom to the page. This is the best place to 01147 // do this as everything should now be stable. 01148 LPCTSTR lpcszZoomOp = GetDocument()->GetInitialZoom(); 01149 if (lpcszZoomOp) 01150 { 01151 // Remember the old prev. zoom setting. 01152 INT32 nPrev; 01153 FIXED16 fxPrev; 01154 WorkCoord wcPrev; 01155 nPrev = pDocView->GetPrevZoomIndex(); 01156 fxPrev = pDocView->GetPrevZoomScale(); 01157 wcPrev = pDocView->GetPrevZoomOffset(); 01158 01159 // There is, so zoom it to show the new page bounds. Set-up the kernel. 01160 DocView* pOldCurrent = DocView::GetCurrent(); 01161 pDocView->SetCurrent(); 01162 01163 // Perform the Zoom-to-Page Operation (it's non-undo-able). 01164 OpDescriptor* pOp = OpDescriptor::FindOpDescriptor((LPTSTR) lpcszZoomOp); 01165 ERROR3IF(!pOp, "Can't find the Zoom Operation in ScreenView::OnInitialUpdate"); 01166 pOp->Invoke(0); 01167 01168 // Restore the old prev. zoom setting. 01169 pDocView->SetPrevZoomIndex(nPrev); 01170 pDocView->SetPrevZoomScale(fxPrev); 01171 pDocView->SetPrevZoomOffset(wcPrev); 01172 } 01173 01174 #endif 01175 } 01176 01177 01178 01179 /********************************************************************************************* 01180 > void ScreenView::OnActivateView(BOOL bActivate, CView* pActiveView, CView* pDeactiveView) 01181 01182 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01183 Created: ages ago 01184 Inputs: A boolean which if TRUE means that this view is being activated, if FALSE 01185 that this view is being deactivated; two pointers to the CView objects which 01186 are being activated/deactivated. 01187 Outputs: Possibly changes the pointed-to views. 01188 Returns: - 01189 Purpose: Called by MFC when a view gains or loses the input focus, either due to the 01190 the user clicking about, or another application popping up a window etc etc. 01191 I would just like to point out that this MFC function is the most brain-damaged 01192 Microsoft have come up so far. It's documentation bears no resemblance to 01193 the way the function is called/used - for example, as far as I can see, the 01194 two CView* parameters are NEVER different! 01195 Errors: - 01196 Scope: Protected 01197 SeeAlso: Pretty unique, this one, so I can't think of anything to put here. 01198 01199 **********************************************************************************************/ 01200 01201 void ScreenView::OnActivateView( bool bActivate, wxView* pActiveView, wxView* pDeactiveView ) 01202 { 01203 if ( !pDocView ) 01204 { 01205 TRACE( _T("ScreenView::OnActivateView - Warning: pDocView uninitialised\n") ); 01206 return; 01207 } 01208 01209 if (bActivate) SetCurrentStates(); 01210 01211 Document* KernelDoc = NULL; 01212 if (pDocView) KernelDoc = pDocView->GetDoc(); 01213 01214 // MFC does some hidden stuff here . . . 01215 CCamView::OnActivateView( bActivate, pActiveView, pDeactiveView ); 01216 01217 // Trigger off some messages into the kernel. 01218 if (bActivate) 01219 { 01220 // make sure the global preference reflects the current state 01221 SetDefaultRulersState(Status->RulersVisible); 01222 SetDefaultScrollersState(Status->ScrollersVisible); 01223 01224 // Update our records of who is top-most and set the keyboard input focus to 01225 // the rendering child window. 01226 GetCanvas()->SetFocus(); 01227 01228 // Inform the kernel that the view's Z-order has changed. This sets the selected 01229 // View, Document, and spread, to legal values. 01230 Document::SetSelectedViewAndSpread(KernelDoc, pDocView, NULL); 01231 } 01232 } 01233 01234 01235 01236 /******************************************************************************************** 01237 > BOOL ScreenView::IsTopmost() const 01238 01239 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01240 Created: 17/11/93 01241 Inputs: - 01242 Outputs: - 01243 Returns: TRUE if this view is the active view. 01244 Purpose: Tests if this ScreenView is the active view, ie. is on top of all other views. 01245 Errors: - 01246 SeeAlso: - 01247 ********************************************************************************************/ 01248 01249 BOOL ScreenView::IsTopmost() const 01250 { 01251 PORTNOTETRACE("other","ScreenView::IsTopmost - do nothing"); 01252 #ifndef EXCLUDE_FROM_XARALX 01253 // always true for ralph 01254 #ifdef RALPH 01255 return TRUE; 01256 #else 01257 return ( (wxView *)this ) == GetParentFrame()->GetActiveView(); 01258 #endif 01259 #else 01260 return TRUE; 01261 #endif 01262 } 01263 01264 01265 01266 /******************************************************************************************** 01267 > void ScreenView::ShowScrollers(BOOL ShowOrHide) 01268 01269 Author: Chris_Parks (Xara Group Ltd) <camelotdev@xara.com> 01270 Created: 2/11/94 01271 Inputs: - 01272 Outputs: - 01273 Returns: - 01274 Purpose: Hide or Show Scrollers. 01275 Errors: - 01276 SeeAlso: - 01277 ********************************************************************************************/ 01278 01279 void ScreenView::ShowScrollers(BOOL Show) 01280 { 01281 PORTNOTETRACE("other","ScreenView::ShowScrollers - do nothing"); 01282 #ifndef EXCLUDE_FROM_XARALX 01283 // Set flags and Show/Hide the Scrollers 01284 if (Show) 01285 { 01286 VScrollBar->ShowWindow(SW_SHOW); 01287 HScrollBar->ShowWindow(SW_SHOW); 01288 } 01289 else 01290 { 01291 Status->ScrollersVisible = FALSE; 01292 VScrollBar->ShowWindow(SW_HIDE); 01293 HScrollBar->ShowWindow(SW_HIDE); 01294 } 01295 01296 Status->ScrollersVisible = Show; 01297 01298 // call OnSize directly to force new layout 01299 wxRect WRect; 01300 GetClientRect(&WRect); 01301 SendMessage(WM_SIZE, SIZE_RESTORED, MAKELPARAM(WRect.Width(), WRect.Height())); */ 01302 #endif 01303 } 01304 01305 01306 01307 /******************************************************************************************** 01308 > void ScreenView::ShowRulers(BOOL ShowOrHide) 01309 01310 Author: Chris_Parks (Xara Group Ltd) <camelotdev@xara.com> 01311 Created: 2/11/94 01312 Inputs: - 01313 Outputs: - 01314 Returns: - 01315 Purpose: Hide or Show Rulers. 01316 Errors: - 01317 SeeAlso: - 01318 ********************************************************************************************/ 01319 01320 void ScreenView::ShowRulers(BOOL Show) 01321 { 01322 // WEBSTER - markn 15/1/97 01323 // No rulers in Webster 01324 #ifndef WEBSTER 01325 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 01326 if(!VRuler||!HRuler) 01327 return; 01328 01329 // Set flags and Show/Hide the Scrollers 01330 if(VRuler) 01331 VRuler->ShowRuler(Show); 01332 if(HRuler) 01333 HRuler->ShowRuler(Show); 01334 01335 Status->RulersVisible = Show; 01336 01337 // call OnSize directly to force new layout 01338 CRect WRect; 01339 GetClientRect(&WRect); 01340 SendMessage(WM_SIZE, SIZE_RESTORED, MAKELPARAM(WRect.Width(), WRect.Height())); 01341 #endif 01342 #endif // WEBSTER 01343 } 01344 01345 01346 01347 /********************************************************************************************* 01348 > afx_msg void ScreenView::OnSize(UINT32 nType, INT32 cx, INT32 cy) 01349 01350 Author: Chris_Parks (Xara Group Ltd) <camelotdev@xara.com> 01351 Created: ages ago 01352 Inputs: A flag indicating whether the window is maximised, minimised 01353 etc., the width and height of the ScreenView client area. 01354 Outputs: - 01355 Returns: - 01356 Purpose: Moved down to ScreenCamView 01357 Errors: - 01358 Scope: Protected 01359 SeeAlso: CScroller::CalcPosFromParentClient(); CScroller::SetPageSize(); 01360 CScroller::SetLineSize(); class CRendWnd; class CScrollerCorner; 01361 struct ViewState; DocView::ViewStateChanged() 01362 01363 **********************************************************************************************/ 01364 01365 void ScreenView::OnSize( wxSizeEvent & ) 01366 { 01367 } 01368 01369 01370 01371 /********************************************************************************************* 01372 > afx_msg LRESULT ScreenView::OnFrameMove(WPARAM, LPARAM) 01373 01374 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01375 Created: 12.4.94 01376 Inputs: Not used. 01377 Outputs: - 01378 Returns: - 01379 Purpose: Updates the ViewState object with the view's position, in an OS- 01380 independent form. This message is sent by the view's frame window 01381 whenever it is moved. 01382 Errors: - 01383 Scope: Protected 01384 SeeAlso: UpdateViewPosition; CCamMDIChild::OnMove; 01385 struct ViewState; DocView::ViewStateChanged() 01386 01387 **********************************************************************************************/ 01388 01389 // v1.1 BODGE BODGE BODGE 01390 // JustinF says: Don't process WM_FRAMEMOVE messages to the view as Windows sends a WM_MOVE 01391 // message to a view frame before ScreenView knows its correct size (ie. before 01392 // ScreenView is sent a WM_SIZE message). This causes the scrollers to be drawn 01393 // momentarily in the wrong place when a view window is being created or activated. 01394 // Fixes bug #1448. 01395 01396 #if 0 01397 01398 LRESULT ScreenView::OnFrameMove(WPARAM, LPARAM) 01399 { 01400 01401 SetCurrentStates(); 01402 // Update the ViewState. 01403 UpdateViewPosition(); 01404 if (fSetupDone) pDocView->ViewStateChanged(); 01405 return 0; 01406 } 01407 01408 #endif 01409 01410 01412 // Painting. 01413 01414 /********************************************************************************************* 01415 > void ScreenView::GetClientSize(int * pWidth, int * pHeight) const TYPENOTE: Correct 01416 01417 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01418 Created: ages ago 01419 Inputs: - 01420 Outputs: The width and height of the client area which the kernel can render into. 01421 Returns: - 01422 Purpose: Calculates the size of the ScreenView's RendWnd. 01423 Errors: - 01424 Scope: Public 01425 SeeAlso: class CRendWnd 01426 01427 **********************************************************************************************/ 01428 01429 void ScreenView::GetClientSize(int * pWidth, int * pHeight) const /* TYPENOTE: Correct */ 01430 { 01431 // OilRect r = CurrentSize.ToOil(pDocView); 01432 // *pWidth = r.Width(); 01433 // *pHeight = r.Height(); 01434 WinRect wrect(0,0,0,0); 01435 GetCanvas()->GetClientSize(&wrect.width,&wrect.height); 01436 OilRect orect = wrect.ToOil(pDocView); 01437 *pWidth = orect.Width(); 01438 *pHeight = orect.Height(); 01439 } 01440 01441 01442 01443 /********************************************************************************************* 01444 > void ScreenView::InvalidateView(const OilRect* pRect = NULL, BOOL updatenow = FALSE) 01445 01446 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01447 Created: ages ago 01448 Inputs: A pointer to the client area rectangle, an OilRect, which is to be 01449 invalidated (marked as needing to be redrawn). This parameter may be 01450 omitted. If the first parameter is present, an optional second parameter 01451 may be specified, which if TRUE tells Windows to immediately send a 01452 WM_PAINT message to the view, which will force an instant redraw of any 01453 invalid areas (normally Windows waits until all other messages have been 01454 processed before sending the WM_PAINT message). 01455 Outputs: - 01456 Returns: - 01457 Purpose: Invalidates the appropriate section of the RendWnd client area - if the 01458 passed parameter is NULL then the whole client area is invalidated. The 01459 rectangle will be redrawn at some time in the (near) future. 01460 Errors: - 01461 Scope: Public 01462 SeeAlso: class CRendWnd; ScreenView::OnDraw() 01463 01464 **********************************************************************************************/ 01465 01466 void ScreenView::InvalidateView(const OilRect* pRect, BOOL updatenow) 01467 { 01468 if (pRect != NULL) 01469 { 01470 // Convert passed rectangle to an MFC-derived type and invalidate it. Add an extra 01471 // pixel to the right and bottom edges of the rectangle to ensure that the whole 01472 // rectangle, after scaling and rounding, is invalidated. 01473 WinRect r = pRect->ToWin( pDocView ); 01474 r.width++; 01475 r.height++; 01476 GetCanvas()->Refresh( true, &r ); 01477 } 01478 else 01479 { 01480 // We are completely redrawing the client area, so it is possible that the 01481 // "cached" previous scroll offsets, contained in OldOffset, will become 01482 // incorrect. 01483 GetCanvas()->Refresh( true ); 01484 GetScrollOffset(&OldOffset); 01485 } 01486 01487 if (updatenow) GetCanvas()->Update(); 01488 } 01489 01490 01491 01492 01493 /********************************************************************************************* 01494 > afx_msg void ScreenView::OnPaint() 01495 01496 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01497 Created: ages ago 01498 Inputs: - 01499 Outputs: - 01500 Returns: - 01501 Purpose: Handles WM_PAINT messages for the ScreenView window. As the window is 01502 entirely covered by child windows, which know how to paint themselves, 01503 this function simply validates its (invisible) client area, removing 01504 the paint message. No drawing of any kind is done. 01505 Errors: - 01506 Scope: Protected 01507 SeeAlso: class CRendWnd 01508 01509 **********************************************************************************************/ 01510 01511 PORTNOTE("other","Removed ScreenView::OnPaint usage") 01512 #ifndef EXCLUDE_FROM_XARALX 01513 void ScreenView::OnPaint() 01514 { 01515 try 01516 { 01517 Error::RenderThreadIn(); 01518 wxPaintDC dc(this); // this validates the client area 01519 Error::RenderThreadOut(); 01520 } 01521 catch( CResourceException e ) 01522 { 01523 ENSURE(FALSE, "Resource exception in ScreenView::OnPaint!\n"); 01524 } 01525 } 01526 #endif 01527 01528 /********************************************************************************************* 01529 01530 > afx_msg LRESULT ScreenView::OnRenderView(WPARAM, LPARAM lp) 01531 01532 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01533 Created: ages ago 01534 Inputs: A pointer to a CPaintDC, cast into an LPARAM. The WPARAM is not used. 01535 Outputs: - 01536 Returns: Returns 0, indicating to Windows that the message was successfully 01537 processed. 01538 Purpose: Responds to a WM_PAINT message sent to the RendWnd window object. 01539 Effectively tricks MFC into painting the RendWnd as if it was a 01540 CView window, not a child of a CView - calls CView::OnPrepareDC() 01541 and ScreenView::OnDraw(). 01542 Errors: - 01543 Scope: Protected 01544 SeeAlso: class CRendWnd; CRenderWnd::OnPaint(); ScreenView::OnDraw(); 01545 01546 **********************************************************************************************/ 01547 01548 PORTNOTE("other","Removed ScreenView::OnRenderView usage") 01549 #ifndef EXCLUDE_FROM_XARALX 01550 LRESULT ScreenView::OnRenderView(WPARAM, LPARAM lp) 01551 { 01552 CPaintDC* pDC = (CPaintDC*) lp; 01553 OnPrepareDC(pDC); 01554 OnDraw(pDC); 01555 return 0; 01556 } 01557 #endif 01558 01559 01560 // set this to 1 to show update rectangles using cross-hatching, 0 to not 01561 #define SHOW_RECT 0 01562 01563 #if SHOW_RECT 01564 void DumpRect( wxDC *pDC, WinRect *lpRect, TCHAR *type ) 01565 { 01566 static INT32 BrushNum = wxFIRST_HATCH; 01567 wxBrush Brush; 01568 01569 Brush.SetStyle(BrushNum); 01570 Brush.SetColour(0, 0, 0); 01571 01572 if (++BrushNum > wxLAST_HATCH) 01573 BrushNum = wxFIRST_HATCH; 01574 01575 pDC->SetBrush(Brush); 01576 pDC->DrawRectangle(*lpRect); 01577 01578 if (type) 01579 { 01580 TRACE( _T("%s (%ld, %ld) [%ld, %ld]"), type, lpRect->GetLeft(), lpRect->GetTop(), 01581 lpRect->GetWidth(), lpRect->GetHeight() ); 01582 } 01583 } 01584 01585 #else 01586 #define DumpRect(pdc, rect, name) 01587 #endif 01588 01589 /********************************************************************************************* 01590 > virtual void ScreenView::OnDraw(CDC* pDC) 01591 01592 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01593 Created: ages ago 01594 Inputs: A pointer to the CDC object to render into. 01595 Outputs: - 01596 Returns: - 01597 Purpose: Makes sure that the kernel knows which view to render into. Retrieves the 01598 clipping rectangle from the CDC. Passes the CDC and the rectangle to 01599 DocView::OnDraw(), which does the actual rendering. 01600 Errors: - 01601 Scope: Public 01602 SeeAlso: CView::OnPrepareDC(); ScreenView::OnRenderView(); DocView::OnDraw() 01603 01604 **********************************************************************************************/ 01605 01606 void ScreenView::OnDraw( wxDC *pDC ) 01607 { 01608 // TRACE( _T("ScreenView::OnDraw\n")); 01609 01610 if (pDocView==NULL) 01611 return; 01612 01613 // Set the current DocView, ie. the DocView being worked upon. (and the Doc!) 01614 pDocView->SetCurrent(); 01615 (pDocView->GetDoc())->SetCurrent(); 01616 01617 // Are we printing? 01618 PORTNOTE("print","Removed Printing from OnDraw") 01619 #ifndef EXCLUDE_FROM_XARALX 01620 if (pDC->IsPrinting()) 01621 { 01622 //TRACE( _T("BAD ! ScreenView::OnDraw reckons we're printing\n")); 01623 #ifndef STANDALONE 01624 01625 // Yes - do the printing! 01626 01627 // Find out from the display context the rectangle bounding the invalid 01628 // region. 01629 WinRect clip; 01630 01631 if (pDC->GetClipBox(&clip) == NULLREGION) 01632 return; 01633 01634 // Pass the drawing parameters on to the associated PrintView object. 01635 pPrintView->AttachToDC(pDC); 01636 pPrintView->OnDraw(pDC, clip.ToOil(pPrintView)); 01637 pPrintView->AttachToDC(NULL); 01638 01639 #endif 01640 } 01641 else 01642 #endif 01643 { 01644 WinRect clip; 01645 01646 // wxWidget only provides a unified accessor, so that's 01647 // what we'll use 01648 wxRegionIterator upd( m_pCanvas->GetUpdateRegion() ); // get the update rect list 01649 while( upd ) 01650 { 01651 clip.x = upd.GetX(); 01652 clip.y = upd.GetY(); 01653 clip.width = upd.GetW(); 01654 clip.height = upd.GetH(); 01655 01656 // DumpRect( pDC, &clip, wxT("OnDraw UpdateRect : ") ); 01657 01658 OilRect oRect = clip.ToOil( pDocView ); 01659 // TRACE( _T("OilRect = (%d, %d) - (%d, %d)\n"), oRect.lo.x, oRect.lo.y, oRect.hi.x, oRect.hi.y); 01660 01661 pDocView->OnDraw( pDC, oRect ); 01662 01663 upd ++ ; 01664 } 01665 01666 //#pragma message( __LOCMSG__ "ScreenView::OnDraw - Forcing redraw" ) 01667 //TRACE( _T("ScreenView::OnDraw - Forcing redraw") ); 01668 // Camelot.GetRegionList()->ImmediateRender(true); 01669 01670 #if FALSE 01671 // Find out from the display context the rectangle bounding the invalid 01672 // region. If we can, try to use lists of rectangles. 01673 wxRect *lpRect; 01674 UINT32 count = CCDC::GetRectangleList( pDC, &lpRect ); 01675 01676 TRACE( _T("ScreenView::OnDraw called with %d regions\n"), count); 01677 01678 // If there's more than one rectangle then iterate through them all... 01679 if (count > 1) 01680 { 01681 while (count--) 01682 { 01683 clip.x = lpRect->x; 01684 clip.x = lpRect->y; 01685 clip.width = lpRect->width; 01686 clip.height = lpRect->height; 01687 01688 DumpRect( pDC, &clip, "camrect1" ); 01689 01690 pDocView->OnDraw( pDC, clip.ToOil(pDocView) ); 01691 lpRect++; 01692 } 01693 } 01694 else 01695 { 01696 //TRACE( _T("ScreenView::OnDraw doing simple rectangle stuff")); 01697 01698 // . . . else handle the simple <2 rectangle code 01699 pDC->GetClippingBox( clip ); 01700 if( !clip.IsEmpty() ) 01701 { 01702 // Pass the drawing parameters on to the associated DocView object. 01703 DumpRect( pDC, &clip, "camrect2" ); 01704 pDocView->OnDraw( pDC, clip.ToOil(pDocView) ); 01705 } 01706 } 01707 #endif 01708 } 01709 01710 // TRACE( _T("Leaving ScreenView::OnDraw\n")); 01711 } 01712 01713 /********************************************************************************************* 01714 > BOOL ScreenView::OnPreparePrinting(CPrintInfo* pInfo) 01715 01716 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01717 Created: by the wonderful AppWizard 01718 Inputs: - 01719 Outputs: Fills the passed CPrintInfo with some stuff. 01720 Returns: TRUE if successful preparation for printing. 01721 Purpose: Current just returns that value of CView::DoPreparePrinting() 01722 Errors: - 01723 Scope: Public 01724 SeeAlso: CView::DoPreparePrinting() 01725 01726 **********************************************************************************************/ 01727 01728 PORTNOTE("print","Removed ScreenView::OnPreparePrinting") 01729 #ifndef EXCLUDE_FROM_XARALX 01730 BOOL ScreenView::OnPreparePrinting(CPrintInfo* pInfo) 01731 { 01732 #ifndef STANDALONE 01733 01734 if (!CCPrintDialog::OnPreparePrinting(pInfo,pDocView->GetDoc())) 01735 ERROR2(FALSE,"Unable to initialise the customized print dialog"); 01736 01737 // default preparation 01738 // BOOL Result = CCamView::DoPreparePrinting(pInfo); 01739 // if (!Result) 01740 // return FALSE; 01741 01742 // Check because brainless CView only checks for valid DC in debug builds - handy eh? NOT! 01743 if (pInfo->m_pPD->m_pd.hDC == NULL) 01744 { 01745 ERROR1(FALSE,_R(IDE_NULL_PRINTDC)); 01746 //ERROR2(FALSE, "No valid DC returned by print dialog!"); 01747 } 01748 01749 // Get ourselves a print view and attach it to this CamView. 01750 // NB. Must be after the user has clicked OK on print dialog, as we set up 01751 // anti-aliasing etc. in PrintView constructor. 01752 if (pPrintView != NULL) 01753 { 01754 delete pPrintView; 01755 pPrintView = NULL; 01756 ERROR2(FALSE, "OnPreparePrinting(): we already have a PrintView!"); 01757 } 01758 01759 pPrintView = new PrintView(pDocView->GetDoc()); 01760 if (pPrintView == NULL) 01761 ERROR2(FALSE, "Not enough memory to create PrintView object"); 01762 01763 if (!pPrintView->ConnectToOilView(this)) 01764 { 01765 delete pPrintView; 01766 pPrintView = NULL; 01767 ERROR2(FALSE, "Unable to attach PrintView to CamView."); 01768 } 01769 01770 #endif 01771 01772 // OK if we got this far. 01773 return TRUE; 01774 } 01775 #endif 01776 01777 /********************************************************************************************* 01778 > wxDC* ScreenView::GetRenderDC() const 01779 01780 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01781 Created: 2nd Sept 1993 01782 Inputs: - 01783 Outputs: - 01784 Returns: A pointer to the CDC object associated with the RenderWindow. 01785 Purpose: Allows the kernel to draw on the client area at times other than 01786 when processing WM_PAINT messages. Note that the pointer returned 01787 is temporary and should NOT be stored away for future use - it may well 01788 become invalid on the next idle event. 01789 Errors: Returns NULL if the DC could not be obtained. 01790 Scope: Public 01791 SeeAlso: ScreenView::OnDraw() 01792 01793 **********************************************************************************************/ 01794 01795 wxDC *ScreenView::GetRenderDC() const 01796 { 01797 // 01798 // GAT: Warning - I don't think we want to be using this function anymore. 01799 // Create a DC when required. 01800 // 01801 PORTNOTETRACE("other","ScreenView::GetRenderDC - do nothing"); 01802 #ifndef EXCLUDE_FROM_XARALX 01803 return GetCanvas()->GetDC(); 01804 #else 01805 return NULL; 01806 #endif 01807 } 01808 01809 01810 01811 /********************************************************************************************* 01812 > wxWindow* ScreenView::GetRenderWindow() const 01813 01814 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01815 Created: 15th October 1993 01816 Inputs: - 01817 Outputs: - 01818 Returns: A pointer to the RenderWindow child of this ScreenView 01819 Purpose: Allows the kernel to access to the render window, useful on the odd 01820 occasion, although it does distort "encapsulation". 01821 Errors: - 01822 Scope: Public 01823 SeeAlso: ScreenView::GetRenderDC() 01824 01825 **********************************************************************************************/ 01826 01827 wxWindow *ScreenView::GetRenderWindow() const 01828 { 01829 return GetCanvas(); 01830 } 01831 01832 01833 01834 01836 // Scrolling functions. 01837 01838 // This preference controls whether scrollers appear proportional or standard. 01839 BOOL ScreenView::PropScrollersOn = TRUE; 01840 BOOL ScreenView::DefaultScrollersState = TRUE; 01841 BOOL ScreenView::DefaultRulersState = FALSE; 01842 BOOL ScreenView::UseVisibleDefaults = TRUE; 01843 01844 01845 /********************************************************************************************* 01846 > void ScreenView::ScrollTo(const WorkCoord& offset) 01847 01848 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01849 Created: ages ago 01850 Inputs: The position, in WorkCoords, that the top-left corner of the view is to 01851 move to. 01852 Outputs: - 01853 Returns: - 01854 Purpose: Scroll the client area of the window to the specified position. The offset 01855 must be converted to OS coordinates before being passed to Windows. If the 01856 new position of the view does not overlap the old position then the client 01857 area is completely redrawn. Otherwise, the Windows USER module is called 01858 to scroll the window. 01859 Errors: - 01860 Scope: Private 01861 SeeAlso: ScreenView::SetScrollPos() 01862 01863 **********************************************************************************************/ 01864 01865 void ScreenView::ScrollTo(const WorkCoord& offset) 01866 { 01867 PORTNOTETRACE("other","ScreenView::ScrollTo - do nothing"); 01868 #ifndef EXCLUDE_FROM_XARALX 01869 // Calculate the difference between where we are and where we want to be. Notice 01870 // the asymmetry in the calculations, to account for the Windows coordinate origin 01871 // being in the top-left, not the bottom-left. 01872 FIXED16 PixelWidth, PixelHeight; 01873 pDocView->GetPixelSize(&PixelWidth, &PixelHeight); 01874 INT32 dx = ((offset.x - OldOffset.x) / PixelWidth.MakeLong() ); 01875 INT32 dy = ((OldOffset.y - offset.y) / PixelHeight.MakeLong() ); 01876 if (dx == 0 && dy == 0) return; 01877 01878 // ZZZ 01879 01880 01881 // Scroll part of, or redraw the whole of, the client area. 01882 if (Abs(dx) >= CurrentSize.GetRight() || Abs(dy) >= CurrentSize.GetBottom() ) 01883 GetCanvas()->Refresh( true ); 01884 else 01885 GetCanvas()->ScrollWindow(-dx, -dy); 01886 01887 // WEBSTER - markn 15/1/97 01888 // No rulers in Webster 01889 #ifndef WEBSTER 01890 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 01891 if(Status->RulersVisible) 01892 { 01893 if(HRuler) 01894 HRuler->ScrollRuler(-dx); 01895 if(VRuler) 01896 VRuler->ScrollRuler(-dy); 01897 01898 } 01899 #endif 01900 #endif // WEBSTER 01901 // Remember this scroll offset, which corresponds to what will be drawn on the screen, 01902 // and force an immediate repaint of the invalid area. 01903 OldOffset = offset; 01904 GetCanvas()->UpdateWindow(); 01905 01906 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 01907 // Make sure that the system will update the state of gadgets after this, some of 01908 // which may now be "greyed" because what they apply to is no longer visible etc. 01909 // This is the best place to put this, as all scroll requests, whether they come 01910 // from the user or are internally generated, go through this function. 01911 DialogBarOp::SetSystemStateChanged(TRUE); 01912 #endif 01913 #endif 01914 } 01915 01916 01917 01918 /********************************************************************************************* 01919 > BOOL ScreenView::GetScrollerStyle() const 01920 01921 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01922 Created: ages ago 01923 Inputs: - 01924 Outputs: - 01925 Returns: TRUE if this ScreenView is currently sporting proportional scroll bars, FALSE 01926 if it isn't, and its scroll bars look like typical naff Windows ones. 01927 Purpose: Tests whether proportional scroll bars are currently in operation. 01928 Errors: - 01929 Scope: Public 01930 SeeAlso: ScreenView::SetScrollerStyle; CScroller::SetProportional() 01931 01932 **********************************************************************************************/ 01933 01934 BOOL ScreenView::GetScrollerStyle() const 01935 { 01936 return ScrollerStyle; 01937 } 01938 01939 01940 01941 /********************************************************************************************* 01942 > void ScreenView::SetScrollerStyle(BOOL proportional) 01943 01944 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01945 Created: ages ago 01946 Inputs: A boolean which if TRUE means that proportional scroll bars should be turned 01947 on, if FALSE that the scroll bars should look normal. 01948 Outputs: - 01949 Returns: - 01950 Purpose: Allows DocView to change the style - groovy or dull - of ScreenView's scroll 01951 bars. Records the setting and calls the appropriate functions of the scroll 01952 bar gadgets 01953 Errors: - 01954 Scope: Public 01955 SeeAlso: ScreenView::GetScrollerStyle(); CScroller::SetProportional() 01956 01957 **********************************************************************************************/ 01958 01959 void ScreenView::SetScrollerStyle(BOOL proportional) 01960 { 01961 if(!HScrollBar||!VScrollBar) 01962 return; 01963 01964 ScrollerStyle = proportional; 01965 PORTNOTETRACE("other","ScreenView::SetScrollerStyle - do nothing"); 01966 #ifndef EXCLUDE_FROM_XARALX 01967 HScrollBar->SetProportional(ScrollerStyle); 01968 VScrollBar->SetProportional(ScrollerStyle); 01969 #endif 01970 } 01971 01972 01973 01974 /********************************************************************************************* 01975 > void ScreenView::GetWorkAreaExtent(WorkRect* pArea) const 01976 01977 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01978 Created: ages ago 01979 Inputs: - 01980 Outputs: Changes the pointed to WorkRect to the current WorkAreaExtent. 01981 Returns: - 01982 Purpose: Provides read-only access to the WorkAreaExtent, as maintained by 01983 DocView/ScreenView. 01984 Errors: - 01985 Scope: Public 01986 SeeAlso: ScreenView::SetWorkAreaExtent() 01987 01988 **********************************************************************************************/ 01989 /* 01990 GAT: Never used. 01991 01992 void ScreenView::GetWorkAreaExtent(WorkRect* pArea) const 01993 { 01994 *pArea = Status->WorkAreaExtent; 01995 } 01996 01997 */ 01998 01999 /********************************************************************************************* 02000 > void ScreenView::SetWorkAreaExtent(const WorkRect& area, BOOL redraw) 02001 02002 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 02003 Created: ages ago 02004 Inputs: A WorkRect describing the new WorkAreaExtent, a boolean which if TRUE 02005 means immediately repaint the view window to reflect the change. 02006 Outputs: - 02007 Returns: - 02008 Purpose: Calculates the size of the RendWnd, setting the "page size" of the 02009 scroll bars accordingly. Sets the scroll range of the scroll bars 02010 to the size of the WorkAreaExtent (note that the Y range is negated 02011 and inverted - the mother of all bodges). 02012 Errors: - 02013 Scope: Public 02014 SeeAlso: ScreenView::GetWorkAreaExtent(); CScroller::SetPageSize(); 02015 CScroller::SetScrollRange(); class CRendWnd 02016 02017 **********************************************************************************************/ 02018 02019 void ScreenView::SetWorkAreaExtent(const WorkRect& area, BOOL redraw) 02020 { 02021 WorkArea = area; 02022 FIXED16 PixelWidth, PixelHeight; 02023 pDocView->GetPixelSize(&PixelWidth,&PixelHeight); 02024 // This doesn't give us a redraw flag. 02025 GetCanvas()->SetVirtualSize( 02026 INT32((area.hi.x-area.lo.x)/PixelWidth .MakeDouble()), 02027 INT32((area.hi.y-area.lo.y)/PixelHeight.MakeDouble()) 02028 ); 02029 } 02030 02031 02032 02033 /********************************************************************************************* 02034 > void ScreenView::GetScrollOffset(WorkCoord* pOffset) const 02035 02036 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 02037 Created: ages ago 02038 Inputs: - 02039 Outputs: The current scroll offset is written to the passed WorkCoord. 02040 Returns: - 02041 Purpose: Reads the offset from the horizontal and vertical scroll bars, 02042 combining then into a WorkCoord. 02043 Errors: - 02044 Scope: Public 02045 SeeAlso: ScreenView::SetScrollOffset(); CScroller::GetScrollPos() 02046 02047 **********************************************************************************************/ 02048 02049 void ScreenView::GetScrollOffset(WorkCoord* pOffset) const 02050 { 02051 FIXED16 PixelWidth,PixelHeight; 02052 pDocView->GetPixelSize(&PixelWidth,&PixelHeight); 02053 02054 // TRACE( _T("SV::GetScrollOffset\n")); 02055 // TRACE( _T("CanvasPos = (%d, %d)\n"), GetCanvas()->GetScrollPos(wxHORIZONTAL), GetCanvas()->GetScrollPos(wxVERTICAL)); 02056 02057 pOffset->x = XLONG(WorkArea.lo.x+GetCanvas()->GetScrollPos(wxHORIZONTAL)*PixelWidth .MakeDouble()); 02058 pOffset->y = XLONG(WorkArea.hi.y-GetCanvas()->GetScrollPos(wxVERTICAL )*PixelHeight.MakeDouble()); 02059 02060 // TRACE( _T("ScrollOffset = (%d, %d)\n"), (INT32)(pOffset->x), (INT32)(pOffset->y)); 02061 } 02062 02063 02064 02065 /********************************************************************************************* 02066 > void ScreenView::SetScrollOffset(const WorkCoord& pos, BOOL redraw) 02067 02068 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 02069 Created: ages ago 02070 Inputs: The desired scroll offset, in WorkCoords, and a boolean indicating if 02071 TRUE that the view window should be repainted immediately to reflect 02072 the change in scroll position. 02073 Outputs: - 02074 Returns: - 02075 Purpose: Changes the scroll offset in the horizontal and vertical scroll bar. Note 02076 that it DOES NOT immediately scroll the client area, which is only done 02077 when the scroll bars send back a WM_SCROLLEREVENT message to the ScreenView. 02078 Errors: - 02079 Scope: Public 02080 SeeAlso: ScreenView::GetScrollOffset; CScroller::SetScrollPos(); 02081 ScreenView::OnScrollerEvent() 02082 02083 **********************************************************************************************/ 02084 02085 void ScreenView::SetScrollOffset(const WorkCoord& pos, BOOL redraw) 02086 { 02087 // TRACE( _T("SV::SetScrollOffset(%d, %d)\n"), (INT32)(pos.x), (INT32)(pos.y)); 02088 FIXED16 PixelWidth,PixelHeight; 02089 pDocView->GetPixelSize(&PixelWidth,&PixelHeight); 02090 02091 // INT32 sx = INT32((pos.x-WorkArea.lo.x)/PixelWidth .MakeDouble()); 02092 // INT32 sy = INT32((WorkArea.hi.y-pos.y)/PixelHeight.MakeDouble()); 02093 // TRACE( _T("Scrolling to (%d, %d)\n"), sx, sy); 02094 02095 GetCanvas()->Scroll( 02096 INT32((pos.x-WorkArea.lo.x)/PixelWidth .MakeDouble()), 02097 INT32((WorkArea.hi.y-pos.y)/PixelHeight.MakeDouble()) 02098 ); 02099 02100 // Neville 22/8/97 02101 // Somebody is setting the scroll position so make sure that this is set 02102 // Other calls to OnScrollerEvent can be filtered out completely so that a document 02103 // can load in completely but not had one single call to ScrollTo code allowed. Everything 02104 // looks ok but if you scroll slightly then becuase the OldOffset is wrong, usually 0,0, 02105 // a large redraw problem can occur OR the whole drawing will be redrawn needlessly. 02106 // This is called by the document loading code and so when it says it wants this scroll position 02107 // it is generally late enough in the loading process that the 'Fixes bug #1448.' comment 02108 // should have been sorted. 02109 fSetupDone = TRUE; 02110 } 02111 02112 02113 02114 /********************************************************************************************* 02115 > afx_msg LRESULT ScreenView::OnScrollerEvent(WPARAM redraw, LPARAM) 02116 02117 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 02118 Created: ages ago 02119 Inputs: A boolean, cast to a WPARAM, which indicates whether ScreenView should update 02120 the client area in response to this message. The LPARAM is not used. 02121 Outputs: - 02122 Returns: Returns 0, indicating to Windows that the message has been processed 02123 successfully. 02124 Purpose: This message is sent by the scroll bars in response to an earlier call to 02125 ScreenView::SetScrollOffset(). The scroll offset is read from the scroll bars 02126 and the ScrollPosition field of the ViewState is updated accordingly. If 02127 the WPARAM parameter is TRUE then the client area is repainted via a call 02128 to ScreenView::ScrollTo(). 02129 Errors: - 02130 Scope: Protected 02131 SeeAlso: ScreenView::SetScrollOffset(); ScreenView::ScrollTo(); CScroller::MoveThumb() 02132 02133 **********************************************************************************************/ 02134 02135 PORTNOTE("other","Removed ScreenView::OnScrollerEvent") 02136 #ifndef EXCLUDE_FROM_XARALX 02137 LRESULT ScreenView::OnScrollerEvent(WPARAM redraw, LPARAM barptr) 02138 { 02139 SetCurrentStates(); 02140 if (Status && fSetupDone) 02141 { 02142 WorkCoord temp; 02143 GetScrollOffset(&temp); 02144 Status->SetScrollPos(temp); 02145 if (redraw) ScrollTo( Status->GetScrollPos() ); 02146 } 02147 return 0; 02148 } 02149 #endif 02150 02151 /********************************************************************************************* 02152 > afx_msg LRESULT ScreenView::OnJoystickMove(WPARAM buttons, LPARAM pos) 02153 02154 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 02155 Created: 22/6/94 02156 Inputs: The Joystick position and button states 02157 Outputs: - 02158 Returns: Returns 0, indicating to Windows that the message has been processed 02159 successfully. 02160 Purpose: This function is called whenever the joystick moves. 02161 It is used currently to set the Pretend Pen Pressure from the joystick 02162 position. 02163 This function only exists under Win32. 02164 Errors: - 02165 Scope: Protected 02166 SeeAlso: ScreenView::OnKeyDown() 02167 02168 **********************************************************************************************/ 02169 02170 PORTNOTE("other","Removed ScreenView::OnJoystickMove") 02171 #ifndef EXCLUDE_FROM_XARALX 02172 #ifdef WIN32 02173 LRESULT ScreenView::OnJoystickMove(WPARAM buttons, LPARAM pos) 02174 { 02175 SetCurrentStates(); 02176 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 02177 // WEBSTER - markn 25/4/97 02178 // No pen stuff required in Webster 02179 // Taken out by vector stroking code Neville 2/10/97 02180 #ifdef VECTOR_STROKING 02181 (Camelot.GetPressurePen())->SetPressureFromJoystick(buttons, pos); 02182 #endif // VECTOR_STROKING 02183 #endif 02184 02185 return 0; 02186 } 02187 #endif 02188 #endif 02189 02190 02192 // Mouse dragging and tool operation functions. 02193 02194 // This user preference controls how many pixels the mouse must move before a 02195 // drag is initiated. 02196 INT32 ScreenView::DragLatency = 3; 02197 02198 // Used to start drags after user has clicked but not moved mouse for n milliseconds. 02199 INT32 ScreenView::DragDelay = 500; 02200 MonotonicTime ScreenView::DragTimer; 02201 02202 02203 02204 /********************************************************************************************* 02205 > afx_msg BOOL ScreenView::OnSetCursor(wxWindow* pWnd, UINT32 nHitTest, UINT32 nMessage) 02206 02207 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 02208 Created: 14 Oct 93 02209 Inputs: "pWnd" points to the window that contains the cursor; 02210 "nHitTest" contains a code indicating the part of the window the cursor is over; 02211 "nMessage" contains the mouse-message numeric identifier (WM_LBUTTONDOWN etc). 02212 Returns: TRUE, ie. the cursor has been set, and no further processing is necessary. 02213 FALSE if the cursor has not been set, e.g. this view is not active. 02214 Purpose: Calls the kernel DocView object to set the cursor for this ScreenView. 02215 Scope: Protected 02216 SeeAlso: DocView::OnSetCursor 02217 02218 **********************************************************************************************/ 02219 02220 PORTNOTE("other","Removed ScreenView::OnSetCursor") 02221 #ifndef EXCLUDE_FROM_XARALX 02222 BOOL ScreenView::OnSetCursor(wxWindow* pWnd, UINT32 nHitTest, UINT32 nMessage) 02223 { 02224 // Child windows assume responsibility for setting their own cursor. 02225 if (pWnd == GetCanvas()) 02226 { 02227 // Get the kernel to do the business for the view display .... 02228 ENSURE(pDocView != 0, "No link to kernel DocView in ScreenView::OnSetCursor!\n"); 02229 02230 SetCurrentStates(); 02231 pDocView->OnSetCursor(); 02232 return TRUE; 02233 } 02234 else if (pWnd == Corner) 02235 return Corner->OnSetCursor(Corner, nHitTest, nMessage); 02236 02237 return FALSE; 02238 } 02239 #endif 02240 02241 /********************************************************************************************* 02242 > static void ScreenView::GetClickMods(wxMouseEvent &event, ClickModifiers* p) 02243 02244 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 02245 Created: ages ago 02246 Inputs: The mouse event passed by wx to a mouse message-handler function. 02247 Outputs: Changes the ClickModifier to reflect the button flags. 02248 Returns: - 02249 Purpose: Helps convert an OIL-layer mouse event into a form acceptable to the kernel. 02250 Sets the fields of the ClickModifier according to which button is down/up, 02251 whether the SHIFT, CONTROL, or ALT key is held down etc. Note that as the 02252 fields of a ClickModifier are only one bit wide, we must be carefule when 02253 assigning the (integer) results of logical tests to them. 02254 Errors: - 02255 Scope: Public 02256 SeeAlso: ScreenView::HandleDragEvent() 02257 **********************************************************************************************/ 02258 02259 void ScreenView::GetClickMods(wxMouseEvent &event, ClickModifiers* p) 02260 { 02261 *p = ClickModifiers::GetClickModifiers(event); 02262 } 02263 02264 02265 02266 02267 /******************************************************************************************** 02268 > void ScreenView::HandleDragEvent(UINT32 Button, wxMouseEvent event, ClickType t) const 02269 02270 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 02271 Created: ages ago 02272 Inputs: Button - the actual button being pressed for a click/double click event. 02273 nFlags - The mouse button flags 02274 point - the coordinate of the mouse cursor 02275 t - the kind of mouse event (button up/down, move, drag start/finish etc.) 02276 Outputs: - 02277 Returns: - 02278 Purpose: Gathers together Windows information about a mouse event and passes it on to 02279 the kernel, by calling DocView::OnClick() 02280 Errors: - 02281 Scope: Private 02282 SeeAlso: ScreenView::GetClickMods(); ScreenView::OnLButtonDown(); ScreenView::OnRButtonDown() 02283 DocView::OnClick() 02284 02285 ********************************************************************************************/ 02286 02287 /******************************************************************************************** 02288 02289 Technical notes (by Tim): 02290 02291 The Button is parameter is necessary, because sometimes when we get the *first* button 02292 down event, nFlags has more than one mouse button bit set. This only happens when you 02293 rampantly click buttons very quickly but nevertheless we *do* need to know which button 02294 was pressed, otherwise we never release the drag event and we end up with button-up-drag 02295 city. 02296 02297 I assume this is due to some latency in Windows, e.g., it gets a button down event, and 02298 while preparing it goes and reads the mouse button state and meanwhile another button has 02299 been pressed so we get a button down event with nFlags indicating more than one button 02300 is down. 02301 02302 ********************************************************************************************/ 02303 02304 void ScreenView::HandleDragEvent(UINT32 Button, wxMouseEvent &event, ClickType t) 02305 { 02306 if (DocView::GetSelected() != pDocView) 02307 { 02308 // TRACEUSER( "JustinF", _T("Ignored drag-event cos not in the selected view\n")); 02309 // If selected doc is null, let's select it anyway. 02310 if (DocView::GetSelected() == NULL) 02311 { 02312 // We're in a weird state that should never happen but does - a document 02313 // has the focus, but isn't selected 02314 Document* pKDoc =NULL; 02315 if(pDocView) 02316 pKDoc = pDocView->GetDoc(); 02317 02318 if (pKDoc) 02319 { 02320 Document::SetSelectedViewAndSpread(pKDoc, pDocView, NULL); 02321 } 02322 02323 } 02324 return; 02325 } 02326 02327 SetCurrentStates(); 02328 02329 // Find out which buttons etc are down. 02330 GetClickMods(event, &LastClickMods); 02331 02332 // If it's the first single click, then reset the drag delay timer, and ask for a 02333 // Windows timer. 02334 if (((t == CLICKTYPE_SINGLE) || (t == CLICKTYPE_DOUBLE)) && 02335 (FirstClickButton == 0)) 02336 { 02337 // Remember this event. 02338 LastClickPoint = event.GetPosition(); 02339 LastClickType = t; 02340 LastClickButton = Button; 02341 FirstClickButton = Button; 02342 DragTimer.Sample(); 02343 02344 #if (_OLE_VER >= 0x200) 02345 // The user's doing something so don't update any container docs 02346 CCamDoc::ResetContainerUpdateTimer(); 02347 #endif 02348 02349 PORTNOTE("other","Removed FixSetTimer usage") 02350 #ifndef EXCLUDE_FROM_XARALX 02351 // Ask the system for a timer. Fails (returns FALSE) if there isn't one available. 02352 // The timer is used to generate DragPointerIdle events, which are not directly 02353 // supported by Windows. 02354 UINT32 rate; 02355 ::SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &rate, 0); 02356 if (!::FixSetTimer(m_hWnd, 1, rate, 0)) 02357 { 02358 ENSURE(FALSE, "Cannot get a timer in ScreenView::StartDrag()!\n"); 02359 } 02360 #endif 02361 } 02362 02363 if (DragOpInvoke) 02364 { 02365 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(DragOpToken); 02366 02367 ERROR3IF_PF(pOpDesc == NULL,("FindOpDescriptor(%s) failed",(TCHAR*)DragOpToken)); 02368 02369 if (pOpDesc != NULL) 02370 pOpDesc->Invoke(pDragOpParam); 02371 02372 // Reset the vars ready for the next call to InvokeDragOp() 02373 DragOpInvoke = FALSE; 02374 pDragOpParam = NULL; 02375 } 02376 else 02377 { 02378 // Convert the click position to OIL coordinates before passing to the kernel. 02379 // pDocView->SetCurrent(); 02380 WinCoord point; 02381 event.GetPosition( &point.x, &point.y ); 02382 pDocView->OnClick( ( (WinCoord *)&point )->ToOil(pDocView, TRUE), t, LastClickMods); 02383 } 02384 } 02385 02386 02387 02388 /******************************************************************************************** 02389 > BOOL ScreenView::HandleMouseWheelEvent(UINT32 nFlags, short zDelta, wxPoint pt) 02390 Author: Priestley (Xara Group Ltd) <camelotdev@xara.com> 02391 Created: 25/10/2000 02392 Purpose: Handle MouseWheel for Scroll document and Zoom operations 02393 Also dispatches a message to the Gallery the mouse is over, if any... 02394 Inputs: nFlags - The mouse flags 02395 zDelta - movement of the mousewheel 02396 pt - the coordinate of the mouse cursor 02397 ********************************************************************************************/ 02398 02399 BOOL ScreenView::HandleMouseWheelEvent( wxMouseEvent &event ) 02400 { 02401 // Reasons Why This Is Done As It Is... 02402 // ************************************ 02403 // 02404 // The WM_MOUSEWHEEL message is only ever sent to the window with focus. Galleries 02405 // never have the focus, even though they show they have (their windows are highlighted) 02406 // as this is done using rendering onto a blank window (as is their grey-ing out) 02407 // As a result of this, a Gallery is never sent a WM_MOUSEWHEEL message. 02408 // We therefore need to trap the message (here is as good a place as any) and check if the 02409 // user was actually over a gallery... 02410 // Finding out if they are over a Gallery SHOULD have been quite easy (eg WindowFromPoint()) 02411 // EXCEPT that we don't create the Galleries in any sensible manner, thus they aren't 02412 // children of the current window - they are children of the Program Manager - sensible... 02413 // So, when we ask for the appropriate HWND it returns a nonsense value... Anyhow, the 02414 // following code gets around this and gives us the real HWND of the Gallery underneath the 02415 // mouse, OR returns NULL if no bar was found. 02416 // In the case where we get the Gallery HWND, we dispatch a message to scroll up/down according 02417 // to mousewheel delta. In the case where we have no HWND we check if the mouse lies within the 02418 // currently selected view and if it does, then scroll appropriately. 02419 // If anyone can see an easier way, then let me know!!! 02420 // Matt 1/11/00 02421 02422 PORTNOTETRACE("other","ScreenView::HandleMouseWheelEvent - do nothing"); 02423 #ifndef EXCLUDE_FROM_XARALX 02424 // We need to know if the mouse pointer is over a Gallery, and if it is what the 02425 // HWND of that Gallery is, so that I can send it a scroll message... 02426 HWND OverBar = GetMainFrame()->IsScreenPointInBar(pt); 02427 02428 if (OverBar) 02429 { 02430 if (zDelta < 0) 02431 { 02432 BROADCAST_TO_CLASS(DialogMsg(OverBar, DIM_MOUSEWHEEL_DOWN, 256), DialogOp); 02433 } 02434 else 02435 { 02436 BROADCAST_TO_CLASS(DialogMsg(OverBar, DIM_MOUSEWHEEL_UP, 256), DialogOp); 02437 } 02438 } 02439 else 02440 { 02441 //Preliminary Checks... 02442 if (DocView::GetSelected() != pDocView) 02443 { 02444 // If selected doc is null, let's select it anyway. 02445 if (DocView::GetSelected() == NULL) 02446 { 02447 // We're in a weird state that should never happen but does - a document 02448 // has the focus, but isn't selected 02449 Document* pKDoc =NULL; 02450 if(pDocView) 02451 { 02452 pKDoc = pDocView->GetDoc(); 02453 } 02454 02455 if (pKDoc) 02456 { 02457 Document::SetSelectedViewAndSpread(pKDoc, pDocView, NULL); 02458 } 02459 02460 } 02461 return FALSE; 02462 } 02463 02464 SetCurrentStates(); 02465 02466 // We now need to work out if the Mouse is currently over part of the document - if it isn't 02467 // then we should ignore the message and let something else handle it... 02468 Spread* pSpread = Document::GetSelectedSpread(); 02469 if (pSpread == NULL) { return FALSE; } 02470 02471 DocCoord MousePos; 02472 if(!DocView::GetCurrentMousePos(&pSpread, &MousePos)) 02473 { 02474 return FALSE; 02475 } 02476 02477 02478 #if (_OLE_VER >= 0x200) 02479 // The user's doing something so don't update any container docs 02480 CCamDoc::ResetContainerUpdateTimer(); 02481 #endif 02482 02483 //If the user is holding down CTRL whilst scrolling the wheel, then we should do the standard zoom-in/out 02484 if (nFlags & MK_CONTROL) 02485 { 02486 // TRACEUSER( "Matt", _T("MouseWheel + CTRL = Zoom, in ScreenView\n")); 02487 02488 // Try to create an instance of the zoom operation. 02489 OpZoom* pZoomOp = new OpZoom; 02490 if (pZoomOp == NULL) 02491 { 02492 // We ran out of memory, so sorry. 02493 InformError(_R(IDE_NOMORE_MEMORY)); 02494 return FALSE; 02495 } 02496 02497 DocCoord DocMouse = MousePos.ToDoc(pSpread, pDocView); 02498 WorkCoord WorkMouse; 02499 WorkMouse = DocMouse.ToWork(pSpread, pDocView); 02500 02501 02502 // Get the current view's scaling factor as a rounded precentage. 02503 INT32 nOldScalePercent = ((pDocView->GetViewScale() * 100) + FIXED16_DBL(0.5)).MakeInt(); 02504 02505 02506 // Zoom in or out around the mouse position... 02507 if (zDelta > 0) 02508 { 02509 // Search backwards until we find a higher zoom, or the end of the table 02510 for (INT32 i = cZoomTableSize - 1; i >= 0; i--) 02511 { 02512 // Found a higher zoom? If so, set it, remember it's position and return. 02513 if (nOldScalePercent < pZoomOp->GetPresetZoomPercent(i)) 02514 { 02515 // Do the zoom. We will (optionally) end the operation. 02516 pDocView->SetZoomTableIndex(i); 02517 // pZoomOp->ZoomAtPoint(WorkMouse, pZoomOp->GetPresetZoomScale(i), FALSE); 02518 pZoomOp->MouseWheelZoomAtPoint(WorkMouse, pZoomOp->GetPresetZoomScale(i), FALSE); 02519 break; 02520 } 02521 } 02522 02523 // pZoomOp->ZoomIn(WorkMouse); 02524 } 02525 else 02526 { 02527 // Search forwards through the zoom table until we find a lower zoom factor 02528 for (INT32 i = 0; i < cZoomTableSize; i++) 02529 { 02530 // Found a lower zoom? If so, set it, remember it's position in the zoom table 02531 if (nOldScalePercent > pZoomOp->GetPresetZoomPercent(i)) 02532 { 02533 // Do the zoom. We will (optionally) end the operation. 02534 pDocView->SetZoomTableIndex(i); 02535 // pZoomOp->ZoomAtPoint(WorkMouse, pZoomOp->GetPresetZoomScale(i), FALSE); 02536 pZoomOp->MouseWheelZoomAtPoint(WorkMouse, pZoomOp->GetPresetZoomScale(i), FALSE); 02537 break; 02538 } 02539 } 02540 02541 // pZoomOp->ZoomOut(WorkMouse); 02542 } 02543 02544 // Tidy away... 02545 delete pZoomOp; 02546 02547 return TRUE; 02548 } 02549 else 02550 { 02551 // The CTRL key was not pressed, so we should simply (is anything simple around here) 02552 // scroll the viewport up/down. (OR left/right if SHIFT is held down - Matt 16/11/2000) 02553 // TRACEUSER( "Matt", _T("MouseWheel = Scroll, in ScreenView\n")); 02554 02555 if (nFlags & MK_SHIFT) 02556 { 02557 // If HScrollBar doesn't exist at this point then something's not quite right... 02558 if(!HScrollBar) { return FALSE; } 02559 02560 // Get the current Horizontal Scroll Position, increment it by a zoom-dependent amount 02561 // and set the Horizontal Scroll Position to be this value, flagging it to redraw... 02562 XLONG horizpos; 02563 HScrollBar->GetScrollPos(&horizpos); 02564 horizpos -= (XLONG)((zDelta/120) * 750 * 15); 02565 HScrollBar->SetScrollPos(horizpos, true); 02566 } 02567 else 02568 { 02569 // If VScrollBar doesn't exist at this point then something's not quite right... 02570 if(!VScrollBar) { return FALSE; } 02571 02572 // Get the current Vertical Scroll Position, increment it by a zoom-dependent amount 02573 // and set the Vertical Scroll Position to be this value, flagging it to redraw... 02574 XLONG vertpos; 02575 VScrollBar->GetScrollPos(&vertpos); 02576 vertpos -= (XLONG)((zDelta/120) * 750 * 15); 02577 VScrollBar->SetScrollPos(vertpos, true); 02578 } 02579 02580 // NOTE : If we wanted to be really flash, we could make the scroll distance affected by the 02581 // user's settings in the Control Panel - ie, default is to scroll 3 lines on 120 zDelta, but 02582 // can be adjusted so we could look at that value... 02583 } 02584 // tell everyone we've changed the screen 02585 BROADCAST_TO_ALL(ScreenChangeMsg()); 02586 } 02587 #endif 02588 // If we get to here, then we must have handled the MouseWheel, so return true... 02589 return TRUE; 02590 } 02591 02592 02593 02594 /********************************************************************************************* 02595 > void ScreenView::HandleButtonUp(UINT32 nFlags, wxPoint point) 02596 02597 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 02598 Created: 9th Sept 1993 02599 Inputs: Button - which mouse button has been released. 02600 nFlags - The mouse button flags. 02601 point - the coordinate of the mouse cursor. 02602 Outputs: - 02603 Returns: - 02604 Purpose: Finishes the current drag, if there is one, by elucidating the state of 02605 the buttons etc and calling DragDFinished() in the kernel (DocView). Called 02606 whenever a mouse button is released. 02607 Errors: - 02608 Scope: Private 02609 SeeAlso: ScreenView::GetClickMods(); ScreenView::OnLButtonDown(); ScreenView::OnRButtonDown() 02610 DocView::OnClick() 02611 02612 **********************************************************************************************/ 02613 02614 void ScreenView::HandleButtonUp(UINT32 Button, wxMouseEvent &event) 02615 { 02616 //Graham 18/6/96: Changed the logical conditions of this function 02617 //to support clicks with one mouse button while another button is 02618 //dragging 02619 02620 if (DocView::GetSelected() != pDocView) 02621 { 02622 ENSURE(pCurrentDragOp == NULL, "Drag operation in a view that isn't 'selected' !!"); 02623 // TRACEUSER( "JustinF", _T("Ignored button-up cos not in the selected view\n")); 02624 return; 02625 } 02626 02627 // Set Current states... 02628 SetCurrentStates(); 02629 02630 //Graham: Here's the change - in the logical conditions only. The actual 02631 //functions called are the same. 02632 02633 WinCoord point; 02634 event.GetPosition( &point.x, &point.y ); 02635 02636 //Was the button that went up the first one that went down? 02637 if (Button==FirstClickButton) 02638 { 02639 //Yes it was. 02640 //Is there a drag currently running? 02641 if (pCurrentDragOp != NULL) 02642 { 02643 // Yes there is. 02644 // Release the capture and terminate the drag. Note that we try to release 02645 // the mouse capture as soon as possible after a drag has finished, in case the 02646 // DragFinished method below brings up a dialog box or something. 02647 if (m_pCanvas && m_pCanvas->GetCapture()==m_pCanvas) 02648 m_pCanvas->ReleaseMouse(); 02649 pDocView->DragFinished(pCurrentDragOp, ((WinCoord*) &point)->ToOil(pDocView, TRUE), 02650 LastClickMods, TRUE); 02651 02652 02653 // Now cater for the special case that the user used the PushCentreTool Click Modifier 02654 // and they didn't move the mouse - this means they either wanted to Centre the 02655 // view about the cursor, ZoomIn() or ZoomOut() depending on the modifiers.... 02656 if ((LastClickPoint == CurrentMousePos) && LastClickMods.PushCentreTool) 02657 { 02658 // Did we want to ZoomIn()? 02659 if( event.ControlDown() ) 02660 { 02661 OpZoom* pZoomOp = new OpZoom; 02662 ERROR3IF(!pZoomOp,"Couldn't create pZoomOp"); 02663 02664 // Find the mid-point of the view, in work coordinates... 02665 WorkRect wrView = pDocView->GetViewRect(); 02666 WorkCoord wcMidView((wrView.lo.x + wrView.hi.x) / 2, (wrView.lo.y + wrView.hi.y) / 2); 02667 02668 pZoomOp->ZoomIn(wcMidView); 02669 } 02670 // Did we want to ZoomOut()? 02671 else if( event.ShiftDown() ) 02672 { 02673 OpZoom* pZoomOp = new OpZoom; 02674 ERROR3IF(!pZoomOp,"Couldn't create pZoomOp"); 02675 02676 // Find the mid-point of the view, in work coordinates... 02677 WorkRect wrView = pDocView->GetViewRect(); 02678 WorkCoord wcMidView((wrView.lo.x + wrView.hi.x) / 2, (wrView.lo.y + wrView.hi.y) / 2); 02679 02680 pZoomOp->ZoomOut(wcMidView); 02681 } 02682 else 02683 { 02684 // Then we must have wanted to centre the screen about the cursor... 02685 02686 DocCoord MousePos; 02687 Spread *pSpread = Document::GetSelectedSpread(); 02688 if(!DocView::GetCurrentMousePos(&pSpread, &MousePos)) 02689 { 02690 return; 02691 } 02692 02693 02694 WorkCoord testwork(MousePos.ToWork(pSpread, pDocView)); 02695 02696 02697 // Find out where the middle of the current view is... 02698 DocRect ViewRect = (pDocView->GetDocViewRect(pSpread)).ToSpread(pSpread, pDocView); 02699 DocCoord ViewMidPoint(0,0); 02700 ViewMidPoint.x = INT32(ViewRect.lo.x + (ViewRect.hi.x - ViewRect.lo.x)/2.0); 02701 ViewMidPoint.y = INT32(ViewRect.lo.y - (ViewRect.lo.y - ViewRect.hi.y)/2.0); 02702 02703 // Work out what the offset between the centre of the screen and the MousePos is... 02704 DocCoord Offset = MousePos - ViewMidPoint; 02705 02706 WorkCoord ScrollOffset; 02707 WorkCoord WorkOffset; 02708 02709 WorkOffset.x = (XLONG) (MakeXLong(Offset.x) * pDocView->GetViewScale()); 02710 WorkOffset.y = (XLONG) (MakeXLong(Offset.y) * pDocView->GetViewScale()); 02711 02712 ScrollOffset = pDocView->GetScrollOffsets(); 02713 ScrollOffset.x = ScrollOffset.x + WorkOffset.x; 02714 ScrollOffset.y = ScrollOffset.y + WorkOffset.y; 02715 02716 if (ScrollOffset.x < (XLONG) 0) ScrollOffset.x = (XLONG) 0; 02717 if (ScrollOffset.y > (XLONG) 0) ScrollOffset.y = (XLONG) 0; 02718 02719 // Scroll the screen to centre about the cursor! 02720 pDocView->SetScrollOffsets(ScrollOffset, TRUE); 02721 } 02722 } 02723 } 02724 else 02725 { 02726 // No there isn't. 02727 // Kill the timer started in HandleDragEvent(), 02728 // as we don't want to wait for a drag anymore. 02729 PORTNOTE("other","Removed FixKillTimer usage") 02730 #ifndef EXCLUDE_FROM_XARALX 02731 ::FixKillTimer(m_hWnd, 1); 02732 #endif 02733 FirstClickButton = 0; 02734 02735 //Then pass the Up-Click message to ScreenView::OnClick 02736 pDocView->OnClick(((WinCoord*) &point)->ToOil(pDocView, TRUE), CLICKTYPE_UP, LastClickMods); 02737 } 02738 } 02739 else 02740 { 02741 //No, the button that went up was not the first one to go down. 02742 //In that case, we expect the first button that went down is still down and 02743 //hence there is a drag running. 02744 //Is there a drag running? 02745 if (pCurrentDragOp != NULL) 02746 { 02747 //Yes, as expected. 02748 //Pass the Up-Click message to ScreenView::OnClick 02749 pDocView->OnClick(((WinCoord*) &point)->ToOil(pDocView, TRUE), CLICKTYPE_UP, LastClickMods); 02750 } 02751 //If not, something odd has happened - perhaps the user has clicked fast 02752 //with the mouse. This need not worry us but we should not do anything 02753 //with the up-click message. 02754 //The only problem that could occur is if we are in a button-up-drag. This 02755 //is handled below. 02756 02757 } 02758 02759 //Ensure there is not a button-up drag in progress 02760 //That is, there is a drag in progress AND no buttons down 02761 // ERROR3IF((Operation::GetCurrentDragOp()==NULL)&&(nFlags & ~(MK_SHIFT | MK_CONTROL) == 0), 02762 // "ScreenView::HandleButtonUp - drag operation in progress but no buttons down"); 02763 } 02764 02765 // The following is Justin's original logical conditions, commented out, in case 02766 // anyone needs them or if the above doesn't work 02767 /* // Are we in a real mess, Mr User? 02768 if (Button != FirstClickButton) 02769 { 02770 // TRACEUSER( "JustinF", _T("Ignored button-up cos different button went down\n")); 02771 return; 02772 } 02773 02774 02775 02776 // Are we currently running a drag operation. 02777 if (pCurrentDragOp != NULL) 02778 { 02779 // Yes, so release the capture and terminate the drag. Note that we try to release 02780 // the mouse capture as soon as possible after a drag has finished, in case the 02781 // DragFinished method below brings up a dialog box or something. 02782 ::ReleaseCapture(); 02783 pDocView->DragFinished(pCurrentDragOp, ((WinCoord*) &point)->ToOil(pDocView, TRUE), 02784 LastClickMods, TRUE); 02785 } 02786 else 02787 { 02788 // No. Is this the button that was pressed first? If so, kill the timer started in 02789 // HandleDragEvent(), as we don't want to wait for a drag anymore. 02790 if (Button == FirstClickButton) 02791 { 02792 ::FixKillTimer(m_hWnd, 1); 02793 FirstClickButton = 0; 02794 } 02795 else 02796 { 02797 // NB. the test above should prevent this ENSURE going off . . . 02798 ENSURE((nFlags & ~(MK_SHIFT | MK_CONTROL)) == 0, 02799 "No buttons down - Welcome to Button-Up-Drag City!"); 02800 } 02801 02802 // Send a button-up event if we weren't running a drag. 02803 pDocView->OnClick(((WinCoord*) &point)->ToOil(pDocView, TRUE), CLICKTYPE_UP, LastClickMods); 02804 02805 }*/ 02806 02807 02808 02809 /********************************************************************************************* 02810 > BOOL ScreenView::InvokeDragOp(String_256 OpToken,UINT32 Flags,wxPoint point,OpParam* pParam) 02811 02812 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 02813 Created: 21/9/95 02814 Inputs: OpToken = Op token of op to invoke 02815 pParam = ptr to a param block that's passed to the op 02816 NOTE! Object at *pParam must have a long life time. I.e. do NOT 02817 call this func with ptr to a local OpParam var 02818 Flags = flags that specify which modifiers were down during the click 02819 point = screen coord of the start of the drag 02820 Outputs: - 02821 Returns: Returns TRUE if successful. Returns FALSE if not 02822 Purpose: This func provides a mechanism that allows a drag op to be invoked as if it has been started 02823 as a result of clicking in the view. This allows drag ops to be invoked that aren't 02824 associated to a given tool. 02825 02826 This allows a drag op to be started directly, instead of being a result of a tool handling 02827 the click. This allows you to write drag ops in the usual way. 02828 02829 If pParam is NULL, the op's Do() function will be called. If pParam != NULL, the op's 02830 DoWithParam(pParam) func will be called. Either way, Operation::StartDrag() should be 02831 called as a result. 02832 02833 It was introduced to allow the rulers to create guidelines undoably, no matter what 02834 tool you are in. See winoil\oilruler.cpp & kernel\guides.cpp & OpGuideLine 02835 02836 Errors: - 02837 Scope: - 02838 SeeAlso: - 02839 02840 **********************************************************************************************/ 02841 /* Implementation notes: 02842 02843 It does this: 02844 Posts itself a WM_LBUTTONDOWN message with the flags and point provided 02845 02846 and in HandleDragEvent() 02847 Creates an instance of the op specified by OpToken 02848 Calls the DragStart() virt func, that should call Operation::StartDrag() at some point 02849 */ 02850 02851 BOOL ScreenView::InvokeDragOp(String_256* pOpToken,OpParam* pParam,UINT32 Flags,wxPoint point) 02852 { 02853 PORTNOTETRACE("other","ScreenView::InvokeDragOp - do nothing"); 02854 #ifndef EXCLUDE_FROM_XARALX 02855 DragOpToken = *pOpToken; 02856 pDragOpParam = pParam; 02857 DragOpInvoke = TRUE; 02858 02859 PostMessage(WM_LBUTTONDOWN,Flags,point.x | (point.y << 16)); 02860 #endif 02861 return TRUE; 02862 } 02863 02864 02865 02866 02867 /********************************************************************************************* 02868 > BOOL ScreenView::StartDrag(Operation* pOp, DragType type, BOOL KeepAccuracy) 02869 02870 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 02871 Created: ages ago 02872 Inputs: A pointer to the current (drag) Operation; the type of the drag. 02873 Outputs: - 02874 Returns: Returns TRUE if successful. Returns FALSE if a timer couldn't be allocated. 02875 Purpose: Begins a drag operation, from the point of view of the OIL layer. Unbounds 02876 the mouse cursor, so it can go off-screen (display driver permitting). 02877 Captures all mouse input, to guarantee that the drag being started will 02878 terminate properly at some time in the future. Sets some internal variables 02879 indicating that ScreenView is in "drag mode". Finally, asks the system for a 02880 timer which is used to generate "idle" mouse events. 02881 Errors: ASSERTion failure if the ScreenView is already dragging. 02882 Scope: Public 02883 SeeAlso: ScreenView::EndDrag(); ScreenView::HandleDragEvent(); 02884 02885 **********************************************************************************************/ 02886 02887 BOOL ScreenView::StartDrag(Operation* pOp, DragType type, BOOL KeepAccuracy) 02888 { 02889 ENSURE( pCurrentDragOp == 0, "ScreenView::StartDrag: pCurrentDragOp is not zero"); 02890 02891 // This has been commented out as some screen drivers can not handle the mouse drifting 02892 // off the top of the screen. 02893 // Unbound mouse from the screen and set the current drag operation. Note that under 02894 // Win32 raw mouse coordinates change from being 16-bit INTs to 16-bit SHORTs. 02895 //WinRect unbound(SHRT_MIN / 4, SHRT_MIN / 4, SHRT_MAX / 4, SHRT_MAX / 4); 02896 //::GetClipCursor(&MouseClipRect); 02897 //::ClipCursor(&unbound); 02898 GetCanvas()->CaptureMouse(); 02899 02900 // Remember what kind of drag we are performing. 02901 pCurrentDragOp = pOp; 02902 CurrentDragType = type; 02903 OLERecaptureMouse = FALSE; 02904 DragKeepAccuracy = KeepAccuracy; 02905 AutoScrollExcludeRulers = FALSE; 02906 m_OLELastOutTime.Sample(); 02907 return TRUE; 02908 } 02909 02910 02911 02912 /********************************************************************************************* 02913 > BOOL ScreenView::EndDrag(Operation* pOp) 02914 02915 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 02916 Created: ages ago 02917 Inputs: A pointer to the current drag operation (currently not used). 02918 Outputs: - 02919 Returns: TRUE if the drag is successfully terminated. 02920 Purpose: Finishes a drag operation in the OIL layer. Releases mouse capture and 02921 restores the previous mouse cursor clipping rectangle (generally the screen). 02922 Sets internal variables to indicate that ScreenView is not in "drag mode". 02923 Kills the timer set in StartDrag(). 02924 Errors: ASSERTion failure if ScreenView was not already in "drag mode". 02925 Scope: Public 02926 SeeAlso: ScreenView::StartDrag(); ScreenView::HandleDragEvent() 02927 02928 **********************************************************************************************/ 02929 02930 BOOL ScreenView::EndDrag(Operation*) 02931 { 02932 /* 02933 #ifdef _DEBUG 02934 // Prevent a very nasty recursive ENSURE! 02935 if (!CCamApp::IsDisabled()) 02936 { 02937 ENSURE(pCurrentDragOp != 0, "ScreenView::EndDrag: pCurrentDragOp is zero"); 02938 } 02939 #endif // _DEBUG 02940 */ 02941 // Restore the previous mouse clipping rectangle. Windows will move the 02942 // mouse, if necessary, so that the mouse is within the new clipping 02943 // rectangle (or so the documentation says!) 02944 //::ClipCursor(&MouseClipRect); 02945 pCurrentDragOp = 0; 02946 FirstClickButton = 0; 02947 DragKeepAccuracy = TRUE; 02948 if (m_pCanvas && m_pCanvas->GetCapture() == m_pCanvas) 02949 m_pCanvas->ReleaseMouse(); 02950 02951 // Check status of temporary tool selection - this is because we don't change tool 02952 // mid-drag! (e.g. user holds down Alt to get selector, starts drag, releases Alt, 02953 // then ends drag - we want to restore the original tool). 02954 Tool::EndDrag(); 02955 02956 // Kill the timer started in HandleDragEvent(). 02957 PORTNOTE("other","Removed FixKillTimer usage") 02958 #ifndef EXCLUDE_FROM_XARALX 02959 return ::FixKillTimer(m_hWnd, 1); 02960 #else 02961 return TRUE; 02962 #endif 02963 } 02964 02965 02966 02967 /******************************************************************************************** 02968 02969 > BOOL ScreenView::ChangeDragType(DragType Type) 02970 02971 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 02972 Created: 3/4/95 02973 Inputs: Type - the type of drag to change to 02974 Returns: TRUE 02975 Purpose: Allows someone to change the type of a drag (eg have Auto Scrolling on 02976 in some situations, but not in others). This function is mostly called from 02977 the Kernel (DocView) version of the same function 02978 SeeAlso: DocView::ChangeDragType 02979 02980 ********************************************************************************************/ 02981 02982 BOOL ScreenView::ChangeDragType(DragType Type) 02983 { 02984 // Change the current drag type 02985 CurrentDragType = Type; 02986 m_OLELastOutTime.Sample(); 02987 OLERecaptureMouse = FALSE; 02988 02989 return TRUE; 02990 } 02991 02992 02993 02994 /******************************************************************************************** 02995 02996 > BOOL ScreenView::IsWaitingMouseMove() 02997 02998 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 02999 Created: 23/11/94 03000 Returns: TRUE if there is a mouse move message waiting to be processed 03001 Purpose: There are some things in Camelot that are processed as a result of a mouse 03002 move message (Magnetic snapping to all the objects in the document for 03003 example). If these operations take a long time, there is little point 03004 in carrying on with the calculations if the mouse has already moved away 03005 from the coord being tested (and hence invalidating the findings of the 03006 search). 03007 This function checks to see if there is a mouse move message waiting in 03008 the queue to be processed, so that the callers can abort any processing they 03009 were doing if applicable. 03010 03011 ********************************************************************************************/ 03012 03013 BOOL ScreenView::IsWaitingMouseMove() 03014 { 03015 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 03016 MSG Msg; 03017 // if there is a current drag all messages will be routed to the drag capture 03018 // capture window so there's no point in looking in this queue 03019 if(DragManagerOp::GetCurrentManager()==NULL) 03020 { 03021 while (PeekMessage(&Msg,m_hWnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE)) 03022 { 03023 // Check that this message is meant for this CamView OR it's RenderWindow child 03024 // window because the OS sometimes leaves the RenderWindow handle in the MouseMove 03025 // message (that window was the first to receive the message) 03026 if (m_hWnd==Msg.hwnd || Msg.hwnd==GetCanvas()->m_hWnd) 03027 { 03028 // There is a mouse move message in the queue. 03029 // Have to cast to INT8 so we get correct sign-extension. 03030 wxPoint Point; 03031 Point.x = (INT8) LOWORD(Msg.lParam); 03032 Point.y = (INT8) HIWORD(Msg.lParam); 03033 03034 // See if this mouse move message is different from the last one 03035 if (Point!=CurrentMousePos) 03036 return TRUE; 03037 03038 // Sadly, it was the same as the last one 03039 // so remove it from the queue as this should not happen 03040 PeekMessage(&Msg, m_hWnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE); 03041 } 03042 else 03043 { 03044 // Peek message bug. Gave me a message for someone elses window 03045 // Have to return something, so we will assume that there was not 03046 // a message in the queue. 03047 return FALSE; 03048 } 03049 } 03050 } 03051 else // there is a current drag 03052 { 03053 if(DragManagerOp::GetDragCaptureWnd()!=NULL){ 03054 while (PeekMessage(&Msg,DragManagerOp::GetDragCaptureWnd()->m_hWnd,WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE)) 03055 { 03056 // Check that this message is meant for this CamView OR it's RenderWindow child 03057 // window because the OS sometimes leaves the RenderWindow handle in the MouseMove 03058 // message (that window was the first to receive the message) 03059 if (Msg.hwnd==DragManagerOp::GetDragCaptureWnd()->m_hWnd) 03060 { 03061 // There is a mouse move message in the queue. 03062 // Have to cast to INT8 so we get correct sign-extension. 03063 wxPoint Point; 03064 Point.x = (INT8) LOWORD(Msg.lParam); 03065 Point.y = (INT8) HIWORD(Msg.lParam); 03066 03067 // See if this mouse move message is different from the last one 03068 if (Point!=CurrentMousePos) 03069 return TRUE; 03070 03071 // Sadly, it was the same as the last one 03072 // so remove it from the queue as this should not happen 03073 PeekMessage(&Msg, m_hWnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE); 03074 } 03075 else 03076 { 03077 // Peek message bug. Gave me a message for someone elses window 03078 // Have to return something, so we will assume that there was not 03079 // a message in the queue. 03080 return FALSE; 03081 } 03082 } 03083 } 03084 } 03085 #endif 03086 // there were no mouse move messages in the queue 03087 return FALSE; 03088 } 03089 03090 03091 03092 /********************************************************************************************* 03093 > void ScreenView::HandleDragScrolling(wxPoint point) 03094 03095 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 03096 Created: 20th Sept 1993 03097 Inputs: The current position of the mouse cursor. 03098 Outputs: - 03099 Returns: - 03100 Purpose: Checks if the view window needs to be scrolled because the cursor has been 03101 dragged outside the window. The window will be scrolled if the current 03102 mode is AUTO_SCROLL (and the Scroll Lock key isn't latched!!). The scrolling 03103 itself is done by calling the routine in DocView, not ScreenView, so that the 03104 kernel has fair warning to remove any blobbies before the blit is done. 03105 03106 Called when ScreenView receives mouse-move messages and timer ("mouse-idle") 03107 messages. Also handles DEFERRED_SCROLLING. 03108 Errors: - 03109 Scope: Private 03110 SeeAlso: ScreenView::OnMouseMove; ScreenView::OnTimer 03111 03112 **********************************************************************************************/ 03113 03114 void ScreenView::HandleDragScrolling(wxPoint point) 03115 { 03116 // Get the size of the view. We may have to deflate the rectangle a little here, if the 03117 // bottom-right edges of the view coincide with the bottom-right edges of the screen, 03118 // otherwise it is not possible to auto-scroll to the right or down as the mouse never 03119 // leaves the view window. 03120 WinRect wrSize = CurrentSize; 03121 point = GetCanvas()->ClientToScreen( point ); 03122 point = GetFrame()->ScreenToClient( point ); 03123 03124 // WEBSTER - markn 15/1/97 03125 // No rulers in Webster 03126 #ifndef WEBSTER 03127 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 03128 // This is used to allow guidelines to be deleted by dropping on to the rulers - normally 03129 // we would start to auto scroll at this point which is a little off putting.. 03130 if (AutoScrollExcludeRulers && CurrentDragType != DRAGTYPE_OLESCROLL) 03131 { 03132 UINT32 RulerWidth = OILRuler::GetWidth(); 03133 wrSize.left -= RulerWidth; 03134 wrSize.top -= RulerWidth; 03135 } 03136 #endif 03137 #endif // WEBSTER 03138 03139 PORTNOTE("other","Removed special handling for Zoomed and FullScreen") 03140 #ifndef EXCLUDE_FROM_XARALX 03141 CCamFrame* pMainWnd = GetMainFrame(); 03142 if (pMainWnd != NULL && (pMainWnd->InFullScreenMode() || pMainWnd->IsZoomed()) && 03143 CurrentDragType != DRAGTYPE_OLESCROLL) 03144 { 03145 // TRACEUSER( "JustinF", _T("Deflating bounds for special auto-scroll handling\n")); 03146 //const INT32 nMargin = (IsWin32c()) ? 4 : 8; 03147 const INT32 nMargin = (CCamApp::IsNewWindowsUI()) ? 4 : 8; 03148 wrSize.Inflate(-nMargin, -nMargin); 03149 } 03150 #endif 03151 03152 // Initialise Deltas... 03153 INT32 dx = 0; 03154 INT32 dy = 0; 03155 03156 // Depending on the type of the drag... 03157 switch (CurrentDragType) 03158 { 03159 //------------------------- 03160 case DRAGTYPE_NOSCROLL: 03161 break; 03162 03163 //------------------------- 03164 case DRAGTYPE_AUTOSCROLL: 03165 { 03166 // Has the mouse moved outside there bounds? 03167 if (!wrSize.IsEmpty() && !wrSize.Inside(point)) 03168 { 03169 // The mouse is outside the view, and we have to scroll the view 03170 // proportionate to how far outside it is. 03171 CalcScrollDeltas(point,wrSize,&dx,&dy); 03172 } 03173 break; 03174 } 03175 03176 //------------------------- 03177 case DRAGTYPE_OLESCROLL: 03178 { 03179 PORTNOTE("other","Disable DRAGTYPE_OLESCROLL") 03180 #ifndef EXCLUDE_FROM_XARALX 03181 WinRect Outer = wrSize; 03182 03183 // Set auto-scroll region to be one scrollbar width within the current 03184 // view (as per The Windows Interface Guidelines Chapter 5). 03185 INT32 ScrollbarSize = VScrollBar->GetScrollerSize(); 03186 wrSize.Inflate(-ScrollbarSize,-ScrollbarSize); 03187 03188 if (!wrSize.IsEmpty() && !Outer.IsEmpty() 03189 && !wrSize.Inside(point) // Outside allowed scroll rectangle 03190 ) 03191 { 03192 if (Outer.Inside(point)) // and still inside visible window 03193 { 03194 // If we've been in the OLE scroll region for long enough 03195 if (m_OLELastOutTime.Elapsed(100)) 03196 { 03197 // NOTE: According to Windows Interface Guidelines Chapter 5 we should 03198 // Test the "speed" of the mouse here but because we have already 03199 // checked that the mouse has been in the region for longer than 100 03200 // milliseconds it doesn't seem neccessary. (To be within the region 03201 // for longer than 100 milliseconds is sort of a speed test anyway!) 03202 03203 // The mouse is in the scroll region, and we have to scroll the view 03204 // proportionate to how far into the region it is. 03205 CalcScrollDeltas(point,wrSize,&dx,&dy); 03206 } 03207 } 03208 else 03209 { 03210 // We've dragged beyond the OLE scroll area, so we can now convert the drag 03211 // into an OLE export drag if we so desire. 03212 HandleOleDragOutOfView(point); 03213 } 03214 } 03215 else 03216 { 03217 // We're not in the OLE scroll region so reset the timer 03218 m_OLELastOutTime.Sample(); 03219 } 03220 #endif 03221 break; 03222 } 03223 03224 //------------------------- 03225 case DRAGTYPE_DEFERSCROLL: 03226 { 03227 // If the mouse is within the window, and we are performing deferred-scrolling 03228 // then we can change over to auto-scrolling. 03229 if (!wrSize.IsEmpty() && wrSize.Inside(point)) 03230 { 03231 CurrentDragType = DRAGTYPE_AUTOSCROLL; 03232 AutoScrollExcludeRulers = TRUE; 03233 } 03234 break; 03235 } 03236 03237 default: 03238 ERROR3("Shouldn't ever get here!"); 03239 break; 03240 } 03241 03242 //------------------------------------ 03243 // Now do the scroll if necessary... 03244 // If dx<>0 or dy<>0 and scroll lock is disabled 03245 03246 // Test if the SCROLL LOCK key has been set. 03247 if( !wxGetKeyState( CAMKEY(SCROLL) ) && !(dx==0 && dy==0)) 03248 { 03249 // Set Current states... 03250 SetCurrentStates(); 03251 03252 // Convert these pixel values into a WorkCoord offset, add to the 03253 // scroll position and update the scroll bars etc. Note that the 03254 // y offset is subtracted as the y-axis is reversed compared to 03255 // Windows . . . 03256 WorkCoord offset; 03257 GetScrollOffset(&offset); 03258 FIXED16 PixelWidth, PixelHeight; 03259 pDocView->GetPixelSize(&PixelWidth, &PixelHeight); 03260 offset.x += dx * PixelWidth; 03261 offset.y -= dy * PixelHeight; 03262 03263 WorkRect wrScrollRect = GetMaxScrollRect(); 03264 if (offset.x < wrScrollRect.lo.x) offset.x = wrScrollRect.lo.x; 03265 if (offset.y < wrScrollRect.lo.y) offset.y = wrScrollRect.lo.y; 03266 if (offset.x > wrScrollRect.hi.x) offset.x = wrScrollRect.hi.x; 03267 if (offset.y > wrScrollRect.hi.y) offset.y = wrScrollRect.hi.y; 03268 03269 // By calling DocView to do the scroll we give it a chance to remove 03270 // any blobbies it might have put on the screen. Note that the scrollers 03271 // will prevent any overscroll. 03272 pDocView->SetScrollOffsets(offset, TRUE); 03273 } 03274 } 03275 03276 03277 03278 03279 /********************************************************************************************* 03280 > void ScreenView::CalcScrollDeltas(wxPoint point, WinRect wrSize, INT32* dx, INT32* dy) 03281 03282 Author: Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> (from Justin) 03283 Created: 22/9/96 03284 Inputs: point The current position of the mouse cursor. 03285 wrSize The rectangle controlling scrolling. 03286 Outputs: dx The amount to scroll in the X axis. 03287 dy The amount to scroll in the Y axis. 03288 Returns: - 03289 Purpose: Calculates the scroll deltas due to the current mouse position being 03290 outside the allowed rectangle. 03291 Helper function. 03292 Errors: - 03293 Scope: Protected 03294 SeeAlso: ScreenView::HandleDragScrolling 03295 03296 **********************************************************************************************/ 03297 03298 void ScreenView::CalcScrollDeltas(wxPoint point, WinRect wrSize, INT32* dx, INT32* dy) 03299 { 03300 if( point.x < wrSize.GetLeft() ) 03301 *dx = point.x - wrSize.GetLeft(); 03302 else 03303 if( point.x >= wrSize.GetRight() ) 03304 *dx = point.x - wrSize.GetRight(); 03305 else 03306 *dx = 0; 03307 03308 if( point.y < wrSize.GetTop() ) 03309 *dy = point.y - wrSize.GetTop(); 03310 else 03311 if( point.y >= wrSize.GetBottom() ) 03312 *dy = point.y - wrSize.GetBottom(); 03313 else 03314 *dy = 0; 03315 } 03316 03317 03318 03319 03320 /********************************************************************************************* 03321 03322 > virtual void ScreenView::HandleOleDragOutOfView(wxPoint point); 03323 03324 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 03325 Created: 26/9/96 03326 03327 Purpose: Called when doing a DRAGTYPE_OLESCROLL and the mouse pointer moves outside 03328 the view window. The base class does nothing, so dragging continues as normal, 03329 but in the derived ScreenCamView class, this is used to cancel the internal 03330 XOR drag operation, and start an OLE drag and drop export procedure. 03331 03332 Notes: May cancel the current Drag Op 03333 03334 Scope: Protected 03335 SeeAlso: ScreenCamView::HandleOleDragOutOfView 03336 03337 **********************************************************************************************/ 03338 03339 void ScreenView::HandleOleDragOutOfView(wxPoint point) 03340 { 03341 // The base class does nothing - this should keep Ralph happy 03342 } 03343 03344 03345 03346 03347 /********************************************************************************************* 03348 > afx_msg void ScreenView::OnLButtonDown(UINT32 nFlags, wxPoint point) 03349 03350 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 03351 Created: ages ago 03352 Inputs: Flags describing which buttons & keys were down when the message was sent; 03353 the coordinates of the mouse cursor. 03354 Outputs: - 03355 Returns: - 03356 Purpose: Called by MFC upon receipt of a left-button-down mouse message. Finds out 03357 which other buttons are down (eg. SHIFT) and passes the message on to the kernel. 03358 Note that the mouse message will have originally come from the RendWnd object, a 03359 child window of ScreenView. 03360 Errors: - 03361 Scope: Protected 03362 SeeAlso: class CRendWnd; ScreenView::HandleDragEvent() 03363 03364 **********************************************************************************************/ 03365 03366 void ScreenView::OnLButtonDown( wxMouseEvent &event ) 03367 { 03368 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 03369 // WEBSTER - markn 25/4/97 03370 // No pen stuff required in Webster 03371 // Taken out by vector stroking code Neville 2/10/97 03372 #ifdef VECTOR_STROKING 03373 // Setup pressure if pen active 03374 (Camelot.GetPressurePen())->CheckMouseMessage(WM_LBUTTONDOWN, point); 03375 #endif // VECTOR_STROKING 03376 #endif 03377 03378 // Support triple clicks 03379 wxRect ClickBounds( LastDoubleClickPos.x - LocalEnvironment::GetXMouseDoubleClickMove(), 03380 LastDoubleClickPos.y - LocalEnvironment::GetYMouseDoubleClickMove(), 03381 LocalEnvironment::GetXMouseDoubleClickMove() * 2, 03382 LocalEnvironment::GetYMouseDoubleClickMove() * 2 ); 03383 03384 MonotonicTime ThisClickTime( event.GetTimestamp() ); 03385 MonotonicTime ClickGap(LocalEnvironment::GetMouseDoubleClickDelay()); 03386 03387 // Is click within allowed movement rectangle and permitted time delay 03388 INT32 TimeDelay = (ThisClickTime - TimeOfLastClick); 03389 if( ClickBounds.Inside( event.GetPosition() ) && ( TimeDelay <= (INT32)ClickGap ) ) 03390 ThisSingleIsTriple = TRUE; 03391 else 03392 ThisSingleIsTriple = FALSE; 03393 03394 // Deal with the click 03395 HandleDragEvent( MK_LBUTTON, event, CLICKTYPE_SINGLE ); 03396 03397 TimeOfLastClick.Sample(); 03398 } 03399 03400 /********************************************************************************************* 03401 > afx_msg void ScreenView::OnMButtonDown(UINT32 nFlags, wxPoint point) 03402 03403 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 03404 Created: ages ago 03405 Inputs: Flags describing which buttons & keys were down when the message was sent; 03406 the coordinates of the mouse cursor. 03407 Outputs: - 03408 Returns: - 03409 Purpose: Called by MFC upon receipt of a middle-button-down mouse message. Finds out 03410 which other buttons are down (eg. SHIFT) and passes the message on to the kernel. 03411 Note that the mouse message will have originally come from the RendWnd object, a 03412 child window of ScreenView. 03413 Errors: - 03414 Scope: Protected 03415 SeeAlso: class CRendWnd; ScreenView::HandleDragEvent() 03416 03417 **********************************************************************************************/ 03418 03419 void ScreenView::OnMButtonDown( wxMouseEvent &event ) 03420 { 03421 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 03422 // WEBSTER - markn 25/4/97 03423 // No pen stuff required in Webster 03424 // Taken out by vector stroking code Neville 2/10/97 03425 #ifdef VECTOR_STROKING 03426 (Camelot.GetPressurePen())->CheckMouseMessage(WM_MBUTTONDOWN, point); 03427 #endif // VECTOR_STROKING 03428 #endif 03429 HandleDragEvent(MK_MBUTTON, event, CLICKTYPE_SINGLE); 03430 } 03431 03432 /********************************************************************************************* 03433 > afx_msg void ScreenView::OnRButtonDown(UINT32 nFlags, wxPoint point) 03434 03435 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 03436 Created: ages ago 03437 Inputs: Flags describing which buttons & keys were down when the message was sent; 03438 the coordinates of the mouse cursor. 03439 Outputs: - 03440 Returns: - 03441 Purpose: Same as for ScreenView::OnLButtonDown(), but for the right mouse button. 03442 Errors: - 03443 Scope: Protected 03444 SeeAlso: class CRendWnd; ScreenView::HandleDragEvent(); ScreenView::OnLButtonDown() 03445 03446 **********************************************************************************************/ 03447 03448 void ScreenView::OnRButtonDown( wxMouseEvent &event ) 03449 { 03450 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 03451 // WEBSTER - markn 25/4/97 03452 // No pen stuff required in Webster 03453 // Taken out by vector stroking code Neville 2/10/97 03454 #ifdef VECTOR_STROKING 03455 (Camelot.GetPressurePen())->CheckMouseMessage( WM_RBUTTONDOWN, event.GetPosition() ); 03456 #endif // VECTOR_STROKING 03457 #endif 03458 HandleDragEvent(MK_RBUTTON, event, CLICKTYPE_SINGLE); 03459 } 03460 03461 /********************************************************************************************* 03462 > afx_msg void ScreenView::OnMouseWheel(UINT32 nFlags, short zDelta, wxPoint pt) 03463 03464 Author: Priestley (Xara Group Ltd) <camelotdev@xara.com> 03465 Created: 25/10/2000 03466 Purpose: 03467 Scope: Protected 03468 03469 **********************************************************************************************/ 03470 03471 void ScreenView::OnMouseWheel( wxMouseEvent &event ) 03472 { 03473 HandleMouseWheelEvent( event ); 03474 } 03475 03476 /********************************************************************************************* 03477 > afx_msg void ScreenView::OnMouseMove(UINT32 nFlags, wxPoint point) 03478 03479 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 03480 Created: ages ago 03481 Inputs: Flags describing which buttons & keys were down when the message was sent; 03482 the coordinates of the mouse cursor. 03483 Outputs: - 03484 Returns: - 03485 Purpose: Packages up OIL-layer mouse-move messages before passing them on to 03486 DocView::DragPointerMove(). If ScreenView is not in "drag mode" the event is 03487 passed to our DocView, which will forward it to the current tool. Otherwise, 03488 checks if a CLICKTYPE_DRAG message has been sent to the kernel, sending one if 03489 it hasn't (this smooths the difference between Windows and RISC OS, the former 03490 system providing little support for drag operations). 03491 Errors: - 03492 Scope: Protected 03493 SeeAlso: class CRendWnd; ScreenView::HandleDragEvent(); DocView::DragPointerMove(); 03494 ScreenView::GetClickMods(); ScreenView::HandleDragScrolling(); 03495 DocView::OnMouseMove() 03496 **********************************************************************************************/ 03497 03498 void ScreenView::OnMouseMove( wxMouseEvent &event ) 03499 { 03500 // Ignore if system is disabled 03501 if (CCamApp::IsDisabled()) 03502 return; // If the system is disabled, ignore 03503 03504 // Only respond to real mouse move messages 03505 if (event.GetPosition()==CurrentMousePos) 03506 return; 03507 03508 // Ignore mouse moves if we're not the foreground window. 03509 if (pDocView != DocView::GetSelected()) 03510 { 03511 return; 03512 } 03513 03514 UINT32 nFlags = ClickModifiers::SynthesizeMouseEventFlags(event); 03515 03516 //PORTNOTE("other","Remove StatusLine related code") 03517 //#ifndef EXCLUDE_FROM_XARALX 03518 StatusLine* pStatusLine=NULL; 03519 // flag that the StatusLine's mouse position field needs updating 03520 #ifndef RALPH 03521 03522 pStatusLine=GetApplication()->GetpStatusLine(); 03523 if (pStatusLine) 03524 pStatusLine->FlagMousePosNeedsUpdating(); 03525 #endif 03526 //#endif 03527 SetCurrentStates(); 03528 03529 PORTNOTE("other","Remove PeekMessage related code") 03530 #ifndef EXCLUDE_FROM_XARALX 03531 // Only discard mouse move messages if the initiator of the drag has requested this. 03532 if (!DragKeepAccuracy) 03533 { 03534 // Due to problems with auto-repeat on modifier keys, we can lag a long way behind 03535 // with mouse messages, so we discard all except the most recent mouse move messages. 03536 // However we stop discarding mouse move messages if we come across any other mouse 03537 // messages such as button up/down events. 03538 MSG Msg; 03539 BOOL FoundMsg = FALSE; 03540 03541 for(;;) 03542 { 03543 // We have to test that the window handles match because of a bug in PeekMessage (we 03544 // get messages which aren't for the window we specified, strangely). 03545 03546 if (::PeekMessage(&Msg, m_hWnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE) && 03547 (m_hWnd == Msg.hwnd) && 03548 (Msg.message == WM_MOUSEMOVE)) 03549 { 03550 // Found a mouse move message on the queue... 03551 // Remember it then discard it. 03552 nFlags = (UINT32) Msg.wParam; 03553 03554 // Have to cast to INT8 so we get correct sign-extension. 03555 point.x = (INT8) LOWORD(Msg.lParam); 03556 point.y = (INT8) HIWORD(Msg.lParam); 03557 03558 // Discard the message 03559 PeekMessage(&Msg, m_hWnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE); 03560 FoundMsg = TRUE; 03561 } 03562 else 03563 { 03564 // Either: there are no messages, or it's not for our window, or it's a mouse 03565 // event which is not a mouse *move* event - whatever it is, stop looking 03566 // for mouse events. 03567 break; 03568 } 03569 } 03570 03571 // If we found any other mouse messages, use the data from the most recent one and 03572 // ignore the others. 03573 if (FoundMsg) 03574 { 03575 ENSURE(m_hWnd == Msg.hwnd, "Bad message in OnMouseMove"); 03576 nFlags = (UINT32) Msg.wParam; 03577 point.x = (INT8) LOWORD(Msg.lParam); 03578 point.y = (INT8) HIWORD(Msg.lParam); 03579 03580 03581 } 03582 } 03583 03584 // Slow mouse reponse due to key auto-repeat msgs? 03585 // 03586 // We could be experiencing delayed mouse move messages due to the message 03587 // queue getting flooded with key auto-repeat msgs. 03588 // 03589 // To overcome this, we remove all mouse move messages, keeping only the most 03590 // recent msg's coords & flags. 03591 // 03592 // Stripping the message cue in this way means we get less mouse moves to drag handlers, hence less accurate 03593 // mouse move data. But, as we only do this if we get an auto-repeated key stroke, accuracy should not be 03594 // a problem, even for the freehand tool. Freehand drags have two key modifiers (Alt for straught line and 03595 // Shift for rubbing out) that only require the latest mouse move event 03596 03597 MSG Msg; 03598 // Has there been a key msg during the mouse move? 03599 if (::PeekMessage(&Msg, m_hWnd, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE)) 03600 { 03601 // Have a look at the key msg (use KeyPressSysMsg to turn the msg into a system-independant format) 03602 KeyPressSysMsg KeySysMsg(&Msg); 03603 03604 // Is the key msg an auto-repeated key press (i.e. previously down)? 03605 if (KeySysMsg.IsValid() && KeySysMsg.PrevDown) 03606 { 03607 // Auto repeat key msg found, so get the latest mouse move msg 03608 // Note: We don't remove the msg from the queue, it may need to be processed elsewhere (e.g. button-ups) 03609 while (::PeekMessage(&Msg, m_hWnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE)) 03610 { 03611 // Is the mouse msg a mouse move msgs? 03612 if (Msg.message == WM_MOUSEMOVE) 03613 { 03614 // Found a mouse move message on the queue so remember it 03615 nFlags = (UINT32) Msg.wParam; 03616 03617 // Have to cast to INT8 so we get correct sign-extension. 03618 point.x = (INT8) LOWORD(Msg.lParam); 03619 point.y = (INT8) HIWORD(Msg.lParam); 03620 03621 // Remove the mouse move msg, and get the next mouse msg in the queue 03622 ::PeekMessage(&Msg, m_hWnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE); 03623 } 03624 else 03625 { 03626 // We have got a mouse msg that's not a mouse move msg, so break out of 'while' loop 03627 // This could be a button-up msg, in which case we should stop looking for 03628 // mouse moves as they may be irrelevent to the current drag 03629 break; 03630 } 03631 } 03632 } 03633 } 03634 #endif 03635 03636 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 03637 // WEBSTER - markn 25/4/97 03638 // No pen stuff required in Webster 03639 // Taken out by vector stroking code Neville 2/10/97 03640 #ifdef VECTOR_STROKING 03641 03642 // Now check the Mouse Message to see if it has any pressure information 03643 (Camelot.GetPressurePen())->CheckMouseMessage(WM_MOUSEMOVE, point); 03644 #endif // VECTOR_STROKING 03645 #endif 03646 03647 // Set the DocView (and Document) 03648 // pDocView->SetCurrent(); 03649 03650 03651 // Find out which buttons/keys are down. 03652 GetClickMods(event, &LastClickMods); 03653 03654 // Are we dragging at the moment? 03655 if (pCurrentDragOp) 03656 { 03657 // Yes, but just check that the drag isn't "paused" while we do an OLE drag outside the window 03658 if (GetCanvas()->GetCapture() == GetCanvas()) 03659 { 03660 WinCoord point; 03661 event.GetPosition( &point.x, &point.y ); 03662 03663 // Send an on-going drag event to the kernel. 03664 pDocView->DragPointerMove(pCurrentDragOp, point.ToOil(pDocView, TRUE), LastClickMods); 03665 03666 // Check if we need to scroll this view. 03667 HandleDragScrolling(point); 03668 } 03669 } 03670 else 03671 { 03672 // We are not dragging at the moment, but are we about to start a drag? If the 03673 // last mouse event was a single click, the same buttons are down, and the mouse 03674 // has either moved (3 or more), then a drag is beginning. 03675 WinCoord point; 03676 event.GetPosition( &point.x, &point.y ); 03677 03678 INT32 dx = point.x - LastClickPoint.x; 03679 INT32 dy = point.y - LastClickPoint.y; 03680 INT32 dz2 = (dx * dx) + (dy * dy); 03681 if ((nFlags & FirstClickButton) && (dz2 >= (DragLatency * DragLatency))) 03682 { 03683 // Inform the kernel that a drag is starting. 03684 wxMouseEvent KernelEvent( event ); 03685 KernelEvent.m_x = LastClickPoint.x; 03686 KernelEvent.m_y = LastClickPoint.y; 03687 HandleDragEvent(FirstClickButton, KernelEvent, CLICKTYPE_DRAG); 03688 } 03689 else 03690 { 03691 // We are not dragging, just moving the mouse around, so pass the position 03692 // of the mouse to the tool, giving it an opportunity to set the cursor etc. 03693 pDocView->OnMouseMove( point.ToOil(pDocView, TRUE), LastClickMods); 03694 } 03695 } 03696 03697 // Remember the last position of the mouse passed on to the kernel. The position 03698 // passed on any subsequent DragPointerIdle events must be the same as this! 03699 CurrentMousePos = event.GetPosition(); 03700 03701 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 03702 // if status line has not already been updated by someone calling CSnap::Snap(), call 03703 // CSnap::Snap(), snapping to grid only, to update status line (and ruler mouse followers) 03704 if (pStatusLine && pStatusLine->MousePosNeedsUpdating()) 03705 { 03706 OilCoord OilPos=((WinCoord*)&point)->ToOil(pDocView, TRUE); 03707 DocCoord DocPos(0,0); 03708 Spread* pSpread=pDocView->OilToSpreadCoord(OilPos,&DocPos); 03709 if (pSpread) 03710 pDocView->Snap(pSpread,&DocPos,TRUE,TRUE); 03711 } 03712 #endif 03713 } 03714 03715 03716 /******************************************************************************************** 03717 > BOOL ScreenView::GetCurrentMousePos(OilCoord* pMousePos) const 03718 03719 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 03720 Created: 12/10/94 03721 Inputs: - 03722 Outputs: pMousePos the mouse position within this view, in OIL coordinates 03723 Returns: TRUE if the mouse is within this view, and hence that *pMousePos holds 03724 its position; FALSE if the mouse is outside the view (in which case 03725 *pMousePos is unchanged). 03726 Purpose: Finds out the current mouse position within this view window. 03727 Errors: - 03728 SeeAlso: - 03729 ********************************************************************************************/ 03730 03731 BOOL ScreenView::GetCurrentMousePos(OilCoord* pMousePos) const 03732 { 03733 // Get the Windows screen coordinates of the mouse cursor. 03734 // Convert from screen to window coordinates. 03735 WinCoord pt; 03736 *(wxPoint *)&pt = GetCanvas()->ScreenToClient( ::wxGetMousePosition() ); 03737 03738 // If the mouse is outside the view then we can do nothing more. 03739 if (!CurrentSize.Inside(pt)) return FALSE; 03740 03741 // Convert to OIL coordinates. 03742 if (pMousePos!=NULL) 03743 *pMousePos = pt.ToOil(pDocView, TRUE); 03744 03745 // We stored something useful. 03746 return TRUE; 03747 } 03748 03749 03750 03751 /********************************************************************************************* 03752 > afx_msg void ScreenView::OnKeyDown(UINT32 nChar, UINT32 nRepCnt, UINT32 nFlags) 03753 03754 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 03755 Created: 22/6/94 03756 Inputs: Vitual key code of the key that was pressed. 03757 Outputs: - 03758 Returns: - 03759 Purpose: Called when a key is pressed, so we can do something with it. 03760 It is currently only used to adjust the Pretend Pen Pressure. 03761 THIS CODE HAS BEEN COMMENTED OUT UNTIL THE NEW KEYBOARD SYSTEM IS FULLY 03762 OPERATIONAL!! 03763 Errors: - 03764 Scope: Protected 03765 SeeAlso: ScreenView::OnJoystickMove 03766 **********************************************************************************************/ 03767 /* 03768 void ScreenView::OnKeyDown(UINT32 nChar, UINT32 nRepCnt, UINT32 nFlags) 03769 { 03770 switch (nChar) 03771 { 03772 case CamKey_IncPressure: // Defined in 'pen.h' 03773 Camelot.GetPressurePen()->IncreasePenPressure(); 03774 break; 03775 03776 case CamKey_DecPressure: 03777 Camelot.GetPressurePen()->DecreasePenPressure(); 03778 break; 03779 }; 03780 } 03781 */ 03782 03783 03784 /********************************************************************************************* 03785 > afx_msg void ScreenView::OnTimer(UINT32 nIDEvent) 03786 03787 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 03788 Created: ages ago 03789 Inputs: The elapsed timer's numeric identifier (not used). 03790 Outputs: - 03791 Returns: - 03792 Purpose: Sends DragPointerIdle "events" to the kernel, when dragging. As Windows 03793 doesn't support such "idle" messages, the OIL drag system sets up a timer 03794 when a drag starts, and sends idle messages every time the timer elapses, 03795 until the drag is finished. 03796 Errors: - 03797 Scope: Protected 03798 SeeAlso: ScreenView::HandleDragEvent(); DocView::DragPointerMove(); 03799 ScreenView::GetClickMods(); 03800 03801 **********************************************************************************************/ 03802 03803 PORTNOTE("other","Removed ScreenView::OnTimer usage") 03804 #ifndef EXCLUDE_FROM_XARALX 03805 void ScreenView::OnTimer(UINT32) 03806 { 03807 03808 // Ignore if system is disabled 03809 if (CCamApp::IsDisabled()) 03810 return; // If the system is disabled, ignore 03811 03812 // This window should never get a timer event that does not occur between calls to 03813 // StartDrag() and EndDrag(). 03814 // ENSURE(pCurrentDragOp != 0, "ScreenView::StartDrag: pCurrentDragOp is null"); 03815 03816 // Find out which keys/buttons are being held down at the moment. The mouse buttons 03817 // are more difficult, as they may have been swapped. 03818 UINT32 nFlags = ClickModifiers::SynthesizeMouseEventFlags(); 03819 03820 SetCurrentStates(); 03821 03822 if (pCurrentDragOp == NULL) 03823 { 03824 // We are not dragging at the moment, so check for a time-out condition to 03825 // start a drag: 03826 // If a mouse button is down, and the timer has expired, then start a drag. 03827 if (LastClickType!=CLICKTYPE_NONE 03828 && (nFlags & (MK_LBUTTON|MK_MBUTTON|MK_RBUTTON)) 03829 && DragTimer.Elapsed(DragDelay) 03830 && GetCurrentMousePos(NULL) 03831 ) 03832 { 03833 // Inform the kernel that a drag is starting. 03834 HandleDragEvent(FirstClickButton, nFlags, LastClickPoint, CLICKTYPE_DRAG); 03835 } 03836 } 03837 else 03838 { 03839 // If we're doing an OLE drag and drop operation, then our DragOperation is still 03840 // active, but we have lost the Mouse Capture, so we should not update anything. 03841 // If the user drags back into our view window, the OLE drag will be shut down 03842 // and we will be given back our mouse capture so we can continue as if nothing 03843 // had happened. This just stops us scrolling while the OLE system is in charge! 03844 if (GetCanvas()->GetCapture() == GetCanvas()) 03845 { 03846 // Check if we need to scroll the screen . . . 03847 HandleDragScrolling(CurrentMousePos); 03848 03849 // The above call may have aborted the current DragOp, so we must check if it is NULL 03850 if (pCurrentDragOp != NULL) 03851 { 03852 // Now "fake" a mouse event for the kernel . . . 03853 GetClickMods(nFlags, &LastClickMods); 03854 pDocView->DragPointerIdle(pCurrentDragOp, 03855 ((WinCoord*)&CurrentMousePos)->ToOil(pDocView, TRUE), 03856 LastClickMods); 03857 } 03858 } 03859 else 03860 { 03861 // We don't own the capture - but if the user was OLE dragging and has dragged back into our 03862 // view window, then the OLE drag will have been cancelled, and we need to recapture the 03863 // mouse so that we can continue processing the drag as if nothing happened. Our OLE DropSource 03864 // will set our OLERecaptureMouse flag if it cancels itself and wishes us to continue... 03865 if (OLERecaptureMouse) 03866 { 03867 GetCanvas()->SetCapture(); 03868 OLERecaptureMouse = FALSE; // Only capture it back once! 03869 } 03870 } 03871 } 03872 } 03873 #endif 03874 03875 /********************************************************************************************* 03876 03877 > void ScreenView::RecaptureMouseOnNextUpdate(void) 03878 03879 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 03880 Created: ?/10/96 03881 03882 Purpose: Called by the OLE drag & drop system (CCamDropSource::QueryContinueDrag, 03883 winoil\dataobj.cpp) when dragging a selection - if the mouse pointer goes 03884 outside the view, the selection drag is "paused", and an OLE drag is started. 03885 If the pointer comes back into our view, we cancel the OLE drag and resume 03886 the selector drag - the only thing we need to do to resume is to reclaim 03887 the mouse capture (but we must do it on the next idle to ensure that 03888 we get & keep the capture, so we flag it here and fix it up in OnTimer, above) 03889 03890 The other thing we must now do is to XOR the dragged objects once to restore 03891 them to screen (as we now hide the XOR when you drag out of the window) 03892 03893 **********************************************************************************************/ 03894 03895 void ScreenView::RecaptureMouseOnNextUpdate(void) 03896 { 03897 // Flag the fact that we must recapture the mouse 03898 OLERecaptureMouse = TRUE; 03899 03900 Spread *pSpread = pDocView->FindEnclosingSpread(((WinCoord*)&CurrentMousePos)->ToOil(pDocView, TRUE)); 03901 03902 if (pSpread != NULL) 03903 { 03904 // Get the DocView's viewport, in Spread Coords, because we have to supply a DocRect to 03905 // this stupid routine which won't let us pass a NULL pointer in to just redraw 03906 // it all, depsite the fact that all the functions it calls will allow it. Grrr. 03907 // (And using the Spread's bounding rect doesn't work because its bounding rect is in 03908 // chapter coords, not spread coords. Tread carefully... 03909 DocRect ClipRect = pDocView->GetDocViewRect(pSpread); 03910 pSpread->DocCoordToSpreadCoord(&ClipRect); 03911 03912 if (pCurrentDragOp != NULL) 03913 pCurrentDragOp->RenderDragBlobs(ClipRect, pSpread, pDocView->GetCurrentSolidDragState()); 03914 } 03915 } 03916 03917 03918 03919 /********************************************************************************************* 03920 > afx_msg void ScreenView::OnCancelMode() 03921 03922 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 03923 Created: 22nd Sept 1993 03924 Inputs: - 03925 Outputs: - 03926 Returns: - 03927 Purpose: Called by the system whenever this window loses the focus to a dialogue box 03928 etc. Checks if the window is in drag mode, if it is makes sure that the 03929 drag is tidily cancelled, eg. the mouse is uncaptured and its clipping area 03930 restored. Calls DocView::DragFinished() (WITH JUNK PARAMETERS FOR THE MOUSE 03931 POSITION/BUTTONS) to indicate that the drag has been cancelled. 03932 Errors: - 03933 Scope: Protected 03934 SeeAlso: DocView::DragFinished(); ScreenView::EndDrag() 03935 03936 **********************************************************************************************/ 03937 03938 PORTNOTE("other","Removed ScreenView::OnCancelMode usage") 03939 #ifndef EXCLUDE_FROM_XARALX 03940 void ScreenView::OnCancelMode() 03941 { 03942 SetCurrentStates(); 03943 // If the system is disabled all messages should be ignored 03944 if (!pCurrentDragOp) return; 03945 03946 // Make sure the capture is released. 03947 ::ReleaseCapture(); 03948 03949 if (!CCamApp::IsDisabled()) 03950 pDocView->DragFinished(pCurrentDragOp, OilCoord(0, 0), LastClickMods, FALSE); 03951 03952 // EndDrag(pCurrentDragOp); 03953 } 03954 #endif 03955 03956 03957 /********************************************************************************************* 03958 > afx_msg void ScreenView::OnLButtonUp(UINT32 nFlags, wxPoint point) 03959 03960 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 03961 Created: ages ago 03962 Inputs: Flags describing which buttons & keys were down when the message was sent; 03963 the coordinates of the mouse cursor 03964 Outputs: - 03965 Returns: - 03966 Purpose: Passes the event on to HandleButtonUp() 03967 Errors: - 03968 Scope: Protected 03969 SeeAlso: class CRendWnd; ScreenView::OnLButtonDown(); ScreenView::GetClickMods(); 03970 DocView::DragFinished(); ScreenView::HandleButtonUp() 03971 03972 **********************************************************************************************/ 03973 03974 void ScreenView::OnLButtonUp(wxMouseEvent &event) 03975 { 03976 HandleButtonUp(MK_LBUTTON, event); 03977 } 03978 03979 03980 03981 03982 /********************************************************************************************* 03983 > afx_msg void ScreenView::OnMButtonUp(UINT32 nFlags, wxPoint point) 03984 03985 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 03986 Created: ages ago 03987 Inputs: Flags describing which buttons & keys were down when the message was sent; 03988 the coordinates of the mouse cursor. 03989 Outputs: - 03990 Returns: - 03991 Purpose: Passes the event on to HandleButtonUp(). 03992 Errors: - 03993 Scope: Protected 03994 SeeAlso: class CRendWnd; ScreenView::OnMButtonDown(); ScreenView::GetClickMods(); 03995 DocView::DragFinished(); ScreenView::HandleButtonUp() 03996 03997 **********************************************************************************************/ 03998 03999 void ScreenView::OnMButtonUp(wxMouseEvent &event) 04000 { 04001 HandleButtonUp(MK_MBUTTON, event); 04002 } 04003 04004 04005 04006 04007 /********************************************************************************************* 04008 > afx_msg void ScreenView::OnRButtonUp(UINT32 nFlags, wxPoint point) 04009 04010 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 04011 Created: ages ago 04012 Inputs: Flags describing which buttons & keys were down when the message was sent; 04013 the coordinates of the mouse cursor. 04014 Outputs: - 04015 Returns: - 04016 Purpose: Same as ScreenView::OnLButtonUp(), but for the right mouse button. 04017 Errors: - 04018 Scope: Protected 04019 SeeAlso: class CRendWnd; ScreenView::OnRButtonDown(); ScreenView::GetClickMods(); 04020 DocView::DragFinished(); ScreenView::HandleButtonUp() 04021 04022 **********************************************************************************************/ 04023 04024 void ScreenView::OnRButtonUp( wxMouseEvent &event ) 04025 { 04026 HandleButtonUp(MK_RBUTTON, event); 04027 } 04028 04029 04030 04031 04032 /********************************************************************************************* 04033 > afx_msg void ScreenView::OnLButtonDblClk(UINT32 nFlags, wxPoint point) 04034 04035 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 04036 Created: ages ago 04037 Inputs: Flags describing which buttons & keys were down when the message was sent; 04038 the coordinates of the mouse cursor. 04039 Outputs: - 04040 Returns: - 04041 Purpose: Passes a left-button double-click to ScreenView::HandleDragEvent(). 04042 Errors: - 04043 Scope: Protected 04044 SeeAlso: class CRendWnd; ScreenView::HandleDragEvent() 04045 04046 **********************************************************************************************/ 04047 04048 void ScreenView::OnLButtonDblClk(wxMouseEvent &event) 04049 { 04050 // Support quad clicks 04051 wxRect ClickBounds( LastDoubleClickPos.x-LocalEnvironment::GetXMouseDoubleClickMove(), 04052 LastDoubleClickPos.y-LocalEnvironment::GetYMouseDoubleClickMove(), 04053 LastDoubleClickPos.x+LocalEnvironment::GetXMouseDoubleClickMove(), 04054 LastDoubleClickPos.y+LocalEnvironment::GetYMouseDoubleClickMove()); 04055 MonotonicTime ThisClickTime( event.GetTimestamp() ); 04056 MonotonicTime ClickGap(LocalEnvironment::GetMouseDoubleClickDelay()); 04057 // Is click within allowed movement rectangle and permitted time delay 04058 INT32 TimeDelay = (ThisClickTime - TimeOfLastClick); 04059 if (ClickBounds.Inside( event.GetPosition() ) && (TimeDelay <= (INT32)ClickGap)) 04060 ThisDoubleIsQuad = TRUE; 04061 else 04062 ThisDoubleIsQuad = FALSE; 04063 04064 HandleDragEvent(MK_LBUTTON, event, CLICKTYPE_DOUBLE); 04065 04066 TimeOfLastClick.Sample(); 04067 LastDoubleClickPos = event.GetPosition(); 04068 } 04069 04070 04071 04072 04073 /********************************************************************************************* 04074 > afx_msg void ScreenView::OnMButtonDblClk(UINT32 nFlags, wxPoint point) 04075 04076 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 04077 Created: ages ago 04078 Inputs: Flags describing which buttons & keys were down when the message was sent; 04079 the coordinates of the mouse cursor. 04080 Outputs: - 04081 Returns: - 04082 Purpose: Passes a middle-button double-click to ScreenView::HandleDragEvent(). 04083 Errors: - 04084 Scope: Protected 04085 SeeAlso: class CRendWnd; ScreenView::HandleDragEvent() 04086 04087 **********************************************************************************************/ 04088 04089 void ScreenView::OnMButtonDblClk(wxMouseEvent &event) 04090 { 04091 HandleDragEvent(MK_MBUTTON, event, CLICKTYPE_DOUBLE); 04092 } 04093 04094 04095 04096 04097 /********************************************************************************************* 04098 > afx_msg void ScreenView::OnRButtonDblClk(UINT32 nFlags, wxPoint point) 04099 04100 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 04101 Created: ages ago 04102 Inputs: Flags describing which buttons & keys were down when the message was sent; 04103 the coordinates of the mouse cursor 04104 Outputs: - 04105 Returns: - 04106 Purpose: Same as ScreenView::OnLButtonDblClk(), bit for the right button. 04107 Errors: - 04108 Scope: Protected 04109 SeeAlso: class CRendWnd; ScreenView::OnLButtonDblClk() 04110 04111 **********************************************************************************************/ 04112 04113 void ScreenView::OnRButtonDblClk( wxMouseEvent &event ) 04114 { 04115 HandleDragEvent(MK_RBUTTON, event, CLICKTYPE_DOUBLE); 04116 } 04117 04118 04119 04120 /******************************************************************************************** 04121 > void ScreenView::OnDropFiles(HDROP hDropInfo) 04122 04123 Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> 04124 Created: 29/07/94 04125 Inputs: hDropInfo - handle to information about drag event. 04126 Purpose: Respond to files being dropped onto the view window. It sets up the 04127 current document and docview, and passes control on to the OpDroppedFile 04128 operation. 04129 SeeAlso: OpDroppedFile 04130 ********************************************************************************************/ 04131 04132 PORTNOTE("other","Removed ScreenView::OnDropFiles usage") 04133 #ifndef EXCLUDE_FROM_XARALX 04134 void ScreenView::OnDropFiles(HDROP hDropInfo) 04135 { 04136 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 04137 #ifdef STANDALONE 04138 // Force Viewer to 'Load' rather than Import 04139 GetMainFrame()->OnDropFiles(hDropInfo); 04140 #else 04141 // Set the correct docivew (and hence document) 04142 pDocView->SetCurrent(); 04143 04144 // Invoke the dropped files operation 04145 OpDescriptor *pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_DROPPEDFILE); 04146 pOpDesc->Invoke((OpParam *) hDropInfo); 04147 04148 // Clean up 04149 DragFinish(hDropInfo); 04150 #endif 04151 #endif 04152 } 04153 #endif 04154 04155 04156 04157 /********************************************************************************************* 04158 04159 > void ScreenView::ClearClickState() 04160 04161 Author: Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> 04162 Created: 26/02/2004 04163 04164 Purpose: Clear the current click state so that any logic in progress is stopped before 04165 it does anything nasty. 04166 04167 **********************************************************************************************/ 04168 04169 void ScreenView::ClearClickState() 04170 { 04171 LastClickType = CLICKTYPE_NONE; 04172 if( GetParentFrame()->HasCapture() ) 04173 { 04174 GetParentFrame()->ReleaseMouse(); 04175 } 04176 } 04177 04178 04180 // Menu functions 04181 04182 04183 /********************************************************************************************* 04184 > void ScreenView::OnFilePrintPreview() 04185 04186 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 04187 Created: ages ago 04188 Inputs: - 04189 Outputs: - 04190 Returns: - 04191 Purpose: Simply makes CView::OnFilePrintPreview() have public scope. 04192 Used by the menu system. 04193 Errors: - 04194 Scope: Public 04195 SeeAlso: CView::OnFilePrintPreview(); CCamView::OnFilePrint() 04196 04197 **********************************************************************************************/ 04198 04199 void ScreenView::OnFilePrintPreview() 04200 { 04201 SetCurrentStates(); 04202 04203 CCamView::OnFilePrintPreview(); 04204 } 04205 04206 04207 04208 04209 /********************************************************************************************* 04210 > DocView* ScreenView::GetDocViewPtr() const 04211 04212 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 04213 Created: ages ago 04214 Inputs: - 04215 Outputs: - 04216 Returns: A pointer to the DocView object associated with this CCamView. 04217 Purpose: Used by Will's rendering system - somehow. 04218 Errors: - 04219 Scope: Public 04220 SeeAlso: Will's stuff. 04221 04222 **********************************************************************************************/ 04223 04224 DocView* ScreenView::GetDocViewPtr() const 04225 { 04226 return pDocView; 04227 } 04228 04229 04230 04231 04232 04234 // OLE container/server support and commands 04235 04236 /********************************************************************************************* 04237 > virtual BOOL ScreenView::IsSelected(const CObject* pDocItem) const 04238 04239 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 04240 Created: ages ago 04241 Inputs: A constant pointer to a CObject which is a candidate for some 04242 OLE action. 04243 Outputs: - 04244 Returns: TRUE if the parameter is selected in this view. 04245 Purpose: "Tests for a selected OLE client item". 04246 Errors: - 04247 Scope: Public 04248 SeeAlso: ScreenView::OnInsertObject() 04249 04250 **********************************************************************************************/ 04251 04252 BOOL ScreenView::IsSelected(const CObject* pDocItem) const 04253 { 04254 // TODO: implement this function that tests for a selected OLE client item 04255 04256 #if (_OLE_VER >= 0x200) 04257 // This implementation is adequate if your selection only consists of CCamCntrItems. 04258 // To handle different selection mechanisms, this implementation should be changed. 04259 return pDocItem == m_pSelection; 04260 #else 04261 return FALSE; 04262 #endif 04263 } 04264 04265 04266 04267 /********************************************************************************************* 04268 > afx_msg void ScreenView::OnInsertObject() 04269 04270 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 04271 Created: ages ago 04272 Inputs: - 04273 Outputs: - 04274 Returns: - 04275 Purpose: "Creates an embedded OLE object with a type-name retrieved 04276 from the user" - currently unimplemented. 04277 Errors: - 04278 Scope: Protected 04279 SeeAlso: ScreenView::IsSelected() 04280 04281 **********************************************************************************************/ 04282 04283 PORTNOTE("other","Removed ScreenView::OnInsertObject usage") 04284 #ifndef EXCLUDE_FROM_XARALX 04285 void ScreenView::OnInsertObject() 04286 { 04287 04288 SetCurrentStates(); 04289 04290 04291 #if (_OLE_VER >= 0x200) 04292 04293 // OLE 2.0+ default implementation. 04294 // Invoke the standard Insert Object dialog box to obtain information for a new 04295 // CCamCntrItem object. 04296 COleInsertDialog dlg; 04297 if (dlg.DoModal() != IDOK) return; 04298 04299 BeginBusyCursor(); 04300 04301 CCamCntrItem* pItem = NULL; 04302 TRY 04303 { 04304 // Create new item connected to this document. 04305 CCamDoc* pDoc = GetDocument(); 04306 ASSERT_VALID(pDoc); 04307 pItem = new CCamCntrItem(pDoc); 04308 ASSERT_VALID(pItem); 04309 04310 // Initialize the item from the dialog data. 04311 if (!dlg.CreateItem(pItem)) 04312 AfxThrowMemoryException(); // any exception will do 04313 ASSERT_VALID(pItem); 04314 04315 // If item created from class list (not from file) then launch 04316 // the server to edit the item. 04317 if (dlg.GetSelectionType() == COleInsertDialog::createNewItem) 04318 pItem->DoVerb(OLEIVERB_SHOW, this); 04319 04320 ASSERT_VALID(pItem); 04321 04322 // As an arbitrary user interface design, this sets the selection 04323 // to the last item inserted. 04324 04325 // TODO: reimplement selection as appropriate for your application 04326 04327 m_pSelection = pItem; // set selection to last inserted item 04328 pDoc->UpdateAllViews(NULL); 04329 } 04330 04331 CATCH(CException, e) 04332 { 04333 if (pItem != NULL) 04334 { 04335 ASSERT_VALID(pItem); 04336 pItem->Delete(); 04337 } 04338 AfxMessageBox(_R(IDP_FAILED_TO_CREATE)); 04339 } 04340 END_CATCH 04341 04342 EndBusyCursor(); 04343 04344 #else 04345 04346 // OLE 1.0 default implementation. 04347 wxString strTypeName; 04348 04349 #if (_MFC_VER < 0x300) 04350 if (!AfxOleInsertDialog(strTypeName)) 04351 return; // no OLE class selected 04352 #endif 04353 04354 TRACE( _T("Trying to Insert OLE item with type '%s'\n"), (const char*)strTypeName); 04355 04356 // TODO: create an embedded OLE object with that class name 04357 char szT[300]; 04358 wsprintf(szT, "Listen pal - don't do that again! This " 04359 "particular function is not completely implemented.\n" 04360 "You must add code to create a COleClientItem with a " 04361 "type name of '%s'. See ScreenView::OnInsertObject in\n" 04362 "CAMVW.CPP for more info.", (LPCSTR)strTypeName); 04363 AfxMessageBox(szT); 04364 04365 #endif 04366 } 04367 #endif 04368 04369 04370 /********************************************************************************************* 04371 > afx_msg void ScreenView::OnCancelEdit() 04372 04373 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (AppWizard 2.5) 04374 Created: 19 Jan 94 04375 Inputs: - 04376 Outputs: - 04377 Returns: - 04378 Purpose: "The following command handler provides the standard keyboard user interface 04379 to cancel an in-place (OLE 2.0) editing session." 04380 Errors: - 04381 Scope: Protected 04382 SeeAlso: ScreenView::IsSelected() 04383 04384 **********************************************************************************************/ 04385 04386 #if (_OLE_VER >= 0x200) 04387 04388 PORTNOTE("other","Removed ScreenView::OnCancelEdit usage") 04389 #ifndef EXCLUDE_FROM_XARALX 04390 void ScreenView::OnCancelEdit() 04391 { 04392 SetCurrentStates(); 04393 if (GetDocument()) 04394 { 04395 // Close any in-place active item on this view. 04396 COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); 04397 if (pActiveItem != NULL) 04398 { 04399 pActiveItem->Close(); 04400 } 04401 04402 ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL); 04403 } 04404 } 04405 #endif 04406 #endif 04407 04408 04409 04410 04411 /********************************************************************************************* 04412 > afx_msg void ScreenView::OnSetFocus(wxWindow* pOldWnd) 04413 04414 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (AppWizard 2.5) 04415 Created: 19 Jan 94 04416 Inputs: - 04417 Outputs: - 04418 Returns: - 04419 Purpose: "Special handling of OnSetFocus is required for a container when an object 04420 is being edited in-place (OLE 2.0)." 04421 Errors: - 04422 Scope: Protected 04423 SeeAlso: ScreenView::IsSelected() 04424 04425 **********************************************************************************************/ 04426 04427 #if (_OLE_VER >= 0x200) 04428 04429 void ScreenView::OnSetFocus(wxWindow* pOldWnd) 04430 { 04431 SetCurrentStates(); 04432 if (GetDocument()) 04433 { 04434 COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); 04435 if (pActiveItem && (pActiveItem->GetItemState() == COleClientItem::activeUIState)) 04436 { 04437 // need to set focus to this item if it is in the same view 04438 wxWindow* pWnd = pActiveItem->GetInPlaceWindow(); 04439 if (pWnd) 04440 { 04441 pWnd->SetFocus(); // don't call the base class 04442 return; 04443 } 04444 } 04445 04446 CCamView::OnSetFocus(pOldWnd); 04447 } 04448 } 04449 04450 #endif 04451 04452 04453 /******************************************************************************************** 04454 > afx_msg LRESULT ScreenView::OnDescribeView(WPARAM, LPARAM); 04455 04456 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 04457 Created: 5/4/94 04458 Inputs: (not used) 04459 Outputs: - 04460 Returns: 0 (not used) 04461 Purpose: Dumps some vital statistics about this ScreenView in response to the 04462 privately-defined WM_DESCRIBEVIEW message, sent by double-clicking on 04463 a view's bottom-right corner gadget. Only included in debug builds. 04464 Errors: - 04465 SeeAlso: CScrollerCorner::OnRBtnDblClick; CCamMDIChild::OnNcRBtnDblClk 04466 ********************************************************************************************/ 04467 04468 #ifdef _DEBUG 04469 04470 PORTNOTE("other","Removed ScreenView::OnDescribeView usage") 04471 #ifndef EXCLUDE_FROM_XARALX 04472 LRESULT ScreenView::OnDescribeView(WPARAM, LPARAM) 04473 { 04474 SetCurrentStates(); 04475 04476 // Report the connexions to other objects. 04477 TRACE( _T("\nScreenView at address 0x%lX (1 of %d)\n"), (UINT32) this, HowMany()); 04478 TRACE( _T("\tAttached to CCamDoc at 0x%lX\n"), (UINT32) GetDocument()); 04479 TRACE( _T("\t ViewState at 0x%lX\n"), (UINT32) Status); 04480 TRACE( _T("\t DocView at 0x%lX\n"), (UINT32) pDocView); 04481 TRACE( _T("\t Document at 0x%lX\n"), (UINT32) pDocView->GetDoc()); 04482 TRACE( _T("\t FrameWnd at 0x%lX\n"), (UINT32) GetParentFrame()); 04483 TRACE( _T("\t RenderWnd at 0x%lX\n\n"), (UINT32) RenderWindow); 04484 04485 // Report window handles, to help when using Spy. 04486 TRACE( _T("\tHandles: ScreenView 0x%lX\n"), (UINT32) m_hWnd); 04487 TRACE( _T("\t CCamMDIChild 0x%lX\n"), (UINT32) (GetParentFrame()->m_hWnd)); 04488 TRACE( _T("\t CRenderWnd 0x%lX\n"), (UINT32) RenderWindow->m_hWnd); 04489 04490 // Report the "placement" of the frame window, in pixels. 04491 WINDOWPLACEMENT wp; 04492 wp.length = sizeof(wp); 04493 GetParentFrame()->GetWindowPlacement(&wp); 04494 04495 const TCHAR* pcsz; 04496 switch (wp.showCmd) 04497 { 04498 case SW_SHOWNORMAL: 04499 pcsz = TEXT("normal"); 04500 break; 04501 04502 case SW_SHOWMAXIMIZED: 04503 pcsz = TEXT("maximised"); 04504 break; 04505 04506 case SW_SHOWMINIMIZED: 04507 pcsz = TEXT("minimised"); 04508 break; 04509 04510 default: 04511 pcsz = TEXT("some weird"); 04512 break; 04513 } 04514 04515 TRACE( _T("\n\tFrame is in %s state.\n"), pcsz); 04516 TRACE( _T("\tIcon at (%d, %d)\n"), wp.ptMinPosition.x, wp.ptMinPosition.y); 04517 TRACE( _T("\tNormally at (%d, %d) --> (%d, %d)\n"), 04518 wp.rcNormalPosition.left, wp.rcNormalPosition.top, 04519 wp.rcNormalPosition.right, wp.rcNormalPosition.bottom); 04520 TRACE( _T("\tMaximised at (%d, %d)\n\n"), wp.ptMaxPosition.x, wp.ptMaxPosition.y); 04521 if(GetDocument()) 04522 { 04523 // Report the document flags. 04524 CCamDoc* pDoc = (CCamDoc*) GetDocument(); 04525 TRACE( _T("\nDocument flags:-\n")); 04526 TRACE( _T("\tAuto-deletable: is %s\n", (pDoc->IsUntouched() ? "TRUE" : "FALSE"))); 04527 TRACE( _T("\tModified: is %s\n", (pDoc->IsModified() ? "TRUE" : "FALSE"))); 04528 TRACE( _T("\tRead Only: is %s\n", (pDoc->IsReadOnly() ? "TRUE" : "FALSE"))); 04529 TRACE( _T("\tCopy: is %s\n\n", (pDoc->IsACopy() ? "TRUE" : "FALSE"))); 04530 } 04531 // Now dump out the ViewState, if there is one. 04532 if (Status != NULL) 04533 { 04534 Status->Dump(); 04535 } 04536 else 04537 { 04538 TRACE( _T("There is no ViewState attached to this ScreenView!\n")); 04539 } 04540 04541 return 0; 04542 } 04543 #endif 04544 #endif // _DEBUG 04545 04546 04547 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 04548 04549 /******************************************************************************************** 04550 04551 > void ViewDragTarget::ViewDragTarget() 04552 04553 Author: Chris_Snook (Xara Group Ltd) <camelotdev@xara.com> 04554 Created: 12/1/95 04555 Inputs: - 04556 Outputs: - 04557 Returns: - 04558 Purpose: Constructor 04559 Errors: - 04560 SeeAlso: - 04561 04562 ********************************************************************************************/ 04563 ViewDragTarget::ViewDragTarget(HWND TheWindow, CRect *ClientArea, DragInformation* pDragInfo) 04564 :WinoilDragTarget(TheWindow,ClientArea ) 04565 { 04566 pThisDoc = ScreenView::GetDocViewFromHwnd(TheWindow); 04567 OverOutline = FALSE; 04568 OverNode = NULL; 04569 04570 pCurrentDragInfo = pDragInfo; 04571 04572 DocView::GetCurrentMousePos(&pSpread, &DropPos); 04573 04574 // Find out the Magnetic Line Radius preference from its owner 04575 LineRad = NodeRenderableBounded::MagneticLineRadius; 04576 04577 // Scale it according to the ScaleFactor. 04578 if (pThisDoc!=NULL) 04579 { 04580 // Get the Scale factor and modify the magnetic radius 04581 double Scale = pThisDoc->GetViewScale().MakeDouble(); 04582 LineRad = (INT32) ((double)LineRad / Scale); 04583 } 04584 04585 } 04586 04587 04588 04589 /******************************************************************************************** 04590 04591 > void ViewDragTarget::GetCursorID() 04592 04593 Author: Chris_Snook (Xara Group Ltd) <camelotdev@xara.com> 04594 Created: 10/1/95 04595 Purpose: Base Method to set cursor over this target 04596 04597 04598 ********************************************************************************************/ 04599 04600 UINT32 ViewDragTarget::GetCursorID() 04601 { 04602 ERROR2IF(pCurrentDragInfo==NULL,FALSE,"No DragInfo available when getting Cursor"); 04603 04604 return pCurrentDragInfo->GetCursorID(this); 04605 } 04606 04607 04608 04609 /******************************************************************************************** 04610 04611 > virtual BOOL ViewDragTarget::GetStatusLineText(String_256 * TheText) 04612 04613 Author: Chris_Snook (Xara Group Ltd) <camelotdev@xara.com> 04614 Created: 15/1/95 04615 Returns: Whether String is valid 04616 Purpose: provide status line text for this target 04617 04618 ********************************************************************************************/ 04619 04620 04621 BOOL ViewDragTarget::GetStatusLineText(String_256 * TheText) 04622 { 04623 ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()"); 04624 ERROR2IF(pCurrentDragInfo==NULL,FALSE,"No DragInfo available when getting Status Text"); 04625 04626 return pCurrentDragInfo->GetStatusLineText(TheText, this); 04627 } 04628 04629 /******************************************************************************************** 04630 04631 > BOOL ViewDragTarget::GetDropInfo(PageDropInfo* pDropInfo) 04632 04633 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 04634 Created: 25/3/95 04635 Inputs: - 04636 Outputs: - 04637 Returns: - 04638 Purpose: Get info about the current drag state of this target 04639 Errors: - 04640 SeeAlso: - 04641 04642 ********************************************************************************************/ 04643 04644 BOOL ViewDragTarget::GetDropInfo(PageDropInfo* pDropInfo) 04645 { 04646 ERROR2IF(pDropInfo==NULL,FALSE,"NULL DropInfo pass to GetDropInfo()"); 04647 04648 pDropInfo->pDocView = pThisDoc; 04649 pDropInfo->pDoc = pThisDoc->GetDoc(); 04650 pDropInfo->pSpread = pSpread; 04651 pDropInfo->DropPos = DropPos; 04652 04653 pDropInfo->TargetHit = OverTarget; 04654 pDropInfo->pObjectHit = OverNode; 04655 04656 return TRUE; 04657 } 04658 04659 /******************************************************************************************** 04660 04661 > void ViewDragTarget::ProcessEvent(DragEventType Event, 04662 DragInformation *pDragInfo, 04663 wxPoint *pMousePos, KeyPress* pKeyPress) 04664 04665 Author: Chris_Snook (Xara Group Ltd) <camelotdev@xara.com> 04666 Created: 12/1/95 04667 Inputs: - 04668 Outputs: - 04669 Returns: - 04670 Purpose: Event Handler for View Drag target 04671 Errors: - 04672 SeeAlso: - 04673 04674 ********************************************************************************************/ 04675 04676 BOOL ViewDragTarget::ProcessEvent(DragEventType Event, 04677 DragInformation *pDragInfo, 04678 wxPoint *pMousePos, KeyPress* pKeyPress) 04679 { 04680 switch (Event) 04681 { 04682 case DRAGEVENT_INITIALISE: 04683 break; 04684 case DRAGEVENT_ABORT: 04685 break; 04686 case DRAGEVENT_KEYPRESS: 04687 break; 04688 case DRAGEVENT_COMPLETED: 04689 { 04690 // Do another HitTest check 04691 OverNode = NULL; 04692 DocView::GetCurrentMousePos(&pSpread, &DropPos); 04693 OverTarget = pThisDoc->IsPointerOverNode(&OverNode,LineRad,FALSE,TRUE); 04694 04695 if (!OverNode) OverTarget = NO_TARGET; 04696 04697 // call doc dragfinished to do whatever is needed 04698 return pThisDoc->DM_DragFinished(pDragInfo,this); 04699 break; 04700 } 04701 case DRAGEVENT_MOUSESTOPPED: 04702 case DRAGEVENT_MOUSEMOVED: 04703 case DRAGEVENT_MOUSEIDLE: 04704 { 04705 OverNode = NULL; 04706 DocView::GetCurrentMousePos(&pSpread, &DropPos); 04707 OverTarget = pThisDoc->IsPointerOverNode(&OverNode,LineRad, TRUE, TRUE); 04708 04709 if (!OverNode) OverTarget = NO_TARGET; 04710 04711 return TRUE; 04712 break; 04713 } 04714 } 04715 return FALSE; 04716 } 04717 04718 /******************************************************************************************** 04719 04720 Author: Marc_Power (Xara Group Ltd) <camelotdev@xara.com> 04721 Created: 6/10/95 04722 Purpose: The framework calls this member function when the user clicks a window's 04723 horizontal scroll bar. 04724 04725 ********************************************************************************************/ 04726 04727 void ScreenView::OnHScroll( UINT32 nSBCode, UINT32 nPos, CScrollBar*) 04728 { 04729 if(HScrollBar) 04730 { 04731 HScrollBar->HandleScrollMessage(nSBCode, nPos); 04732 } 04733 } 04734 04735 /******************************************************************************************** 04736 04737 Author: Marc_Power (Xara Group Ltd) <camelotdev@xara.com> 04738 Created: 6/10/95 04739 Purpose: The framework calls this member function when the user clicks a window's 04740 vertical scroll bar. 04741 04742 ********************************************************************************************/ 04743 04744 void ScreenView::OnVScroll( UINT32 nSBCode, UINT32 nPos, CScrollBar*) 04745 { 04746 if(VScrollBar) 04747 { 04748 VScrollBar->HandleScrollMessage(nSBCode, nPos); 04749 } 04750 } 04751 04752 04753 #endif // EXCLUDE_FROM_RALPH, EXCLUDE_FROM_XARALX