basebar.h

Go to the documentation of this file.
00001 // $Id: basebar.h 1361 2006-06-25 16:43:38Z 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 /* $Log*/
00099 
00100 #ifndef INC_BASEBAR
00101 #define INC_BASEBAR
00102 
00103 //#include "dockbar.h"  - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 
00106 
00107 #ifndef WIN32
00108 #include "dlgmgr.h"     // for DLGTEMPLATE etc
00109 #endif
00110 
00111 
00112 class Cursor;
00113 
00114 #define TITLE_BAR_HEIGHT 10 
00115 #define BAR_BORDERSIZE 4
00116 #define BAR_VERTICAL_CENTEROFFSET 2
00117 #define BAR_HORIZONTAL_CENTEROFFSET 3
00118 
00119 #define DO_TIDY TRUE
00120 #define DONT_TIDY FALSE
00121 
00122 #define CHANGE_MARGIN 4
00123 
00124 #define INFOBAR_WIDTH 600
00125 
00126 #define DRAG_START_MARGIN 1
00127 
00128 // the gap between lines of controls on floating bars
00129 #define VERTICAL_SPACE 2
00130 
00131 enum DDeckerControlHeights { SMALL_DDECKERS = 13, LARGE_DDECKERS  = 16 };
00132 
00133 // BaseBars can either be in a dialog or a bar mode
00134 enum BaseBarMode {DIALOG, BAR}; 
00135 
00136 // The different drag types 
00137 enum DlgDragType { NONE = 0, MOVE, GROW_NORTH, GROW_SOUTH, GROW_EAST, GROW_WEST,
00138                 GROW_SOUTHEAST,GROW_NORTHEAST,GROW_SOUTHWEST,GROW_NORTHWEST, TRYING };
00139 
00140 // The Nearest edge to dragged bar 
00141 enum NearestEdge { LEFT,RIGHT,TOP,BOTTOM,NOEDGE };
00142 
00143 enum SeparatorWidths { SMALL_SEPARATOR = 6,LARGE_SEPARATOR = 10};
00144 
00145 
00146 enum ForceControlSize { USE_BAR,FORCE_SMALL,FORCE_LARGE};
00147 
00148 enum DDeckerReadState {DDECKER_NONE,DDECKER_TOP,DDECKER_BOTTOM};
00149 
00150 enum ControlDragMode{CUT,COPY};
00151 
00152 enum ControlDragState{READY,DRAGGING,NO_DRAG};
00153 
00154 typedef enum
00155 {
00156     BUTTON,
00157     BITMAPBUTTON,
00158     SMALLBITMAPBUTTON,
00159     STATICBITMAP,
00160     DECKER_TOP,
00161     DECKER_BOTTOM,
00162     DECKER_END,
00163     SEPARATOR,
00164     LINEFEED,
00165     COMBO,
00166     EDIT,
00167     LIST,
00168     STATIC,
00169     SCROLLBAR,
00170     TEXT3D,
00171     ROTATEGRID,
00172     OTHERCONTROL,
00173     SLIDER,
00174     BITMAPCOMBO1D,
00175     BITMAPCOMBO2D,
00176     UNKNOWN_ITEM    
00177 } BarItemType;
00178 
00179 BarItemType GetEnumItemType(BarItem * Item);
00180 
00181 /********************************************************************************************
00182 
00183 >   class FormatPosition : public ListItem
00184 
00185     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
00186     Created:    22/5/94
00187     Purpose:    A class used for holding Format Positions.
00188 
00189 ********************************************************************************************/
00190 
00191 class FormatPosition : public ListItem
00192 {
00193     CC_DECLARE_DYNAMIC( FormatPosition )
00194 
00195 public:
00196     INT32 Height;
00197     INT32 Width;
00198 
00199     FormatPosition()
00200     {
00201         Height=0;
00202         Width=0;
00203     };
00204     
00205     FormatPosition(INT32 w,INT32 h)
00206     {
00207         Height =h;
00208         Width =w;
00209     };
00210 
00211 
00212 };
00213 
00214 
00215 
00216 /********************************************************************************************
00217 
00218 >   class BaseBar : public CWnd
00219 
00220     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00221     Created:    30/03/94
00222     SeeAlso:    DialogBarOp
00223 
00224 ********************************************************************************************/
00225 
00226 
00227 class BaseBar : public wxWindow
00228 {
00229 public:
00230     
00231     BaseBar(); 
00232     virtual ~BaseBar();
00233 
00234     static BOOL DeclarePreferences();
00235     static BOOL PlotStretchedMaskedBitmap(wxDC* destDC, wxBitmap* srcBitmap, wxRect Pos); // UIC
00236     static BOOL HaveNonClientMetricsChanged(); // UIC
00237 
00238     INT32 Create(DialogBarOp* Op);
00239     BOOL Hide(DialogBarOp* Op);
00240     BOOL Show(DialogBarOp* Op);
00241 
00242         
00243     BOOL Recreate(DockBarType DockBarTyp, BaseBar* BaseBar, DialogBarOp* Op,BOOL CanCopy );
00244     BOOL RecreateAt(KernelBarPos Pos,DockBarType DockBarTyp,
00245                BaseBar* BaseBar, DialogBarOp* Op, wxWindow* OldHwnd );  
00246 
00247     static BOOL IsDoingErrorBox();
00248     static void StartErrorBox();
00249     static void FinishErrorBox();
00250 
00251     static BOOL IsBarInRecreate();
00252     static BOOL GetStatusLineText(String_256 * StatusText);
00253 
00254     static BOOL HasGalleryGotFocus(){return GalleryHasFocus;};
00255         
00256     static BOOL AltPressed(BOOL state);
00257     static BOOL CtlPressed(BOOL state);
00258     static BOOL EscPressed(BOOL state);
00259     static BOOL CancelAllDrags();
00260     static void ClearFocusFlags(){ControlHasFocus = FALSE;HwndWithFocus =(wxWindow*)0;}; // used to be ControlHasFocus+=NULL ???
00261 
00262     void ConvertToolbarOnStartup ();
00263     static BaseBar* GetPtrToToolBar () { return (PtrToToolBar); }
00264     BOOL FormatToolBar (INT32 NewWidth);
00265     DialogBarOp* GetDialogBarOp () { return (pOp); }
00266     wxRect GetBarsDims (DockBarType DockBarType);
00267 
00268     BOOL TidyUpControlDrag();
00269     BOOL TidyUpBarDrag();
00270 
00271     UINT32 GetNearestControl(wxPoint DropPoint);
00272     BOOL IsBarActive(){return Active;};
00273     BOOL IsInfoBar(){ return ThisIsAnInfoBar ;} ;
00274     BOOL IsBarAllCtlBar(){return pOp->IsAllBarsOp(); };
00275     
00276     void SetBarActiveState(BOOL State){ Active = State;};
00277     
00278     // Get cached rectangle 
00279     virtual wxRect GetFormatRect(DockBarType BarType);
00280 
00281     void InitFormatRects();
00282 
00283     String_32 GetBarName(){return pOp->GetName();};
00284 
00285     LRESULT WindowProc( UINT32 message, WPARAM wParam, LPARAM lParam ); 
00286 
00287     DECLARE_DYNAMIC_CLASS( BaseBar )
00288     DECLARE_EVENT_TABLE()
00289 
00290 protected:
00291     
00292     // -------------------------------------------------------------------------------------
00293     // Functions 
00294     
00295     
00296     BOOL EndControlDrag(wxPoint point);
00297     BOOL DropControl(wxPoint point,wxWindow* OverBar,BOOL InsertSeparator);
00298     void CacheAllDockRects();
00299 
00300     void Paint3dPlinth(wxDC* pDC, wxRect *rect, BOOL PlinthOut);
00301 
00302     // Test if dragged bar will touch a dock
00303     virtual DockBarType BarCloseToDock(wxPoint CursorPos);
00304 
00305     // just sets up a few variables must be called at every create ( and recreate etc ..)
00306     virtual void SetFormatVariables();
00307                             
00308     // Used to paint the non-client area when in DIALOG mode
00309     virtual void PaintDialogNonClient(BOOL Active);
00310     
00311     virtual void PaintWin95DialogNonClient(BOOL IsActive);
00312 
00313     virtual void PaintChicagoBorder();
00314 
00315     // Paints the XOR drag rectangle 
00316     void PaintXORDragRect(wxRect Rect, DockBarType DockBar); 
00317     
00318     void PaintDragRect(wxRect Rect,wxRect OldRect,DockBarType DockBar,DockBarType OldBarType);
00319 
00320     // The StartDrag function is used to start a move or resize drag
00321     virtual void StartDrag(wxPoint point, DlgDragType TypeOfDrag);
00322 
00323     // Used to decide whether we can start a drag yet
00324     virtual BOOL CanStartDrag(wxPoint point);
00325 
00326     virtual DockBarType IsPointerOverDock(wxPoint point);
00327 
00328     // Close all dropdown windows
00329     void CloseCombos();
00330 
00331     virtual wxRect GetDragFormatRect(DockBarType BarType, wxPoint CursorPos, BOOL ToLeft, BOOL Below);
00332 
00333     // Get new drag offsets if rectangle has changed shape
00334     virtual wxPoint CalcDragOffset(wxRect DragRect, wxPoint CursorPos, BOOL ToLeft, BOOL Below);
00335     virtual void CalcDragOffsetDirection(DockBarType BarType, wxPoint CursorPos);
00336 
00337     BOOL SimpleIntersect( const wxRect &rect1, const wxRect &rrect2 );
00338 
00339 
00340     // This function returns back a rectangle defining the shape of the DlgBar if it was dropped 
00341     // in the specified docking bar. 
00342     virtual wxRect GetDlgBarRect(DockBarType DockBar, wxRect CurrentBarRect); 
00343 
00344     // Used to inform ControlHelper that controls are about to die
00345     void InformControlsDead(); 
00346 
00347     // Used to copy or load resource controls
00348     BOOL CopyOrLoadControls(wxWindow* BarHwnd);
00349 
00350     // Loads the operation's resource controls into the window
00351     BOOL LoadResourceControls(); 
00352 
00353     // Creates tool bitmap button control
00354     BOOL CreateToolBtn(BarToolButton* pToolBtn);
00355 
00356     // Position and Format controls
00357     virtual BOOL PositionControls(BOOL DoRedraw = TRUE);
00358 
00359     HINSTANCE GetModuleInst(const BarControlInfo*pBarCtlInfo,UINT32 * ToolModuleID );
00360     
00361     DLGITEMTEMPLATE* GetPointerToControl(DLGTEMPLATE* pDlg ,UINT32 CtlId);
00362     
00363     // Creates a control from a resource
00364 
00365     BOOL CreateControlFromResource(BarControl* pBarItem);
00366     
00367     BOOL CreateInfoControlFromResource(BarControl* pBarItem,BOOL Init);
00368 
00369     // CreateControlFromResource helper which actually creates the control
00370     BOOL CreateControlItem(DLGITEMTEMPLATE * pCurrentControl, 
00371                            BarControl* pBarItem, 
00372                            HINSTANCE ModuleInst,
00373                            UINT32 ToolModuleID);
00374 
00375     // Format this bar according to its dock type
00376     virtual BOOL FormatBar(BOOL MoveWindows,ForceControlSize Force);
00377 
00378     // Format a Floating bar from the kernel BarItem list
00379     virtual BOOL FormatFloatingBar(BOOL MoveWindows,ForceControlSize Force);
00380 
00381     // Format a Horizontal bar from the kernel BarItem list
00382     virtual BOOL FormatHorizontalBar(BOOL MoveWindows,ForceControlSize Force);
00383 
00384     // Format a Vertical bar from the kernel BarItem list
00385     virtual BOOL FormatVerticalBar(BOOL MoveWindows,ForceControlSize Force);
00386 
00387     // tidy up line feeds after control drag
00388 
00389     BOOL TidyBarItemsAfterDrag();
00390 
00391     // Format LineFeeds in a Floating Bar
00392     BOOL FormatLineFeeds(INT32 Targetx,wxSize * pBarSize = NULL,INT32 * pNoLfs = NULL);
00393 
00394     // Return Current (Slot / Offset ) (Floating x / y) position
00395     KernelBarPos  * GetBarPosition();
00396     
00397     // Return  Parent  DockBarType
00398     DockBarType GetDockBarType();
00399 
00400     // Return TRUE if dock has switched vertical/horizontal
00401     BOOL HasOrientationChanged(DockBarType Old,DockBarType New);
00402     
00403     // Swap cursors during drag cut/copy
00404     static BOOL  SwapCursors(DWORD CursorID);
00405 
00406     // Size the actual window
00407     virtual wxRect SetBarSize(DockBarType BarType,BOOL DoRedraw = TRUE);
00408 
00409     // Adjust the size of a bar post format
00410     virtual void AdjustFormattedBarSize(wxSize* BarSize);
00411 
00412     // Create any extra controls
00413     virtual INT32 CreateExtraControls();
00414 
00415     // Position any extra controls
00416     virtual void PositionExtraControls(wxSize BarSize, INT32 xpos, INT32 ypos);
00417 
00418     // Cache the data we need to improve vertical resizing
00419     BOOL CacheFormatingData();
00420     BOOL GetBestCachedWidth(INT32 TargetHeight, INT32 * FoundWidth);
00421 
00422     // set status line text
00423     virtual BOOL SetStatusLineText();
00424 
00425     // get Status line text in a buffer
00426     virtual BOOL GetStatusText(String_256 * StatusTextBuf);
00427      
00428     // Resource utility fns
00429     LPWSTR MovePastWideStr(LPWSTR pWideStr);
00430     size_t SizeDlgHeader(DLGTEMPLATE *pHeader); 
00431     size_t SizeCtrlData(DLGITEMTEMPLATE *pControl);
00432 
00433 
00434 
00435     // -------------------------------------------------------------------------------------
00436     
00437     static BaseBar * CurrentBar;
00438 
00439     // We need to store a pointer to the operation so we can inform it when its window changes
00440     DialogBarOp* pOp; 
00441 
00442     // The docking bar on which the bar is currently placed
00443     DockBarType ParentDockBarType;
00444 
00445     // The docking bar the dialog bar is over during a drag
00446     DockBarType DragDockBarType; 
00447     
00448     // The docking bar the dialog bar was over last
00449     DockBarType OldDragBarType;
00450 
00451     DockBarType LastFixedDragType;
00452 
00453     // Actual parent of this bar
00454     OILDockingBar* ParentDockBar;
00455 
00456     // Used when painting
00457     wxPaintDC *PaintDC;
00458 
00459     // used to create drag brush
00460     wxBitmap BrushBitmap ;
00461 
00462     // The current dialog bar mode DIALOG/BAR
00463     BaseBarMode CurrentDlgBarMode;
00464     
00465     wxRect ScreenRect;
00466 
00467     // Rects for Drop Hit Testing
00468     wxRect TopRect;
00469     wxRect LeftRect;
00470     wxRect RightRect;
00471     wxRect BottomRect;
00472 
00473 
00474     // The drag cursors
00475     static Cursor*  pCurrentCursor;
00476     static Cursor*  pButtonCopyCursor;
00477     static Cursor*  pButtonCutCursor;
00478     static INT32        CurrentCursorID;
00479     static INT32        BorderWidth ;
00480     static INT32        TitleBarHeight ;
00481 
00482 
00483     // When the DialogBar is in dialog mode the following rectangles specify the dialogs active 
00484     // regions. They are used for hit detection.  
00485 
00486 
00487     wxRect SysMenuRect;
00488     wxRect TopBorderRect;
00489     wxRect BottomBorderRect;
00490     wxRect LeftBorderRect;
00491     wxRect RightBorderRect;
00492     wxRect CaptionBarRect;
00493     wxRect TopLeftGrowRect;
00494     wxRect BottomLeftGrowRect;
00495     wxRect TopRightGrowRect;
00496     wxRect BottomRightGrowRect;
00497 
00498     //current separator width
00499 
00500     SeparatorWidths SeparatorWidth;
00501 
00503     //INT32 BorderWidth;
00504 
00505 
00506     INT32 HeightEstimate;
00507 
00508         // used during resize floatingbar operations
00509     double WidestFloat;
00510     double TallestFloat;
00511 
00512     // Used to record x values that will cause a new floating format
00513     List FormatPositions ;
00514 
00515     wxRect DragStartRect;
00516 
00517     static DlgDragType DragType;  // Set to NONE when no drag is taking place
00518 
00519     static BOOL InRecreate;
00520 
00521     static BOOL DoingErrorBox;      // Used so error boxes created when galleries are opening aren't fatal
00522 
00523     static BOOL ControlHasFocus;
00524     
00525     static wxWindow* HwndWithFocus ;
00526 
00527     static BOOL GalleryHasFocus ;
00528 
00529     // NEW BUTTON STUFF
00530     static UINT32 GalButtonWidth;
00531 
00532 
00533     // use this to switch background rendering back on after a drag if needed
00534     static BOOL IsBackGroundRendering;
00535 
00536     BOOL ListBoxHasFocus;
00537     
00538     // mouse position at start of drag
00539     wxPoint StartDragPoint ;
00540     
00541     // DragOffset used when moving window
00542     wxPoint DragOffset;   
00543     BOOL    DragOffsetFromTop;
00544     BOOL    DragOffsetFromLeft;
00545 
00546     KernelBarPos LastSmallBarPos;
00547 
00548     // Offset used in resize
00549     wxPoint BorderOffset;
00550 
00551     static wxRect OldDragRect; 
00552 
00553     // Cached Format Rects
00554     wxRect FloatSmallRect;
00555     wxRect HorizontalSmallRect;
00556     wxRect VerticalSmallRect;
00557     wxRect FloatLargeRect;
00558     wxRect HorizontalLargeRect;
00559     wxRect VerticalLargeRect;
00560 
00561 PORTNOTE("other", "removed fonts from bars")
00562 #ifndef EXCLUDE_FROM_XARALX
00563     // Font to paint caption
00564     wxFont * TitleFont;
00565 
00566     // Font to use in bars
00567     wxFont * BarFont;
00568 
00569     // Fonts to use in double decker controls
00570     wxFont * SmallThinFont;
00571     wxFont * LargeThinFont;
00572 #endif
00573 
00574     // Is Bar an InfoBar 
00575     BOOL ThisIsAnInfoBar ;
00576 
00577 
00578     // Is Bar painted Active
00579     BOOL Active;
00580 
00581     static wxWindow * LastWindowWithFocus;
00582 
00583     // The following windows objects are cached when a drag starts and released 
00584     // when it ends. 
00585 
00586     wxDC* pDisplayDC; 
00587     INT32 OldDrawMode; 
00588     wxBrush * pOldBrush; 
00589     wxBrush * pDragBrush;
00590 
00591 
00592     // used to track DDecker state during Bar creation
00593     DDeckerReadState DDeckerState;
00594 
00595     DDeckerReadState IsDoubleDecker(BarItem * ThisControl,BarItem * Start,BarItem * End);
00596 
00597     // Control Dragging stuff
00598 
00599     static wxRect   LastCtlDragRect;
00600     wxRect  DragCtlClientRect;
00601     wxWindow*   DragCtlHwnd;
00602     BOOL    IsDraggingControl;
00603     wxPoint DragCtlOffset;
00604     static ControlDragMode CtlDragMode;
00605     static ControlDragState CtlDragState;
00606 
00607     static BaseBar* PtrToToolBar;
00608 
00609 public:
00610 
00611     // This returns TRUE if we are currently dragging a bar or a gallery around.
00612     static BOOL IsDragging() { return DragType != 0; /* DlgDragType::NONE */ }
00613 };
00614 
00615 #endif
00616                                                 

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