ralphdoc.h

Go to the documentation of this file.
00001 // $Id: ralphdoc.h 1282 2006-06-09 09:46:49Z 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 
00100 
00101 #ifndef RALPHDOC_INC
00102 #define RALPHDOC_INC
00103 
00104 class Document;
00105 class RalphView;
00106 
00107 //#include <afxole.h>
00108 //#include "ralphint.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "wrkcoord.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 #include "ccafile.h"
00112 //#include "docrect.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 
00114 // constant used for claiming timer for window
00115 const INT32             CAM_TIMER_ID = 42;
00116 // constant used for frequency of timer events (in milliseconds)
00117 const INT32             CAM_TIMER_FREQUENCY  = 100;
00118 // When async loading how many clock ticks before we render anything.
00119 const INT32             ASYNC_RENDER_RATE = 3;
00120                                                                       
00121 #define TEMP_FILE_PREFIX "XAR"
00122 
00123 #define QUALITY_LEVEL_ANTI      110
00124 #define QUALITY_LEVEL_NORMAL    100
00125 #define QUALITY_LEVEL_SIMPLE    50
00126 #define QUALITY_LEVEL_OUTLINE   10
00127 
00128 // must be called at the start of every ralph method
00129 #define START_RALPH_METHOD()    HRESULT hrX = S_OK;\
00130                                 pThis->InsideRalphMethod = TRUE;
00131 
00132 // must be used to return a value from a ralph method                           
00133 #define RALPH_RETURN(hr) {      ASSERT(pThis->InsideRalphMethod);\
00134                                 pThis->InsideRalphMethod = FALSE;\
00135                                 return (hr);}
00136 
00137 // call to test whether a serious ERROR1 has been set - 
00138 // if so will clear the error condition and return                      
00139 #define GET_RALPH_ERROR()       hrX = Error::GetRalphError();\
00140                                 if(hrX!=S_OK && hrX!=RALPH_E_INTERNAL)\
00141                                 {   pThis->InsideRalphMethod = TRUE;\
00142                                     Error::ClearError();\
00143                                     RALPH_RETURN (hrX);}
00144 
00145 
00146 #define WM_DOWNLOADINIT WM_USER + 0x1105    
00147 
00148 #define WM_DOWNLOADCOMPLETE WM_USER + 0x1106
00149 
00150 // Sent from the importer viewcomp result in a zoom to rect in the default thread. Hopefully stops
00151 // corruption of RenderRegion stuff..
00152 #define WM_ZOOMTORECT       WM_USER + 0x1107
00153 
00154 // The old C++ Ralph Document
00155 
00156 /********************************************************************************************
00157 
00158 >   class LoadContext : public CCObject
00159             
00160     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
00161     Created:    20/4/96
00162     Purpose:    To encapsulate all data local to a download
00163 
00164 ********************************************************************************************/
00165 
00166 class LoadContext : public CCObject
00167 {
00168     CC_DECLARE_DYNCREATE( LoadContext )
00169     
00170     public:
00171         LoadContext(); 
00172         virtual ~LoadContext();
00173         // asynch stuff
00174         wxCondition    *hDataAvailableEvent; 
00175         volatile INT32   TotalBytes;
00176         volatile INT32   BytesAvailable;
00177         volatile BOOL   AsynchDownLoadComplete;
00178 
00179 };
00180 // The old C++ Ralph Document
00181 
00182 /********************************************************************************************
00183 
00184 >   class RalphDoc : public CCObject
00185             
00186     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
00187     Created:    20/4/96
00188     Purpose:    
00189 
00190 ********************************************************************************************/
00191 /*
00192 class RalphDoc :    public CCObject
00193 {
00194     CC_DECLARE_DYNCREATE( RalphDoc )
00195     
00196     public:
00197          RalphDoc() { }; 
00198          RalphDoc(HWND ParentWnd);
00199         ~RalphDoc();
00200         
00201         // get a pointer to the ralphview window
00202         CWnd * GetViewWindow();
00203         
00204         // Create a RalphDoc as a child of this window
00205         BOOL Create(HWND ParentWnd);
00206         
00207         // Load a Document
00208         BOOL LoadDocument(TCHAR * pFileToLoad);
00209         
00210         // put the document back into a new state
00211         // delete tree operation history etc..
00212         BOOL NewDocument();
00213 
00214     private:
00215         Document * pDocument;
00216         RalphView * pRalphView;
00217         HWND hParentWnd;
00218 };
00219 */
00220 
00221 /********************************************************************************************
00222 
00223     class RalphDocument: public CCmdTarget
00224 
00225     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00226     Created:    13/6/96
00227     Purpose:    The RalphDocument COM object 
00228 
00229 ********************************************************************************************/
00230 
00231 
00232 class RalphDocument : public wxEvtHandler
00233 {
00234     DECLARE_DYNAMIC_CLASS( RalphDocument )
00235 
00236 protected:
00237     RalphDocument();            // protected constructor used by dynamic creation
00238     virtual ~RalphDocument();
00239 public:
00240     virtual void OnFinalRelease();
00241 
00242     // this state is set whenever a ralph method is entered
00243     // see START_RALPH_METHOD() RALPH_RETURN()
00244     BOOL IsInRalphMethod(){ return InsideRalphMethod;};
00245     
00246     // pass the error to the IErrorCallback if available
00247     BOOL PassErrorToHarness(HRESULT ErrCode);
00248     // Call to pass a web address selection to a harness
00249     void WebAddressSelected(String_256* InAddress);
00250 
00251     static BOOL SelectTool(ToolMode toolmode);
00252     BOOL SelectViewQuality(INT32 ViewQuality);
00253     BOOL SelectViewMode(ViewMode Viewmode);
00254     BOOL SelectDitherType(DitherType Dither);
00255     BOOL SelectPaletteMode(BOOL Foreground);
00256     void SetSelected();
00257     // Functions to change the browser's status bar
00258     void SetStatusBar(String_256* pNewText);
00259     void SetStatusBar(wxString pNewText);
00260     void SetStatusBar();
00261 
00262 
00263     BOOL PrintRalphView( wxDC *TheDC, DWORD X, DWORD Y, DWORD Width, DWORD Height, DWORD DPI);
00264 
00265     // Ralph Document states
00266     DitherType          Dither;
00267     ToolMode            Toolmode;
00268     QualityLevel        Quality;
00269     ViewMode            Viewmode;           // PAGE_VIEW, DOCUMENT_VIEW, DRAWING_VIEW
00270 
00271     // filename of the temp file during the asynch download
00272     //char FileBuffer [_MAX_PATH];
00273     wxString            PathString;
00274                       
00275     CCAsynchDiskFile   *TempWriteAsynchFile;
00276     CCAsynchDiskFile   *TempReadAsynchFile;
00277 
00278     wxThread           *pLoadThread ;
00279     BOOL                IsImportOK;
00280     BOOL                LoadErrorHasOccured;
00281     BOOL                CleanUpAfterAsynchDownLoad(BOOL ok);
00282 
00283 private:
00284     DocRect             ViewportRect; 
00285         // Stores the viewport rectangle we must zoom to in the case of an async render
00286 public:
00287     void SetViewportRect(DocRect& Viewport) { ViewportRect = Viewport; };
00288     DocRect* GetViewportRect() { return &ViewportRect; };
00289 
00290     RalphView * GetRalphView(){ return pRalphView; };
00291 
00292     Document * GetRalphDocument(){return pDocument;};
00293 
00294     String_256 GetDocumentURL();
00295     String_256 GetBaseURL();
00296 
00297     //------------------- Asynch download stuff ----------------
00298     // statics used in the great GetSelected/Current bodge
00299     static Document* GetImportingDoc(){
00300         //if(sm_pImportingDoc != NULL)
00301             //TRACEUSER( "Richard", _T("### GetImportingDoc() returning NON-NULL doc\n"));
00302         return sm_pImportingDoc; };
00303     static DWORD  GetImportingThreadID(){
00304         //if(sm_ImportThreadID != NULL)
00305             //TRACEUSER( "Richard", _T("### GetImportingThreadID() returning NON-NULL ID\n"));
00306         return sm_ImportThreadID;};
00307    
00308     // public cause they are used in the loadthread proc - sorry
00309     static Document* sm_pImportingDoc;
00310     static DWORD sm_ImportThreadID;
00311     
00312     // the event we use to end the download 
00313     static wxCondition *g_hAbortDownLoadEvent; 
00314     
00315     // the safe to enter event
00316     static wxCondition *g_hSafeToEnterLoad;
00317     
00318     // array to hold the above events for multiple waits
00319     static wxCondition *WakeEvents[2];
00320 
00321     static void OnRalphAboutToDie();
00322 
00323     static wxWindow    *pTimerWnd;
00324 
00325     // Set to TRUE on entry and FALSE on exit from the timer proc. 
00326     static BOOL InsideRenderLoop; 
00327 
00328     static void SetRenderTimer(BOOL State);
00329         // Start/Stop the render timer 
00330 protected:
00331     static BOOL RenderTimerOn;
00332 protected:
00333     
00334     // a load context for this document -it encapsulates
00335     // all data required for thread synchronisation during downloads
00336     LoadContext TheLoadContext;
00337 
00338     wxString CurrentStatusText;
00339     wxString DocumentURL;
00340 
00341 PORTNOTE("other","Remove OLE interface table")
00342 #ifndef EXCLUDE_FROM_XARALX
00343     DECLARE_OLECREATE(RalphDocument)
00344 
00345     DECLARE_INTERFACE_MAP()
00346     
00347     BEGIN_INTERFACE_PART(Creation, ICreation)
00348         STDMETHOD(CreateViewWindow) (   HWND ParentWnd,
00349                                         ViewMode Viewmode,
00350                                         BOOL ShowScrollers,
00351                                         BOOL ShowWindow,
00352                                         BOOL HasBorder,
00353                                         HWND * ViewWindow);
00354  
00355         STDMETHOD(LoadDocument) (TCHAR* pFileToLoad);
00356         STDMETHOD(GetVerNum) (TCHAR* pVerNum);
00357         STDMETHOD(RenderToDC) (HDC TheDC, DWORD X, DWORD Y, DWORD Width, DWORD Height, DWORD DPI);
00358     END_INTERFACE_PART(Creation)
00359 
00360 
00361     BEGIN_INTERFACE_PART(CommandControl, ICommandControl)
00362         STDMETHOD (SetToolMode)     (ToolMode toolMode);
00363         STDMETHOD(PreviousZoom)     ();
00364         STDMETHOD(ZoomToDrawing)    ();
00365         STDMETHOD(ZoomToFullScale)  ();
00366         STDMETHOD(SetQuality)       (QualityLevel Quality);
00367         STDMETHOD(SetDitherType)    (DitherType Dither) ;
00368         STDMETHOD(SetPaletteMode)   (BOOL Foreground) ;
00369         STDMETHOD(HasPreviousZoom)  () ;
00370         STDMETHOD(SetURL)           (wxString InURL);
00371  
00372     END_INTERFACE_PART(CommandControl)
00373 
00374     BEGIN_INTERFACE_PART(ViewControl, IViewControl)
00375         STDMETHOD (ShowScrollers) ( BOOL State);
00376         STDMETHOD (SetViewMode ) (ViewMode Viewmode);
00377     END_INTERFACE_PART(ViewControl)
00378 
00379     BEGIN_INTERFACE_PART(InitRalph, IInitRalph)
00380         STDMETHOD (SetErrorCallback) (IErrorCallback* pCallbackInterface);
00381         STDMETHOD (SetEventCallback) (IEventCallback* pCallbackInterface);
00382     END_INTERFACE_PART(InitRalph)
00383 
00384     BEGIN_INTERFACE_PART(AsynchDownLoad, IAsynchDownLoad)
00385         STDMETHOD(StartAsynchDownLoad) ();
00386         STDMETHOD(OnDataAvailable) (unsigned char* pReadBuffer,DWORD BytesRead);
00387         STDMETHOD(EndAsynchDownLoad) (HRESULT Status);
00388     END_INTERFACE_PART(AsynchDownLoad)
00389 #endif
00390 
00391 
00392 private:
00393     
00394     Document           *pDocument;      // A pointer to the document associated with an instance of a 
00395                                         // RALPH Document. 
00396     RalphView          *pRalphView;     // The one and only view that can be associated with the document. 
00397     wxWindow           *hParentWnd;
00398     BOOL DocumentViewInit;
00399     BOOL ZoomToFullScale();
00400     BOOL SaveZoomAndScroll();
00401     BOOL RestoreZoomAndScroll();
00402     BOOL SetDocumentViewMode(); // set up initial zoom and scroll offsets
00403 
00404     // used to save the last zoom and scroll offsets
00405     INT32 LastZoomIndex ;
00406     FIXED16 LastViewScale ;
00407     WorkCoord LastScrollOffset ;
00408     IErrorCallback * pIErrorCallback;
00409     IEventCallback * pIEventCallback;
00410 
00411     
00412     // flag set on entering ralph methods - cleared on exit
00413     // used by the error reporting system
00414     BOOL InsideRalphMethod ; 
00415 
00416 
00417 
00418     BOOL StartLoadThread();
00419     BOOL EndAsynchDownLoad(HRESULT Status);
00420     BOOL OnDataAvailable(unsigned char* pReadBuffer,DWORD BytesRead);
00421     
00422     static INT32 RalphDocCnt;
00423 
00424     wxCursor           *hOldCurs;
00425     
00426 public:
00427     // Flag for forcing a palette or not. The quick viewer should set this
00428     // to TRUE so it can force its own palette in the foreground. The plugins
00429     // should set it to FALSE, since they're dependant on their host...
00430     static BOOL ForegroundPalette;
00431 
00432     static void* RestoreStackLimit;
00433 
00434     // this will be called from the destructor of RalphView
00435     // to ensure that it isn't deleted twice
00436     void MakepRalphViewNULL() {pRalphView = NULL;};
00437 };
00438 
00439 
00440 #endif

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