basebar2.cpp

Go to the documentation of this file.
00001 // $Id: basebar2.cpp 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 #include "camtypes.h"
00102 //#include "dlgbar.h"
00103 //#include "ensure.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 #include "camframe.h"
00105 #include "oilmods.h"
00106 #include "dlgmgr.h"
00107 //#include "bitbutn.h"
00108 //#include "resource.h" // temp
00109 //#include "barsdlgs.h"
00110 //#include "childbar.h"
00111 //#include "bbutdef.h"
00112 //#include "ctrlhelp.h"
00113 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 #include "camelot.h"
00115 //#include "ctl3d.h"
00116 //#include "fonts.h"
00117 #include "gallery.h"
00118 //#include "sgallery.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00119 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00120 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00121 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00122 #include "camview.h"
00123 #include "keypress.h"
00124 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00125 #include "selector.h"
00126 //#include "reshelp.h"
00127 //#include "dragmgr.h"
00128 //#include "custmsg.h"
00129 //#include "cursor.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00130 #include "csrstack.h"
00131 //#include "phil.h"
00132 //#include "convert.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00133 #include "bubbleid.h"
00134 //#include "will2.h"                        // for HideDisableGadgetAndResuffleBar and
00135                                         // ShowEnableGadgetAndResuffleBar
00136                                         // to jump to point where ID's are used search
00137                                         // for 'HideDisableGadgetAndResuffleBar' ....
00138 
00139 #include "basebar.h"
00140 
00141 #ifdef STANDALONE
00142 #include "galbar.h"
00143 #endif
00144 
00145 IMPLEMENT_DYNAMIC_CLASS( BaseBar, wxWindow )
00146 
00147 // Statics
00148 
00149 wxRect BaseBar::OldDragRect(0,0,0,0);
00150 
00151 DlgDragType BaseBar::DragType = NONE; 
00152 
00153 BOOL BaseBar::InRecreate = FALSE;
00154 BOOL BaseBar::DoingErrorBox = FALSE;
00155 
00156 // NEW BUTTON STUFF
00157 UINT32 BaseBar::GalButtonWidth = 0;
00158 
00159 
00160 wxWindow * BaseBar::LastWindowWithFocus = NULL;
00161 
00162 BOOL BaseBar::ControlHasFocus = FALSE;
00163 
00164 BOOL BaseBar::IsBackGroundRendering = FALSE;
00165 
00166 wxWindow* BaseBar::HwndWithFocus = NULL ;
00167 
00168 BaseBar * BaseBar::CurrentBar = NULL;
00169 
00170 INT32 BaseBar::TitleBarHeight = 0;  // UIC
00171 INT32 BaseBar::BorderWidth = 0;   // UIC    
00172 
00173 
00174 // control dragging stuff
00175 ControlDragState BaseBar::CtlDragState = NO_DRAG;
00176 ControlDragMode BaseBar::CtlDragMode = CUT;
00177 
00178 Cursor*  BaseBar::pCurrentCursor = NULL;
00179 Cursor*  BaseBar::pButtonCopyCursor = NULL;
00180 Cursor*  BaseBar::pButtonCutCursor = NULL;
00181 INT32    BaseBar::CurrentCursorID = 0;
00182 BaseBar* BaseBar::PtrToToolBar = NULL;
00183 
00184 // This macro aligns a BYTE ptr to a dword boundary  
00185 #if WIN32
00186 #define DWORD_ALIGN(x)  if (((DWORD)(x))&3) x+=4-(((DWORD)(x))&3)
00187 #else
00188 #define DWORD_ALIGN(x)
00189 #endif
00190 
00191 #define NO_REDRAW FALSE
00192 
00193 CC_IMPLEMENT_DYNAMIC(FormatPosition, ListItem) 
00194 
00195 
00196 // Used to be 725, 600
00197 // Used to be 770, 614
00198 enum InfoBarWidths { LARGE_INFO_BAR = 910, SMALL_INFO_BAR = 774 };
00199 
00200 #define COMBOHEIGHT  SMALLBUTTONHEIGHT - 2
00201 
00202 #define IS_CHICAGO ((LOBYTE(LOWORD(GetVersion()))) > 3) 
00203 
00204 #define COMMIT 2
00205 
00206 #define Y_BASEUNITS 16
00207 #define X_BASEUNITS 8
00208 
00209 
00210 //#define IS_CHICAGO 1
00211 
00212 
00213 
00214 /********************************************************************************************
00215 
00216 >   BaseBar::GetEnumItemType(BarItem * Item)
00217 
00218     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00219     Created:    30/3/94
00220     Inputs:     the baritem to type
00221     Outputs:    -
00222     Returns:    An Enumerated BarType 
00223     Purpose:    To return an enumerated BarType from a BarItem
00224     Errors:     -
00225     SeeAlso:    -
00226 
00227 ********************************************************************************************/
00228 
00229 BarItemType GetEnumItemType(BarItem * Item)
00230 {
00231     PORTNOTETRACE( "dialog", "GetEnumItemType - do nothing" );
00232 #ifndef EXCLUDE_FROM_XARALX
00233     if(Item == NULL)
00234         return UNKNOWN_ITEM;
00235     if (Item->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
00236     {
00237         HWND hcontrol=(HWND)((BarControl*)Item)->GetWinID();    // Get the Window Handle
00238         
00239         String_256 ClassNameStr;
00240 
00241         GetClassName(hcontrol, (TCHAR*)ClassNameStr, 255);  // Check type of control
00242         if (ClassNameStr == String_16(TEXT("cc_BitmapButton")))
00243             return BITMAPBUTTON;
00244         if (ClassNameStr == String_16(TEXT("Button")))
00245             return BUTTON;
00246         if (ClassNameStr == String_16(TEXT("cc_SmallButton")))
00247             return SMALLBITMAPBUTTON;
00248         if (ClassNameStr == String_16(TEXT("Static")))
00249             return STATIC;
00250         if (ClassNameStr == String_16(TEXT("ComboBox")))
00251             return COMBO;                                            
00252         if (ClassNameStr == String_16(TEXT("Edit")))
00253             return EDIT;
00254         if (ClassNameStr == String_16(TEXT("cc_StaticBitmap")))
00255             return STATICBITMAP;
00256         if (ClassNameStr == String_16(TEXT("cc_Grid")))
00257             return ROTATEGRID;
00258         if (ClassNameStr == String_16(TEXT("cc_Text3D")))
00259             return TEXT3D;
00260         if (ClassNameStr == String_16(TEXT("cc_Slider")))
00261             return SLIDER;
00262         if (ClassNameStr == String_64(TEXT("cc_1dBitmapComboBoxEdit")))
00263             return BITMAPCOMBO1D;
00264         if (ClassNameStr == String_64(TEXT("cc_2dBitmapComboBoxEdit")))
00265             return BITMAPCOMBO2D;
00266         return OTHERCONTROL;
00267     }
00268 
00269     if ( Item->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)) )
00270         return SEPARATOR;
00271     if ( Item->IsKindOf(CC_RUNTIME_CLASS(BarLineFeed)) )
00272         return LINEFEED;
00273     if ( Item->IsKindOf(CC_RUNTIME_CLASS(DDeckerTop)))
00274         return DECKER_TOP;
00275     if ( Item->IsKindOf(CC_RUNTIME_CLASS(DDeckerBottom)))
00276         return DECKER_BOTTOM;
00277     if ( Item->IsKindOf(CC_RUNTIME_CLASS(DDeckerEnd)))
00278         return DECKER_END;
00279     ENSURE(FALSE,"Unknown Bar Item");
00280 #endif
00281     return UNKNOWN_ITEM;
00282 }
00283 
00284 /********************************************************************************************
00285 
00286 >   static BOOL BaseBar::DeclarePreferences()
00287 
00288     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00289     Created:    20/12/95
00290     Returns:    TRUE if it worked, FALSE if it failed
00291     Purpose:    Declares any preferences that the BaseBar class needs to decalre
00292 
00293 ********************************************************************************************/
00294 
00295 BOOL BaseBar::DeclarePreferences()
00296 {
00297     // Use a built-in resource rather than an ini file setting...
00298     INT32 TempWidth = 72;
00299     Convert::StringToLong( String_8( _R(IDS_DEFAULT_GAL_BUTTON_SIZE) ), &TempWidth );
00300     GalButtonWidth = (UINT32)TempWidth;
00301     return TRUE;
00302 
00303 //  GalButtonWidth = 72;
00304 //  return Camelot.DeclareSection("Galleries",2)
00305 //  && Camelot.DeclarePref("Galleries", "ButtonWidth", &GalButtonWidth);
00306 }
00307  
00308 /********************************************************************************************
00309 
00310 >   BaseBar::BaseBar()
00311 
00312     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00313     Created:    30/3/94
00314     Inputs:     -
00315     Outputs:    -
00316     Returns:    -
00317     Purpose:    The BaseBar constructor 
00318     Errors:     -
00319     SeeAlso:    -
00320 
00321 ********************************************************************************************/
00322 
00323 BaseBar::BaseBar()   
00324 {
00325     // Get pointers to Stock Fonts for Title and controls
00326 //  TitleFont = FontFactory::GetwxFont(STOCKFONT_DIALOGBARTITLE);
00327 //  BarFont = FontFactory::GetwxFont(STOCKFONT_DIALOGBARCLIENT);
00328 //  SmallThinFont = FontFactory::GetwxFont(STOCKFONT_DIALOGBARSMALL);
00329 //  LargeThinFont = FontFactory::GetwxFont(STOCKFONT_DIALOGBARLARGE);
00330 
00331     // Get the System FrameWidth
00332     BorderWidth = wxSystemSettings::GetMetric( wxSYS_FRAMESIZE_X );
00333     
00334     // Get the height of the title bar  UIC
00335     // under '95 this is system wide    UIC
00336 
00337 #if defined(__WXMSW__)
00338     if(IS_CHICAGO)
00339     {
00340         TitleBarHeight = 14;   // UIC
00341         #if _MFC_VER >= 0x400
00342             TitleBarHeight = wxSystemSettings::GetMetric(SM_CYSMCAPTION);
00343         #endif
00344     }
00345     else
00346 #endif
00347     {
00348         TitleBarHeight = 10;   // UIC
00349     }
00350     // used in GrowNorth GrowSouth 
00351     TallestFloat = WidestFloat = 1;
00352 
00353     // init drag state  
00354     DragType = NONE;
00355     DragCtlHwnd = NULL;
00356     
00357     Active = TRUE;
00358     
00359     
00360     InitFormatRects();
00361     LastSmallBarPos.x = LastSmallBarPos.y = -1;
00362     
00363     // create a bitmap for the drag rendering
00364 #pragma message( __LOCMSG__ "Not using dither pattern" )
00365 //  WORD WindowsGray [] = { 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA } ;
00366 //  BrushBitmap.CreateBitmap (8, 8, 1, 1, (LPSTR) WindowsGray) ;
00367     BrushBitmap.Create( 8, 8, 1 );
00368 }
00369 
00370 
00371 
00372 
00373 /********************************************************************************************
00374 
00375 >   BaseBar::~BaseBar()
00376 
00377     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00378     Created:    30/3/94
00379     Inputs:     -
00380     Outputs:    -
00381     Returns:    -
00382     Purpose:    BaseBar destructor
00383     Errors:     -
00384     SeeAlso:    -
00385 
00386 ********************************************************************************************/
00387 
00388 BaseBar::~BaseBar()
00389 {
00390     FormatPositions.DeleteAll();
00391 }
00392 
00393 /********************************************************************************************
00394 
00395 >   BOOL BaseBar::IsBarInRecreate()
00396 
00397     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00398     Created:    30/3/94
00399     Inputs:     -
00400     Outputs:    -
00401     Returns:    -
00402     Purpose:    BaseBar destructor
00403     Errors:     -
00404     SeeAlso:    -
00405 
00406 ********************************************************************************************/
00407 
00408 BOOL BaseBar::IsBarInRecreate()
00409 {
00410     return InRecreate;
00411 }
00412 
00413 
00414 /********************************************************************************************
00415 
00416 >   static BOOL BaseBar::IsDoingErrorBox()
00417 
00418     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00419     Created:    22/6/95
00420     Inputs:     -
00421     Outputs:    -
00422     Returns:    -
00423     Purpose:    Returns whether we're doing an error box or not...
00424     Errors:     -
00425     SeeAlso:    -
00426 
00427 ********************************************************************************************/
00428 
00429 BOOL BaseBar::IsDoingErrorBox()
00430 {
00431     // If it's an MFC exception, etc...
00432 /*  if(CCamApp::IsDisabled())
00433         return TRUE;*/
00434 
00435     return DoingErrorBox;
00436 }
00437 
00438 /********************************************************************************************
00439 
00440 >   static void BaseBar::StartErrorBox()
00441 
00442     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00443     Created:    22/6/95
00444     Inputs:     -
00445     Outputs:    -
00446     Returns:    -
00447     Purpose:    To set the variable which stops us grabbing back the focus in mainframe if
00448                 the bar / gallery hasn't been created
00449     Errors:     -
00450     SeeAlso:    -
00451 
00452 ********************************************************************************************/
00453 
00454 void BaseBar::StartErrorBox()
00455 {
00456     DoingErrorBox = TRUE;
00457 }
00458 
00459 /********************************************************************************************
00460 
00461 >   static void BaseBar::FinishErrorBox()
00462 
00463     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00464     Created:    22/6/95
00465     Inputs:     -
00466     Outputs:    -
00467     Returns:    -
00468     Purpose:    To reset the variable which stops us grabbing back the focus in mainframe if
00469                 the bar / gallery hasn't been created
00470     Errors:     -
00471     SeeAlso:    -
00472 
00473 ********************************************************************************************/
00474 
00475 void BaseBar::FinishErrorBox()
00476 {
00477     DoingErrorBox = FALSE;
00478 }
00479 
00480 /********************************************************************************************
00481 
00482 >   BaseBar::SetFormatVariables()
00483 
00484     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00485     Created:    9/5/94
00486     Inputs:     -
00487     Outputs:    -
00488     Returns:    -
00489     Purpose:    Sets up various formating variables according to dockbar type 
00490                 large/small controls etc .. must be called on every create
00491     Errors:     -
00492     SeeAlso:    -
00493 
00494 ********************************************************************************************/
00495 
00496 
00497 void BaseBar::SetFormatVariables()
00498 {
00499 #pragma message( __LOCMSG__ "BaseBar::SetFormatVariables - do nothing" )
00500     TRACE( _T("Warning - BaseBar::SetFormatVariables called") );
00501 /*  if (GetMainFrame()->GetDockBar(ParentDockBarType)->IsBigControls())
00502         SeparatorWidth = LARGE_SEPARATOR;
00503     else
00504         SeparatorWidth = SMALL_SEPARATOR; */
00505 }
00506 
00507 
00508 
00509 /********************************************************************************************
00510 
00511 >   void BaseBar::CloseCombos()
00512 
00513     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00514     Created:    16/5/94
00515     Inputs:     -
00516     Outputs:    -
00517     Returns:    -
00518     Purpose:    Close any drop-down windows
00519     Errors:     -
00520     SeeAlso:    -
00521 
00522 ********************************************************************************************/
00523 
00524              
00525 void BaseBar::CloseCombos()
00526 {                                                            
00527 #pragma message( __LOCMSG__ "BaseBar::CloseCombos - do nothing" )
00528     TRACE( _T("Warning - BaseBar::CloseCombos called") );
00529 /*  String_256 ClassNameStr;
00530     HWND CurrentChild;
00531     HWND NextChild;
00532 
00533     // Get control HWND's 
00534     for (CurrentChild = ::GetWindow(GetSafeHwnd(),GW_CHILD);
00535          CurrentChild != NULL; 
00536          CurrentChild = NextChild)
00537     {
00538         GetClassName(CurrentChild, (TCHAR*)ClassNameStr, 255);
00539         // check for ComboBox/ListBox
00540         if ( (ClassNameStr == String_8(TEXT("ListBox"))) ||
00541              (ClassNameStr == String_8(TEXT("ComboBox"))) ||
00542              (ClassNameStr == String_64(TEXT("cc_1dBitmapComboBoxEdit"))) ||
00543              (ClassNameStr == String_64(TEXT("cc_2dBitmapComboBoxEdit")))
00544            )
00545         {
00546             // send close message
00547             ::SendMessage(CurrentChild,CB_SHOWDROPDOWN,FALSE,0);
00548         }
00549         NextChild = ::GetWindow(CurrentChild,GW_HWNDNEXT);
00550     } */
00551 
00552 }
00553 
00554 
00555 
00556 
00557 /********************************************************************************************
00558 
00559 >   wxRect BaseBar::GetDragFormatRect(DockBarType BarType, wxPoint CursorPos, BOOL ToLeft
00560                                                                               BOOL Below)
00561 
00562     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00563     Created:    19/5/94
00564     Inputs:     BarType:            Type of docking bar to create new bar shape for
00565                 CursorPos:          Current cursor position
00566                 (and class statics)
00567                 OldDragRect:        Previous dragged rectangle
00568                 DragOffset:         Offset of cursro into previous rectangle
00569                 DragOffsetFromLeft: TRUE when cursor is offset from left of previous
00570                 DragOffsetFromTop:  TRUE when cursor is offset from top of previous
00571 
00572     Outputs:    -
00573     Returns:    -
00574     Purpose:    Get cached format size and offset it appropriately around the current drag
00575                 position.
00576     Errors:     -
00577     SeeAlso:    -
00578 
00579 ********************************************************************************************/
00580 
00581 wxRect  BaseBar::GetDragFormatRect(DockBarType BarType, wxPoint CursorPos, BOOL ToLeft,
00582                                                                             BOOL Below )
00583 {
00584     wxRect  DragRect(0,0,0,0);
00585     DragRect = GetFormatRect(BarType);
00586 
00587 //  TRACEUSER( "Gerry", _T("FormatRect(%d) = (%d, %d) - (%d, %d)\n"), BarType, DragRect.left, DragRect.top, DragRect.GetRight(), DragRect.GetBottom());
00588 
00589     wxPoint NewOffset = CalcDragOffset(DragRect, CursorPos, ToLeft, Below);
00590 
00591 //  TRACEUSER( "Gerry", _T("Offset         = (%d, %d)\n"), NewOffset.x, NewOffset.y);
00592 
00593     DragRect.Offset( CursorPos.x - NewOffset.x, CursorPos.y - NewOffset.y );
00594 
00595 //  TRACEUSER( "Gerry", _T("After Offset   = (%d, %d) - (%d, %d)\n"), DragRect.left, DragRect.GetTop(), DragRect.GetRight(), DragRect.GetBottom());
00596 
00597     return ( DragRect );
00598 }
00599 
00600 
00601 
00602 
00603 /********************************************************************************************
00604 
00605 >   wxPoint BaseBar::CalcDragOffset(wxRect DragRect, wxPoint CursorPos, BOOL ToLeft, BOOL Below)
00606 
00607     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00608     Created:    19/5/94
00609     Inputs:     DragRect:           Current dragged rectangle
00610                 (and class statics)
00611                 OldDragRect:        Previous dragged rectangle
00612                 DragOffset:         Offset of cursor into previous rectangle
00613                 DragOffsetFromLeft: TRUE when cursor is offset from left of previous
00614                 DragOffsetFromTop:  TRUE when cursor is offset from top of previous
00615     Outputs:    -
00616     Returns:    -
00617     Purpose:    Use the current drag rect the previous one and the current cursor pos to
00618                 calculate the new offsets into the new drag rectangle.
00619     Errors:     -
00620     SeeAlso:    -
00621 
00622 ********************************************************************************************/
00623 
00624 wxPoint BaseBar::CalcDragOffset(wxRect DragRect, wxPoint CursorPos, BOOL ToLeft, BOOL Below)
00625 {
00626     wxPoint NewOffset;
00627 
00628     if (ToLeft)
00629     {
00630         NewOffset.x = DragOffset.x;
00631         if (NewOffset.x > DragRect.GetWidth())
00632             NewOffset.x = DragRect.GetWidth()-6;
00633     }
00634     else
00635     {
00636         NewOffset.x = DragRect.GetWidth()-(OldDragRect.GetWidth()-DragOffset.x);
00637         if (NewOffset.x < 0)
00638             NewOffset.x = 6;
00639     }
00640 
00641     if (Below)
00642     {
00643         NewOffset.y = DragOffset.y;
00644         if (NewOffset.y > DragRect.GetHeight())
00645             NewOffset.y = DragRect.GetHeight()-6;
00646     }
00647     else
00648     {
00649         NewOffset.y = DragRect.GetHeight()-(OldDragRect.GetHeight()-DragOffset.y);
00650         if (NewOffset.y < 0)
00651             NewOffset.y = 6;
00652     }
00653 
00654     return ( NewOffset );
00655 }
00656 
00657 
00658 /********************************************************************************************
00659 
00660 >   wxRect BaseBar::BaseBar::UnCacheFormatRects()
00661 
00662     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00663     Created:    4/5/94
00664     Inputs:     DockBarType
00665     Outputs:    -
00666     Returns:    -
00667     Purpose:    Set all Cache Format rectangles empty
00668     Errors:     -
00669     SeeAlso:    -
00670 
00671 ********************************************************************************************/
00672 
00673 void  BaseBar::InitFormatRects()
00674 {
00675 
00676     FloatLargeRect      = wxRect();
00677     VerticalLargeRect   = wxRect();
00678     HorizontalLargeRect = wxRect();
00679     FloatSmallRect      = wxRect();
00680     VerticalSmallRect   = wxRect();
00681     HorizontalSmallRect = wxRect();
00682 
00683 }
00684 
00685 /********************************************************************************************
00686 
00687 >   wxRect BaseBar::GetFormatRect(DockBarType BarType)
00688 
00689     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00690     Created:    4/5/94
00691     Inputs:     DockBarType
00692     Outputs:    -
00693     Returns:    Cached Rectangle according to dock and control size
00694     Purpose:    Get cached format size - if none available format and cache
00695     Errors:     -
00696     SeeAlso:    -
00697 
00698 ********************************************************************************************/
00699 
00700 wxRect  BaseBar::GetFormatRect(DockBarType BarType)
00701 {
00702 #pragma message( __LOCMSG__ "BaseBar::GetFormatRect - do nothing" )
00703     TRACE( _T("Warning - BaseBar::GetFormatRect called") );
00704 /*  OILDockingBar* DockBar = GetMainFrame()->GetDockBar(BarType);
00705     switch(BarType)
00706     {
00707         case DOCKBAR_FLOAT:
00708             if (DockBar->IsBigControls())
00709             {
00710                 if (FloatLargeRect.IsEmpty())
00711                     FormatFloatingBar(FALSE,USE_BAR);
00712                 return FloatLargeRect;
00713             }
00714             else
00715             {
00716                 if (FloatSmallRect.IsEmpty())
00717                     FormatFloatingBar(FALSE,USE_BAR);
00718                 return FloatSmallRect;
00719             }
00720             break;
00721         case DOCKBAR_LEFT:
00722         case DOCKBAR_RIGHT:
00723             if (DockBar->IsBigControls())
00724             {
00725                 if (VerticalLargeRect.IsEmpty())
00726                     FormatVerticalBar(FALSE,USE_BAR);
00727                 return VerticalLargeRect;
00728             }
00729             else
00730             {
00731                 if (VerticalSmallRect.IsEmpty())
00732                     FormatVerticalBar(FALSE,USE_BAR);
00733                 return VerticalSmallRect;
00734             }
00735         break;
00736     
00737     case DOCKBAR_TOP:
00738     case DOCKBAR_BOTTOM:
00739         if (DockBar->IsBigControls())
00740         {
00741             if (HorizontalLargeRect.IsEmpty())
00742                 FormatHorizontalBar(FALSE,USE_BAR);
00743             return HorizontalLargeRect;
00744         }
00745         else
00746         {
00747             if (HorizontalSmallRect.IsEmpty())
00748                 FormatHorizontalBar(FALSE,USE_BAR);
00749             return HorizontalSmallRect;
00750         }
00751         break;
00752     default:
00753         ENSURE(FALSE,"Unknown Dockbar Type");
00754 
00755     } */
00756     return wxRect(0,0,0,0) ;
00757 }
00758 
00759 /********************************************************************************************
00760 
00761 >   DockBarType BaseBar::IsPointerOverDock(wxPoint point)
00762 
00763     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00764     Created:    18/5/94
00765     Inputs:     point in Screen Coordinates
00766     Outputs:    -
00767     Returns:    The DockBarType that the pointer is over
00768     Purpose:    Test whether the pointer is currently over a dockingbar
00769     Errors:     -
00770     SeeAlso:    -
00771 
00772 ********************************************************************************************/
00773 
00774 DockBarType BaseBar::IsPointerOverDock(wxPoint point)
00775 {
00776 #pragma message( __LOCMSG__ "BaseBar::IsPointerOverDock - do nothing" )
00777     TRACE( _T("Warning - BaseBar::IsPointerOverDock called") );
00778 /*  wxRect temp ;
00779     OILFixedDockingBar * ParentDockBar;
00780      
00781     ParentDockBar = (OILFixedDockingBar * )GetMainFrame()->GetDockBar(DOCKBAR_LEFT); 
00782     ParentDockBar->GetDockScreenRect(&temp);
00783     if (temp.PtInRect(point))
00784         return DOCKBAR_LEFT;
00785 
00786     ParentDockBar = (OILFixedDockingBar * )GetMainFrame()->GetDockBar(DOCKBAR_RIGHT); 
00787     ParentDockBar->GetDockScreenRect(&temp);
00788     if (temp.PtInRect(point))
00789         return DOCKBAR_RIGHT;
00790     
00791     ParentDockBar = (OILFixedDockingBar * )GetMainFrame()->GetDockBar(DOCKBAR_TOP); 
00792     ParentDockBar->GetDockScreenRect(&temp);
00793     if (temp.PtInRect(point))
00794         return DOCKBAR_TOP;
00795     
00796     ParentDockBar = (OILFixedDockingBar * )GetMainFrame()->GetDockBar(DOCKBAR_BOTTOM); 
00797     ParentDockBar->GetDockScreenRect(&temp);
00798     if (temp.PtInRect(point))
00799         return DOCKBAR_BOTTOM; */
00800 
00801     return DOCKBAR_FLOAT;
00802 }
00803 
00804 
00805 /********************************************************************************************
00806 
00807 >   BaseBar::SetBarSize(DockBarType BarType,BOOL DoRedraw)
00808 
00809     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00810     Created:    4/5/94
00811     Inputs:     BarType - type of dock the bar is attached to
00812                 Redraw - flag to indicate a redraw is needed
00813     Outputs:    -
00814     Returns:    new size
00815     Purpose:    Set the Window size
00816     Errors:     -
00817     SeeAlso:    -
00818 
00819 ********************************************************************************************/
00820 
00821 wxRect  BaseBar::SetBarSize(DockBarType BarType ,BOOL DoRedraw)
00822 {
00823     wxRect temp;
00824 
00825 #pragma message( __LOCMSG__ "BaseBar::SetBarSize - do nothing" )
00826     TRACE( _T("Warning - BaseBar::SetBarSize called") );
00827 /*  switch(BarType)
00828     {
00829     case DOCKBAR_FLOAT:
00830         if (ParentDockBar->IsBigControls())     
00831             temp = FloatLargeRect;
00832         else
00833             temp = FloatSmallRect;
00834         break;
00835 
00836     case DOCKBAR_LEFT:
00837     case DOCKBAR_RIGHT:
00838         if (ParentDockBar->IsBigControls())     
00839             temp = VerticalLargeRect;
00840         else
00841             temp = VerticalSmallRect;
00842         break;
00843     
00844     case DOCKBAR_TOP:
00845     case DOCKBAR_BOTTOM:
00846         if (ParentDockBar->IsBigControls())     
00847             temp = HorizontalLargeRect;
00848         else
00849             temp = HorizontalSmallRect;
00850         break;
00851     }
00852     UINT32 flags = SWP_NOMOVE|SWP_NOZORDER;
00853     if(! DoRedraw)
00854         flags |= SWP_NOREDRAW;
00855     SetWindowPos( NULL, 0, 0, temp.GetRight(), temp.GetBottom(), flags ); */
00856 
00857     return temp;
00858 }
00859   
00860 /********************************************************************************************
00861 
00862 >   BaseBar::PositionControls(BOOL DoRedraw = TRUE)
00863 
00864     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00865     Created:    4/5/94
00866     Inputs:     -
00867     Outputs:    -
00868     Returns:    -
00869     Purpose:    Format and place controls according to docking bar type
00870     Errors:     -
00871     SeeAlso:    -
00872 
00873 ********************************************************************************************/
00874 
00875 BOOL  BaseBar::PositionControls(BOOL DoRedraw)
00876 {
00877     // Position the controls in the bar
00878     switch(ParentDockBarType)
00879     {
00880     case DOCKBAR_FLOAT:
00881         FormatFloatingBar(TRUE,USE_BAR);
00882         pOp->SetCurrentOrientation(Horizontal); 
00883         break;
00884     
00885     case DOCKBAR_LEFT:
00886     case DOCKBAR_RIGHT:
00887         FormatVerticalBar(TRUE,USE_BAR);
00888         pOp->SetCurrentOrientation(Vertical); 
00889         break;
00890     
00891     case DOCKBAR_TOP:
00892     case DOCKBAR_BOTTOM:
00893         FormatHorizontalBar(TRUE,USE_BAR);
00894         pOp->SetCurrentOrientation(Horizontal); 
00895         break;
00896     default:
00897         ENSURE(FALSE,"Unknown Parent DockBar");
00898     }
00899     // Size the window correctly
00900     SetBarSize(ParentDockBarType, DoRedraw);
00901     return TRUE ;
00902 }
00903 
00904 
00905 /********************************************************************************************
00906 
00907 >   BOOL BaseBar::Show(DialogBarOp* Op)
00908 
00909     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>     
00910     Created:    30/3/94
00911     Inputs:     -
00912     Outputs:    -
00913     Returns:    TRUE if successful, else FALSE
00914     Purpose:    Creates a BaseBar window
00915     Errors:     -
00916     SeeAlso:    -      
00917 
00918 ********************************************************************************************/
00919 
00920 
00921 BOOL BaseBar::Show(DialogBarOp* Op)
00922 {
00923 #pragma message( __LOCMSG__ "BaseBar::Show - do nothing" )
00924     TRACE( _T("Warning - BaseBar::Show called") );
00925 /*  if (Op->IS_KIND_OF(InformationBarOp))
00926         ((InformationBarOp*)Op)->SetInfo();
00927     DockBarType InfoDock;
00928 
00929     InfoDock = Op->GetDockBarType();
00930     if(InfoDock != ParentDockBarType)
00931     {
00932         
00933         OILDockingBar * NewDock ;
00934         OILDockingBar * OldDock ;
00935         BOOL CanCopy;
00936         NewDock = GetMainFrame()->GetDockBar(InfoDock);
00937         OldDock = GetMainFrame()->GetDockBar(ParentDockBarType);
00938         CanCopy = NewDock->IsBigControls() == OldDock->IsBigControls();     
00939         if(HasOrientationChanged(ParentDockBarType,DragDockBarType))
00940             CanCopy = FALSE;
00941     
00942         // dynamically create a new BaseBar/derived Bar
00943         BaseBar* NewBaseBar = (BaseBar *)GetClassInfo()->CreateObject(); 
00944 
00945         NewBaseBar->Recreate(InfoDock, this, Op,CanCopy); 
00946         // The current BaseBar dies
00947         CCamApp::GetDlgManager()->Delete(GetSafeHwnd(),Op);  
00948         return TRUE;
00949     }
00950 
00951     KernelBarPos ThisPos;
00952     ThisPos.Dock = ParentDockBarType;
00953      
00954     if (ParentDockBarType == DOCKBAR_FLOAT)
00955     {
00956         // Get x/y position of floating bar
00957         wxPoint FloatPos = Op->GetFloatingCPoint();
00958         ThisPos.x=FloatPos.x;
00959         ThisPos.y=FloatPos.y;
00960     }
00961     else
00962     {
00963         // Get slot/offset position of docked bar
00964         ThisPos.Slot = Op->GetSlot(); 
00965         ThisPos.Position = Op->GetOffset();
00966         // Get a pointer to the docking bar
00967         OILFixedDockingBar * FixedDock = (OILFixedDockingBar*)GetMainFrame()->
00968                                           GetDockBar(ParentDockBarType); 
00969     }
00970     // Attach the BaseBar to the docking bar 
00971     ParentDockBar->PlaceBar(GetSafeHwnd(),ThisPos);
00972     
00973     SetWindowText(Op->GetName());
00974     
00975     // send a create to info bars  so they can set the state of controls before 
00976     // we show the window
00977 
00978     // Show the Window
00979     ShowWindow(SW_SHOW);
00980 
00981     InvalidateRect(NULL,TRUE);  
00982     UpdateWindow(); */
00983 
00984     return TRUE;
00985 }
00986 
00987 /********************************************************************************************
00988 
00989 >   BOOL BaseBar::Hide(DialogBarOp* Op)
00990 
00991     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>     
00992     Created:    30/3/94
00993     Inputs:     -
00994     Outputs:    -
00995     Returns:    TRUE if successful, else FALSE
00996     Purpose:    Creates a BaseBar window
00997     Errors:     -
00998     SeeAlso:    -      
00999 
01000 ********************************************************************************************/
01001 BOOL BaseBar::Hide(DialogBarOp* Op)
01002 {
01003 #pragma message( __LOCMSG__ "BaseBar::Hide - do nothing" )
01004     TRACE( _T("Warning - BaseBar::Hide called") );
01005 /*  BOOL DoTidy = DO_TIDY;
01006 
01007     ShowWindow(SW_HIDE);
01008     
01009     if (Op->IS_KIND_OF(InformationBarOp))
01010         ((InformationBarOp*)Op)->GetInfo();
01011 
01012 #ifndef STANDALONE  
01013     // we dont want a tidy (reposition and redraw of bars)
01014     // if we are just switching out of the Selector Tool
01015     if(SelectorTool::IsSelectorCaching())
01016         DoTidy = DONT_TIDY;
01017 #endif
01018     
01019     GetMainFrame()->GetDockBar(ParentDockBarType)->ReleaseBar(this->GetSafeHwnd(),DoTidy);
01020     //TRACE( _T("Hide now %d"),ParentDockBarType); */
01021     return TRUE;
01022 }
01023 
01024 /********************************************************************************************
01025 
01026 >   BOOL BaseBar::Create(DialogBarOp* Op)
01027 
01028     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>     
01029     Created:    30/3/94
01030     Inputs:     -
01031     Outputs:    -
01032     Returns:    TRUE if successful, else FALSE
01033     Purpose:    Creates a BaseBar window
01034     Errors:     -
01035     SeeAlso:    -      
01036 
01037 ********************************************************************************************/
01038 
01039 BOOL BaseBar::Create(DialogBarOp* Op)
01040 {
01041 #pragma message( __LOCMSG__ "BaseBar::Create - do nothing" )
01042     TRACE( _T("Warning - BaseBar::Create called") );
01043 /*  InRecreate = TRUE;
01044     pOp = Op; 
01045 
01046     #ifdef STANDALONE
01047     if (pOp->IS_KIND_OF(InformationBarOp))
01048     {   // We don't want any info bars in the standalone version.
01049         
01050         InRecreate = FALSE;
01051         return FALSE;
01052     }
01053     #endif
01054 
01055     ParentDockBarType = pOp->GetDockBarType(); //   Get the current dock bar
01056     
01057     //TRACE( _T("Create now %d"),ParentDockBarType);  
01058     ParentDockBar = GetMainFrame()->GetDockBar(ParentDockBarType); 
01059 
01060     ENSURE(ParentDockBar != NULL, "Could not find docking bar"); 
01061     
01062     // init control size etc ..
01063     SetFormatVariables();
01064   
01065     KernelBarPos ThisPos;
01066     ThisPos.Dock = ParentDockBarType;
01067      
01068     BOOL WindowCreated ; 
01069 
01070     wxPoint p ;
01071 
01072     if (ParentDockBarType == DOCKBAR_FLOAT)
01073 //      || pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
01074     {
01075         // Get x/y position of floating bar
01076         wxPoint FloatPos = pOp->GetFloatingwxPoint();
01077 
01078         if (!MonitorFromPoint(FloatPos, MONITOR_DEFAULTTONULL))
01079         {
01080             // The float pos is not on any monitor in the system so lets use the top left
01081             // corner of the monitor nearest the point
01082             MONITORINFO mi;
01083             mi.cbSize = sizeof(MONITORINFO);
01084             if (GetMonitorInfo(MonitorFromPoint(FloatPos, MONITOR_DEFAULTTONEAREST), &mi))
01085             {
01086                 FloatPos.x = mi.rcWork.left;
01087                 FloatPos.y = mi.rcWork.GetTop();
01088             }
01089             else
01090             {
01091                 FloatPos.x = FloatPos.y = 0;
01092             }
01093         }
01094         
01095         ThisPos.x=FloatPos.x;
01096         ThisPos.y=FloatPos.y;
01097         
01098     
01099         //TRACE( _T("FLOAT At %d %d"),ThisPos.Slot,ThisPos.Position);
01100         // Set bar mode
01101         CurrentDlgBarMode = DIALOG; 
01102 
01103         // Create a popup floater
01104         WindowCreated = CreateEx(0, // WS_EX_TOOLWINDOW - I think we should've used one of these, Matt 1/11/00
01105                                  NULL,
01106                                  NULL, WS_POPUP |WS_CHILD,// | WS_BORDER, 
01107                                  FloatPos.x, FloatPos.y,0,0,
01108                                  GetMainFrame()->GetSafeHwnd(),   // Parent is the frame window 
01109                                  NULL);
01110     }
01111     else
01112     {
01113         // Get slot/offset position of docked bar
01114         ThisPos.Slot = pOp->GetSlot(); 
01115         ThisPos.Position = pOp->GetOffset();
01116         CurrentDlgBarMode = BAR; 
01117 
01118         // Get a pointer to the docking bar
01119         OILFixedDockingBar * FixedDock = (OILFixedDockingBar*)GetMainFrame()->
01120                                           GetDockBar(ParentDockBarType); 
01121         
01122         // Get a client coordinate for this slot/offset
01123         FixedDock->BarPosToScreen(ThisPos,&p);
01124 
01125         // Create a child window of the docking bar
01126         WindowCreated = CreateEx(0, NULL, 
01127                                     NULL, WS_CHILD | WS_BORDER, 
01128                                  p.x,p.y,0,0,
01129                                  ParentDockBar->GetSafeHwnd(), 
01130                                  NULL);
01131     }
01132 
01133     if (!WindowCreated)
01134     {
01135         InRecreate = FALSE;
01136         return FALSE; 
01137     }
01138     
01139     if (!LoadResourceControls()|| (!CreateExtraControls()))
01140     {
01141         // We failed to load the controls 
01142         // Delete the window, and all children which may have been created 
01143         CCamApp::GetDlgManager()->Delete(GetSafeHwnd(), Op); 
01144         InRecreate = FALSE;
01145         return FALSE; 
01146     }               
01147 
01148     if (!PositionControls())
01149     {
01150         InRecreate = FALSE;
01151         return FALSE;
01152     }
01153     // Attach the BaseBar to the docking bar 
01154     ParentDockBar->PlaceBar(GetSafeHwnd(),ThisPos);
01155  
01156     // send a create to info bars  so they can set the state of controls before 
01157     // we show the window
01158 
01159     pOp->WindowID = (CWindowID)(GetSafeHwnd());
01160     BROADCAST_TO_CLASS(DialogMsg(GetSafeHwnd(), DIM_CREATE, NULL) ,DialogBarOp);  
01161     
01162     // Update the bar's state before showing
01163     Op->UpdateState();
01164     
01165     // Show the Window
01166     ShowWindow(SW_SHOW);
01167     ::InvalidateRect(GetSafeHwnd(),NULL,TRUE);  
01168     ::UpdateWindow(GetSafeHwnd());
01169 
01170     // inform help system
01171     ControlHelper::NotifyBarCreated(GetSafeHwnd());                          
01172 
01173     FormatHorizontalBar(FALSE,FORCE_SMALL);
01174     FormatVerticalBar(FALSE,FORCE_SMALL);
01175     FormatFloatingBar(FALSE,FORCE_SMALL);
01176     FormatHorizontalBar(FALSE,FORCE_LARGE);
01177     FormatVerticalBar(FALSE,FORCE_LARGE);
01178     FormatFloatingBar(FALSE,FORCE_LARGE);
01179 
01180     InRecreate = FALSE;
01181     
01182     SetWindowText(Op->GetName());
01183     
01184     // ZZZZ
01185     LastSmallBarPos =  ThisPos; 
01186     
01187     // get a pointer to the toolbar - so that we can do things with it!
01188     
01189     if (Op->GetName () == String_32 (TEXT ("Toolbar")))
01190     {
01191         PtrToToolBar = this;
01192     } */
01193     
01194     return TRUE; 
01195 }
01196 
01197 
01198 
01199 /********************************************************************************************
01200 
01201 >   BaseBar::RecreateAt(KernelBarPos Pos,DockBarType DockBar,
01202                           BaseBar* BaseBar, DialogBarOp* Op,HWND OldHwnd )
01203 
01204     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
01205     Created:    11/5/94
01206     Inputs:     
01207                 Pos  - Kernel position to place at ((slot/offset)|(x/y))
01208                 Dockbar - Type of dock attached to
01209                 BaseBar - item to recreate
01210                 Op - attached op
01211                 OldHwnd - Hwnd of previous incarnation 
01212     Outputs:    -
01213     Returns:    -
01214     Purpose:    ReCreates an existing bar after a change of controlsize - as the bar stays
01215                 in the same dock we don't need to release / reattach - we need only inform
01216                 the docking bar of the new HWND
01217     Errors:     -
01218     SeeAlso:    -
01219 
01220 ********************************************************************************************/
01221 
01222 
01223 BOOL BaseBar::RecreateAt(KernelBarPos Pos,DockBarType DockBarTyp,
01224                       BaseBar* BaseBar, DialogBarOp* Op, wxWindow* OldHwnd) 
01225 {
01226 #pragma message( __LOCMSG__ "BaseBar::RecreateAt - do nothing" )
01227     TRACE( _T("Warning - BaseBar::RecreateAt called") );
01228 /*  LastSmallBarPos = Pos;
01229     pOp = Op; 
01230     ParentDockBarType = DockBarTyp; // Record the current dock bar
01231       
01232     ParentDockBar = GetMainFrame()->GetDockBar(DockBarTyp); 
01233     
01234     SetFormatVariables();
01235 
01236     wxRect NewBarSize = OldDragRect;     // Screen coords 
01237     if (DockBarTyp == DOCKBAR_FLOAT)
01238 //      || pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
01239     {
01240         CurrentDlgBarMode = DIALOG; // For now 
01241 
01242         // Create a popup floater
01243         CreateEx(0,  NULL,
01244                 NULL, WS_POPUP |WS_CHILD, //| WS_BORDER ,
01245                  Pos.x, Pos.y,0,0, 
01246                  GetMainFrame()->GetSafeHwnd(),   // Parent is the frame window 
01247                  NULL);
01248 
01249     }
01250      else
01251     {
01252         CurrentDlgBarMode = BAR; // For now 
01253         OILFixedDockingBar * FixedDock = 
01254                             (OILFixedDockingBar*)GetMainFrame()->GetDockBar(DockBarTyp); 
01255         wxPoint p;
01256         FixedDock->BarPosToScreen(Pos,&p);
01257         // Create a child bar
01258         CreateEx(0, NULL,
01259                 NULL, WS_CHILD |  WS_BORDER ,
01260                  p.x,p.y,0,0, 
01261                  ParentDockBar->GetSafeHwnd(), 
01262                  NULL);
01263     }
01264     if (!LoadResourceControls()|| (!CreateExtraControls()))
01265     {
01266         // We failed to load the controls 
01267         // Delete the window, and all children which may have been created 
01268         CCamApp::GetDlgManager()->Delete(GetSafeHwnd(), Op);  
01269         return FALSE; 
01270     } 
01271     
01272     if (!PositionControls())
01273         return FALSE;
01274 
01275 
01276     //TRACE( _T("Done Recreate %d"),GetSafeHwnd());
01277     // Place BaseBar via docking bar 
01278     if (DockBarTyp == DOCKBAR_FLOAT)
01279     {
01280         ParentDockBar->PlaceBar(GetSafeHwnd(),Pos);  
01281     }
01282     else
01283     {
01284         OILFixedDockingBar * FixedDock = 
01285                             (OILFixedDockingBar*)GetMainFrame()->GetDockBar(DockBarTyp); 
01286         if ((ParentDockBar->SetNewHwnd(OldHwnd,GetSafeHwnd()))==NULL)
01287             return FALSE;       
01288         FixedDock->PlaceBarAt(GetSafeHwnd(),Pos);  
01289  
01290     }
01291     // inform help system
01292     ControlHelper::NotifyBarCreated(GetSafeHwnd());     
01293     
01294         // send a create to info bars  so they can set the state of controls before 
01295     // we show the window
01296     
01297     pOp->WindowID = (CWindowID)(GetSafeHwnd());
01298     BROADCAST_TO_CLASS(DialogMsg(GetSafeHwnd(), DIM_CREATE, NULL) ,DialogBarOp);  
01299     
01300     // Update the bar's state before showing
01301     Op->UpdateState();
01302 
01303     // Show the Window
01304     ShowWindow(SW_SHOW);
01305 
01306     ::InvalidateRect(GetSafeHwnd(),NULL,TRUE);  
01307     ::UpdateWindow(GetSafeHwnd());
01308     
01309     FormatHorizontalBar(FALSE,FORCE_SMALL);
01310     FormatVerticalBar(FALSE,FORCE_SMALL);
01311     FormatFloatingBar(FALSE,FORCE_SMALL);
01312     FormatHorizontalBar(FALSE,FORCE_LARGE);
01313     FormatVerticalBar(FALSE,FORCE_LARGE);
01314     FormatFloatingBar(FALSE,FORCE_LARGE);
01315     
01316     SetWindowText(Op->GetName());
01317 
01318     if (Op->GetName () == String_32 (TEXT ("Toolbar")))
01319     {
01320         PtrToToolBar = this;
01321     } */
01322 
01323     return TRUE; 
01324 }
01325 
01326 
01327 
01328 /********************************************************************************************
01329 
01330 >   BaseBar::Recreate(DockBarType DockBar, BaseBar* BaseBar, DialogBarOp* Op,BOOL CanCopy )
01331 
01332     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01333     Created:    30/3/94
01334     Inputs:     -
01335     Outputs:    -
01336     Returns:    -
01337     Purpose:    
01338     Errors:     -
01339     SeeAlso:    -
01340 
01341 ********************************************************************************************/
01342 
01343 
01344 BOOL BaseBar::Recreate(DockBarType DockBarTyp, BaseBar* BaseBar, DialogBarOp* Op,BOOL CanCopy ) 
01345 {
01346 #pragma message( __LOCMSG__ "BaseBar::Recreate - do nothing" )
01347     TRACE( _T("Warning - BaseBar::Recreate called") );
01348 /*  pOp = Op; 
01349     ParentDockBarType = DockBarTyp; // Record the current dock ba
01350       
01351     ParentDockBar = GetMainFrame()->GetDockBar(DockBarTyp); 
01352 
01353     SetFormatVariables();
01354 
01355     wxRect NewBarSize = OldDragRect;     // Screen coords 
01356 
01358 
01359     // 'dynamic' infobar update logic
01360 
01362     
01363     String_32 dialogBarOpName = Op->GetName ();
01364 
01365     if (dialogBarOpName == TEXT (String_32 (_R(IDS_FILLTOOL_FILLINFOBARNAME))))
01366 //      || add the name of your 'dynamic' infobar here
01367     {
01368         //pOp->ResetHiddenGadgetStates ();
01369     }
01370 
01372     
01373     if (DockBarTyp == DOCKBAR_FLOAT)
01374     {
01375         CurrentDlgBarMode = DIALOG; // For now 
01376 
01377         // Create a popup floater
01378         CreateEx(0,  NULL,
01379                 NULL, WS_POPUP |WS_CHILD,// | WS_BORDER ,
01380                  NewBarSize.GetLeft()+(NewBarSize.GetWidth()/2), NewBarSize.GetTop()+(NewBarSize.GetHeight()/2), NewBarSize.GetWidth(), NewBarSize.GetHeight(), 
01381                  GetMainFrame()->GetSafeHwnd(),   // Parent is the frame window 
01382                  NULL);
01383 
01384     }
01385     else
01386     {
01387         CurrentDlgBarMode = BAR; // For now 
01388         
01389         // Convert the NewBarSize to client coords
01390         ::ScreenToClient(ParentDockBar->GetSafeHwnd(), &NewBarSize.TopLeft()); 
01391         ::ScreenToClient(ParentDockBar->GetSafeHwnd(), &NewBarSize.BottomRight()); 
01392 
01393         // Create a child bar
01394         CreateEx(0,  NULL, NULL, WS_CHILD|  WS_BORDER ,
01395                  NewBarSize.GetLeft(), NewBarSize.GetTop(), NewBarSize.GetWidth(), NewBarSize.GetHeight(), 
01396                  ParentDockBar->GetSafeHwnd(), 
01397                  NULL); 
01398 
01399     }
01400     if (CanCopy)
01401     {
01402         if (!CopyOrLoadControls(GetSafeHwnd())|| (!CreateExtraControls()))
01403         {
01404             // We failed to load the controls 
01405             // Delete the window, and all children which may have been created 
01406             CCamApp::GetDlgManager()->Delete(GetSafeHwnd(),Op);  
01407             return FALSE; 
01408         }   
01409     }
01410     else
01411     {
01412         if (!LoadResourceControls()|| (!CreateExtraControls()))
01413         {
01414             // We failed to load the controls 
01415             // Delete the window, and all children which may have been created 
01416             CCamApp::GetDlgManager()->Delete(GetSafeHwnd(),Op);  
01417             return FALSE; 
01418         } 
01419     }
01420     if (! PositionControls())
01421         return FALSE;
01422 
01423     // Attach the BaseBar to the docking bar 
01424     ParentDockBar->PlaceBar(GetSafeHwnd(), wxPoint(OldDragRect.GetLeft(), OldDragRect.GetTop()));  
01425     // inform help system
01426     
01427     pOp->WindowID = (CWindowID)(GetSafeHwnd());
01428 
01429     BROADCAST_TO_CLASS(DialogMsg(GetSafeHwnd(), DIM_CREATE, NULL) ,DialogBarOp);  
01430 
01431     wxRect temprect;
01432     GetClientRect(&temprect);
01433 
01434     // Update the bar's state before showing
01435     Op->UpdateState();
01436 
01437     //if (Op->GetName () != String_32 (TEXT ("Toolbar")))
01438     {
01439         // Show the Window
01440         ShowWindow(SW_SHOW);
01441 
01442         ::InvalidateRect(GetSafeHwnd(),NULL,TRUE);  
01443         ::UpdateWindow(GetSafeHwnd());
01444     }
01445     
01446     ControlHelper::NotifyBarCreated(GetSafeHwnd());     
01447 
01448     FormatHorizontalBar(FALSE,FORCE_SMALL);
01449     FormatVerticalBar(FALSE,FORCE_SMALL);
01450     FormatFloatingBar(FALSE,FORCE_SMALL);
01451     FormatHorizontalBar(FALSE,FORCE_LARGE);
01452     FormatVerticalBar(FALSE,FORCE_LARGE);
01453     FormatFloatingBar(FALSE,FORCE_LARGE);
01454     
01455     SetWindowText(Op->GetName());
01456     
01457     // ZZZZZ
01458     LastSmallBarPos =  * GetMainFrame()->GetDockBar(ParentDockBarType)->
01459                      GetBarPos(this->GetSafeHwnd());
01460 
01461     if (Op->GetName () == String_32 (TEXT ("Toolbar")))
01462     {
01463         PtrToToolBar = this;
01464     } */
01465                         
01466     return TRUE; 
01467 }
01468 
01469 /********************************************************************************************
01470 
01471 >   BaseBar::LoadResourceControls()
01472 
01473     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01474     Created:    11/4/94
01475     Inputs:     -
01476     Outputs:    -
01477     Returns:    -
01478     Purpose:    
01479     Errors:     -
01480     SeeAlso:    -
01481 
01482 ********************************************************************************************/
01483 
01484 
01485 BOOL BaseBar::LoadResourceControls()
01486 {
01487      // Find out how many bar items
01488     UINT32 NumBarItems = pOp->GetNumBarItems(); 
01489 
01490     BarItem* pBarItem;
01491 
01492     // track ddecker state 
01493     DDeckerState = DDECKER_NONE; 
01494 
01495 //  ThisIsAnInfoBar = ( (pOp->IsKindOf(CC_RUNTIME_CLASS(InformationBarOp)))
01496 //                      || (pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery))) );
01497 
01498     ThisIsAnInfoBar = pOp->IsKindOf(CC_RUNTIME_CLASS(InformationBarOp));
01499     BOOL ThisIsAGallery = pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery));
01500 
01501     for (UINT32 i = 0; i< NumBarItems; i++)
01502     {
01503         // Get the next BarItem
01504         pBarItem = pOp->GetPtrBarItem(i); 
01505         
01506         ENSURE(pBarItem != NULL, "NumBarItems is incorrect"); 
01507         // Check whether we need to create thin items for double deckers
01508         
01509         if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
01510         {
01511             BarControl * pBarControl = (BarControl*)pBarItem;
01512             if (ThisIsAnInfoBar || ThisIsAGallery)
01513             { 
01514                 // If the DialogBarOp is an InformationBarOp then the Bar controls 
01515                 // control ID will be unique for the InformationBar's Message handler
01516                 pBarControl->SetUniqueGadgetID(
01517                     pBarControl->GetBarControlInfo(pOp->IsHorizontal()).ControlID);  
01518             }
01519             else
01520             {
01521                 // use index as gadget id
01522                 pBarControl->SetUniqueGadgetID(i + 100);  
01523             }
01524             // create the control i==0 indicates initialise
01525             if (!CreateInfoControlFromResource(pBarControl,i==0))
01526             {
01527                 // We failed to create the control 
01528                 //ENSURE(FALSE,"Failed to create control"); 
01529                 return FALSE ;
01530             }
01531         }
01532         else if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerTop)))
01533         {
01534             DDeckerState = DDECKER_TOP;
01535         }
01536         else if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerBottom)))
01537         {
01538             DDeckerState = DDECKER_BOTTOM;
01539         }
01540         else if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerEnd)))
01541         {
01542             DDeckerState = DDECKER_NONE;
01543         }
01544     }
01545 
01546     // call to free resources;
01547     CreateInfoControlFromResource(NULL,0);
01548     return TRUE; 
01549 }; 
01550 
01551 /********************************************************************************************
01552 
01553 >   BaseBar::CopyOrLoadResourceControls()
01554 
01555     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01556     Created:    11/4/94
01557     Inputs:     -
01558     Outputs:    -
01559     Returns:    -
01560     Purpose:    
01561     Errors:     -
01562     SeeAlso:    -
01563 
01564 ********************************************************************************************/
01565 
01566 BOOL BaseBar::CopyOrLoadControls(wxWindow* BarHwnd)
01567 {
01568     PORTNOTETRACE( "dialog", "BaseBar::CopyOrLoadControls - do nothing" );
01569 #ifndef EXCLUDE_FROM_XARALX
01570     // Find out how many bar items
01571     UINT32 NumBarItems = pOp->GetNumBarItems(); 
01572 
01573     // track ddecker state 
01574     DDeckerState = DDECKER_NONE;
01575 
01576     BarItem* pBarItem; 
01577 
01578     ThisIsAnInfoBar = (pOp->IsKindOf(CC_RUNTIME_CLASS(InformationBarOp)));
01579 
01580     for (UINT32 i = 0; i< NumBarItems; i++)
01581     {
01582         // Get the next BarItem
01583         pBarItem = pOp->GetPtrBarItem(i); 
01584 
01585         ENSURE(pBarItem != NULL, "NumBarItems is incorrect"); 
01586 
01587         // Check whether we need to create thin items for double deckers
01588     
01589         if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
01590         {
01591             BarControl * pBarControl = (BarControl*)pBarItem;
01592             
01593 
01594             // Obtain handle to the controls HWnd
01595             HWND hWndControl=(HWND)(pBarControl)->GetWinID();  
01596             // -------------------------------------------------------
01597             // Find out if the control is copyable
01598             // - This code may appear a little on the brink of insanity, however
01599             // it is neccessary cos windows is edit/combo/list set parently 
01600             // challenged.
01601 
01602             // Determine the control's class
01603             
01604             switch (GetEnumItemType(pBarItem))
01605             {
01606                 case BUTTON:
01607                 case LIST:
01608                 case COMBO:
01609                 case STATIC:
01610                 case EDIT:
01611                 case BITMAPCOMBO1D:     // IF THIS ISN'T HERE - THEN FOR SOME
01612                                         // BIZARRE REASON - OUR CONTROL CANNOT ACCESS
01613                                         // ITS DATA, AND CAMELOT FALLS OVER!
01614                 case BITMAPCOMBO2D:
01615                 {
01616                     // The control cannot be copied, so must be recreated from the
01617                     // resource.
01618 
01619                     if (!CreateInfoControlFromResource(pBarControl,i==0))
01620                     {
01621                         // We failed to create the control 
01622                         ENSURE(FALSE,"Failed to create control"); 
01623                         return(FALSE);
01624                     }
01625                 }
01626                 break;
01627                 default :
01628                 {
01629                     // We can safely copy the control to its new parent
01630                     ::SetParent(hWndControl, BarHwnd);
01631                 }
01632                 break;
01633             }
01634         }
01635         else if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerTop)))
01636         {
01637             DDeckerState = DDECKER_TOP;
01638         }
01639         else if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerBottom)))
01640         {
01641             DDeckerState = DDECKER_BOTTOM;
01642         }
01643         else if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerEnd)))
01644         {
01645             DDeckerState = DDECKER_NONE;
01646         } 
01647     }
01648     CreateInfoControlFromResource(NULL,0);
01649 #endif
01650     return TRUE; 
01651 }; 
01652 
01653 
01654 /********************************************************************************************
01655 
01656 >   BaseBar::GetBarPosition()
01657 
01658     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
01659     Created:    25/4/94
01660     Inputs:     -
01661     Outputs:    -
01662     Returns:    Pointer to KernelBarPos Object containing current Slot / Offset
01663     Purpose:    - 
01664     Errors:     -
01665     SeeAlso:    -
01666 
01667 ********************************************************************************************/
01668 
01669 KernelBarPos  * BaseBar::GetBarPosition()
01670 {
01671 #pragma message( __LOCMSG__ "BaseBar::GetBarPosition - do nothing" )
01672     TRACE( _T("Warning - BaseBar::GetBarPosition called") );
01673 //  return GetMainFrame()->GetDockBar(ParentDockBarType)->GetBarPos(GetSafeHwnd());
01674 
01675     return NULL;
01676 }; 
01677 
01678 /********************************************************************************************
01679 
01680 >   BaseBar::GetDockBarType()
01681 
01682     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
01683     Created:    25/4/94
01684     Inputs:     -
01685     Outputs:    -
01686     Returns:    Parent DockBarType
01687     Purpose:    - 
01688     Errors:     -
01689     SeeAlso:    -
01690 
01691 ********************************************************************************************/
01692 
01693 DockBarType BaseBar::GetDockBarType()
01694 {
01695  
01696  return ParentDockBarType;
01697   
01698 };
01699 
01700 
01701 /********************************************************************************************
01702 
01703 >   BaseBar::IsDoubleDecker(BarItem * ThisControl,BarItem * Start,BarItem * End)
01704 
01705     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
01706     Created:    18/4/94
01707     Inputs:     ThisControl Control to test
01708                 Start to return a pointer to first item in the DD
01709                 End to return a pointer to last item in  the DD
01710     Outputs:    Pointers to first and last controls in this group if one found
01711     Returns:    DDECKER_NONE / DDECKER_TOP /DDECKER_BOTTOM
01712     Purpose:    to determine whether a given control is part of a double decker group 
01713     Errors:     -
01714     SeeAlso:    -
01715 
01716 ********************************************************************************************/
01717 
01718 DDeckerReadState BaseBar::IsDoubleDecker(BarItem * ThisControl,BarItem * Start,BarItem * End)
01719 {
01720     BarItem * pBarItem = pOp->GetPtrBarNext(ThisControl) ;  
01721     BarItem * LastItem = NULL;
01722     // Test assumes that the bar list will contain DDeckerTop/DDeckerBottom/DDeckerEnd
01723     // in that order                            
01724 
01725     DDeckerReadState State = DDECKER_NONE;
01726     while ( pBarItem != NULL )
01727     {
01728 
01729         if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerTop)))
01730         {   
01731             State = DDECKER_NONE;
01732         }
01733 
01734         else if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerBottom)))
01735         {   
01736             State = DDECKER_TOP;
01737         }
01738 
01739         else if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerEnd)))
01740         {   
01741             if(State == DDECKER_NONE)
01742                 State = DDECKER_BOTTOM;
01743 
01744             // point End to last control in group
01745             if(LastItem != NULL && End != NULL)
01746                 End = LastItem;
01747         }
01748 
01749         // keep a pointer to the last control
01750         else if ( pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
01751         {
01752             LastItem = pBarItem;
01753         }
01754         pBarItem = pOp->GetPtrBarNext(pBarItem); 
01755     }
01756 
01757     // point Start to the first control in this group
01758     if(Start != NULL && State != DDECKER_NONE )
01759     {
01760         
01761         pBarItem = ThisControl;     
01762         BarItem * Head = pOp->GetPtrBarHead();
01763 
01764         // run backwards through the list until we find the start 
01765         // of the double decker or get to the head of the bar list
01766         while(pBarItem != Head)
01767         {
01768             // check for start of double decker
01769             if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerTop)))
01770             {   
01771                 Start = LastItem;
01772                 break;
01773             }
01774 
01775             // keep a pointer to the last control
01776             else if ( pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
01777             {
01778                 LastItem = pBarItem;
01779             }
01780             pBarItem = pOp->GetPtrBarPrev(pBarItem); 
01781         }
01782     }
01783 
01784     // not a double decker - set Start and End to NULL
01785     if( State == DDECKER_NONE)
01786         Start = End = NULL;
01787 
01788     return State; 
01789 };
01790 
01791 /********************************************************************************************
01792 
01793 >   BaseBar::TidyBarItemsAfterDrag()
01794 
01795     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
01796     Created:    18/4/94
01797     Returns:    BOOL 
01798     Purpose:    Tidy up Linefeeds and Separators after dragging controls 
01799     Errors:     -
01800     SeeAlso:    -
01801 
01802 ********************************************************************************************/
01803 
01804 BOOL BaseBar::TidyBarItemsAfterDrag()
01805 {
01806     // nothing to tidy
01807     if(pOp->GetNumBarItems()==0)
01808         return TRUE;
01809          
01810     // remove any SP's that preceed LF's 
01811     BarItem * pBarItem = pOp->GetPtrBarHead(); 
01812     while (pBarItem != NULL)
01813     {
01814         if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarLineFeed)))
01815         {
01816             BarItem * pLastItem = pOp->GetPtrBarPrev(pBarItem);
01817             if(pLastItem)
01818             {
01819                 if(pLastItem->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)))
01820                 {
01821                     pOp->RemoveBarItem(pLastItem);
01822                     delete pLastItem;
01823                 }
01824             }
01825         }
01826         pBarItem = pOp->GetPtrBarNext(pBarItem); 
01827     }
01828 
01829     // stip leading and multiple line feeds - we can get into this state after dragging controls around
01830     BOOL LF = FALSE;
01831     BOOL FoundControl=FALSE;
01832     BarItem * pLastControl = NULL;
01833     pBarItem = pOp->GetPtrBarHead(); 
01834 
01835     while (pBarItem != NULL)
01836     {
01837         // keep a record of the last control so that we can strip any trailing LFs
01838         if ( pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
01839         {
01840             pLastControl = pBarItem;
01841             FoundControl = TRUE;
01842         }
01843         if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarLineFeed)))
01844         {
01845             BarItem * pFoundItem = pBarItem;
01846             pBarItem = pOp->GetPtrBarNext(pBarItem);
01847             
01848             // either it's a mulitiple (LF is set) or we haven't found any controls yet
01849             if(LF || !FoundControl)                     
01850             {
01851                 pOp->RemoveBarItem(pFoundItem);
01852                 delete pFoundItem;
01853             }
01854             else
01855             {
01856                 if(FoundControl)
01857                     LF = TRUE;
01858             } 
01859         }
01860         else
01861         {
01862             LF = FALSE;
01863             pBarItem = pOp->GetPtrBarNext(pBarItem); 
01864         }
01865     }
01866 
01867     // stip leading and multiple Separators - we can get into this state after dragging controls around
01868     BOOL SP = FALSE;
01869     FoundControl=FALSE;
01870     pLastControl = NULL;
01871     pBarItem = pOp->GetPtrBarHead(); 
01872 
01873     while (pBarItem != NULL)
01874     {
01875         // keep a record of the last control so that we can strip any trailing SPs
01876         if ( pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
01877         {
01878             pLastControl = pBarItem;
01879             FoundControl = TRUE;
01880         }
01881         if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)))
01882         {
01883             BarItem * pFoundItem = pBarItem;
01884             pBarItem = pOp->GetPtrBarNext(pBarItem);
01885             // either it's a mulitiple (SP is set) or we haven't found any controls yet
01886             if(SP || !FoundControl)                     
01887             {
01888                 pOp->RemoveBarItem(pFoundItem);
01889                 delete pFoundItem;
01890             }
01891             else
01892             {
01893                 if(FoundControl)
01894                     SP = TRUE;
01895             } 
01896         }
01897         else
01898         {
01899             SP = FALSE;
01900             pBarItem = pOp->GetPtrBarNext(pBarItem); 
01901         }
01902     }
01903 
01904     // we don't need anything after the last control
01905     // so.... move past it
01906     pLastControl = pOp->GetPtrBarNext(pLastControl); 
01907     
01908     // and delete the rest
01909     while(pLastControl)
01910     {
01911         BarItem * pItem = pLastControl;
01912         pLastControl = pOp->GetPtrBarNext(pLastControl);
01913         delete pOp->RemoveBarItem(pItem);
01914     }
01915 
01916     return TRUE; 
01917 };
01918 
01919 /********************************************************************************************
01920 
01921 >   BOOL BaseBar::BaseBar::CacheFormatingData()
01922     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
01923     Created:    12/2/96
01924     Inputs:     -
01925     Outputs:    -
01926     Returns:    Failure/Success
01927     Purpose:    Delete and recache  bar height to width mapping values - these are required
01928                 for vertical sizing -
01929                 There is one limitation with this system - we can't use height values to find every 
01930                 possible format - many widths can map to one height..we compromise and cache the 
01931                 narrowest width for each height
01932     Errors:     -
01933     SeeAlso:    -
01934 
01935 ********************************************************************************************/
01936 
01937 BOOL BaseBar::CacheFormatingData()
01938 {
01939     // delete the last cache
01940     if(!FormatPositions.IsEmpty())
01941         FormatPositions.DeleteAll();
01942 
01943     FormatPosition * pNewFP = NULL;
01944     wxSize BarSize(0,0);
01945     wxSize LastBarSize(0,0);
01946     INT32 NoLFs = -1;
01947 
01948     // incrementally call FormatLineFeeds - cache the value every time we get a new height
01949     // when there are no LF's in the bar we have found it's widest format
01950     for(INT32 TryWidth = 16;NoLFs!=0;TryWidth +=4)
01951     {
01952         FormatLineFeeds(TryWidth,&BarSize,&NoLFs);
01953     
01954         // there may be many valid widths that map to this height
01955         // we just cache the first one
01956         if(BarSize.x != LastBarSize.x)
01957         {
01958             LastBarSize = BarSize;
01959             pNewFP = new FormatPosition( TryWidth, BarSize.x );
01960             
01961             ERROR2IF(pNewFP == NULL,FALSE,"Couldn't create Format Position");
01962             
01963             // we add to new item to the head so that we can search from the shortest up
01964             // in  GetBestCachedWidth()
01965             FormatPositions.AddHead((ListItem *)pNewFP);    
01966         }
01967     }
01968     
01969     return TRUE;
01970 };
01971 
01972 /********************************************************************************************
01973 
01974 >   BOOL BaseBar::BaseBar::GetBestCachedWidth(INT32 TargetHeight,INT32 * FoundWidth)
01975     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
01976     Created:    12/2/96
01977     Inputs:     TargetHeight:
01978     Outputs:    A cached Width
01979     Returns:    Failure/Success
01980     Purpose:    given a height return a cached Width value to use during vertical resizing
01981     Errors:     -
01982     SeeAlso:    -
01983 
01984 ********************************************************************************************/
01985 
01986 BOOL BaseBar::GetBestCachedWidth(INT32 TargetHeight, INT32 * FoundWidth)
01987 {
01988     ERROR2IF(FormatPositions.IsEmpty(),FALSE,"No Format Cache");
01989     
01990     FormatPosition * pFormatPosition=(FormatPosition *) FormatPositions.GetHead(); 
01991 
01992     ERROR2IF(pFormatPosition==NULL,FALSE,"No Format Cache");
01993     
01994     INT32 LastWidth = pFormatPosition->Width;
01995     
01996     // find the cached Width that maps onto the target height
01997     while (pFormatPosition)             
01998     {
01999         // break if we have gone past the target height
02000         if (pFormatPosition->Height>TargetHeight)   //found the bar
02001             break;
02002                 
02003         // record this width - we will output the "last" value
02004         LastWidth = pFormatPosition->Width;
02005         pFormatPosition =(FormatPosition *) FormatPositions.GetNext(pFormatPosition);   
02006     
02007     }// end while
02008 
02009     * FoundWidth = LastWidth;
02010     
02011     return TRUE;
02012 };
02013 
02014 /********************************************************************************************
02015 
02016 >   BaseBar::FormatLineFeeds(INT32 Targetx,wxSize * pBarSize, INT32 * pNoLFs)
02017 
02018     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
02019     Created:    18/4/94
02020     Inputs:     TargetWidth
02021     Outputs:    wxSize* pBarSize:returns the size of the bar - used during vertical resizing
02022                 INT32* pNoLFs:the number of linefeeds in the bar -used during vertical resizing
02023     Returns:    -
02024     Purpose:    Reformat a floating toolbar 
02025     Errors:     -
02026     SeeAlso:    -
02027 
02028 ********************************************************************************************/
02029 
02030 BOOL BaseBar::FormatLineFeeds(INT32 Targetx,wxSize * pBarSize, INT32 * pNoLFs)
02031 {
02032 #pragma message( __LOCMSG__ "BaseBar::FormatLineFeeds - do nothing" )
02033     TRACE( _T("Warning - BaseBar::FormatLineFeeds called") );
02034 /*  //List is empty just return 
02035         if (pOp->IsListEmpty())
02036         return FALSE;
02037 
02038     INT32 xpos = 0;
02039     INT32 WidestControl=0;
02040     INT32 CarryWidth = 0;
02041     INT32 LastWidth = 0;
02042     INT32 StartControlX =0;
02043     INT32 ControlHeight ;
02044     INT32 BarWidth =0;
02045     
02046     if(pNoLFs)
02047         (* pNoLFs) = 0;
02048 
02049     OILDockingBar * ThisDock ;
02050     ThisDock = GetMainFrame()->GetDockBar(DOCKBAR_FLOAT);
02051     
02052     // are we on a big/small dock
02053     if (ThisDock->IsBigControls())                                              
02054         ControlHeight = LARGEBUTTONHEIGHT;      
02055     else
02056         ControlHeight = SMALLBUTTONHEIGHT;      
02057         
02058     INT32 BarHeight = ControlHeight+TitleBarHeight;     // UIC
02059     
02060     INT32 DDeckerStart = 0;
02061     INT32 DDeckerEnd = 0;
02062 
02063     Targetx += BAR_BORDERSIZE;
02064 
02065     BarItem * pBarItem = NULL; 
02066     BarItem * SeparatorPtr = NULL;
02067     BarItem * head = NULL;
02068     BOOL GroupSplit = FALSE;
02069     BOOL LastItemWasDDTop = FALSE;
02070     BOOL FirstControlInDecker = FALSE;
02071     BOOL ItsABarItem = FALSE;
02072     DDeckerReadState DDeckerState = DDECKER_NONE;
02073   
02074     // Remove the existing linefeeds
02075     pBarItem = pOp->GetPtrBarHead(); 
02076 
02077     while (pBarItem != NULL)
02078     {
02079         if ( pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
02080         {
02081                 wxRect WindSize;
02082                 ::GetClientRect((HWND)((BarControl*)pBarItem)->GetWinID(),&WindSize);
02083                 if(WindSize.GetWidth()>WidestControl)
02084                     WidestControl = WindSize.GetWidth();
02085         }
02086         if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarLineFeed)))
02087         {
02088             BarItem * FoundItem = pBarItem;
02089             pBarItem = pOp->GetPtrBarNext(pBarItem);
02090             pOp->RemoveBarItem(FoundItem);
02091             delete FoundItem; 
02092         }
02093         else
02094             pBarItem = pOp->GetPtrBarNext(pBarItem); 
02095     }
02096     // we can't make the bar narrower than the widest control
02097     if(Targetx <(WidestControl+(BAR_BORDERSIZE*2)))
02098     {
02099         Targetx = WidestControl + (BAR_BORDERSIZE*2) ;
02100     }
02101     //TRACEUSER( "chris", _T("\n -- Format line feeds -- \n\n"));
02102     // Insert new LineFeeds
02103     head = pBarItem = pOp->GetPtrBarHead();     
02104     
02105     while ( pBarItem != NULL )
02106     {
02107         
02108         ENSURE(!pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarLineFeed)),"LineFeed still in List");
02109         // Double Decker stuff...
02110         if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerTop)))
02111         {
02112             DDeckerState = DDECKER_TOP;
02113             DDeckerStart = xpos;
02114             LastItemWasDDTop = TRUE;
02115 //          TRACEUSER( "chris", _T("DD Top\n"));
02116         }
02117         if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerBottom)))
02118         {
02119             DDeckerState = DDECKER_BOTTOM;
02120             DDeckerEnd = xpos;
02121             // go back to start
02122             xpos = DDeckerStart;
02123 //          TRACEUSER( "chris", _T("DD Bottom\n"));
02124         }
02125         if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(DDeckerEnd)))
02126         {
02127             DDeckerState = DDECKER_NONE;
02128             if(xpos < DDeckerEnd)
02129                 xpos = DDeckerEnd;
02130 //          TRACEUSER( "chris", _T("DD End\n"));
02131         }
02132         if ( pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)) )
02133         {
02134             if( DDeckerState == DDECKER_NONE)
02135             {
02136                 if(pBarItem!=head)
02137                 {
02138                     SeparatorPtr = pBarItem;
02139                     CarryWidth = xpos;
02140                 }
02141             }
02142             xpos += SeparatorWidth;
02143         }
02144         else if ( (ItsABarItem = pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))||DDeckerState != DDECKER_NONE )
02145         {
02146             if ( ItsABarItem)
02147             {
02148                 wxRect WindSize;
02149                 ::GetClientRect((HWND)((BarControl*)pBarItem)->GetWinID(),&WindSize);
02150 
02151                 LastWidth = WindSize.GetWidth();
02152                 xpos += WindSize.GetWidth();
02153                 // we need a record of the widest line
02154                 if(xpos>BarWidth)
02155                         BarWidth= xpos;
02156                 FirstControlInDecker = FALSE;
02157                 if(LastItemWasDDTop)
02158                 {
02159                    FirstControlInDecker = TRUE;
02160                    LastItemWasDDTop = FALSE;
02161                 }
02162 //              TRACEUSER( "chris", _T("Control Size %d"),LastWidth);
02163             }
02164 //          TRACEUSER( "chris", _T("targetx - %d xpos - %d \n"),Targetx,xpos);
02165             // Control overlaps TargetWidth - don't insert at head of list    
02166             if ( xpos >= Targetx && pBarItem != head) 
02167             {
02168                 // We can't split if we are in a double decker control                      
02169                 BOOL CanSplit = FALSE;
02170                 if(FirstControlInDecker)
02171                     CanSplit = TRUE;
02172                 if(DDeckerState == DDECKER_NONE)
02173                     CanSplit = TRUE;
02174 //              TRACEUSER( "chris", _T("%s\n",CanSplit ?"Can Split ":"Can't Split"));
02175                 if(CanSplit)
02176                 {
02177                     BarItem * NewLineFeed = new BarLineFeed;
02178                     if(pNoLFs)
02179                         (* pNoLFs)++;
02180                     BarHeight += ControlHeight+VERTICAL_SPACE;
02181                     if ( SeparatorPtr != NULL )         // insert a LineFeed before the last separator
02182                     {
02183                         pOp->InsertItemBefore(SeparatorPtr,NewLineFeed);
02184                         SeparatorPtr = NULL;
02185                         xpos -= CarryWidth;             // decrease xpos by pos of last separator  
02186                         DDeckerStart = xpos;
02187                         GroupSplit = FALSE;
02188                         BarHeight += SeparatorWidth; 
02189 //                      TRACEUSER( "chris", _T("Separator split - xpos %d\n"),xpos);
02190                     }
02191                     else                    // no separator on this line 
02192                     {
02193                 
02194                         if(!FirstControlInDecker)
02195                             pOp->InsertItemBefore(pBarItem,NewLineFeed);
02196                         else
02197                             pOp->InsertItemBefore(pOp->GetPtrBarPrev(pBarItem),NewLineFeed);
02198                         xpos = LastWidth;               // xpos set to width of last control
02199                         if(FirstControlInDecker)
02200                             DDeckerStart = xpos-LastWidth;
02201                         GroupSplit = TRUE ;             // we must have split a group
02202 //                      TRACEUSER( "chris", _T("Normal split - xpos %d\n"),xpos);
02203                         //LastWidth = 0;
02204                     }
02205                 }
02206             }
02207             else if (GroupSplit && SeparatorPtr)
02208             {
02209                 
02210                     BarItem * NewLineFeed = new BarLineFeed;
02211                     if(pNoLFs)
02212                         (* pNoLFs)++;
02213                     pOp->InsertItemBefore(SeparatorPtr,NewLineFeed);
02214                     SeparatorPtr = NULL;
02215                     xpos -= CarryWidth;             // decrease xpos by pos of last separator
02216                     DDeckerStart = xpos;
02217                     GroupSplit = FALSE; 
02218 //                  TRACEUSER( "chris", _T("Group split - xpos %d\n"),xpos);
02219                     BarHeight += ControlHeight+VERTICAL_SPACE +  SeparatorWidth; 
02220             }
02221         }
02222         pBarItem = pOp->GetPtrBarNext(pBarItem); 
02223     }
02224     
02225     HeightEstimate = BarHeight;
02226     if(pBarSize)
02227         * pBarSize = wxSize(BarWidth,BarHeight); */
02228     return TRUE; 
02229 };
02230 
02231 
02232 /********************************************************************************************
02233 
02234 >   BaseBar::GetNearestControl(wxPoint DropPnt)
02235 
02236     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
02237     Created:    18/4/94
02238     Inputs:     -
02239     Outputs:    -
02240     Returns:    An index to place the new control in the bar item list
02241     Purpose:    Return the nearest control given a mouse position in client coords
02242     Errors:     -
02243     SeeAlso:    -
02244 
02245 ********************************************************************************************/
02246 
02247 UINT32 BaseBar::GetNearestControl(wxPoint DropPoint)
02248 {
02249 #pragma message( __LOCMSG__ "BaseBar::GetNearestControl - do nothing" )
02250     TRACE( _T("Warning - BaseBar::GetNearestControl called") );
02251 /*  HWND hcontrol;                                  // handle of current control
02252     INT32 ControlIndex = 0;                         // index in bar item list
02253     BarItem * pBarItem;                             // baritem pointer
02254     BarItemType ThisControl;                        // type of current item
02255     DDeckerReadState DDeckerState = DDECKER_NONE;   // enum to record current double decker state
02256     // check orientation of the bar we are dropping on
02257     BOOL bIsHorizontal = pOp->IsHorizontal();       
02258     
02259     
02260     // if  the bar is empty it must be the first item on the list
02261     if (pOp->IsListEmpty())
02262         return ControlIndex ;
02263 
02264     // get head item of the bar item list
02265     pBarItem = pOp->GetPtrBarHead(); 
02266 
02267     while (pBarItem != NULL)
02268     {
02269         
02270         ThisControl = GetEnumItemType(pBarItem);
02271         // Double Decker stuff...
02272         switch(ThisControl)
02273         {
02274             case DECKER_TOP:
02275                 DDeckerState = DDECKER_TOP;
02276                 break;
02277             case DECKER_BOTTOM:
02278                 DDeckerState = DDECKER_BOTTOM;
02279                 break;
02280             case DECKER_END:
02281                 DDeckerState = DDECKER_NONE;
02282                 break;
02283         }
02284 
02285         if(DDeckerState != DDECKER_TOP)
02286         {
02287             if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
02288             {
02289              
02290                 // get the handle
02291                 hcontrol=(HWND)((BarControl*)pBarItem)->GetWinID();
02292             
02293                 // Get window rect - screen coords
02294                 wxRect WindSize;
02295                 ::GetWindowRect(hcontrol,&WindSize);                
02296             
02297                 // to Client - mouse messages are in client coords
02298                 ScreenToClient(&WindSize);
02299             
02300                 // expand the rect slightly to the top and bottom
02301                 wxRect HitTest(WindSize.GetLeft(),WindSize.GetTop()-4,WindSize.GetRight(),WindSize.GetBottom()+4);
02302                 
02303                 // check the next item - if it's a line feed we might have a load of empty space to the right
02304                 // of this control - in which case we'll expand the hit test rect to include it
02305                 BarItem * pNextBarItem = pOp->GetPtrBarNext(pBarItem);
02306                 if(pNextBarItem )
02307                 {
02308                     if(bIsHorizontal)
02309                     {
02310                         if(pNextBarItem->IsKindOf(CC_RUNTIME_CLASS(BarLineFeed)))
02311                         {
02312                             wxRect ThisWindowRect;
02313                             GetWindowRect(&ThisWindowRect);
02314                             HitTest.GetRight() += (ThisWindowRect.GetRight() - WindSize.GetRight());
02315                         }
02316                         else if (pNextBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
02317                         {
02318                             // get the handle
02319                             HWND hNextControl=(HWND)((BarControl*)pNextBarItem)->GetWinID();
02320                             // Get window rect - screen coords
02321                             wxRect NextWindSize;
02322                             ::GetWindowRect(hNextControl,&NextWindSize);
02323                             // to Client - mouse messages are in client coords
02324                             ScreenToClient(&NextWindSize);
02325                         
02326                             // the hit test area should extends from the control's left edge
02327                             // to the next control's left edge
02328                             if(NextWindSize.GetLeft() > HitTest.GetRight())
02329                                 HitTest.GetRight() = NextWindSize.GetLeft();
02330                         }
02331                     }
02332                     BarItem * pLastBarItem = pOp->GetPtrBarPrev(pBarItem);
02333                     if(pLastBarItem)
02334                     {
02335                         if (pLastBarItem->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)))
02336                         {
02337                             if(bIsHorizontal)
02338                                 HitTest.GetLeft() -= SeparatorWidth;
02339                             else
02340                                 HitTest.GetTop() -=SeparatorWidth;
02341                         }
02342                     }   
02343                 }
02344 
02345                 // if the mouse is in this area we have found our drop point
02346                 if(HitTest.PtInRect(DropPoint))
02347                     return ControlIndex ;
02348                 
02349             }
02350         }
02351         
02352         // increment index
02353         ControlIndex ++;
02354         
02355         // we skip past the dragged control as it will be deleted later
02356         // this avoids the problem where a control is dropped into the
02357         // correct place only to be shifted to the left after the original control is deleted
02358         if(DragCtlHwnd==hcontrol)
02359             ControlIndex ++;
02360         
02361         // move to next item
02362         pBarItem = pOp->GetPtrBarNext(pBarItem); 
02363     }
02364     
02365     // off the end !
02366     // return index of last item
02367     return pOp->GetNumBarItems(); */
02368 
02369     return (UINT32)-1;
02370 };
02371 
02372 
02373 /****************************************************************************
02374 
02375 >   BOOL BaseBar::FormatToolBar (INT32 NewWidth)
02376 
02377     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
02378     Created:    16/11/2004
02379 
02380     Inputs:     NewWidth    - 
02381     Returns:    TRUE if ok, FALSE if bother
02382     Purpose:    
02383 
02384 ****************************************************************************/
02385 
02386 BOOL BaseBar::FormatToolBar (INT32 NewWidth)
02387 {
02388     if (this != PtrToToolBar)
02389     {
02390         return (FALSE);
02391     }
02392     else
02393     {
02394         FormatLineFeeds (NewWidth);
02395         FormatFloatingBar(FALSE,USE_BAR);
02396 
02397         return (TRUE);
02398     }
02399 }
02400 
02401 
02402 
02403 
02404 /****************************************************************************
02405 
02406 >   BOOL BaseBar::FormatBar(BOOL MoveWindows,ForceControlSize ForceSize)
02407 
02408     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
02409     Created:    16/11/2004
02410 
02411     Inputs:     MoveWindows - 
02412                 ForceSize   - 
02413     Returns:    TRUE if ok, FALSE if bother
02414     Purpose:    
02415 
02416 ****************************************************************************/
02417 
02418 BOOL BaseBar::FormatBar(BOOL MoveWindows,ForceControlSize ForceSize)
02419 {
02420     switch(ParentDockBarType)
02421     {
02422         case DOCKBAR_FLOAT:
02423             return(FormatFloatingBar(MoveWindows, ForceSize));
02424             break;
02425 
02426         case DOCKBAR_TOP:
02427         case DOCKBAR_BOTTOM:
02428             return(FormatHorizontalBar(MoveWindows, ForceSize));
02429             break;
02430 
02431         case DOCKBAR_LEFT:
02432         case DOCKBAR_RIGHT:
02433             return(FormatVerticalBar(MoveWindows, ForceSize));
02434             break;
02435 
02436         default:
02437             break;
02438     }
02439     return(FALSE);
02440 }   
02441 
02442     
02443 /********************************************************************************************
02444 
02445 >   BaseBar::FormatFloatingBar(BOOL MoveWindows,ForceControlSize Force)
02446 
02447     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
02448     Created:    18/4/94
02449     Inputs:     MoveWindows - flag to force a set window pos on the controls
02450                 Force normally we use the current dock size to format the bar - sometimes
02451                 however we need to know how big the bar would be large or small.
02452     Outputs:    -
02453     Returns:    TRUE
02454     Purpose:    Format a floating toolbar with separators and newlines
02455     Errors:     -
02456     SeeAlso:    -
02457 
02458 ********************************************************************************************/
02459 
02460 BOOL BaseBar::FormatFloatingBar(BOOL MoveWindows,ForceControlSize ForceSize)
02461 {
02462 //  TRACEUSER( "Gerry", _T("FormatFloatingBar\n"));
02463 
02464 #pragma message( __LOCMSG__ "BaseBar::FormatFloatingBar - do nothing" )
02465     TRACE( _T("Warning - BaseBar::FormatFloatingBar called") );
02466 /*  HWND hcontrol;
02467     wxSize BarSize(0,0);
02468     INT32 xpos = BAR_BORDERSIZE;
02469     INT32 ypos = BAR_BORDERSIZE;
02470     INT32 yOffset   = 0;
02471     INT32 MaxWidth = 0;
02472     INT32 DDeckerStart = 0;
02473     INT32 DDeckerEnd = 0;
02474 
02475     BarItem * pBarItem; 
02476     BarItem * LastItem = NULL;
02477 
02478     // Check Current Control Sizes in this Docking Bar
02479     INT32 ControlWidth = 0;
02480     INT32 ControlHeight = 0;
02481     ControlSizes ControlSize;
02482 
02483     DDeckerReadState DDeckerState = DDECKER_NONE;
02484     DDeckerControlHeights DDeckerHeight = SMALL_DDECKERS;
02485 
02486     //if we are dragging a bar check the size of the dock we are over
02487     // otherwise use control size of parent dock 
02488     OILDockingBar * ThisDock ;
02489     DockBarType CurrentType;
02490 
02491     CurrentType = (DragType==MOVE) ? DragDockBarType : ParentDockBarType; 
02492     ThisDock = GetMainFrame()->GetDockBar(CurrentType);
02493     
02494     BarItemType ThisControl;
02495     BarItemType LastControl = OTHERCONTROL;
02496 
02497     INT32 LargeWidth  = LARGEBUTTONWIDTH;
02498     INT32 LargeHeight = LARGEBUTTONHEIGHT;
02499     INT32 SmallWidth  = SMALLBUTTONWIDTH;
02500     INT32 SmallHeight = SMALLBUTTONHEIGHT;
02501     INT32 Control =0;
02502 
02503     // Get the current control size for this dock
02504     if (ForceSize == USE_BAR)
02505     {
02506         if (ThisDock->IsBigControls())                                              
02507         {
02508             ControlWidth = LargeWidth;
02509             ControlHeight = LargeHeight;        
02510         }
02511         else
02512         {
02513             ControlWidth = SmallWidth;
02514             ControlHeight = SmallHeight;        
02515         }
02516     }
02517     else if (ForceSize == FORCE_LARGE)
02518     {
02519         ControlWidth = LargeWidth;
02520         ControlHeight = LargeHeight;        
02521 
02522     }
02523     else if (ForceSize == FORCE_SMALL)
02524     {
02525         ControlWidth = SmallWidth;
02526         ControlHeight = SmallHeight;        
02527     }
02528     
02529     
02530     if (ControlHeight == LargeHeight )
02531     {
02532         ControlSize = LARGE_CONTROLS;
02533         DDeckerHeight = LARGE_DDECKERS ;
02534     }
02535     else
02536     {
02537         ControlSize =  SMALL_CONTROLS;
02538         DDeckerHeight = SMALL_DDECKERS ;
02539     }           
02540     // if list is empty just set a minimum size 
02541     if (! pOp->IsListEmpty())
02542     {
02543 //      TRACEUSER( "chris", _T("\n --- FORMAT ---\n"));
02544         pBarItem = pOp->GetPtrBarHead(); 
02545 
02546         while (pBarItem != NULL)
02547         {
02548             ThisControl = GetEnumItemType(pBarItem);
02549             // Double Decker stuff...
02550             switch(ThisControl)
02551             {
02552                 case DECKER_TOP:
02553                 {
02554                     DDeckerState = DDECKER_TOP;
02555                     // xpos to come back to
02556                     DDeckerStart = xpos;
02557                 }
02558                 break;
02559                 case DECKER_BOTTOM:
02560                 {
02561                     DDeckerState = DDECKER_BOTTOM;
02562                     // extent of double decker
02563                     DDeckerEnd = xpos;
02564                     // go back to start
02565                     xpos = DDeckerStart;
02566                 
02567                 }
02568                 break;
02569                 case DECKER_END:
02570                 {
02571                     DDeckerState = DDECKER_NONE;
02572                     // check for longest line top or bottom ?
02573                     if(xpos < DDeckerEnd)
02574                         xpos = DDeckerEnd;
02575                 }
02576                 break;
02577                 case SEPARATOR:
02578                 // insert a separator normally this is horizontal but if the last control was
02579                 // a LineFeed we do a vertical separator
02580                 {
02581                     if(LastItem)
02582                     {
02583                         if (LastItem->IsKindOf(CC_RUNTIME_CLASS(BarLineFeed)))
02584                             ypos += SeparatorWidth;
02585                         else
02586                             xpos += SeparatorWidth;
02587                     }
02588 //                  TRACEUSER( "chris", _T("Separator\n"));
02589                 }
02590                 break;
02591                 case LINEFEED:
02592                 // move down to next line and reset xpos
02593                 {
02594                     ypos += ControlHeight+VERTICAL_SPACE;               // Move down to the next line
02595                     if(IS_CHICAGO && pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
02596                         ypos +=4;
02597                     xpos = BAR_BORDERSIZE;
02598                     DDeckerStart = xpos;
02599                 }
02600                 break;
02601             }
02602             if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
02603             {
02604 //              TRACEUSER( "chris", _T("Control\n"));
02605                 hcontrol=(HWND)((BarControl*)pBarItem)->GetWinID(); // Get the Window Handle
02606                 wxRect WindSize;
02607 
02608                 ::GetClientRect(hcontrol,&WindSize);                // Get the window size
02609                 switch (DDeckerState)
02610                 {
02611                 case DDECKER_TOP:
02612                     if(ThisControl == SMALLBITMAPBUTTON)
02613                     {
02614                         if (ControlSize == LARGE_CONTROLS)
02615                             yOffset = (ControlHeight / 2) - sLARGEBUTTONHEIGHT +1; //get offset to center control
02616                         else
02617                             yOffset = (ControlHeight / 2) - sSMALLBUTTONHEIGHT +1;
02618                         xpos++;
02619                     }
02620                     else
02621                     {
02622                         yOffset = (ControlHeight / 2) - // WindSize.GetHeight()+1;
02623                                     DDeckerHeight + 1 ;
02624                     }
02625 
02626                     // bodge to center static text
02627                     if(ThisControl == STATIC)
02628                         yOffset +=3;
02629 
02630                     break;
02631                 case DDECKER_BOTTOM :
02632                     yOffset = (ControlHeight / 2) ; //get offset to center control
02633                     // bodge to center static text
02634                     if(ThisControl == STATIC)
02635                         yOffset +=3;
02636                     if ( ThisControl == SMALLBITMAPBUTTON)
02637                     {
02638                         yOffset ++ ;
02639                         xpos ++;
02640                     }
02641                     if(IS_CHICAGO)
02642                     {
02643                         yOffset ++;
02644                     }
02645                     break;
02646                 case DDECKER_NONE :
02647                     yOffset = (ControlHeight - WindSize.GetHeight()) / 2; //get offset to center control
02648                     break;
02649                 }
02650                 
02651                 if (MoveWindows)
02652                     ::SetWindowPos(hcontrol,NULL,xpos,ypos + yOffset,0,0,   // Move the control 
02653                                    SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOZORDER|SWP_NOREDRAW);
02654                 
02655                 xpos += WindSize.GetWidth()-1;
02656                 if(ThisControl == STATICBITMAP)
02657                     xpos ++;
02658                 else if(ThisControl == SLIDER)
02659                     xpos +=4;
02660                 LastControl = ThisControl ;
02661 
02662                 if(IS_CHICAGO)
02663                 {
02664                     if(ThisControl == EDIT)
02665                         xpos += 2;
02666                 }
02667                 
02668             }               
02669 
02670             // keep MaxWidth up to date 
02671             if (xpos > MaxWidth)
02672                     MaxWidth = xpos;
02673 
02674             // remember last control
02675             LastItem = pBarItem;
02676 
02677             // move to next item
02678             pBarItem = pOp->GetPtrBarNext(pBarItem); 
02679         }
02680 
02681     
02682         // 
02683         BarSize.width = MaxWidth + BAR_BORDERSIZE + (BorderWidth * 2) + 1 ;
02684         BarSize.cx = ypos + ControlHeight + BAR_BORDERSIZE + (BorderWidth * 2)  ;
02685 
02686     }       
02687     // Set a Minimum Bar Height
02688     if (BarSize.cx < ControlHeight + (BAR_BORDERSIZE)+ (BorderWidth * 2))
02689         BarSize.cx = ControlHeight + (BAR_BORDERSIZE)+ (BorderWidth * 2);   
02690 
02691     // ----------------------------
02692     // Set a Minimum Bar Width
02693 
02694     String_32 Name = pOp->GetName();
02695 
02696     INT32 SmallestWidth = ControlWidth + (BAR_BORDERSIZE * 2)+ (BorderWidth * 2);
02697 
02698     // If this an empty bar make sure we can see the title
02699     if (pOp->IsListEmpty())
02700     { 
02701         // Select the title font into a screen dc and get the text extent of the title
02702         wxDC *dc = GetWindowDC();
02703 
02704         wxFont * OldFont=dc->SelectObject(TitleFont);
02705 
02706         wxSize TextSize=dc->GetTextExtent(Name,camStrlen(Name));
02707 
02708         dc->SelectObject(OldFont);
02709 
02710         ReleaseDC(dc);
02711 
02712         // Check that the title string will be visible UIC
02713         if ((TextSize.width + TitleBarHeight + (BorderWidth * 4) ) > SmallestWidth)
02714             SmallestWidth = TextSize.width + TitleBarHeight + (BorderWidth * 4);
02715     }
02716 
02717     
02718     if (BarSize.width < SmallestWidth)
02719         BarSize.width = SmallestWidth ; 
02720 
02721     AdjustFormattedBarSize(&BarSize);
02722     if (MoveWindows) 
02723         PositionExtraControls(BarSize,xpos,ypos+ControlHeight);
02724     // Cache the rectangle
02725     if (ForceSize == USE_BAR)
02726     {
02727         if (ThisDock->IsBigControls())                                              
02728         {
02729             FloatLargeRect.GetRight() = BarSize.width;
02730             FloatLargeRect.GetBottom() = BarSize.cx + TitleBarHeight;   // UIC
02731         }
02732         else
02733         {
02734             FloatSmallRect.GetRight() = BarSize.width;
02735             FloatSmallRect.GetBottom() = BarSize.cx + TitleBarHeight;   //  UIC
02736         }
02737     }
02738     else if (ForceSize == FORCE_LARGE)
02739     {
02740         FloatLargeRect.GetRight() = BarSize.width;
02741         FloatLargeRect.GetBottom() = BarSize.cx + TitleBarHeight;       // UIC
02742     }
02743     else if (ForceSize == FORCE_SMALL)
02744     {
02745         FloatSmallRect.GetRight() = BarSize.width;
02746         FloatSmallRect.GetBottom() = BarSize.cx + TitleBarHeight;       // UIC
02747     } */
02748     return TRUE; 
02749 };
02750 
02751 /********************************************************************************************
02752 
02753 >   BaseBar::FormatHorizontalBar(BOOL MoveWindows,ForceControlSize Force)
02754 
02755     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
02756     Created:    18/4/94
02757     Inputs:         
02758                 MoveWindows - flag to force a set window pos on the controls
02759                 Force normally we use the current dock size to format the bar - sometimes
02760                 however we need to know how big the bar would be large or small.
02761     Outputs:    -
02762     Returns:    -
02763     Purpose:    Format a Horizontal toolbar with separators 
02764     Errors:     -
02765     SeeAlso:    -
02766 
02767 ********************************************************************************************/
02768 BOOL BaseBar::FormatHorizontalBar(BOOL MoveControls,ForceControlSize ForceSize)
02769 {
02770 //  TRACEUSER( "Gerry", _T("FormatHorizontalBar\n"));
02771 
02772 #pragma message( __LOCMSG__ "BaseBar::FormatHorizontalBar - do nothing" )
02773     TRACE( _T("Warning - BaseBar::FormatHorizontalBar called") );
02774 /*  BOOL AtFront = TRUE;    
02775     HWND hcontrol;
02776     // Find out how many bar items
02777     UINT32 NumBarItems = pOp->GetNumBarItems(); 
02778     INT32 ypos = 0 ;
02779     INT32 xpos = BAR_BORDERSIZE;
02780     INT32 yOffset = 0;
02781     INT32 DDeckerStart = 0;
02782     INT32 DDeckerEnd = 0;
02783     wxSize BarSize(0,0);
02784     BarItem* pBarItem;
02785     ControlSizes ControlSize;
02786     DDeckerReadState DDeckerState = DDECKER_NONE;
02787     DDeckerControlHeights DDeckerHeight = SMALL_DDECKERS;
02788     INT32 ButtonSize;
02789     BarItemType ThisControl ;
02790     BarItemType LastControl = OTHERCONTROL;
02791     // if we are dragging a bar check the size of the dock we are over
02792     // otherwise use control size of parent dock 
02793 
02794     OILDockingBar * ThisDock ;
02795     DockBarType CurrentType;
02796 
02797     CurrentType = (DragType==MOVE) ? DragDockBarType : ParentDockBarType; 
02798     ThisDock = GetMainFrame()->GetDockBar(CurrentType);
02799 
02800     // Get the current control size for this dock
02801     if (ForceSize == USE_BAR)
02802     {
02803         if (ThisDock->IsBigControls())                                              
02804             ControlSize = LARGE_CONTROLS;
02805         else
02806             ControlSize = SMALL_CONTROLS;                
02807     }
02808     else if (ForceSize == FORCE_LARGE)
02809     {
02810         ControlSize = LARGE_CONTROLS;
02811     }
02812     else if (ForceSize == FORCE_SMALL)
02813     {
02814         ControlSize = SMALL_CONTROLS;   
02815     }
02816     
02817     
02818     if (ControlSize == LARGE_CONTROLS)
02819     {
02820         ButtonSize = LARGEBUTTONWIDTH-1;
02821         DDeckerHeight = LARGE_DDECKERS ;
02822     }
02823     else
02824     {
02825         ButtonSize = SMALLBUTTONWIDTH-1;
02826         DDeckerHeight = SMALL_DDECKERS ;
02827     }           
02828     // if list is empty just set a minimum size 
02829     if (! pOp->IsListEmpty()||ThisIsAnInfoBar)
02830     {
02831 
02832         pBarItem = pOp->GetPtrBarHead();
02833         
02834         while(pBarItem!=NULL)
02835         {
02836             // Get the next BarItem
02837             ThisControl = GetEnumItemType(pBarItem);
02838             switch ( ThisControl )
02839             {
02840                 case DECKER_TOP:
02841                 {
02842                     DDeckerState = DDECKER_TOP;
02843                     // xpos to come back to
02844                     DDeckerStart = xpos;
02845                 }
02846                 break;
02847                 case DECKER_BOTTOM:
02848                 {
02849                     DDeckerState = DDECKER_BOTTOM;
02850                     // extent of double decker
02851                     DDeckerEnd = xpos;
02852                     // go back to start
02853                     xpos = DDeckerStart;
02854                 
02855                 }
02856                 break;
02857                 case DECKER_END:
02858                 {
02859                     DDeckerState = DDECKER_NONE;
02860                     // check for longest line top or bottom ?
02861                     if ( xpos < DDeckerEnd)
02862                         xpos = DDeckerEnd;
02863                 }
02864                 break;
02865                 case SEPARATOR:
02866                 {
02867                     if( ! AtFront ) // don't separate at the front of a bar
02868                     {   
02869                         xpos += SeparatorWidth;
02870                     }
02871                 }
02872                 break;
02873             }
02874             
02875             if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
02876             {
02877                 hcontrol=(HWND)((BarControl*)pBarItem)->GetWinID();         // Get the Window Handle
02878     
02879                 wxRect WindSize;
02880                 ::GetClientRect(hcontrol,&WindSize);
02881                 switch (DDeckerState)
02882                 {
02883                 case DDECKER_TOP:
02884                     
02885                     // this is all rather messy because SMALLBITMAPBUTTONS and Chicago
02886                     // buttons don't overlap where normal pre chicago buttons do ...
02887 
02888                     if ( ThisControl == SMALLBITMAPBUTTON)
02889                     {
02890                         if (ControlSize == LARGE_CONTROLS)
02891                             yOffset = (ControlSize / 2) - sLARGEBUTTONHEIGHT +1 ; //get offset to center control
02892                         else
02893                             yOffset = (ControlSize / 2) - sSMALLBUTTONHEIGHT +1 ;   
02894                         
02895                         xpos++;
02896                     }
02897                     else
02898                     {
02899                         yOffset = (ControlSize / 2) - DDeckerHeight +1;
02900                         
02901                     }
02902                     // bodge to center static text
02903                     if(ThisControl == STATIC)
02904                         yOffset +=3;
02905 
02906                     
02907                     break;
02908                 case DDECKER_BOTTOM :
02909     
02910                     yOffset = (ControlSize / 2) ; //get offset to center control
02911     
02912                     if ( ThisControl == SMALLBITMAPBUTTON)
02913                     {
02914                         yOffset ++ ;
02915                         xpos ++;
02916                     }
02917                     if ( ThisControl == STATIC)
02918                     {
02919                         yOffset +=3;
02920                     }
02921                     break;
02922                 case DDECKER_NONE :
02923                     yOffset = (ControlSize - WindSize.GetHeight()) / 2; //get offset to center control
02924                     break;
02925                 }
02926                 if ( MoveControls )
02927                     ::SetWindowPos(hcontrol,NULL,xpos,ypos + yOffset,0,0,
02928                                    SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOZORDER|SWP_NOREDRAW);
02929         
02930                 xpos += WindSize.GetWidth()-1;
02931                 
02932                 if(ThisControl == STATICBITMAP)
02933                     xpos++;
02934 
02935                 LastControl = ThisControl ;
02936                 if(IS_CHICAGO)
02937                 {
02938                     if(ThisControl == EDIT)
02939                         xpos += 2;
02940                 }
02941             }
02942             AtFront = FALSE;
02943             pBarItem = pOp->GetPtrBarNext(pBarItem);
02944         }// end while 
02945 
02946         BarSize.width = xpos + (BAR_BORDERSIZE*2)-1;
02947         
02948     }
02949         // Set a Minimum Bar Size
02950     if (BarSize.width < ControlSize + (BAR_BORDERSIZE *2))
02951     {
02952         BarSize.width = ControlSize + (BAR_BORDERSIZE *2);  
02953     }
02954   
02955     // This test forces horizontal infobars to be a set width 
02956     if (ThisIsAnInfoBar && ! pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
02957     {
02958         if(ControlSize == LARGE_CONTROLS)
02959             BarSize.width = LARGE_INFO_BAR;
02960         else
02961             BarSize.width = SMALL_INFO_BAR;
02962     }
02963 
02964     BarSize.cx = ControlSize +1;
02965     
02966     if(IS_CHICAGO)
02967         BarSize.height--;
02968 
02969     // Cache this bar size
02970     if (ForceSize == USE_BAR)
02971     {
02972         if (ThisDock->IsBigControls())                                              
02973         {
02974             HorizontalLargeRect.GetRight() = BarSize.width;
02975             HorizontalLargeRect.GetBottom() = BarSize.height;
02976         }
02977         else
02978         {
02979             HorizontalSmallRect.GetRight() = BarSize.width;
02980             HorizontalSmallRect.GetBottom() = BarSize.height;
02981         }
02982     }
02983     else if (ForceSize == FORCE_LARGE)
02984     {
02985         HorizontalLargeRect.GetRight() = BarSize.width;
02986         HorizontalLargeRect.GetBottom() = BarSize.height;
02987     }
02988     else if (ForceSize == FORCE_SMALL)
02989     {
02990         HorizontalSmallRect.GetRight() = BarSize.width;
02991         HorizontalSmallRect.GetBottom() = BarSize.height;
02992     } */
02993     return TRUE; 
02994 }; 
02995                       
02996 
02997 
02998 
02999 /********************************************************************************************
03000 
03001 >   BaseBar::FormatVerticalBar(BOOL MoveWindows,ForceControlSize Force)
03002 
03003     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
03004     Created:    18/4/94
03005     Inputs:     
03006                 MoveWindows - flag to force a set window pos on the controls
03007                 Force normally we use the current dock size to format the bar - sometimes
03008                 however we need to know how big the bar would be large or small.
03009     Outputs:    -
03010     Returns:    -
03011     Purpose:    Format a Vertical toolbar with separators 
03012     Errors:     -
03013     SeeAlso:    -
03014 
03015 ********************************************************************************************/
03016 
03017 
03018 BOOL BaseBar::FormatVerticalBar(BOOL MoveControls,ForceControlSize ForceSize)
03019 {
03020 //  TRACEUSER( "Gerry", _T("FormatVerticalBar\n"));
03021 #pragma message( __LOCMSG__ "BaseBar::FormatVerticalBar - do nothing" )
03022     TRACE( _T("Warning - BaseBar::FormatVerticalBar called") );
03023 /*  BOOL AtFront = TRUE;    
03024     HWND hcontrol;
03025 
03026     // Find out how many bar items
03027     UINT32 NumBarItems = pOp->GetNumBarItems(); 
03028     INT32 xpos = BAR_VERTICAL_CENTEROFFSET;
03029     INT32 ypos = BAR_BORDERSIZE;
03030     BarItem* pBarItem;
03031     BarItemType ThisControl; 
03032     ControlSizes ControlSize;
03033     INT32 ButtonSize;
03034 
03035     wxSize BarSize(0,0) ;
03036     
03037     //if we are dragging a bar check the size of the dock we are over
03038     // otherwise use control size of parent dock 
03039     OILDockingBar * ThisDock ;
03040     DockBarType CurrentType;
03041 
03042     CurrentType = (DragType==MOVE) ? DragDockBarType : ParentDockBarType; 
03043     ThisDock = GetMainFrame()->GetDockBar(CurrentType);
03044 
03045     // Get the current control size for this dock
03046     if (ForceSize == USE_BAR)
03047     {
03048         if (ThisDock->IsBigControls())                                              
03049             ControlSize = LARGE_CONTROLS;
03050         else
03051             ControlSize = SMALL_CONTROLS;
03052     }
03053     else if (ForceSize == FORCE_LARGE)
03054     {
03055         ControlSize = LARGE_CONTROLS;
03056     }
03057     else if (ForceSize == FORCE_SMALL)
03058     {
03059         ControlSize = SMALL_CONTROLS;   
03060     }
03061 
03062     if (ControlSize == LARGE_CONTROLS)
03063         ButtonSize = LARGEBUTTONHEIGHT-1;
03064     else
03065         ButtonSize = SMALLBUTTONHEIGHT-1;
03066 
03067     // if list is empty just set a minimum size 
03068     if (! pOp->IsListEmpty())
03069     {
03070 
03071         pBarItem = pOp->GetPtrBarHead(); 
03072         while (pBarItem != NULL)
03073         {
03074             ThisControl = GetEnumItemType(pBarItem);
03075             if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)))
03076             {
03077                 if(!AtFront ) // don't separate at the front of a bar
03078                 {
03079                     ypos += SeparatorWidth;
03080                 }
03081             }
03082             else if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
03083             {
03084                 hcontrol=(HWND)((BarControl*)pBarItem)->GetWinID();     // Get the Window Handle
03085                 wxRect WindSize;
03086                     ::GetClientRect(hcontrol,&WindSize);
03087                 INT32 Offset = (ControlSize - WindSize.GetWidth())/2;
03088                 if (MoveControls)
03089                     ::SetWindowPos(hcontrol,NULL,Offset,ypos,0,0,
03090                                    SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOZORDER|SWP_NOREDRAW);
03091 
03092                 if(ThisControl == SLIDER)
03093                 {
03094                     ypos += WindSize.GetHeight();
03095                 }
03096                 else
03097                 {
03098                     ypos += ButtonSize;
03099                 }
03100             }
03101             AtFront = FALSE;
03102             pBarItem = pOp->GetPtrBarNext(pBarItem); 
03103         }
03104 
03105         BarSize.height = ypos + (BAR_BORDERSIZE*2)-1;
03106     }
03107     // Set a Minimum Bar Size
03108     if (BarSize.height < ControlSize + (BAR_BORDERSIZE *2))
03109         BarSize.height = ControlSize + (BAR_BORDERSIZE *2); 
03110 
03111     BarSize.width = ControlSize +1;
03112    
03113     if(IS_CHICAGO)
03114         BarSize.width--;
03115 
03116     if (ForceSize == USE_BAR)
03117     {
03118         if (ThisDock->IsBigControls())                                              
03119         {
03120             VerticalLargeRect.GetRight() = BarSize.width;
03121             VerticalLargeRect.GetBottom() = BarSize.height;
03122         }
03123         else
03124         {
03125             VerticalSmallRect.GetRight() = BarSize.width;
03126             VerticalSmallRect.GetBottom() = BarSize.height;
03127         }
03128     }
03129     else if (ForceSize == FORCE_LARGE)
03130     {
03131         VerticalLargeRect.GetRight() = BarSize.width;
03132         VerticalLargeRect.GetBottom() = BarSize.height;
03133     }
03134     else if (ForceSize == FORCE_SMALL)
03135     {
03136         VerticalSmallRect.GetRight() = BarSize.width;
03137         VerticalSmallRect.GetBottom() = BarSize.height;
03138     } */
03139  
03140     return TRUE; 
03141 };
03142 
03143 /********************************************************************************************
03144 
03145 >   void BaseBar::AdjustFormattedBarSize(wxSize* BarSize)
03146 
03147     Author:     Alex
03148     Created:    1/7/94
03149     Inputs:     Pointer to the bar size record to adjust 
03150     Outputs:    -
03151     Returns:    None
03152     Purpose:    Adjusts the proposed new size of a bar once formatting has taken place   
03153     Errors:     -
03154     SeeAlso:    GalleryBar::AdjustFormattedBarSize
03155 
03156 This function does nothing in the base class, but may be overridden, for instance by Gallery
03157 Bars.
03158 
03159 ********************************************************************************************/
03160 
03161 void BaseBar::AdjustFormattedBarSize(wxSize* BarSize)
03162 {
03163 }
03164 
03165 /********************************************************************************************
03166 
03167 >   void BaseBar::PositionExtraControls(wxSize BarSize, INT32 xpos, INT32 ypos)
03168 
03169     Author:     Alex
03170     Created:    1/7/94
03171     Inputs:     Bar size record, x & y coord of current format position. 
03172     Outputs:    -
03173     Returns:    None
03174     Purpose:    Moves extra controls about once they have been created   
03175     Errors:     -
03176     SeeAlso:    GalleryBar::PositionExtraControls, BaseBar::CreateExtraControls
03177 
03178 This function does nothing in the base class, but may be overridden, for instance by Gallery
03179 Bars.
03180 
03181 ********************************************************************************************/
03182 
03183 void BaseBar::PositionExtraControls(wxSize BarSize, INT32 xpos, INT32 ypos)
03184 {
03185 }
03186 
03187 /********************************************************************************************
03188 
03189 >   INT32 BaseBar::CreateExtraControls()
03190 
03191     Author:     Alex
03192     Created:    1/7/94
03193     Inputs:     None 
03194     Outputs:    TRUE if successful, else FALSE
03195     Returns:    None
03196     Purpose:    Allows subclasses to create additional bar controls   
03197     Errors:     -
03198     SeeAlso:    GalleryBar::CreateExtraControls, BaseBar::PositionExtraControls
03199 
03200 This function does nothing in the base class, but may be overridden, for instance by Gallery
03201 Bars.
03202 
03203 ********************************************************************************************/
03204 
03205 INT32 BaseBar::CreateExtraControls()
03206 {
03207     return TRUE;
03208 }
03209 
03210   
03211 
03212 
03213 /********************************************************************************************
03214 
03215 >   BOOL BaseBar::CreateToolBtn(BarToolButton* pToolBtn)
03216 
03217     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
03218     Created:    13/4/94
03219     Inputs:     pToolBtn: The 
03220     Outputs:    -
03221     Returns:    TRUE if succesful, FALSE otherwise
03222     Purpose:    Creates tool bar button control   
03223     Errors:     -
03224     SeeAlso:    -
03225 
03226 ********************************************************************************************/
03227 // This function is probably dead wood
03228 BOOL BaseBar::CreateToolBtn(BarToolButton* pToolBtn)
03229 {
03230 return TRUE ;
03231 } 
03232 
03233 
03234 DLGITEMTEMPLATE* BaseBar::GetPointerToControl(DLGTEMPLATE* pDlg ,UINT32 CtlId)
03235 {
03236     PORTNOTETRACE( "dialog", "BaseBar::GetPointerToControl - do nothing - DLGITEMTEMPLATE usage" );
03237 #ifndef EXCLUDE_FROM_XARALX
03238     DLGITEMTEMPLATE* pCurrentControl = (DLGITEMTEMPLATE *) (((ADDR)pDlg) + SizeDlgHeader(pDlg));
03239     WORD NumControls = pDlg->cdit;
03240     ENSURE(pCurrentControl != NULL, "Hideous Error in Load Controls"); 
03241 
03242     for (UINT32 i = 0; i< NumControls; i++)
03243     {
03244         if (pCurrentControl->id == CtlId)
03245         {
03246             return pCurrentControl;
03247         }
03248         pCurrentControl = (DLGITEMTEMPLATE *)
03249             (((ADDR)pCurrentControl) + SizeCtrlData(pCurrentControl));  
03250     }
03251 #endif
03252     return NULL;
03253 }
03254 
03255 HINSTANCE BaseBar::GetModuleInst(const BarControlInfo*pBarCtlInfo,UINT32 * ToolModuleID )
03256 {
03257 #pragma message( __LOCMSG__ "BaseBar::GetModuleInst - do nothing" )
03258     TRACE( _T("Warning - BaseBar::GetModuleInst called") );
03259 /*  *ToolModuleID = Tool::GetModuleID(pBarCtlInfo->ToolID); 
03260 
03261     // tools.dll not loaded, chances are the resources are in with the rest
03262     if(DLLs[0] == (HINSTANCE)HINSTANCE_ERROR || DLLs[0] == 0)
03263         return AfxGetResourceHandle();
03264     
03265     return ResHelp::GetInstanceFromID( pBarCtlInfo->ResourceID );
03266 
03267 #if 0
03268 // old code before Andy got to it
03269     HINSTANCE ModuleInst;
03270     if (pBarCtlInfo->ToolID != 0)  // We want to get control from tool DLL
03271     {
03272         // Try to get the tools module ID
03273         *ToolModuleID = Tool::GetModuleID(pBarCtlInfo->ToolID); 
03274 
03275         ENSURE(*ToolModuleID != 0, "Could not find module ID"); 
03276         if (*ToolModuleID == 0)
03277             return NULL; 
03278         // Now try to get the module's instance
03279         ModuleInst = OILModule::GetInstance(*ToolModuleID); 
03280         ENSURE (ModuleInst != (HINSTANCE)HINSTANCE_ERROR, "Could not obtain module instance"); 
03281         if (ModuleInst == (HINSTANCE)HINSTANCE_ERROR)
03282             return NULL;
03283         else
03284             return ModuleInst; 
03285     }
03286     else 
03287     {
03288         // get controls from exe
03289         return  AfxGetApp()->m_hInstance;
03290     }                                              
03291 #endif */
03292 
03293     return HINSTANCE(-1);
03294 }
03295 /********************************************************************************************
03296 
03297 >   BOOL BaseBar::CreateInfoControlFromResource(BarControl* pBarControl)
03298 
03299     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
03300     Created:    13/4/94
03301     Inputs:     pBarControl:    The BarControl to create
03302     Outputs:    -
03303     Returns:    -
03304     Purpose:    Special case for info bars 
03305     Errors:     -
03306     SeeAlso:    -
03307 
03308 ********************************************************************************************/
03309 
03310 
03311 BOOL BaseBar::CreateInfoControlFromResource(BarControl* pBarControl,BOOL Init)
03312 {
03313     PORTNOTETRACE( "dialog", "BaseBar::CreateInfoControlFromResource - do nothing" );
03314 #ifndef EXCLUDE_FROM_XARALX
03315     const BarControlInfo * pBarCtlInfo;
03316     static DLGITEMTEMPLATE * pCurrentControl;
03317     static HINSTANCE    ModuleInst   = NULL;
03318     static UINT32 ResID =0;
03319     static UINT32 ControlID; 
03320     static HRSRC hRes = NULL;
03321     static DLGTEMPLATE* pDlg;
03322     static HGLOBAL hGlobalRes = NULL;
03323 
03324     UINT32      ToolModuleID = 0;
03325     HINSTANCE ThisModuleInst = NULL;
03326     
03327     // DISABLE CACHING FOR NOW !
03328     Init = TRUE;
03329 
03330     if(pBarControl==NULL)
03331     {   if(hGlobalRes != NULL)
03332         {
03333             // Lets do the nice thing  
03334             UnlockResource(hGlobalRes);
03335             FreeResource(hGlobalRes);   
03336         }
03337         return FALSE;
03338     }
03339     
03340     // Get control info
03341     if (pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
03342     {
03343         pBarCtlInfo = &(pBarControl->GetHorzControl()->BarCtrlInfo);
03344     }
03345     else
03346     {
03347         switch(ParentDockBarType)
03348         {
03349             case DOCKBAR_TOP:
03350             case DOCKBAR_BOTTOM:
03351             case DOCKBAR_FLOAT:
03352                 pBarCtlInfo =&(pBarControl->GetHorzControl()->BarCtrlInfo);
03353                 break;
03354             case DOCKBAR_LEFT:
03355             case DOCKBAR_RIGHT:
03356                 pBarCtlInfo =&(pBarControl->GetVertControl()->BarCtrlInfo);
03357                 break;
03358         }
03359     }
03360     
03361     // initialise ModuleInst 
03362     if(Init)
03363     {
03364         ModuleInst = GetModuleInst(pBarCtlInfo,&ToolModuleID);
03365     }
03366     // normally just check if we need the same module
03367     else
03368     {
03369         ThisModuleInst = GetModuleInst(pBarCtlInfo,&ToolModuleID);
03370         if(ThisModuleInst != ModuleInst)
03371         {
03372             Init = TRUE;
03373             ModuleInst = ThisModuleInst;
03374         }
03375         if(ModuleInst == NULL)
03376             ENSURE(FALSE,"Can't find Module Instance");
03377         if(pBarCtlInfo->ResourceID != ResID)
03378         {
03379             Init = TRUE;
03380             ResID = pBarCtlInfo->ResourceID;
03381         }
03382     }
03383 
03384     BOOL CreatedControl = FALSE; 
03385 
03386     // Try to find, load and lock the dialog resource
03387     if(Init)
03388     {
03389         if(hGlobalRes!=NULL)
03390         {
03391             // Lets do the nice thing  
03392             UnlockResource(hGlobalRes);
03393             FreeResource(hGlobalRes);   
03394         }
03395 
03396         hRes = FindResource(ModuleInst, MAKEINTRESOURCE(pBarCtlInfo->ResourceID), RT_DIALOG);
03397         if (hRes == NULL)
03398         {
03399             ERROR3_PF( ("Could not find RT_DIALOG id %u in %x", pBarCtlInfo->ResourceID, 
03400                                                                             ModuleInst ) );
03401             return FALSE;
03402         }
03403         // Try to get handle to global block containing resource data 
03404         hGlobalRes = LoadResource(ModuleInst, hRes);
03405         ENSURE(hGlobalRes != NULL, "Could not load resource");
03406         if (hGlobalRes == NULL)
03407             return FALSE;  
03408 
03409         // Get the dialog resource 
03410         pDlg = (DLGTEMPLATE *) LockResource(hGlobalRes);
03411         ENSURE(pDlg != NULL, "Could not lock resource"); 
03412         if (pDlg == NULL)
03413             return FALSE; 
03414         
03415         pCurrentControl = (DLGITEMTEMPLATE *) (((ADDR)pDlg) + SizeDlgHeader(pDlg));
03416     }
03417     
03418     //TRACE( _T("found %d after %d"),pCurrentControl->id,pBarCtlInfo->ControlID);
03419     
03420     if(!Init)
03421     {
03422         if (pCurrentControl->id == pBarCtlInfo->ControlID )
03423         {
03424             // Yippee ! We have found the control required
03425             // Lets create it 
03426             if (CreateControlItem(pCurrentControl,pBarControl,ModuleInst,ToolModuleID))
03427             {
03428                 return  TRUE; 
03429             }
03430             else
03431             {
03432                 ENSURE(FALSE,"Failed to create control");
03433                 return FALSE;
03434             }
03435             pCurrentControl = (DLGITEMTEMPLATE *)
03436             (((ADDR)pCurrentControl) + SizeCtrlData(pCurrentControl));       
03437         }
03438         else
03439         {
03440             Init =TRUE;
03441             return CreateInfoControlFromResource(pBarControl,TRUE);
03442         }
03443     }
03444 
03445 
03446     if(Init)
03447     {
03448     
03449         DLGITEMTEMPLATE * ThisControl = GetPointerToControl(pDlg ,pBarCtlInfo->ControlID);
03450         if(ThisControl==NULL)
03451         {
03452             //ENSURE(FALSE,"Can't find Control in Resource");
03453             ERROR3_PF(("Can't find Control (%d / 0x%x) in Resource (%d / 0x%x)", pBarCtlInfo->ControlID, pBarCtlInfo->ControlID, pBarCtlInfo->ResourceID, pBarCtlInfo->ResourceID));
03454             return FALSE;
03455         }
03456         if (CreateControlItem(ThisControl,pBarControl,ModuleInst,ToolModuleID))
03457         {
03458             return TRUE; 
03459         }
03460         else
03461         {
03462             return FALSE;
03463         }
03464         pCurrentControl = (DLGITEMTEMPLATE *)
03465         (((ADDR)ThisControl) + SizeCtrlData(ThisControl));       
03466     }
03467 
03468     return (CreatedControl);
03469 #else   
03470     return FALSE;
03471 #endif
03472 }
03473 
03474 
03475 /********************************************************************************************
03476 
03477 >   BOOL BaseBar::CreateControlFromResource(BarControl* pBarControl)
03478 
03479     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
03480     Created:    13/4/94
03481     Inputs:     pBarControl:    The BarControl to create
03482     Outputs:    -
03483     Returns:    -
03484     Purpose:    Create 
03485     Errors:     -
03486     SeeAlso:    -
03487 
03488 ********************************************************************************************/
03489 
03490 BOOL BaseBar::CreateControlFromResource(BarControl* pBarControl)
03491 {
03492     PORTNOTETRACE( "dialog", "BaseBar::CreateControlFromResource - do nothing - Resource usage" );
03493 #ifndef EXCLUDE_FROM_XARALX
03494     const BarControlInfo*pBarCtlInfo;
03495 
03496     if (pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
03497     {
03498         pBarCtlInfo = &(pBarControl->GetHorzControl()->BarCtrlInfo);
03499     }
03500     else
03501     {
03502         switch(ParentDockBarType)
03503         {
03504             case DOCKBAR_TOP:
03505             case DOCKBAR_BOTTOM:
03506             case DOCKBAR_FLOAT:
03507                 pBarCtlInfo =&(pBarControl->GetHorzControl()->BarCtrlInfo);
03508                 break;
03509             case DOCKBAR_LEFT:
03510             case DOCKBAR_RIGHT:
03511                 pBarCtlInfo =&(pBarControl->GetVertControl()->BarCtrlInfo);
03512                 break;
03513         }
03514     }
03515 
03516     HINSTANCE   ModuleInst   = NULL; 
03517     UINT32      ToolModuleID = 0;
03518     
03519     ModuleInst = GetModuleInst(pBarCtlInfo,&ToolModuleID);
03520 
03521     // -------------------------------------------------------------------------------------
03522     // Try to find, load and lock the dialog resource
03523 
03524     HRSRC hRes = FindResource(ModuleInst, MAKEINTRESOURCE(pBarCtlInfo->ResourceID), RT_DIALOG);
03525 
03526     ENSURE(hRes != NULL, "Could not find resource"); 
03527     if (hRes == NULL)
03528         return FALSE;  
03529 
03530     // Try to get handle to global block containing resource data 
03531     HGLOBAL hGlobalRes = LoadResource(ModuleInst, hRes);
03532     ENSURE(hGlobalRes != NULL, "Could not load resource");
03533     if (hGlobalRes == NULL)
03534         return FALSE;  
03535 
03536     // Get the dialog resource 
03537     DLGTEMPLATE* pDlg = (DLGTEMPLATE *) LockResource(hGlobalRes);
03538     ENSURE(pDlg != NULL, "Could not lock resource"); 
03539     if (pDlg == NULL)
03540         return FALSE; 
03541 
03542 
03543     // We are totally disinterested in the Dialog itself as it's only a recepticle for storing
03544     // control resources
03545     
03546 
03547     BOOL CreatedControl = FALSE; 
03548 
03549     // Loop until we have found the control to create 
03550     
03551     WORD NumControls = pDlg->cdit; // The number of items in the dialog
03552 
03553     TRACEUSER( "Simon", _T("Dialog has %d controls"), NumControls); 
03554 
03555     // Get pointer to first control
03556     DLGITEMTEMPLATE *pCurrentControl = (DLGITEMTEMPLATE *) (((ADDR)pDlg) + SizeDlgHeader(pDlg));
03557 
03558     ENSURE(pCurrentControl != NULL, "Hideous Error in Load Controls"); 
03559 
03560     for (UINT32 i = 0; i< NumControls; i++)
03561     {
03562         if (pCurrentControl->id == pBarCtlInfo->ControlID)
03563         {
03564             // Yippee ! We have found the control required
03565             // Lets create it 
03566             if (CreateControlItem(pCurrentControl,pBarControl,ModuleInst,ToolModuleID))
03567             {
03568                 CreatedControl = TRUE; 
03569             }
03570             break; 
03571         }
03572         pCurrentControl = (DLGITEMTEMPLATE *)
03573             (((ADDR)pCurrentControl) + SizeCtrlData(pCurrentControl));  
03574     }
03575 
03576     // Lets do the nice thing  
03577     UnlockResource(hGlobalRes);
03578     FreeResource(hGlobalRes);
03579 
03580     return (CreatedControl);
03581 #else
03582     return FALSE;
03583 #endif
03584 }
03585 
03586 
03587 /********************************************************************************************
03588 
03589 >   void BaseBar::CreateControlItem(DLGITEMTEMPLATE * pCurrentControl,
03590                                       BarControl * pBarControl, 
03591                                       HINSTANCE ModuleInst,
03592                                       UINT32 ToolModuleID)  
03593 
03594     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
03595     Created:    13/4/94
03596     Inputs:     pCurrentControl: The control to create
03597                 pBarControl    : Kernel description of control
03598                 ModuleInst     : Module handle
03599                 ToolModuleID   : The tool's module ID
03600     Outputs:    -
03601     Returns:    -
03602     Purpose:    Creates the control and attaches it as a child of the BaseBars window, 
03603     Errors:     -
03604     sCOPE:      private
03605     SeeAlso:    -
03606 
03607 ********************************************************************************************/
03608                                      
03609  BOOL BaseBar::CreateControlItem(DLGITEMTEMPLATE * pCurrentControl,
03610                                     BarControl * pBarControl,
03611                                     HINSTANCE ModuleInst,
03612                                     UINT32 ToolModuleID)
03613 {
03614 #pragma message( __LOCMSG__ "BaseBar::GetModuleInst - do nothing" )
03615     TRACE( _T("Warning - BaseBar::GetModuleInst called") );
03616 /*  BarItemType  ThisControlType = OTHERCONTROL;
03617 
03618     BOOL ResizeWithFont = FALSE;
03619 
03620     #if WIN32
03621     // Get pointer to the data after the DLGITEMTEMPLATE structure.
03622     WORD *pData = (WORD *) (pCurrentControl + 1);
03623 
03624     // Obtain the class
03625     LPWSTR pClass;
03626 
03627     if (*pData == 0xFFFF)
03628     {
03629         // Convert the atom value into a string
03630 
03631         switch((*(pData+1)))
03632         {
03633             case  0x0080:
03634             {
03635                 pClass = L"Button";
03636                 ThisControlType = BUTTON;
03637                 ResizeWithFont = TRUE;
03638                 break;
03639             }
03640             case 0x0081:
03641             {
03642                 pClass = L"Edit";
03643                 ThisControlType = EDIT;
03644                 ResizeWithFont = TRUE;
03645                 break;
03646             }
03647             case 0x0082:
03648             {
03649                 pClass = L"Static";
03650                 ThisControlType = STATIC;
03651                 ResizeWithFont = TRUE;
03652                 break;
03653             }
03654             case 0x0083:
03655             {
03656                 pClass = L"Listbox";
03657                 ThisControlType = LIST;
03658                 ResizeWithFont = TRUE;
03659                 break;
03660             }
03661             case 0x0084:
03662             {
03663                 pClass = L"Scrollbar";
03664                 ThisControlType = SCROLLBAR;
03665                 break;
03666             }
03667             case 0x0085:
03668             {
03669                 pClass = L"Combobox";
03670                 ThisControlType = COMBO;
03671                 ResizeWithFont = TRUE;
03672                 break;
03673             }
03674         }
03675 
03676         pData += 2;
03677     }                                              
03678     else
03679     {
03680         // The class is specified as a string
03681         pClass = (LPWSTR)pData; 
03682         pData = (WORD *) MovePastWideStr((LPWSTR) pData);
03683     }
03684                                                                    
03685     // Obtain the windows title 
03686     LPWSTR pTitle; 
03687                                      
03688     if (*pData == 0xFFFF)
03689     {
03690         // It's a resource
03691         pTitle = (LPWSTR) (pData+1); 
03692         
03693         pData += 2;                                    
03694     }
03695     else
03696     {
03697         pTitle = (LPWSTR) pData; 
03698         // The title array is a string - skip it
03699         pData = (WORD *) MovePastWideStr((LPWSTR) pData);
03700     }
03701 
03702     // Obtain the creation data
03703     LPVOID pCreationData = (LPVOID*) (pData+2); 
03704 
03705 
03706     // ------------------------------------------------------------------------------------
03707 
03708     #else
03709     // Get pointer to the data after the DLGITEMTEMPLATE structure.
03710     ADDR pData = (ADDR) (pCurrentControl + 1);
03711     // Obtain the class
03712 
03713     LPCTSTR pClass; 
03714     LPCTSTR pTitle;
03715 
03716     if ((*pData) & 0x80)
03717     {   
03718         // An atom is specified 
03719         
03720         // Convert the atom 
03721         switch((*(pData+1)))
03722         {
03723             case  0x0080:
03724             {
03725                 pClass = "Button";
03726                 ThisControlType = BUTTON;
03727                 ResizeWithFont = TRUE;
03728                 break;
03729             }
03730             case 0x0081:
03731             {
03732                 pClass = "Edit";
03733                 ThisControlType = EDIT;
03734                 ResizeWithFont = TRUE;
03735                 break;
03736             }
03737             case 0x0082:
03738             {
03739                 pClass = "Static";
03740                 ThisControlType = STATIC;
03741                 ResizeWithFont = TRUE;
03742                 break;
03743             }
03744             case 0x0083:
03745             {
03746                 pClass = "Listbox";
03747                 ThisControlType = LIST;
03748                 ResizeWithFont = TRUE;
03749                 break;
03750             }
03751             case 0x0084:
03752             {
03753                 pClass = "Scrollbar";
03754                 ThisControlType = SCROLLBAR;
03755                 break; 
03756             }
03757             case 0x0085:
03758             {
03759                 pClass = "Combobox";
03760                 ThisControlType = COMBO;
03761                 ResizeWithFont = TRUE;
03762                 break;
03763             }
03764         } 
03765         pData++;
03766     
03767     }
03768     else
03769     {
03770         pClass = (LPCTSTR)pData;  // Get the class string  
03771 
03772         pData = (ADDR) MovePastWideStr((LPWSTR) pData);
03773     }
03774     
03775     // Obtain the windows title
03776     pTitle = (LPCTSTR) pData;
03777     pData = (ADDR) MovePastWideStr((LPWSTR) pData);
03778 
03779     // Obtain the creation data
03780     LPVOID pCreationData = (LPVOID*) pData+1;   // Skip the length
03781 
03782     #endif
03783     
03784     // get the dialog base units so that we can convert to pixels 
03785     INT32 BaseUnits = GetDialogBaseUnits(); 
03786     
03787     // A bit of nasty this.. hard code base units in so controls don't change size
03788     // if the user switches to LARGE FONTS
03789     
03790     WORD DialogUnitX = X_BASEUNITS ;//LOWORD((UINT32)BaseUnits); 
03791     WORD DialogUnitY = Y_BASEUNITS ;//HIWORD((UINT32)BaseUnits);
03792   
03793     char AnsiClass[256];
03794     char AnsiTitle[256];
03795   
03796 #if WIN32
03797     // we cannot pass Unicode strings under Win32s, so we convert to multibyte strings.
03798     // If we ever need a Chinese NT version then we could pass these directly onto
03799     // ::CreateWindowExW, but currently we always convert down to Ansi
03800     // INT32 result;
03801                                                   
03802     // really we should use WideCharToMultiByte, but it refuses to work under Win32s 1.1
03803     // returning zero with a GetLastError of 2, so we use camWcstombs instead.
03804     camWcstombs( AnsiClass, pClass, sizeof(AnsiClass) );
03805     camWcstombs( AnsiTitle, pTitle, sizeof(AnsiTitle) );
03806 #else
03807     // 16-bit version needs no conversion, but we have to copy them because we
03808     // crap upon them
03809     camStrcpy( AnsiClass, pClass );
03810     camStrcpy( AnsiTitle, pTitle );
03811 #endif
03812 
03813     // Check for type here if not already set
03814     if(ThisControlType == OTHERCONTROL)
03815     {
03816         if (camStricmp(AnsiClass, "cc_BitmapButton") == 0)      // Internal
03817             ThisControlType = BITMAPBUTTON;
03818         else if (camStricmp(AnsiClass, "cc_SmallButton") == 0)  // Internal
03819             ThisControlType = SMALLBITMAPBUTTON;
03820         else if (camStricmp(AnsiClass, "cc_StaticBitmap") == 0) // Internal
03821             ThisControlType = STATICBITMAP;
03822         else if (camStricmp(AnsiClass, "cc_Text3D") == 0)           // Internal
03823             ThisControlType = TEXT3D;
03824         else if (camStricmp(AnsiClass, "cc_Grid")==0)               // Internal
03825             ThisControlType = ROTATEGRID;
03826         else if (camStricmp(AnsiClass,"cc_Slider")==0)          // Internal
03827             ThisControlType = SLIDER;
03828         else if (camStricmp(AnsiClass, "cc_1dBitmapComboBoxEdit") == 0) // internal
03829             ThisControlType = BITMAPCOMBO1D;
03830         else if (camStricmp(AnsiClass, "cc_2dBitmapComboBoxEdit") == 0) // internal
03831             ThisControlType = BITMAPCOMBO2D;
03832     }
03833     
03834 
03835     DWORD Style = pCurrentControl->style;
03836 
03837     OpDescriptor* OpDesc ;
03838     if (pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
03839     {
03840         OpDesc = (pBarControl)->GetOpDescriptor(Horizontal);
03841     }
03842     else
03843     {
03844         switch(ParentDockBarType)
03845         {
03846             case DOCKBAR_TOP:
03847             case DOCKBAR_BOTTOM:
03848             case DOCKBAR_FLOAT:
03849                 OpDesc = (pBarControl)-> GetOpDescriptor(Horizontal);
03850                 break;
03851             case DOCKBAR_LEFT:
03852             case DOCKBAR_RIGHT:
03853                 OpDesc = (pBarControl)-> GetOpDescriptor(Vertical);
03854                 break;
03855         }
03856     }
03857 
03858     if (OpDesc != NULL)
03859     {
03860         String_256 Desc; 
03861         OpState NewState = OpDesc->GetOpsState(&Desc);
03862         if(NewState.Greyed)
03863         {   
03864             Style |= BS_DISABLED;
03865         }
03866         else
03867         {
03868             Style &= (~BS_DISABLED);
03869         }
03870     }
03871 
03872     OILDockingBar * ThisDock =GetMainFrame()->GetDockBar(ParentDockBarType);
03873 
03874     if( ThisControlType == ROTATEGRID ||
03875         ThisControlType == TEXT3D)
03876         ResizeWithFont = TRUE;
03877     
03878 
03879     if( ThisControlType == BITMAPBUTTON ||
03880         ThisControlType == STATICBITMAP ||
03881         ThisControlType == SMALLBITMAPBUTTON)
03882     {
03883         if (ThisDock->IsBigControls())
03884         {
03885             Style &= (~BS_HALFSIZE);
03886         }
03887         else
03888         {
03889             Style |= BS_HALFSIZE;
03890         }
03891     }
03892     
03893     // CHICAGO BODGE - this is something to do with dialog units/system font in Chicago
03894     // but until finalised this will do..
03895     
03896     INT32 XSize = (pCurrentControl->cx * DialogUnitX) / 4;
03897     INT32 YSize = (pCurrentControl->cy * DialogUnitY) / 8;
03898 
03899     Style &= (~WS_VISIBLE);
03900     HWND CreatedWindow = ::CreateWindowEx(
03901                         #if WIN32
03902                             pCurrentControl->dwExtendedStyle,
03903                         #else
03904                             0,
03905                         #endif
03906                            AnsiClass, 
03907                            AnsiTitle,
03908                            Style,
03909                            0,
03910                            0,
03911                            XSize,
03912                            YSize,
03913                            GetSafeHwnd(),               // this window is its parent 
03914                            (HMENU)pBarControl->GetUniqueGadgetID(), 
03915                            AfxGetApp()->m_hInstance,
03916                            pCreationData                
03917                            );
03918 
03919     // if the class is a Jason button bar then we need to set its bitmap
03920     if (CreatedWindow != NULL)
03921     {
03922         // Store Hwnd in BarControl list
03923         pBarControl->SetWinID((CWindowID)CreatedWindow);
03924         ThisControlType = GetEnumItemType((BarItem *)pBarControl);
03925         
03926         // Send old style messages to cc_StaticBitmap because that class doesn't yet have
03927         // PNG rendering ability
03928         if (ThisControlType == STATICBITMAP)
03929         {
03930             BitmapButtonInfo BtnInfo;
03931 
03932             // find the position of the specifier's separator
03933             INT32 SeparatorPos = 0;
03934             while (AnsiTitle[SeparatorPos] != 0 && AnsiTitle[SeparatorPos] != '.')
03935                 SeparatorPos++;
03936 
03937             INT32 Index = 0;        // Default to using icon index 0 if no '.' separator was found
03938             if (AnsiTitle[SeparatorPos] == '.')
03939             {
03940                 // We found a separator. In that case, truncate the resource string at the '.'
03941                 // so we can extract the bitmap name, and convert the text after the '.' into
03942                 // an integer index.
03943                 Index = _ttoi( AnsiTitle + SeparatorPos+1 );
03944                 AnsiTitle[SeparatorPos] = 0;
03945             }
03946             
03947             // Fill in the BtnInfo structure
03948             BtnInfo.hAppInstance = ModuleInst;  // We assume that the bitmap resouce can be
03949                                                 // found in the same module as this control.
03950             String_256 Title =("L");
03951             Title += TEXT(AnsiTitle);
03952             
03953             BtnInfo.Bitmap[BMP_L_UNSELECTED] = (LPTSTR)Title;
03954             BtnInfo.Bitmap[BMP_S_UNSELECTED] = (LPTSTR)AnsiTitle;
03955 
03956             BtnInfo.Bitmap[BMP_S_SELECTED] = NULL;  // NULL, or name of selected bitmap
03957             BtnInfo.Bitmap[BMP_L_SELECTED] = NULL;  // NULL, or name of selected bitmap
03958 
03959             BtnInfo.UnselectedIndex=Index;          //  Indices of glyph bitmaps within the
03960             BtnInfo.SelectedIndex=Index;            //  Unselected/Selected bitmaps
03961      
03962             ::SendMessage( CreatedWindow, WM_SETBITMAPS, 0, ((LPARAM) &BtnInfo));
03963         }
03964 
03965         // Send new style messages to the button classes because they can use PNG
03966         // resources
03967         if( ThisControlType == BITMAPBUTTON ||
03968             ThisControlType == SMALLBITMAPBUTTON)
03969         {
03970             DialogManager::SetGadgetBitmaps(CreatedWindow, ModuleInst);
03971         }
03972 
03973 
03974         BOOL Horz=TRUE;
03975         if(ParentDockBarType == DOCKBAR_LEFT || ParentDockBarType == DOCKBAR_RIGHT)
03976              Horz = FALSE;
03977     
03978         // Inform the help system that a control has been created
03979         ControlHelpInfo Info;
03980         Info.pOpDesc  = pBarControl->GetOpDescriptor(Horz);
03981         Info.ModuleID = ToolModuleID;
03982 
03983         // Are we making a tool ?? if so we'll have to set it's select state ...
03984         if (Info.pOpDesc)
03985         {
03986             if ((Info.pOpDesc)->IsKindOf(CC_RUNTIME_CLASS(ToolOpDescriptor)))
03987             {
03988                 ToolOpDescriptor * ThisOpDesc = (ToolOpDescriptor *)Info.pOpDesc;
03989                 ::SendMessage(CreatedWindow, BM_SETSTATE,(WORD)ThisOpDesc->IsCurrentTool(),0L);
03990             }
03991         }
03992 
03993         if (Info.pOpDesc == NULL)
03994         {
03995             Info.BubbleID = pBarControl->GetBubbleID(Horz);
03996             Info.StatusID = pBarControl->GetStatusID(Horz);
03997         }
03998         else
03999         {
04000             Info.BubbleID = _R(IDBBL_NOOP);
04001             Info.StatusID = 0;
04002         }
04003 
04004         if ( ThisControlType != BITMAPBUTTON &&
04005              DDeckerState == DDECKER_NONE)
04006         {
04007             Ctl3dSubClassCtl(CreatedWindow);
04008         }
04009 
04010         ControlHelper::NotifyControlCreated(CreatedWindow,&Info); 
04011         
04012         if(ThisControlType == SLIDER)
04013         {
04014             if(Horz == FALSE)
04015             {
04016                 ::SetWindowPos(CreatedWindow,NULL,0,0,YSize,XSize,
04017                                                SWP_NOZORDER|SWP_NOMOVE|SWP_NOREDRAW);
04018 
04019             }
04020 
04021 
04022         }
04023         // Create correctly sized normal and double decker controls
04024         // Add new controls to here as necessary
04025         if (ResizeWithFont)
04026         {
04027             // Reset the font of this control...
04028             if(DDeckerState == DDECKER_NONE)
04029             {
04030                 ::SendMessage( CreatedWindow, WM_SETFONT, (WPARAM)BarFont->m_hObject, 0);
04031                 switch (ThisControlType)
04032                 {
04033                     case BUTTON:
04034                     case BITMAPBUTTON:
04035                     {
04036                         wxRect cRect;
04037                         ::GetClientRect(CreatedWindow,&cRect);
04038                         if(ParentDockBar->IsBigControls())
04039                             ::SetWindowPos(CreatedWindow,NULL,0,0,cRect.GetWidth(),LARGEBUTTONHEIGHT,
04040                                                SWP_NOZORDER|SWP_NOMOVE|SWP_NOREDRAW);
04041                         else
04042                             ::SetWindowPos(CreatedWindow,NULL,0,0,cRect.GetWidth(),SMALLBUTTONHEIGHT,
04043                                                SWP_NOZORDER|SWP_NOMOVE|SWP_NOREDRAW);
04044                         break;
04045                     }
04046                     case EDIT:
04047                     case COMBO:
04048                     {
04049                         wxRect cRect;
04050                         ::GetClientRect(CreatedWindow,&cRect);
04051                         ::SetWindowPos(CreatedWindow,NULL,0,0,cRect.GetWidth(),COMBOHEIGHT,
04052                                                SWP_NOZORDER|SWP_NOMOVE|SWP_NOREDRAW);
04053                         break;
04054                     }
04055                     case ROTATEGRID:
04056                         if(ParentDockBar->IsBigControls())
04057                             ::SetWindowPos(CreatedWindow,NULL,0,0,LARGEBUTTONHEIGHT,LARGEBUTTONHEIGHT,
04058                                                SWP_NOZORDER|SWP_NOMOVE|SWP_NOREDRAW);
04059                         else
04060                             ::SetWindowPos(CreatedWindow,NULL,0,0,SMALLBUTTONHEIGHT,SMALLBUTTONHEIGHT,
04061                                                SWP_NOZORDER|SWP_NOMOVE|SWP_NOREDRAW);
04062                         break;
04063                 }
04064         
04065             }
04066             // Double decker 
04067             else
04068             {
04069                 DDeckerControlHeights DDeckerHeight;
04070                 wxFont * ThisFont ;
04071                 if(ParentDockBar->IsBigControls())
04072                 {
04073                     if (ThisControlType == BITMAPBUTTON ||ThisControlType == BUTTON)
04074                         ThisFont = FontFactory::GetwxFont(STOCKFONT_DIALOGBARLARGE);
04075                     else
04076                         ThisFont = FontFactory::GetwxFont(STOCKFONT_EDITFIELDLARGE);
04077                     ::SendMessage( CreatedWindow, WM_SETFONT, (WPARAM)ThisFont->m_hObject, 0);
04078                     DDeckerHeight = LARGE_DDECKERS ;
04079                 }
04080                 else
04081                 {
04082                     if (ThisControlType == BITMAPBUTTON ||ThisControlType == BUTTON)
04083                         ThisFont = FontFactory::GetwxFont(STOCKFONT_DIALOGBARSMALL);
04084                     else
04085                         ThisFont = FontFactory::GetwxFont(STOCKFONT_EDITFIELDSMALL);
04086                     ::SendMessage( CreatedWindow, WM_SETFONT, (WPARAM)ThisFont->m_hObject, 0);
04087                     DDeckerHeight = SMALL_DDECKERS ;
04088                 }
04089     
04090             
04091                 switch(ThisControlType)
04092                 {
04093                     case BUTTON:
04094                     case BITMAPBUTTON:
04095                     {
04096                         // NEW BUTTON STUFF
04097                         if(pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
04098                             ::SetWindowPos(CreatedWindow,NULL,0,0,GalButtonWidth,DDeckerHeight ,
04099                                                SWP_NOZORDER|SWP_NOMOVE|SWP_NOREDRAW);
04100                         else
04101                         {
04102                             wxRect cRect;
04103                             ::GetClientRect(CreatedWindow,&cRect);
04104                             ::SetWindowPos(CreatedWindow,NULL,0,0,cRect.GetWidth(),DDeckerHeight ,
04105                                                SWP_NOZORDER|SWP_NOMOVE|SWP_NOREDRAW);
04106                         }
04107 
04108                         
04109                         break;
04110                     }
04111                     case EDIT:
04112                     case STATIC:
04113                     {
04114                         wxRect cRect;
04115                         ::GetClientRect(CreatedWindow,&cRect);
04116                         ::SetWindowPos(CreatedWindow,NULL,0,0,cRect.GetWidth(),DDeckerHeight,
04117                                        SWP_NOZORDER|SWP_NOMOVE|SWP_NOREDRAW);
04118                         break;
04119                     }
04120                     case COMBO:
04121                         ::SendMessage(CreatedWindow,CB_SETITEMHEIGHT,(WPARAM)-1,(LPARAM)DDeckerHeight);
04122                         ::SendMessage(CreatedWindow,CB_SETITEMHEIGHT,(WPARAM)0,(LPARAM)DDeckerHeight);
04123                         break;
04124                 }
04125             }   
04126         }
04127     }
04128     return (CreatedWindow != NULL); */
04129 
04130     return false;
04131 }  
04132 
04133 /********************************************************************************************
04134 
04135 >   LPWSTR BaseBar::MovePastWideStr(LPWSTR pWideStr)
04136 
04137     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
04138     Created:    11/11/93
04139     Inputs:     pWideStr - the start of the string to skip
04140     Returns:    Address of first byte past the end of the string.
04141     Purpose:    Given a ptr to the first byte in a wide string (or char string if win16)
04142                 return a ptr to the byte past the null.
04143 
04144 ********************************************************************************************/
04145 
04146 LPWSTR BaseBar::MovePastWideStr(LPWSTR pWideStr)
04147 {
04148     // Skip the string
04149     while (*pWideStr++)
04150         ;
04151 
04152     // Return the address of the following character
04153     return pWideStr;
04154 }
04155 
04156 /********************************************************************************************
04157 
04158 >   size_t BaseBar::SizeDlgHeader(DLGTEMPLATE *pHeader)
04159 
04160     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
04161     Created:    13/04/94
04162     Inputs:     pHeader - start of the dialog box header.
04163     Returns:    Size of the dialog box header.                     
04164     Purpose:    Given a ptr to DIALOGBOXHEADER, return its size.
04165     Scope:      private
04166 
04167 ********************************************************************************************/
04168 
04169 
04170 size_t BaseBar::SizeDlgHeader(DLGTEMPLATE *pHeader)
04171 {
04172     PORTNOTETRACE( "dialog", "BaseBar::CreateControlFromResource - do nothing - Resource usage" );
04173 #ifndef EXCLUDE_FROM_XARALX
04174     // Move past the header
04175     ADDR pResult = (ADDR) (pHeader + 1);
04176 
04177     // skip szMenuName
04178 
04179     #if WIN32
04180 
04181     pResult = (ADDR) MovePastWideStr((LPWSTR) pResult);
04182 
04183     #else
04184 
04185     switch (*pResult++)
04186     {
04187         // See SDK help file (Dialog Box Resource) for details
04188         case 0:
04189             break;
04190 
04191         case 0xFF:
04192             pResult += 2;
04193             break;
04194 
04195         default:
04196             pResult += camStrlen((LPTCHAR) (pResult)) + 1;
04197             break;
04198     }
04199 
04200     #endif
04201 
04202     // then skip szClassName
04203 
04204     pResult = (ADDR) MovePastWideStr((LPWSTR) pResult);
04205 
04206     // then the caption
04207 
04208     pResult = (ADDR) MovePastWideStr((LPWSTR) pResult);
04209 
04210     // then the font stuff
04211     if ((pHeader->style) & DS_SETFONT)
04212         pResult = (ADDR) MovePastWideStr((LPWSTR) (pResult + 2));       // skip font size too
04213 
04214     DWORD_ALIGN(pResult);
04215 
04216     // Compute the size of the header and return it.
04217     return (size_t) (pResult - ((ADDR) pHeader));
04218 #else
04219     return 0;
04220 #endif
04221 }
04222 
04223 
04224 /********************************************************************************************
04225 
04226 >   size_t BaseBar::SizeCtrlData(DLGITEMTEMPLATE *pData)
04227 
04228     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
04229     Created:    11/11/93
04230     Inputs:     pData - the start of the control structure.
04231     Returns:    Size of the control data.
04232     Purpose:    Given a ptr to a controldata struct, return its length.
04233                 Under Win32, all strings are UniCode (as they are in the res file).
04234 
04235 ********************************************************************************************/
04236 
04237 size_t BaseBar::SizeCtrlData(DLGITEMTEMPLATE *pControl)
04238 {
04239     #if WIN32
04240     // Get pointer to the data after the DLGITEMTEMPLATE structure.
04241     WORD *pData = (WORD *) (pControl + 1);
04242 
04243     // Skip the class
04244     if (*pData == 0xFFFF)
04245         // There is only one more word - the atom of the window class - skip it.
04246         pData += 2;
04247     else
04248         // The class is specified as a string - skip it
04249         pData = (WORD *) MovePastWideStr((LPWSTR) pData);
04250 
04251     // Skip the 'title' array
04252     if (*pData == 0xFFFF)
04253         // There is only one more word - it is a resource ID - skip it.
04254         pData += 2;
04255     else
04256         // The title array is a string - skip it
04257         pData = (WORD *) MovePastWideStr((LPWSTR) pData);
04258 
04259     // Skip the creation data.
04260     UINT32 Extra = (UINT32) *pData;
04261     pData++;
04262 
04263     #else
04264     // Get pointer to the data after the DLGITEMTEMPLATE structure.
04265     ADDR pData = (ADDR) (pControl + 1);
04266 
04267     // Skip the class
04268     if ((*pData) & 0x80)
04269         pData++;
04270     else
04271         pData = (ADDR) MovePastWideStr((LPWSTR) pData);
04272 
04273     // Skip the 'text' array
04274     pData = (ADDR) MovePastWideStr((LPWSTR) pData);
04275 
04276     // Skip the creation data.
04277     BYTE Extra = *pData;
04278     pData++;
04279 
04280     #endif
04281 
04282     // Get end pointer and double-word align it.
04283     ADDR pEnd = (ADDR) pData;
04284     DWORD_ALIGN(pEnd);
04285 
04286     // Compute size of control data and return it.
04287     ADDR pStart = (ADDR) pControl;
04288     pEnd += Extra;
04289     return (size_t) (pEnd - pStart);
04290 }
04291 
04292 
04293 
04294 /********************************************************************************************
04295 
04296 >   BaseBar::InformControlsDead()
04297 
04298     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
04299     Created:    7/4/94
04300     Inputs:     SrcBaseBar: The dialog to copy the controls from 
04301     Outputs:    -
04302     Returns:    -
04303     Purpose:    Copies the child controls of SrcBaseBar to this BaseBar. It does not
04304                 do any positioning of controls. 
04305     Scope:      private
04306     Errors:     -
04307     SeeAlso:    -
04308 
04309 ********************************************************************************************/
04310 
04311 void BaseBar::InformControlsDead()
04312 {                                                        
04313 #pragma message( __LOCMSG__ "BaseBar::InformControlsDead - do nothing" )
04314     TRACE( _T("Warning - BaseBar::InformControlsDead called") );
04315 /*  HWND CurrentChild;
04316     HWND NextChild; 
04317     for (CurrentChild = ::GetWindow(GetSafeHwnd(),GW_CHILD);
04318          CurrentChild != NULL; 
04319          CurrentChild = NextChild)
04320     {
04321         ControlHelper::NotifyControlDeleted(CurrentChild);
04322         NextChild = ::GetWindow(CurrentChild,GW_HWNDNEXT); 
04323     } */
04324 }
04325 
04326 /********************************************************************************************
04327 
04328 >   wxRect BaseBar::GetDlgBarRect(DockBarType DockBar, wxRect CurrentBarRect)
04329 
04330 
04331     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
04332     Created:    6/4/94
04333     Inputs:     DockBar: Specifies which docking bar
04334                 CurrentBarRect: The current bar rectangle  
04335     Outputs:    -
04336     Returns:    The new bar rectangle
04337 
04338     Purpose:    For finding the screen rectangle defining the shape of the BaseBar when
04339                 over DockBar 
04340     Errors:     -
04341     Scope:      private
04342     SeeAlso:    -
04343 
04344 ********************************************************************************************/
04345 wxRect BaseBar::GetDlgBarRect(DockBarType DockBarType, wxRect CurrentBarRect)
04346 {
04347 /*  OILDockingBar* DockBar = GetMainFrame()->GetDockBar(DockBarType);
04348     switch (DockBarType)
04349     {
04350         case DOCKBAR_TOP:
04351         case DOCKBAR_BOTTOM:
04352             if (DockBar->IsBigControls())       
04353             {
04354                 if (HorizontalLargeRect.IsEmpty()())
04355                 {   
04356                     FormatHorizontalBar(FALSE,USE_BAR);
04357                 }
04358             }
04359             else
04360             {
04361                 if (HorizontalSmallRect.IsEmpty()())
04362                 {   
04363                     FormatHorizontalBar(FALSE,USE_BAR);
04364                 }
04365             }
04366             break;
04367         case DOCKBAR_LEFT:
04368         case DOCKBAR_RIGHT:
04369             if (DockBar->IsBigControls())       
04370             {
04371                 if (VerticalLargeRect.IsEmpty()())
04372                 {   
04373                     FormatVerticalBar(FALSE,USE_BAR);
04374                 }
04375             }
04376             else
04377             {
04378                 if (VerticalSmallRect.IsEmpty()())
04379                 {   
04380                     FormatVerticalBar(FALSE,USE_BAR);
04381                 }
04382             }
04383             break;
04384         default: 
04385         {
04386             ENSURE(DockBarType == DOCKBAR_FLOAT, "Unknown Dockbar type"); 
04387             if (DockBar->IsBigControls())       
04388             {
04389                 if (FloatLargeRect.IsEmpty()())
04390                 {   
04391                     FormatFloatingBar(FALSE,USE_BAR);
04392                 }
04393             }
04394             else
04395             {
04396                 if (FloatSmallRect.IsEmpty()())
04397                 {   
04398                     FormatFloatingBar(FALSE,USE_BAR);
04399                 }
04400             }
04401         
04402             break;
04403            
04404         } 
04405     }*/
04406     wxRect temp =GetFormatRect(DockBarType);  
04407     temp.Offset(CurrentBarRect.GetLeft(),CurrentBarRect.GetRight());   
04408 //  temp.OffsetRect(CurrentBarRect.GetLeft(), CurrentBarRect.GetTop());
04409     return temp;
04410 } 
04411 
04412 /********************************************************************************************
04413 
04414 >   BOOL BaseBar::CanStartDrag(wxPoint point, DlgDragType TypeOfDrag)
04415 
04416     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
04417     Created:    7/4/94
04418     Inputs:     CursorPoint: The screen cursor pos
04419     Outputs:    -
04420     Returns:    YES / NO
04421     Purpose:    decides whether we can start a Drag
04422     Scope:      private
04423     Errors:     -
04424     SeeAlso:    -
04425 
04426 ********************************************************************************************/
04427 
04428 
04429 BOOL BaseBar::CanStartDrag(wxPoint point)
04430 {
04431 #ifdef STANDALONE
04432 #ifndef EXCLUDE_GALS
04433     if (!this->IsKindOf(RUNTIME_CLASS(GalleryBar)))
04434         return FALSE;
04435 #endif
04436 #endif
04437 
04438  return (point.x < (StartDragPoint.x - DRAG_START_MARGIN) ||
04439          point.x > (StartDragPoint.x + DRAG_START_MARGIN) ||
04440          point.y < (StartDragPoint.y - DRAG_START_MARGIN) ||
04441          point.y > (StartDragPoint.y + DRAG_START_MARGIN) 
04442          );
04443 }   
04444 
04445 /********************************************************************************************
04446 
04447 >   void BaseBar::StartDrag(wxPoint point, DlgDragType TypeOfDrag)
04448 
04449     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
04450     Created:    7/4/94
04451     Inputs:     CursorPoint: The screen cursor pos
04452                 TypeOfDrag:  The type of drag being started
04453     Outputs:    -
04454     Returns:    -
04455     Purpose:    Starts a Drag
04456     Scope:      private
04457     Errors:     -
04458     SeeAlso:    -
04459 
04460 ********************************************************************************************/
04461 
04462 
04463 void BaseBar::StartDrag(wxPoint point, DlgDragType TypeOfDrag)
04464 {
04465 #pragma message( __LOCMSG__ "BaseBar::StartDrag - do nothing" )
04466     TRACE( _T("Warning - BaseBar::StartDrag called") );
04467 /*#ifdef STANDALONE
04468 #ifndef EXCLUDE_GALS
04469     // In StandAlone version we only let the user drag Galleries around
04470     if (!this->IsKindOf(RUNTIME_CLASS(GalleryBar)))
04471     {
04472         return;
04473     }
04474 #endif
04475 #endif
04476     
04477     //ControlHelper::BubbleHelpDisable();
04478     
04479     // disable resizing of an empty bar
04480     if (TypeOfDrag != MOVE)
04481     {
04482         if (pOp->IsListEmpty())
04483             return ;
04484     }
04485 
04486     ScreenRect.SetRect(0,0,wxSystemSettings::GetMetric(SM_CXSCREEN),wxSystemSettings::GetMetric(SM_CYSCREEN));
04487 
04488     BorderOffset = wxPoint(0,0);
04489 
04490     RECT rect;
04491     GetWindowRect(&rect);
04492     DragStartRect=rect;
04493     DragType = TypeOfDrag;
04494     CurrentBar = this;
04495     OldDragBarType = DragDockBarType = ParentDockBarType;
04496 
04497 
04498 
04499     if (TypeOfDrag == GROW_SOUTH || TypeOfDrag == GROW_NORTH)
04500     {
04501         OILDockingBar* DockBar = GetMainFrame()->GetDockBar(DragDockBarType);
04502         if (DockBar->IsBigControls())       
04503         {
04504             WidestFloat = HorizontalLargeRect.GetWidth();
04505             TallestFloat = VerticalLargeRect.GetHeight();
04506         }
04507         else
04508         {
04509             WidestFloat = HorizontalSmallRect.GetWidth();
04510             TallestFloat = VerticalSmallRect.GetHeight();
04511         }
04512         CacheFormatingData();
04513     } 
04514 
04515     switch (TypeOfDrag)
04516     { 
04517         case MOVE :
04518             // Calculate drag offsets, used only by move drags
04519             DragOffset =  wxPoint(point.x - rect.GetLeft(), point.y - rect.GetTop());
04520             DragOffsetFromTop = TRUE;
04521             DragOffsetFromLeft = TRUE;
04522             CacheAllDockRects();
04523             // Close any drop-down windows in this bar
04524             CloseCombos();
04525             break;
04526         case GROW_WEST :
04527             BorderOffset = wxPoint(point.x - rect.GetLeft(),0);
04528             break;
04529         case GROW_EAST :
04530             BorderOffset = wxPoint(rect.GetRight() - point.x,0);
04531             break;
04532         case GROW_NORTH :
04533             BorderOffset = wxPoint(0,point.y - rect.GetTop());
04534             break;
04535         case GROW_SOUTH :
04536             BorderOffset = wxPoint(0,rect.GetBottom() - point.y);
04537             break;
04538         case GROW_NORTHWEST :
04539             BorderOffset = wxPoint(point.x - rect.GetLeft(),point.y - rect.GetTop());
04540             break;
04541         case GROW_NORTHEAST :
04542             BorderOffset = wxPoint(rect.GetRight() - point.x,point.y - rect.GetTop());
04543             break;
04544         case GROW_SOUTHEAST :
04545             BorderOffset = wxPoint(rect.GetRight() - point.x,rect.GetBottom() - point.y);
04546             break;
04547         case GROW_SOUTHWEST :
04548             BorderOffset = wxPoint(point.x - rect.GetLeft(),rect.GetBottom() - point.y);
04549             break;
04550     }   
04551 
04552 //  TRACEUSER( "Gerry", _T("DragPoint     = (%d, %d)\n"), point.x, point.y);
04553 //  TRACEUSER( "Gerry", _T("DragStartRect = (%d, %d) - (%d, %d)\n"), DragStartRect.GetLeft(), DragStartRect.top, DragStartRect.Width(), DragStartRect.GetHeight());
04554 //  TRACEUSER( "Gerry", _T("BorderOffset  = (%d, %d)\n"), BorderOffset.x, BorderOffset.y);
04555 
04556     SetCapture(); // Capture the mouse 
04557     DragManagerOp::SetDragActive(TRUE);
04558     // Keep a copy of the rectangle so we can XOR it off
04559     OldDragRect = rect; 
04560     PaintDragRect(OldDragRect,wxRect(0,0,0,0),DragDockBarType,DragDockBarType); */
04561 }
04562 
04563 
04564 // -----------------------------------------------------------------------------------------
04565 // Message map - maintained by Class Wizard.
04566 
04567 BEGIN_EVENT_TABLE( BaseBar, wxWindow )
04568 #pragma message( __LOCMSG__ "Removed BaseBar message map" )
04569 /*  ON_WM_NCCALCSIZE()
04570     ON_WM_NCPAINT()
04571     ON_WM_NCACTIVATE()
04572     ON_WM_PAINT()
04573     ON_WM_NCHITTEST()
04574     ON_WM_MOUSEMOVE()
04575     ON_WM_KILLFOCUS()
04576     ON_WM_SETFOCUS()
04577     ON_WM_NCLBUTTONDOWN()
04578     ON_WM_LBUTTONDOWN()
04579     ON_WM_LBUTTONDBLCLK()   
04580     ON_WM_LBUTTONUP()
04581     ON_WM_NCRBUTTONDOWN()
04582     ON_MESSAGE( WM_RESIZECONTROLS,DoResize )
04583     ON_MESSAGE(WM_CTL_SETFOCUS, SetControlFocus)
04584     ON_MESSAGE(WM_MOVEBAR,MoveBar)
04585     ON_MESSAGE(WM_GETBARSIZE,GetBarSize)
04586     ON_MESSAGE(WM_START_CTLDRAG,StartControlDrag)
04587     ON_MESSAGE(WM_END_CTLDRAG,EndControlDrag)
04588     ON_WM_DESTROY( )
04589     ON_WM_DRAWITEM( )
04590     ON_WM_MOUSEACTIVATE( )
04591     ON_WM_ACTIVATE( )
04592     ON_WM_ACTIVATEAPP( )
04593     ON_WM_PARENTNOTIFY( )
04594     ON_LBN_KILLFOCUS(_R(IDC_GALLERY_LISTBOX),ListLostFocus)
04595     ON_LBN_SELCHANGE(_R(IDC_GALLERY_LISTBOX),ListSelChanged)
04596     ON_WM_MOUSEWHEEL() */
04597 END_EVENT_TABLE()
04598 
04599 /********************************************************************************************
04600 
04601 >   void PatB(wxDC * hDC, INT32 x, INT32 y, INT32 dx, INT32 dy, COLORREF rgb)
04602 
04603     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> (Some MFC dude, actually)
04604     Created:    14/3/94
04605     Inputs:     hDC - destination DC
04606                 x,y,dx,dy - rectangle to fill
04607                 rgb - colour to fill with
04608 
04609     Purpose:    Paints a rectangle in the given (dithered) colour
04610                 It looks pretty hideous, but this is how the MFC buttonbar does it...
04611                 The conclusions that this leads to are left as an exercise for the reader.
04612                 (OK, so they're not. It suggest that either MFC sux, or plotting text is
04613                 easier/faster than creating a brush, in which case Windoze sux)
04614 
04615     Scope:      private
04616 
04617 ********************************************************************************************/
04618 
04619 static void PatB( wxDC &DC, INT32 x, INT32 y, INT32 dx, INT32 dy, wxColour &rgb )
04620 {
04621 #pragma message( __LOCMSG__ "PatB - do nothing" )
04622     TRACE( _T("Warning - PatB called") );
04623 /*  RECT rect;
04624 
04625     rect.x      = x;
04626     rect.y      = y;
04627     rect.width  = dx;
04628     rect.height = dy;
04629 
04630     cDC->SetBkColor(rgb);
04631     cDC->ExtTextOut(0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL); */
04632 }
04633 
04634 
04635 /********************************************************************************************
04636 
04637 >   void BaseBar::Paint3dPlinth(wxDC* pDC, wxRect *rect, BOOL PlinthOut)
04638 
04639     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
04640     Created:    3/8/94
04641     Inputs:     pDC - The DC to draw into
04642                 rect - The rectangle to draw around the OUTSIDE of with a plinth
04643                 PlinthOut - FALSE to indent, TRUE to pop-out the plinth.
04644     Outputs:    -
04645     Returns:    -
04646     Purpose:    Draws a rectangular 3d plinth(Chicago/Win 3.1 styles)
04647                 around the edge of the given rectangle
04648 
04649 ********************************************************************************************/
04650 
04651 void BaseBar::Paint3dPlinth(wxDC* pDC, wxRect *rect, BOOL PlinthOut)
04652 {
04653 #pragma message( __LOCMSG__ "BaseBar::Paint3dPlinth - do nothing" )
04654     TRACE( _T("Warning - BaseBar::Paint3dPlinth called") );
04655 /*  if((LOBYTE(LOWORD(GetVersion()))) > 3 )
04656     {
04657         // create brush for the background
04658         wxBrush Back(GetSysColor(COLOR_BTNFACE));
04659         
04660         // select into dc
04661         wxBrush * OldBrush = (wxBrush *) pDC->SelectObject(&Back);
04662         wxRect Fill(rect);
04663         Fill.Inflate(-1,-1);
04664         //Fill.OffsetRect(1,1);
04665         // fill in the background
04666         pDC->FillRect(&Fill, &Back);
04667         
04668         // restore dc state
04669         pDC->SelectObject(OldBrush);
04670     
04671     
04672         COLORREF TopLeft;
04673         COLORREF BotRight;
04674         COLORREF TopLeftInside;
04675         COLORREF BotRightInside;
04676 
04677 
04678         if (!PlinthOut)
04679         {
04680             TopLeft         = GetSysColor(COLOR_WINDOWFRAME);
04681             BotRight        = GetSysColor(COLOR_BTNHIGHLIGHT);
04682             TopLeftInside   = GetSysColor(COLOR_BTNSHADOW);
04683             BotRightInside  = GetSysColor(COLOR_BTNFACE);
04684         }
04685         else
04686         {
04687             TopLeft         = GetSysColor(COLOR_BTNHIGHLIGHT);
04688             BotRight        = GetSysColor(COLOR_WINDOWFRAME);
04689             TopLeftInside   = GetSysColor(COLOR_BTNFACE);
04690             BotRightInside  = GetSysColor(COLOR_BTNSHADOW);
04691         }
04692         INT32 x  = rect->GetLeft();
04693         INT32 y  = rect->GetTop();
04694         INT32 dx = rect->GetWidth()-1;
04695         INT32 dy = rect->GetHeight();
04696 
04697         // The plinth is always made up of 4 right-angle elements
04698         // When indented, the colours are swapped, but the elements retain position
04699         PatB(pDC, x, y, 1, dy-1, TopLeft);
04700         PatB(pDC, x, y, dx-1, 1, TopLeft);
04701 
04702         PatB(pDC, x+dx-1, y, 1, dy, BotRight);
04703         PatB(pDC, x, y+dy-1, dx, 1, BotRight);
04704     
04705         PatB(pDC, x+1, y+1, 1, dy-2, TopLeftInside);
04706         PatB(pDC, x+1, y+1, dx-2, 1, TopLeftInside);
04707     
04708         PatB(pDC, x+dx-2, y+1, 1, dy-2, BotRightInside);
04709         PatB(pDC, x+1, y+dy-2, dx-2, 1, BotRightInside);
04710     }
04711     else
04712     {
04713         // create brushes /pens etc..
04714         wxPen Black(PS_SOLID, 0,RGB(0,0,0));
04715         wxPen Shadow(PS_SOLID, 0, GetSysColor(COLOR_BTNSHADOW));
04716         wxPen White(PS_SOLID, 0, GetSysColor(COLOR_BTNHIGHLIGHT));
04717         wxBrush Back(GetSysColor(COLOR_BTNFACE));
04718 
04719         // select into dc
04720         wxPen *OldPen = (wxPen *) pDC->SelectObject(&Black);
04721         wxBrush * OldBrush = (wxBrush *) pDC->SelectObject(&Back);
04722         
04723         // fill in the background
04724         pDC->FillRect(rect, &Back);
04725      
04726         // draw the black outline
04727         pDC->MoveTo(rect->GetLeft(), rect->bottom-2);
04728         pDC->LineTo(rect->GetLeft(), rect->GetTop());
04729         pDC->MoveTo(rect->right-1, rect->bottom-2);
04730         pDC->LineTo(rect->right-1, rect->GetTop());
04731         pDC->MoveTo(rect->GetLeft()+1, rect->bottom-1);
04732         pDC->LineTo(rect->right-1, rect->bottom-1);
04733         pDC->MoveTo(rect->GetLeft()+1, rect->GetTop());
04734         pDC->LineTo(rect->right-1, rect->GetTop());
04735 
04736 
04737         // draw the 3d slabbing 
04738         pDC->SelectObject(((PlinthOut) ? &White : &Shadow));
04739         pDC->MoveTo(rect->GetLeft()+1, rect->bottom-2);
04740         pDC->LineTo(rect->GetLeft()+1, rect->GetTop()+1);
04741         pDC->LineTo(rect->right-1, rect->GetTop()+1);
04742 
04743         pDC->SelectObject(((PlinthOut) ? &Shadow : &White));
04744         pDC->MoveTo(rect->right-2, rect->GetTop()+2);   // Ensure corner pixel is correct
04745         pDC->LineTo(rect->right-2, rect->bottom-2);
04746         pDC->LineTo(rect->GetLeft()+1, rect->bottom-2);
04747 
04748         // restore dc state
04749         pDC->SelectObject(OldPen);
04750         pDC->SelectObject(OldBrush);
04751     } */
04752  
04753 }
04754 
04755 /********************************************************************************************
04756 
04757 >   void BaseBar::OnDrawItem( INT32 nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct )
04758 
04759     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
04760     Created:    20/7/94
04761     Inputs:     nIDCtl - control id of the gadget to be drawn  
04762                 lpDrawItemStruct - control data
04763     Outputs:    -
04764     Returns:    -
04765     Purpose:    - called when an owner drawn child of this bars needs to be redraw
04766 
04767 ********************************************************************************************/
04768 
04769 
04770 #pragma message( __LOCMSG__ "BaseBar::OnDrawItem removed" )
04771 /*void BaseBar::OnDrawItem( INT32 nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct )
04772 {
04773     // owner drawn text button
04774     if(lpDrawItemStruct->CtlType == ODT_BUTTON)
04775     {
04776         wxRect Rect(lpDrawItemStruct->rcItem);
04777         wxDC hDC;
04778         hDC.Attach(lpDrawItemStruct->hDC);
04779     
04780         // is the button selected 
04781         BOOL Selected = lpDrawItemStruct->itemState & ODS_SELECTED;
04782         BOOL Focus = lpDrawItemStruct->itemState & ODS_FOCUS;
04783     
04784         // paint background and border
04785 //      if(lpDrawItemStruct->CtlType== ODT_BUTTON)
04786             Paint3dPlinth(& hDC,&Rect,!Selected);
04787         
04788         // if selected shift the text x+1 and y+1
04789         if(Selected)
04790             Rect.OffsetRect(1, 1);
04791 
04792         // text paint mode transparent
04793         hDC.SetBkMode(TRANSPARENT);
04794         
04795         if ((lpDrawItemStruct->itemState & (ODS_GRAYED | ODS_DISABLED)) != 0)
04796         {
04797             // Slight cheat here- using the button shadow colour, rather than dithering
04798             // the output text as Windows does. This is because we use a small, thin font
04799             // in these buttons, which does not dither well, and solid colour looks
04800             // much better (Note: We can't use GRAYTEXT, because it's the same as BTNFACE!)
04801             hDC.SetTextColor(GetSysColor(COLOR_BTNSHADOW));
04802         }
04803         else
04804             hDC.SetTextColor(GetSysColor(COLOR_BTNTEXT));
04805         
04806         char wtext[33];
04807     
04808         // get the button text
04809         ::GetWindowText(lpDrawItemStruct->hwndItem,(LPTSTR)wtext,32);
04810     
04811         // now draw it formated into the button rectangle
04812         hDC.DrawText(wtext,-1,&Rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
04813 
04814         if(Focus)
04815         {
04816             wxBrush Back(RGB(0,0,0));
04817             // select into dc
04818             wxBrush * OldBrush = (wxBrush *) hDC.SelectObject(&Back);
04819         
04820             hDC.Ellipse(Rect.GetLeft()+4,Rect.GetTop()+4,Rect.GetLeft()+8,Rect.GetTop()+8);
04821             hDC.SelectObject(OldBrush);
04822         }
04823         // must detach else we eat up GDI16 resources
04824         hDC.Detach();
04825     }
04826 } */
04827 
04828 // ------------------------------------------------------------------------------------------
04829 // Message Handler functions
04830 
04831 /********************************************************************************************
04832 
04833 >   void BaseBar::OnParentNotify( UINT32 message, LPARAM lParam )
04834 
04835     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
04836     Created:    19/7/94
04837     Inputs:     from Windows
04838     Outputs:    -
04839     Returns:    -
04840     Purpose:    Sets ControlHasFocus flag if input focus with a writable control
04841     Errors:     -                                        
04842     SeeAlso:    -
04843     Scope:      Public
04844 
04845 ********************************************************************************************/
04846                         
04847 #pragma message( __LOCMSG__ "BaseBar::OnParentNotify removed" )
04848 /*void BaseBar::OnParentNotify( UINT32 message, LPARAM lParam )
04849 {
04850     if(message == WM_LBUTTONDOWN)
04851     {
04852         String_256 ClassNameStr;
04853         POINT Pnt;
04854         GetCursorPos(&Pnt);
04855         wxWindow * Cwnd = WindowFromPoint(Pnt); 
04856         GetClassName(Cwnd->GetSafeHwnd(), (TCHAR*)ClassNameStr, 255);
04857 
04858         // check for ComboBox/Edit/ListBox
04859         if ( (ClassNameStr == String_8(TEXT("ListBox"))) || //ZZZ
04860              (ClassNameStr == String_8(TEXT("Edit"))) ||
04861              (ClassNameStr == String_8(TEXT("ComboBox"))) ||
04862              (ClassNameStr == String_64(TEXT("cc_1dBitmapComboBoxEdit"))) ||
04863              (ClassNameStr == String_64(TEXT("cc_2dBitmapComboBoxEdit")))
04864            )
04865 
04866         {
04867             ControlHasFocus = TRUE;
04868         }
04869     }    
04870 } */
04871 
04872 /********************************************************************************************
04873 
04874 >   void BaseBar::OnKillFocus(wxWindow * Wnd)
04875 
04876     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
04877     Created:    19/7/94
04878     Inputs:     -
04879     Outputs:    -
04880     Returns:    -
04881     Purpose:    - nothing at the moment
04882     Errors:     -                                        
04883     SeeAlso:    -
04884     Scope:      Public
04885 
04886 ********************************************************************************************/
04887 
04888 #pragma message( __LOCMSG__ "BaseBar::OnKillFocus removed" )
04889 /*void BaseBar::OnKillFocus( wxWindow*Wnd )
04890 {
04891     wxWindow::OnKillFocus(Wnd);
04892 } */
04893 
04894 /********************************************************************************************
04895 
04896 >   void BaseBar::OnSetFocus(wxWindow * Wnd)
04897 
04898     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
04899     Created:    19/7/94
04900     Inputs:     -
04901     Outputs:    -
04902     Returns:    -
04903     Purpose:    
04904     Errors:     -                                        
04905     SeeAlso:    -
04906     Scope:      Public
04907 
04908 ********************************************************************************************/
04909 
04910 
04911 #pragma message( __LOCMSG__ "BaseBar::OnSetFocus removed" )
04912 /*void BaseBar::OnSetFocus( wxWindow * Wnd )
04913 {
04914     wxWindow::OnSetFocus(Wnd);
04915 } */
04916 
04917 /********************************************************************************************
04918 
04919 >   void BaseBar::OnActivateApp( BOOL  bActive, HTASK  hTask )
04920 
04921     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
04922     Created:    19/7/94
04923     Inputs:     from mfc
04924     Outputs:    -
04925     Returns:    -
04926     Purpose:    Forces bars to be repainted to reflect active state
04927     Errors:     -                                        
04928     SeeAlso:    -
04929     Scope:      Public
04930 
04931 ********************************************************************************************/
04932 
04933 #pragma message( __LOCMSG__ "BaseBar::OnActivateApp removed" )
04934 /*void BaseBar::OnActivateApp( BOOL  bActive, HTASK  hTask )
04935 {
04936     
04937     Active = bActive;
04938     ::SendMessage(GetSafeHwnd(), WM_NCPAINT,0,0);
04939         
04940     if(!Active && CurrentBar != NULL)
04941     {
04942         if(CtlDragState==DRAGGING)
04943         {   
04944             CurrentBar->PaintDragRect(CurrentBar->OldDragRect,wxRect(0,0,0,0),DOCKBAR_FLOAT,DOCKBAR_FLOAT);
04945             CurrentBar->TidyUpControlDrag();
04946         }
04947         else if(DragType != NONE)
04948             CurrentBar->TidyUpBarDrag();
04949     }
04950 } */
04951 
04952 /********************************************************************************************
04953 
04954 >   void BaseBar::OnActivate( UINT32 state , wxWindow* LastWin, BOOL IsMin)
04955 
04956     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
04957     Created:    16/6/94
04958     Inputs:     from mfc
04959     Outputs:    -
04960     Returns:    -
04961     Purpose:    attempt to force focus to mainframe 
04962     Errors:     -                                        
04963     SeeAlso:    -
04964     Scope:      Protected
04965 
04966 ********************************************************************************************/
04967 
04968 #pragma message( __LOCMSG__ "BaseBar::OnActivate removed" )
04969 /*void BaseBar::OnActivate( UINT32 State, wxWindow* pWndOther, BOOL bMinimized ) 
04970 {
04971     
04972     //if a control has the focus do nothing
04973     if(ControlHasFocus)
04974         return;
04975     
04976     
04977     // pass the focus back to the mainframe
04978     if ( State == WA_ACTIVE )
04979     {
04980         GetMainFrame()->SetActiveWindow();
04981         return;
04982     }
04983      
04984     //if(GetMainFrame() == pWndOther) return;
04985 
04986     wxWindow::OnActivate(State, pWndOther,bMinimized);
04987     
04988 } */
04989 
04990 /********************************************************************************************
04991 
04992 >   void BaseBar::OnMouseActivate(wxWindow* pDesktopWnd, UINT32 nHitTest, UINT32 message ) 
04993 
04994     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
04995     Created:    16/6/94
04996     Inputs:     from mfc
04997     Outputs:    -
04998     Returns:    -
04999     Purpose:    -
05000     Errors:     -
05001     SeeAlso:    -
05002     Scope:      Protected
05003 
05004 ********************************************************************************************/
05005 
05006 #pragma message( __LOCMSG__ "BaseBar::OnMouseActivate removed" )
05007 /*INT32 BaseBar::OnMouseActivate( wxWindow* pDesktopWnd, UINT32 nHitTest, UINT32 message ) 
05008 {
05009     
05010     // fix by chris
05011     // if camelot isn't active we should just use default handling - i.e. make camelot active 
05012     // don't just throw away the click.
05013     if(GetMainFrame()!= GetActiveWindow())
05014         return wxWindow::OnMouseActivate( pDesktopWnd, nHitTest, message ); 
05015     
05016     
05017     
05018     String_256 ClassNameStr;
05019     POINT Pnt;
05020     GetCursorPos(&Pnt);
05021     wxWindow * Cwnd = WindowFromPoint(Pnt); 
05022     GetClassName(Cwnd->GetSafeHwnd(), (TCHAR*)ClassNameStr, 255);
05023     ControlHasFocus = FALSE;    
05024     // check for ComboBox/Edit
05025     if ( (ClassNameStr == String_8(TEXT("ListBox"))) || //ZZZ
05026          (ClassNameStr == String_8(TEXT("Edit"))) ||
05027          (ClassNameStr == String_8(TEXT("ComboBox"))) ||
05028          (ClassNameStr == String_64(TEXT("cc_1dBitmapComboBoxEdit"))) ||
05029          (ClassNameStr == String_64(TEXT("cc_2dBitmapComboBoxEdit")))
05030         )
05031     {
05032         ControlHasFocus = TRUE;
05033     }
05034     if(ControlHasFocus)
05035         return MA_ACTIVATE;
05036     return MA_NOACTIVATE;
05037     
05038 //  return wxWindow::OnMouseActivate( pDesktopWnd, nHitTest, message );   
05039 } */
05040 
05041 /********************************************************************************************
05042 >   void BaseBar::OnDestroy( )
05043 
05044     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05045     Created:    7/5/94
05046     Inputs:     -
05047     Outputs:    -
05048     Returns:    -
05049     Purpose:    To Notify ControlHelper and DockingBar that BaseBar is about to die 
05050     Errors:     -
05051     SeeAlso:    -
05052 
05053 ********************************************************************************************/
05054 
05055 #pragma message( __LOCMSG__ "BaseBar::OnDestroy removed" )
05056 /*void BaseBar ::OnDestroy( )
05057 {
05058  
05059     // If the current dialog is set to this bar, set the current dlg to NULL
05060     HWND hwnd = GetSafeHwnd();
05061     if(hwnd == 0)
05062         return;
05063     
05064     if (DialogManager::hDlgCurrent == hwnd)
05065         DialogManager::hDlgCurrent = NULL;
05066 
05067     TRACEUSER( "chris", _T("Destruct Bar %X\n"),hwnd);      
05068     // inform Help system
05069     
05070     InformControlsDead();
05071 
05072     ControlHelper::NotifyBarDeleted(GetSafeHwnd());
05073 
05074     // release bar from it's dock
05075     // If the tool is simply changing rather being closed down we don't want to
05076     // force a tidy 
05077 
05078     BOOL DoTidy = DO_TIDY;
05079     if (ThisIsAnInfoBar )
05080         if (Tool::IsToolChanging())
05081             DoTidy = DONT_TIDY;
05082 
05083     if (Camelot.CamelotIsDying())
05084     {
05085         DoTidy = DONT_TIDY; // We can be messy cos camelot is shutting down
05086     }
05087 
05088     GetMainFrame()->GetDockBar(ParentDockBarType)->ReleaseBar(this->GetSafeHwnd(),DoTidy);
05089  
05090 }; */
05091 
05092 /********************************************************************************************
05093 
05094 >   void BaseBar::ListLostFocus(void )
05095 
05096     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05097     Created:    7/5/94
05098     Inputs:     -
05099     Outputs:    -
05100     Returns:    -
05101     Purpose:    Command received when a list box receives the focus 
05102     Errors:     -
05103     SeeAlso:    -
05104 
05105 ********************************************************************************************/
05106 
05107 #pragma message( __LOCMSG__ "BaseBar::ListLostFocus removed" )
05108 /*void  BaseBar::ListLostFocus(void)
05109 {
05110  
05111 }*/ 
05112 
05113 /********************************************************************************************
05114 
05115 >   void BaseBar::ListSelChanged(void )
05116 
05117     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05118     Created:    7/5/94
05119     Inputs:     -
05120     Outputs:    -
05121     Returns:    -
05122     Purpose:    Command received when a list box receives the focus - assumes only galleries 
05123                 will have listbox controls 
05124     Errors:     -
05125     SeeAlso:    -
05126 
05127 ********************************************************************************************/
05128 
05129 #pragma message( __LOCMSG__ "BaseBar::ListSelChanged removed" )
05130 /*void  BaseBar::ListSelChanged(void)
05131 {
05132 //  if( pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)) )
05133 //  {
05134 //      GetMainFrame()->SetActiveWindow();
05135 //  }
05136 }*/
05137 
05138 /********************************************************************************************
05139 
05140 >   LRESULT BaseBar::DoResize(WPARAM , LPARAM )
05141 
05142     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05143     Created:    7/5/94
05144     Inputs:     from windows
05145     Outputs:    -
05146     Returns:    -
05147     Purpose:    To recreate this BaseBar after a change in control sizes 
05148     Errors:     -
05149     SeeAlso:    -
05150 
05151 ********************************************************************************************/
05152 
05153 #pragma message( __LOCMSG__ "BaseBar::DoResize removed" )
05154 /*LRESULT  BaseBar::DoResize(WPARAM , LPARAM)
05155 {
05156     // ZZZZ
05157     KernelBarPos * Pos;
05158     
05159 //  if(LastSmallBarPos.x !=-1 &&LastSmallBarPos.y!=-1)
05160 //      Pos = & LastSmallBarPos;
05161 //  else
05162         Pos = GetMainFrame()->GetDockBar(ParentDockBarType)->
05163                      GetBarPos(this->GetSafeHwnd()); 
05164     
05165     LastSmallBarPos = * Pos;
05166     KernelBarPos NewPos = *Pos;
05167 
05168     // create new BaseBar
05169     BaseBar* NewBaseBar = (BaseBar *)GetRuntimeClass()->CreateObject(); 
05170 
05171     // Recreate the Dialog at the old position
05172     NewBaseBar->RecreateAt(NewPos,ParentDockBarType, this, pOp,this->GetSafeHwnd()); 
05173     //TRACE( _T("Recreate %d"),this->GetSafeHwnd());
05174     // The operations window id has changed 
05175     CCamApp::GetDlgManager()->Delete(this->GetSafeHwnd(),pOp);  
05176     //delete this;
05177 
05178     return 0;
05179 }*/
05180 
05181 /********************************************************************************************
05182 
05183 >   BOOL BaseBar::HaveNonClientMetricsChanged( )
05184 
05185     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05186     Created:    7/5/94
05187     Inputs:     -
05188     Outputs:    -
05189     Returns:    -
05190     Purpose:    returns TRUE if Non-Client metrics have changed 
05191     Errors:     -
05192     SeeAlso:    -
05193 
05194 ********************************************************************************************/
05195 
05196 BOOL  BaseBar::HaveNonClientMetricsChanged( )
05197 {
05198     BOOL returnVal = FALSE;
05199 
05200     #if _MFC_VER >= 0x400
05201         
05202         if( TitleBarHeight != wxSystemSettings::GetMetric(SM_CYSMCAPTION))
05203             returnVal = TRUE;
05204         if(BorderWidth !=  wxSystemSettings::GetMetric(SM_CXFRAME))
05205             returnVal = TRUE;
05206         if(FontFactory::CheckSystemBarFontsChanged())
05207             returnVal = TRUE;   
05208     
05209     #endif
05210     
05211     return returnVal;
05212 }
05213 
05214 /********************************************************************************************
05215 
05216 >   LRESULT BaseBar::GetBarSize(WPARAM DockType, LPARAM ControlSize )
05217 
05218     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05219     Created:    7/5/94
05220     Inputs:     from windows
05221     Outputs:    -
05222     Returns:    -
05223     Purpose:    To return a pointer to a rectangle of bar size 
05224     Errors:     -
05225     SeeAlso:    -
05226 
05227 ********************************************************************************************/
05228 
05229 #pragma message( __LOCMSG__ "BaseBar::GetBarSize removed" )
05230 /*LRESULT  BaseBar::GetBarSize(WPARAM DockType , LPARAM ControlS)
05231 {
05232     DockBarType ThisDock = (DockBarType) DockType;  
05233     ControlSizes ControlSize = (ControlSizes ) ControlS;
05234 
05235     switch (ThisDock)
05236     {
05237         case DOCKBAR_TOP:
05238         case DOCKBAR_BOTTOM:
05239             if(ControlSize == LARGE_CONTROLS)
05240                 return (LRESULT) &HorizontalLargeRect ;
05241             else
05242                 return (LRESULT) &HorizontalSmallRect ; 
05243         case DOCKBAR_LEFT:
05244         case DOCKBAR_RIGHT:
05245             if(ControlSize == LARGE_CONTROLS)
05246                 return (LRESULT) &VerticalLargeRect ;
05247             else
05248                 return (LRESULT) &VerticalSmallRect ; 
05249     
05250         case DOCKBAR_FLOAT:
05251             if(ControlSize == LARGE_CONTROLS)
05252                 return (LRESULT) &FloatLargeRect ;
05253             else
05254                 return (LRESULT) &FloatSmallRect ; 
05255     }
05256     return 0;
05257 } */
05258 
05259 /********************************************************************************************
05260 
05261 >   LRESULT BaseBar::GetBarSize(DockBarType DockBarType)
05262 
05263     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05264     Created:    12/4/2000
05265     Inputs:     the dockbar type
05266     Outputs:    -
05267     Returns:    -
05268     Purpose:    To return the size of the bar
05269     Errors:     -
05270     SeeAlso:    -
05271 
05272 ********************************************************************************************/
05273 
05274 wxRect BaseBar::GetBarsDims (DockBarType DockBarType)
05275 {
05276     wxRect ReturnRect(0,0,0,0);
05277 
05278 #pragma message( __LOCMSG__ "BaseBar::GetBarsDims - do nothing" )
05279     TRACE( _T("Warning - BaseBar::GetBarsDims called") );
05280 /*  OILDockingBar* FloatBars = GetMainFrame ()->GetDockBar (DockBarType);//DOCKBAR_FLOAT);
05281     BOOL BigControls = FloatBars->IsBigControls ();
05282     
05283     switch (DockBarType)
05284     {
05285         case DOCKBAR_TOP:
05286         case DOCKBAR_BOTTOM:
05287             if (BigControls)
05288                 ReturnRect = HorizontalLargeRect;
05289             else
05290                 ReturnRect = HorizontalSmallRect;
05291         case DOCKBAR_LEFT:
05292         case DOCKBAR_RIGHT:
05293             if (BigControls)
05294                 ReturnRect = VerticalLargeRect;
05295             else
05296                 ReturnRect = VerticalSmallRect;
05297     
05298         case DOCKBAR_FLOAT:
05299             if (BigControls)
05300                 ReturnRect = FloatLargeRect;
05301             else
05302                 ReturnRect = FloatSmallRect;
05303     } */
05304 
05305     return ReturnRect;
05306 }
05307 
05308 
05309 
05310 /********************************************************************************************
05311 
05312 >   LRESULT BaseBar::SetControlFocus(WPARAM , LPARAM )
05313 
05314     Author:     everyone...
05315     Created:    7/5/94
05316     Inputs:     -
05317     Outputs:    -
05318     Returns:    -
05319     Purpose:    used to be sent by controls to inform bar that a control has got the focus
05320                 not ****ing sure anymore .
05321     Errors:     -
05322     SeeAlso:    -
05323 
05324 ********************************************************************************************/
05325 
05326 #pragma message( __LOCMSG__ "BaseBar::GetBarSize removed" )
05327 /*LRESULT BaseBar::SetControlFocus(WPARAM State, LPARAM Hwnd)
05328 {
05329     if (State == TRUE)
05330         DialogManager::hDlgCurrent = GetSafeHwnd();
05331     else
05332         DialogManager::hDlgCurrent = NULL;
05333 
05334     if(ControlHasFocus == (BOOL)State)
05335     {
05336         return 0;
05337     }
05338     
05339 
05340     if(State !=COMMIT && HwndWithFocus != (HWND)Hwnd)
05341         return 0;
05342     
05343     // this is sent after return is pressed in a control
05344     if(State == COMMIT)
05345         State = FALSE;
05346 
05347     if(!GetMainFrame()->IsAppActive())
05348     {
05349         return 0;
05350     }
05351     ControlHasFocus = State ;
05352     HwndWithFocus = (HWND)Hwnd ;
05353     // give the focus back to the main frame
05354     if(State == FALSE)
05355     { 
05356         GetMainFrame()->SetActiveWindow();
05357         ::HideCaret(NULL);
05358     }
05359     
05360     return 0;
05361 } */                                                
05362 
05363 /********************************************************************************************
05364 
05365 >   LRESULT BaseBar::StartControlDrag(WPARAM , LPARAM )
05366 
05367     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05368     Created:    15\11/94
05369     Inputs:     from windows 
05370     Outputs:    -
05371     Returns:    -
05372     Purpose:    sent by controls to inform bar that a control is about to be dragged
05373     Errors:     -
05374     SeeAlso:    -
05375 
05376 ********************************************************************************************/
05377 
05378 #pragma message( __LOCMSG__ "BaseBar::GetBarSize removed" )
05379 /*LRESULT  BaseBar::StartControlDrag(WPARAM State, LPARAM Hwnd)
05380 {
05381 #ifdef STANDALONE
05382     return FALSE;
05383 #else
05384 
05385     if(!KeyPress::IsAlternativePressed())
05386         return FALSE;
05387     // we can't drag items on or off infobars or double deckers (for the mo)
05388     BarControl * foundControl = (BarControl*)pOp->GetBarItem((HWND)Hwnd);
05389 
05390     if (foundControl)
05391     {
05392         // use these to get pointers to first and last item of double decker if found  
05393         BarControl * DDStart = NULL; 
05394         BarControl * DDEnd = NULL;
05395         
05396         BOOL DoubleDecker = FALSE;
05397         if(IsDoubleDecker(foundControl,DDStart,DDEnd)!=DDECKER_NONE)
05398             DoubleDecker = TRUE;
05399         
05400         if(!ThisIsAnInfoBar && !DoubleDecker)
05401         {
05402             InRecreate = TRUE;
05403             // keep a record of the ctl hwnd
05404             DragCtlHwnd = (HWND)Hwnd;
05405         
05406             // get the initial outline
05407             ::GetWindowRect(DragCtlHwnd,&OldDragRect);
05408             
05409             // and the 'size'
05410             ::GetClientRect(DragCtlHwnd,&DragCtlClientRect);
05411         
05412             // calculate the cursor offset into the control
05413             wxPoint CursorPos;
05414             GetCursorPos(&CursorPos);
05415             ::ScreenToClient(DragCtlHwnd,&CursorPos);
05416             DragCtlOffset = CursorPos;
05417         
05418             // paint the outline
05419             PaintDragRect(OldDragRect,wxRect(0,0,0,0),DOCKBAR_FLOAT,DOCKBAR_FLOAT);
05420         
05421             // Dragging Control is on
05422             CtlDragState = DRAGGING;
05423 
05424             // and capture the mouse
05425             SetCapture();
05426             CurrentBar = this;
05427     //      GetMainFrame()->SetActiveWindow();          // BODGE! Removed by Phil 13/10/96 (at 23.12!)
05428             DragManagerOp::SetDragActive(TRUE);
05429             
05430             if(CtlDragMode == COPY)
05431                 pCurrentCursor  = new Cursor(_R(IDC_BUTTONDRAGCOPY));
05432             else
05433                 pCurrentCursor  = new Cursor(_R(IDC_BUTTONDRAGCUT));
05434 
05435             // Did the cursor create ok ?
05436             if (pCurrentCursor && pCurrentCursor->IsValid())
05437             {
05438                 CurrentCursorID = CursorStack::GPush(pCurrentCursor, TRUE); // Push cursor, and display now
05439             }
05440 
05441         }
05442         return 0;
05443     }
05444 
05445     return 0;
05446 #endif
05447 } */                                                
05448 
05449 #pragma message( __LOCMSG__ "BaseBar::GetBarSize removed" )
05450 /*LRESULT  BaseBar::EndControlDrag(WPARAM State, LPARAM Hwnd)
05451 {
05452     return 0;
05453 } */
05454 
05455 /********************************************************************************************
05456 
05457 >   LRESULT BaseBar::StartControlDrag(WPARAM , LPARAM )
05458 
05459     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05460     Created:    15\11/94
05461     Inputs:     from windows 
05462     Outputs:    -
05463     Returns:    -
05464     Purpose:    sent by controls to inform bar that a control is about to be dragged
05465     Errors:     -
05466     SeeAlso:    -
05467 
05468 ********************************************************************************************/
05469 
05470 BOOL  BaseBar::SwapCursors(DWORD CursorID)
05471 {
05472     ERROR2IF(pCurrentCursor==NULL,FALSE,"Null last Cursor in SwapCursors");
05473     ERROR2IF(CurrentCursorID==0,FALSE,"CurrentID 0 in SwapCursors");
05474 
05475     if(pCurrentCursor)
05476     {
05477         CursorStack::GPop(CurrentCursorID);
05478         delete pCurrentCursor;
05479         pCurrentCursor = NULL;
05480         CurrentCursorID = 0;
05481     }
05482 
05483     pCurrentCursor  = new Cursor(CursorID);
05484 
05485     // Did the cursor create ok ?
05486     if (pCurrentCursor && pCurrentCursor->IsValid())
05487     {
05488         CurrentCursorID = CursorStack::GPush(pCurrentCursor, TRUE); // Push cursor, and display now
05489     }
05490     else
05491         return FALSE;
05492 
05493 return TRUE ;
05494 }                                               
05495 
05496 
05497                                             
05498 
05499 /********************************************************************************************
05500 
05501 >   LRESULT BaseBar::WindowProc( UINT32 message, WPARAM wParam, LPARAM lParam )
05502 
05503     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
05504     Created:    16/4/94
05505     Inputs:     from windows
05506     Outputs:    -
05507     Returns:    -
05508     Purpose:    The BaseBar's WindowProc firstly sends the message to the dialog manager
05509                 so that it can dispatch it to the appropriate DialogBarOp (if neccessary). 
05510                 Then the message is processed as normal. 
05511     Errors:     -
05512     SeeAlso:    -
05513 
05514 ********************************************************************************************/
05515 
05516 LRESULT BaseBar::WindowProc( UINT32 Message, WPARAM wParam, LPARAM lParam )
05517 {
05518 #pragma message( __LOCMSG__ "BaseBar::WindowProc - do nothing" )
05519     TRACE( _T("Warning - BaseBar::WindowProc called") );
05520 /*  // First send the message to the dialog manager 
05521     DialogManager::SendDialogMessage(this,
05522                                      Message,
05523                                      wParam,
05524                                      lParam);
05525 
05526 
05527     // this checks to see whether this Window is still around 
05528     // it is possible that the kernel just deleted this window 
05529     // no further proceesing if this is the case !
05530     if(!(IsWindow(GetSafeHwnd()))) return  0;
05531     // return brush for ctl3d
05532     switch(Message)
05533     {
05534         case WM_COMMAND:
05535             //TRACEUSER( "chris", _T("WM_COMMAND to %d\n"),GetSafeHwnd());
05536             // user has closed down a combo list - return focus to mainframe 
05537             if(HIWORD(wParam)==CBN_CLOSEUP)
05538                 GetMainFrame()->SetFocus();
05539 
05540             break; 
05541     #ifdef WIN32
05542         case WM_CTLCOLORBTN:
05543         case WM_CTLCOLORDLG:
05544         case WM_CTLCOLOREDIT:
05545         case WM_CTLCOLORLISTBOX:
05546         case WM_CTLCOLORMSGBOX:
05547         case WM_CTLCOLORSCROLLBAR:
05548         case WM_CTLCOLORSTATIC:
05549     #else
05550         case WM_CTLCOLOR:
05551     #endif
05552         HBRUSH hbrush = DoCtl3dCtlColorEx(Message, wParam, lParam);
05553         if (hbrush != NULL)
05554             return (LRESULT)hbrush;
05555     }
05556     // Now process the message normally
05557     return(wxWindow::WindowProc( Message, wParam, lParam )); */
05558 
05559     return 0;
05560 }
05561 
05562 
05563 /********************************************************************************************
05564 
05565 >   void BaseBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
05566 
05567     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
05568     Created:    1/9/93
05569     Inputs:     bCalcValidRects - unused
05570                 lpncsp - pointer to the structure containing the window area.
05571     Outputs:    lpncsp - this contains the adjusted area which indicates which part of the
05572                 window is the client area.  (See documentation on WM_NCCALCSIZE message).
05573                 Although this function has a void return, MFC actually returns 0 to Windows
05574                 in its message dispatcher (but by God you have to search for it).
05575     Returns:    -
05576     Purpose:    Calculates the area of the window which corresponds to the client area.  This
05577                 basically includes the whole window area, but excluding any dragbar.
05578     Errors:     -
05579     SeeAlso:    BaseBar::OnNcHitTest
05580     Scope:      Protected
05581 
05582 ********************************************************************************************/
05583 #pragma message( __LOCMSG__ "BaseBar::OnNcCalcSize removed" )
05584 /*void BaseBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
05585 {
05586     // So that we are compatible with different screen modes we will paint the non-client area
05587     // based on System metrics. 
05588 
05589     if (CurrentDlgBarMode == DIALOG)
05590     {
05591         // The dialog bar is a floater so we must specify our own non client area
05592         lpncsp->rgrc[0].GetLeft() += BorderWidth ;
05593         lpncsp->rgrc[0].GetTop() += TitleBarHeight + BorderWidth;   // UIC
05594         lpncsp->rgrc[0].GetRight() -= BorderWidth;
05595         lpncsp->rgrc[0].GetBottom() -= BorderWidth;
05596     }
05597     else
05598     {
05599         // The dialog bar is a bar so define the standard non client area for a child with a 
05600         // border.
05601         wxWindow::OnNcCalcSize(bCalcValidRects, lpncsp); 
05602     }                                      
05603 } */
05604 
05605 
05606 /********************************************************************************************
05607 
05608 >   void BaseBar::OnNcPaint()
05609 
05610     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
05611     Created:    1/9/93
05612     Inputs:     -
05613     Outputs:    -
05614     Returns:    -
05615     Purpose:    Paint the non-client area - this involves painting the dragbar and any
05616                 controls it has, if any.
05617     Errors:     -
05618     SeeAlso:    BaseBar::PaintDragBar
05619     Scope:      Protected
05620 
05621 ********************************************************************************************/
05622 #pragma message( __LOCMSG__ "BaseBar::OnNcPaint removed" )
05623 /*void BaseBar::OnNcPaint()
05624 {
05625     
05626     if (CurrentDlgBarMode == DIALOG)
05627     {
05628     // nearly-fabby win95 style floating bars
05629         if(IS_CHICAGO)
05630             PaintWin95DialogNonClient(Active);
05631         else
05632     
05633             PaintDialogNonClient(Active);
05634     }
05635     else  // Normal processing
05636     {
05637         if(IS_CHICAGO)
05638             PaintChicagoBorder();
05639         else
05640             wxWindow::OnNcPaint();
05641       
05642     }
05643                                         
05644 } */
05645 
05646 
05647 
05648 /******************************************************************************************** UIC
05649 >   void PlotStretchedMaskedBitmap(wxDC* destDC, CBitmap* srcBitmap, wxRect Pos)
05650 
05651     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05652     Created:    14/3/94
05653     Inputs:     destDC    - DC into which the BMP will be plotted
05654                 srcBitmap - source bitmap
05655                 Pos - rectangle to plot into
05656     Purpose:    Plots the given bitmap (srcDC) into the given rectangle of the destination
05657                 (destDC).
05658                 if srcDC == NULL, then just fills the button with grey, else...
05659 ********************************************************************************************/
05660 
05661 // Raster Ops, used to...
05662 
05663 // Plot colour in the glyph bitmaps transparent (grey) regions
05664 #define ROP_DSPDxax  0x00E20746L
05665 
05666 // Plot colour in the glyph bitmaps non-transparent (coloured) regions
05667 #define ROP_PSDPxax  0x00B8074AL
05668 
05669 
05670 #pragma message( __LOCMSG__ "BaseBar::PlotStretchedMaskedBitmap removed" )
05671 /*BOOL BaseBar::PlotStretchedMaskedBitmap(wxDC* destDC, CBitmap* srcBitmap,wxRect Pos)
05672 {
05673     
05674     ERROR2IF(srcBitmap == NULL,FALSE,"NULL Bitmap in PlotMaskedBitmap()");
05675     ERROR2IF(destDC == NULL,FALSE,"NULL DC in PlotMaskedBitmap()");
05676 
05677     BITMAP bits;
05678     srcBitmap->GetObject(sizeof(BITMAP),&bits);
05679 
05680     // always fill the entire background with BTNFACE to make sure we don't
05681     // miss any pixels 
05682 
05683     PatB(destDC,Pos.GetLeft(),Pos.GetTop(), Pos.GetWidth(), Pos.GetHeight(), GetSysColor(COLOR_BTNFACE));
05684     
05685     // create a screen dc
05686     wxDC scrDC ;
05687     scrDC.CreateCompatibleDC(destDC);
05688     
05689     // and select the bitmap into it
05690     CBitmap* OldSrcBitmap = (CBitmap *) scrDC.SelectObject(srcBitmap);
05691 
05692     // create a mask for the button glyph... First a DC
05693     wxDC hDCMono ;
05694     hDCMono.CreateCompatibleDC(NULL);
05695 
05696     // create a mono bitmap for the mask
05697     CBitmap hbmMono ; 
05698     hbmMono.CreateBitmap(Pos.GetWidth(),Pos.GetHeight(), 1, 1, NULL);
05699     
05700     CBitmap * oldmonobitmap = (CBitmap *)hDCMono.SelectObject(&hbmMono);
05701 
05702     // initalize the bitmapto white (all 1's)
05703     hDCMono.PatBlt(0, 0,Pos.GetWidth(),Pos.GetHeight(), WHITENESS);
05704 
05705     // plot all non-lightgrey  pixels in the glyph as black in our mask
05706     scrDC.SetBkColor( RGB(192,192,192));
05707     hDCMono.StretchBlt(0,0, Pos.GetWidth(),Pos.GetHeight(), &scrDC,
05708             0, 0,bits.bmWidth, bits.bmHeight, SRCCOPY);
05709 
05710     destDC->SetTextColor(0L);                  // 0's in mono -> 0 (for ROP)
05711     destDC->SetBkColor((COLORREF)0x00FFFFFFL); // 1's in mono -> 1
05712 
05713     // plot the glyph 
05714     destDC->StretchBlt( Pos.GetLeft(),Pos.GetTop(),Pos.GetWidth(),Pos.GetHeight(),  &scrDC, 
05715                             0, 0, bits.bmWidth, bits.bmHeight,SRCCOPY);
05716     
05717     // fill with the normal BTNFACE colour
05718     wxBrush HighlightBrush ; 
05719     HighlightBrush.CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
05720 
05721     wxBrush* hbrOld = (wxBrush *) destDC->SelectObject(&HighlightBrush);
05722     if (hbrOld != NULL)
05723     {
05724         // draw highlight color where we have 0's in the mask
05725         destDC->BitBlt( Pos.GetLeft(),Pos.GetTop(), Pos.GetWidth(),Pos.GetHeight(),  &hDCMono, 0, 0, ROP_DSPDxax);
05726         destDC->SelectObject(hbrOld);
05727     }
05728     
05729     // clean up DC's
05730     hDCMono.SelectObject(oldmonobitmap);
05731     scrDC.SelectObject(OldSrcBitmap);
05732     return TRUE;
05733 } */
05734 
05735 
05736  /********************************************************************************************
05737 
05738 >   void BaseBar::PaintWin95DialogNonClient(BOOL Active)
05739 
05740     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05741     Created:    5/8/95
05742     Inputs:     -
05743     Outputs:    -
05744     Returns:    -
05745     Purpose:    This routine gets called by OnNcPaint to paint the non client area of a 
05746                 Windows 95 style floating bar. 
05747     Errors:     -
05748     SeeAlso:    BaseBar::OnNcPaint
05749 
05750 ********************************************************************************************/
05751 
05752 
05753 void BaseBar::PaintWin95DialogNonClient(BOOL IsActive)
05754 {
05755 /*  if( pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)) )
05756     {   
05757         IsActive = ( this == GetActiveWindow() );
05758     }
05759   */
05760 
05761     // When the BaseBar is in DIALOG mode we have to paint the fancy non-client area. 
05762 
05763     // Get the size of the window   
05764     wxRect WinRect( GetRect() );
05765 
05766     // Set up the active non-client regions 
05767     SysMenuRect      = wxRect(WinRect.GetWidth() - TitleBarHeight - BorderWidth+2, 
05768                          BorderWidth + 1, 
05769                          WinRect.GetWidth() - BorderWidth , 
05770                          BorderWidth - 2 + TitleBarHeight );
05771 //  TRACE( _T("SMRB = (%d, %d)\n"), SysMenuRect.GetWidth(), SysMenuRect.GetHeight());
05772     
05773     TopBorderRect    = wxRect(0,
05774                          0, 
05775                          WinRect.GetWidth(), 
05776                          BorderWidth); 
05777 
05778     BottomBorderRect = wxRect(0,
05779                          WinRect.GetHeight() - BorderWidth, 
05780                          WinRect.GetWidth(), 
05781                          WinRect.GetHeight()); 
05782 
05783     LeftBorderRect =   wxRect(0,
05784                          0, 
05785                          BorderWidth,
05786                          WinRect.GetHeight());
05787                          
05788     RightBorderRect =  wxRect(WinRect.GetWidth() - BorderWidth, 
05789                          0,
05790                          WinRect.GetWidth(), 
05791                          WinRect.GetHeight());
05792 
05793     CaptionBarRect =   wxRect(BorderWidth , 
05794                          BorderWidth-1 , 
05795                          WinRect.GetWidth() - BorderWidth + 1, 
05796                          TitleBarHeight+BorderWidth);  
05797 
05798 
05799     TopLeftGrowRect =  wxRect(0, 
05800                          0,
05801                          TitleBarHeight  + BorderWidth +1, 
05802                          TitleBarHeight  + BorderWidth);
05803 
05804     TopRightGrowRect =  wxRect(WinRect.GetWidth() - BorderWidth - TitleBarHeight -1 , 
05805                          0,
05806                          WinRect.GetWidth(), 
05807                          TitleBarHeight  + BorderWidth);
05808 
05809 
05810     BottomLeftGrowRect = wxRect(0, 
05811                          WinRect.GetHeight() - BorderWidth - TitleBarHeight ,
05812                          TitleBarHeight  + BorderWidth +1 , 
05813                          WinRect.GetHeight());
05814 
05815     BottomRightGrowRect = wxRect(WinRect.GetWidth() - BorderWidth - TitleBarHeight -1  , 
05816                          WinRect.GetHeight() - BorderWidth - TitleBarHeight,
05817                          WinRect.GetWidth(), 
05818                          WinRect.GetHeight());
05819 
05820 
05821     // Get a context onto the entire window area
05822     wxClientDC  dc( this );
05823 
05824     
05825     // -------------------------------------------------------------------------------------
05826 /*  // Paint the borders     UIC commented out 
05827 
05828     // Create the pen.
05829     wxPen BorderPen(PS_NULL, 0, GetSysColor(COLOR_WINDOWFRAME));
05830 
05831     // Get standard border brush
05832     wxBrush BorderBrush(GetSysColor(COLOR_BTNFACE));
05833     
05834     // Select these into the DC
05835     wxBrush *OldBrush = dc->SelectObject(&BorderBrush);
05836     wxPen *OldPen = dc->SelectObject(&BorderPen);
05837     wxFont * OldFont=dc->SelectObject(TitleFont);
05838     
05839 
05840     // -------------------------------------------------------------------------------------
05841     // Paint the borders frame  */
05842 
05843 
05844     // Get standard hollow brush
05845     wxBrush FrameBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
05846 
05847     dc.SetBrush( FrameBrush );
05848     dc.DrawRectangle( TopBorderRect);
05849     dc.DrawRectangle( BottomBorderRect);
05850     dc.DrawRectangle( LeftBorderRect);
05851     dc.DrawRectangle( RightBorderRect);
05852     dc.SetBrush( wxNullBrush );
05853 
05854     wxColour TopLeft        = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT );
05855     wxColour BotRight       = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWFRAME );
05856     wxColour TopLeftInside  = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
05857     wxColour BotRightInside = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW );
05858     
05859     INT32 x  = 1;
05860     INT32 y  = 1;
05861     INT32 dx = WinRect.GetWidth()-1;
05862     INT32 dy = WinRect.GetHeight()-1;
05863 
05864     // The plinth is always made up of 4 right-angle elements
05865     // When indented, the colours are swapped, but the elements retain position
05866     PatB(dc, x, y, 1, dy-1, TopLeft);
05867     PatB(dc, x, y, dx-1, 1, TopLeft);
05868 
05869     PatB(dc, x+dx-1, y-1, 1, dy+1, BotRight);
05870     PatB(dc, x-1, y+dy-1, dx+2, 1, BotRight);
05871 
05872     PatB(dc, x+1, y+1, 1, dy-2, TopLeftInside);
05873     PatB(dc, x+1, y+1, dx-2, 1, TopLeftInside);
05874 
05875     PatB(dc, x+dx-2, y, 1, dy-1, BotRightInside);
05876     PatB(dc, x, y+dy-2, dx-2, 1, BotRightInside);
05877 
05878     
05879 
05880 
05881     // -------------------------------------------------------------------------------------
05882 /*  // Paint the caption bar
05883     
05884     INT32 CaptionColour = IsActive ? COLOR_ACTIVECAPTION: COLOR_INACTIVECAPTION;
05885 
05886     wxBrush CaptionBrush(GetSysColor(CaptionColour));
05887     
05888     dc->FillRect(&CaptionBarRect,&CaptionBrush);
05889 */
05890     // Make sure weve got diagonal resizing for the galleries  
05891     if( pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)) )
05892     {   
05893         //remove corner grow rects from  border rects
05894         TopBorderRect.Inflate(-TopLeftGrowRect.GetRight(),0);
05895         
05896         LeftBorderRect.Inflate(0,-TopLeftGrowRect.GetRight());
05897 
05898         BottomBorderRect.Inflate(-TopLeftGrowRect.GetRight(),0);
05899         
05900         RightBorderRect.Inflate(0,-TopLeftGrowRect.GetRight());
05901     }
05902 
05903 /*  // -------------------------------------------------------------------------------------
05904     // Paint the Close Button       UIC commnented out next 2 functions
05905 
05906     Paint3dPlinth(dc,&SysMenuRect,TRUE);
05907     // Get standard Black Pen
05908     wxPen BlackPen;
05909     BlackPen.CreateStockObject(BLACK_PEN);
05910     dc->SelectObject(&BlackPen);
05911     
05912     dc->MoveTo(SysMenuRect.BottomRight()-(wxSize(5,4)));
05913     dc->LineTo(SysMenuRect.TopLeft()+(wxSize(2,2)));
05914 
05915     dc->MoveTo(SysMenuRect.BottomRight()-(wxSize(6,4)));
05916     dc->LineTo(SysMenuRect.TopLeft()+(wxSize(1,2)));
05917 
05918     dc->MoveTo(SysMenuRect.BottomRight()-(wxSize(10,4)));
05919     dc->LineTo(SysMenuRect.TopLeft()+(wxSize(7,2)));
05920     dc->MoveTo(SysMenuRect.BottomRight()-(wxSize(9,4)));
05921     dc->LineTo(SysMenuRect.TopLeft()+(wxSize(8,2)));
05922  
05923     //  ------------------------------------------------------------------------------------
05924     // Print the Title
05925 
05926     INT32 TextColour = IsActive ? COLOR_CAPTIONTEXT: COLOR_INACTIVECAPTIONTEXT;  
05927 
05928     // Text Bounding Box
05929     wxRect BoundBox(BorderWidth + 1,
05930                    BorderWidth - 1,
05931                    WinRect.GetWidth() - (BorderWidth*2) + 1 - TitleBarHeight,
05932                    BorderWidth + TitleBarHeight);
05933 
05934     // Get the Dialog Name
05935     String_32 Name = pOp->GetName();
05936 
05937     // Set the Text Colour
05938     dc->SetTextColor(GetSysColor(TextColour));
05939     dc->SetBkMode(TRANSPARENT);
05940 
05941     // Check that the text will not overlap to the left
05942     wxSize TextSize=dc->GetTextExtent(Name,camStrlen(Name));
05943 
05944     dc->DrawText(Name,camStrlen(Name),BoundBox,DT_LEFT);
05945 
05946     // Clean up and release the DC
05947 
05948     dc->SelectObject(OldBrush);
05949     dc->SelectObject(OldPen);
05950     dc->SelectObject(OldFont);
05951     ReleaseDC(dc);
05952 
05953 }
05954 
05955 */
05956 // Paint the caption    UIC 
05957     
05958     // make sure that DrawCaption shows the correct title
05959     SetLabel( pOp->GetName() );
05960     
05961 #pragma message( __LOCMSG__ "Remove MSW frame redrawing stuff" )
05962 /*  UINT32 DrawFlags = DC_TEXT|DC_SMALLCAP;
05963     
05964     if(IsActive)
05965         DrawFlags|=DC_ACTIVE;
05966 
05967     // draw the caption
05968     ::DrawCaption( this, dc, &CaptionBarRect, DrawFlags );
05969     
05970     // draw the new stretchy close button
05971     dc->DrawFrameControl( &SysMenuRect, DFC_CAPTION, DFCS_CAPTIONCLOSE ); */
05972 }   
05973     
05974 
05975 /********************************************************************************************
05976 
05977 >   void BaseBar::PaintDialogNonClient(BOOL Active)
05978 
05979     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
05980     Created:    5/4/94
05981     Inputs:     -
05982     Outputs:    -
05983     Returns:    -
05984     Purpose:    This routine gets called by OnNcPaint to paint the non client area of a 
05985                 floating bar. 
05986     Errors:     -
05987     SeeAlso:    BaseBar::OnNcPaint
05988 
05989 ********************************************************************************************/
05990 
05991 
05992 void BaseBar::PaintDialogNonClient(BOOL IsActive)
05993 {
05994 #pragma message( __LOCMSG__ "BaseBar::PaintDialogNonClient - do nothing" )
05995     TRACE( _T("Warning - BaseBar::PaintDialogNonClient called") );
05996 /*  // Get the System Frame Size
05997     BorderWidth=wxSystemSettings::GetMetric(SM_CXFRAME);
05998 
05999     // When the BaseBar is in DIALOG mode we have to paint the fancy non-client area. 
06000 
06001     // Get the size of the window   
06002     wxRect WinRect( GetRect() );
06003 
06004     // Set up the active non-client regions 
06005     SysMenuRect      = wxRect(BorderWidth-1, 
06006                          BorderWidth-1, 
06007                          BorderWidth + TitleBarHeight+1, 
06008                          BorderWidth-1 + TitleBarHeight + 1);
06009                              
06010     TopBorderRect    = wxRect(0,
06011                          0, 
06012                          WinRect.GetWidth(), 
06013                          BorderWidth); 
06014 
06015     BottomBorderRect = wxRect(0,
06016                          WinRect.GetHeight() - BorderWidth, 
06017                          WinRect.GetWidth(), 
06018                          WinRect.GetHeight()); 
06019 
06020     LeftBorderRect =   wxRect(0,
06021                          0, 
06022                          BorderWidth,
06023                          WinRect.GetHeight());
06024                          
06025     RightBorderRect =  wxRect(WinRect.GetWidth() - BorderWidth, 
06026                          0,
06027                          WinRect.GetWidth(), 
06028                          WinRect.GetHeight());
06029 
06030     CaptionBarRect =   wxRect(BorderWidth - 1 + TitleBarHeight+1, 
06031                          BorderWidth - 1, 
06032                          WinRect.GetWidth() - BorderWidth + 1, 
06033                          BorderWidth + TitleBarHeight);  
06034 
06035     TopLeftGrowRect =  wxRect(0, 
06036                          0,
06037                          TitleBarHeight  + BorderWidth +1, 
06038                          TitleBarHeight  + BorderWidth);
06039 
06040     TopRightGrowRect =  wxRect(WinRect.GetWidth() - BorderWidth - TitleBarHeight -1 , 
06041                          0,
06042                          WinRect.GetWidth(), 
06043                          TitleBarHeight  + BorderWidth);
06044 
06045 
06046     BottomLeftGrowRect = wxRect(0, 
06047                          WinRect.GetHeight() - BorderWidth - TitleBarHeight ,
06048                          TitleBarHeight  + BorderWidth +1 , 
06049                          WinRect.GetHeight());
06050 
06051     BottomRightGrowRect = wxRect(WinRect.GetWidth() - BorderWidth - TitleBarHeight -1  , 
06052                          WinRect.GetHeight() - BorderWidth - TitleBarHeight,
06053                          WinRect.GetWidth(), 
06054                          WinRect.GetHeight());
06055 
06056 
06057     // Get a context onto the entire window area
06058     wxClientDC dc( this );
06059 
06060     // -------------------------------------------------------------------------------------
06061     // Paint the borders
06062 
06063     // Create the pen.
06064     wxPen BorderPen(PS_NULL, 0, GetSysColor(COLOR_WINDOWFRAME));
06065 
06066     // Get standard border brush
06067     INT32 BorderColour = IsActive ? COLOR_ACTIVEBORDER: COLOR_INACTIVEBORDER; 
06068     wxBrush BorderBrush(GetSysColor(BorderColour));
06069 
06070     // Select these into the DC
06071     dc.SetBrush( BorderBrush );
06072     dc.SetPen( BorderPen );
06073     dc.SetFont( TitleFont );
06074 
06075     // Top
06076     dc.DrawRectangle( TopBorderRect ); 
06077     // Bottom
06078     dc.DrawRectangle( BottomBorderRect ); 
06079     // Left
06080     dc.DrawRectangle( LeftBorderRect ); 
06081     // Right
06082     dc.DrawRectangle( RightBorderRect ); 
06083 
06084 
06085     // -------------------------------------------------------------------------------------
06086     // Paint the borders frame
06087 
06088     wxPen FramePen( GetSysColor(COLOR_WINDOWFRAME), wxSolid );
06089 
06090     // Get standard hollow brush
06091     wxBrush FrameBrush;
06092     FrameBrush.CreateStockObject(HOLLOW_BRUSH);
06093 
06094     // Select these into the DC
06095     dc.SetBrush( FrameBrush );
06096     dc.SetPen( FramePen );
06097 
06098     dc.DrawRectangle(0, 0, WinRect.GetWidth(), WinRect.GetHeight());
06099 
06100     dc.DrawRectangle(BorderWidth-1, 
06101                   BorderWidth-1, 
06102                   WinRect.GetWidth() - BorderWidth + 1, 
06103                   WinRect.GetHeight() - BorderWidth + 1);
06104 
06105     // Galleries have corner grow controls
06106     if( pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)) )
06107     {   
06108         dc.DrawRectangle(TopLeftGrowRect);
06109         dc.DrawRectangle(TopRightGrowRect);
06110             
06111         // Bottom Left Grow 
06112         dc.DrawLine( BottomLeftGrowRect.GetLeft(),BottomLeftGrowRect.GetTop(),
06113             BorderWidth -1 ,BottomLeftGrowRect.GetTop() );
06114         dc.DrawLine( BottomLeftGrowRect.GetRight(),BottomLeftGrowRect.GetBottom(),
06115             BottomLeftGrowRect.GetRight(),BottomLeftGrowRect.GetBottom() - BorderWidth - 1 );
06116     
06117         // Bottom Right Grow
06118         dc.DrawLine(BottomRightGrowRect.GetRight() - BorderWidth +1,BottomRightGrowRect.GetTop(),
06119             BottomRightGrowRect.GetRight(),BottomRightGrowRect.GetTop());
06120         dc.DrawLine(BottomRightGrowRect.GetLeft(),BottomRightGrowRect.GetBottom(),
06121             BottomRightGrowRect.GetLeft(),BottomLeftGrowRect.GetBottom() - BorderWidth - 1);
06122         
06123         //remove corner grow rects from  border rects
06124         TopBorderRect.Inflate(-TopLeftGrowRect.GetRight(),0);
06125         
06126         LeftBorderRect.Inflate(0,-TopLeftGrowRect.GetRight());
06127 
06128         BottomBorderRect.Inflate(-TopLeftGrowRect.GetRight(),0);
06129         
06130         RightBorderRect.Inflate(0,-TopLeftGrowRect.GetRight());
06131 
06132     }
06133 
06134     // -------------------------------------------------------------------------------------
06135     // Paint the Close Button 
06136 
06137     wxBrush ButtonBrush(GetSysColor(COLOR_BTNFACE));
06138     dc.SetBrush( ButtonBrush );
06139     dc.DrawRectangle(SysMenuRect);
06140 
06141     // Paint the Shadow
06142     wxBrush ShadowBrush(GetSysColor(COLOR_BTNSHADOW));
06143     dc.SetPen(GetStockObject(NULL_PEN));
06144     dc.SetBrush(&ShadowBrush);
06145     dc.DrawRectangle(BorderWidth - 1 + (TitleBarHeight/2)-1,
06146                   BorderWidth + 4,
06147                   BorderWidth - 1 + (TitleBarHeight/2)+6, 
06148                   BorderWidth + 8 );
06149 
06150     // Paint the Rectangle/Highlight
06151     dc.SetPen(GetStockObject(BLACK_PEN));
06152     dc.SetBrush(GetStockObject(WHITE_BRUSH));
06153     dc.DrawRectangle(BorderWidth - 1 + (TitleBarHeight/2)-2,
06154                   BorderWidth + 3,
06155                   BorderWidth - 1 + (TitleBarHeight/2)+4, 
06156                   BorderWidth + 6 );
06157 
06158 
06159     // -------------------------------------------------------------------------------------
06160     // Paint the caption bar
06161     
06162     INT32 CaptionColour = IsActive ? COLOR_ACTIVECAPTION: COLOR_INACTIVECAPTION;
06163 
06164     wxBrush CaptionBrush(GetSysColor(CaptionColour));
06165     
06166     dc.SetBrush(CaptionBrush);
06167     dc.DrawRectangle(CaptionBarRect);
06168 
06169     //  ------------------------------------------------------------------------------------
06170     // Print the Title
06171 
06172     INT32 TextColour = IsActive ? COLOR_CAPTIONTEXT: COLOR_INACTIVECAPTIONTEXT;  
06173 
06174     // Text Bounding Box
06175     wxRect BoundBox(BorderWidth +TitleBarHeight,
06176                    BorderWidth-1,
06177                    WinRect.GetWidth() - (BorderWidth*2) + 1,
06178                    BorderWidth + TitleBarHeight);
06179 
06180     // Get the Dialog Name
06181     String_32 Name = pOp->GetName();
06182 
06183     // Set the Text Colour
06184     dc.SetTextForeground(GetSysColor(TextColour));
06185     dc.SetBackgroundMode( wxTRANSPARENT );
06186 
06187     // Check that the text will not overlap to the left
06188     wxSize TextSize=dc->GetTextExtent(Name,camStrlen(Name));
06189 
06190     if (TextSize.width<BoundBox.GetWidth())
06191           dc->DrawText(Name,-1,BoundBox,DT_CENTER|DT_VCENTER|DT_SINGLELINE);  // UIC    
06192         //dc->DrawText(Name,camStrlen(Name),BoundBox,DT_CENTER); 
06193     else
06194         dc->DrawText(Name,camStrlen(Name),BoundBox,DT_LEFT|DT_VCENTER |DT_SINGLELINE); // UIC
06195         //dc->DrawText(Name,camStrlen(Name),BoundBox,DT_LEFT);
06196 
06197     // Clean up and release the DC
06198 
06199     dc->SelectObject(OldBrush);
06200     dc->SelectObject(OldPen);
06201     dc->SelectObject(OldFont); */
06202 
06203 }
06204 
06205 
06206 
06207 /********************************************************************************************
06208 
06209 >   BOOL BaseBar::OnNcActivate(BOOL Active)
06210 
06211     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
06212     Created:    1/9/93
06213     Inputs:     Active - Indicates whether the window is active (TRUE => Active).
06214     Outputs:    -
06215     Returns:    Nonzero to continue default processing, 0 to prevent the window being made
06216                 inactive.
06217     Purpose:    This function is called when the non-client area needs to be updated to
06218                 reflect its active or inactive state.
06219     Errors:     -
06220     SeeAlso:    -
06221     Scope:      Protected
06222 
06223 ********************************************************************************************/
06224 
06225 #pragma message( __LOCMSG__ "BaseBar::OnNcPaint removed" )
06226 /*BOOL BaseBar::OnNcActivate(BOOL IsActive)
06227 {
06228     
06229     //PaintDialogNonClient(IsActive); 
06230     return TRUE;
06231 } */
06232 
06233 
06234 
06235 /********************************************************************************************
06236 
06237 >   void BaseBar::OnPaint()
06238 
06239     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
06240     Created:    1/9/93
06241     Purpose:    Paints the client area of the dilog bar
06242     Scope:      Protected
06243 
06244 ********************************************************************************************/
06245                                          
06246 #pragma message( __LOCMSG__ "BaseBar::OnPaint removed" )
06247 /*void BaseBar::OnPaint()
06248 {
06249     wxPaintDC  PaintDC(this); // device context for painting
06250         // Create the brush and pen to paint the client area
06251     wxBrush Brush(GetSysColor(COLOR_BTNFACE));
06252 
06253     // Get the size of the window client area   
06254     wxRect WinRect;
06255     GetClientRect(&WinRect);    
06256 
06257     // Paint the client area
06258     PaintDC.FillRect(WinRect,&Brush);
06259     
06260 //  if (IS_CHICAGO && CurrentDlgBarMode != DIALOG)
06261 //      PaintChicagoBorder();
06262 
06263 //  wxWindow::OnPaint();
06264 } */
06265 
06266 
06267 /********************************************************************************************
06268 
06269 >   void BaseBar::PaintChicagoBorder()
06270 
06271     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06272     Created:    5/4/94
06273     Inputs:     -
06274     Outputs:    -
06275     Returns:    -
06276     Purpose:    This routine gets called by OnNcPaint to paint the non client area of a 
06277                 docked Chicago bar. 
06278     Errors:     -
06279     SeeAlso:    BaseBar::OnNcPaint
06280 
06281 ********************************************************************************************/
06282 
06283 void BaseBar::PaintChicagoBorder()
06284 {
06285 #pragma message( __LOCMSG__ "BaseBar::PaintChicagoBorder - do nothing" )
06286     TRACE( _T("Warning - BaseBar::PaintChicagoBorder called") );
06287 /*  wxRect WinRect( GetClientRect() );
06288     wxRect ParWin( GetParent()->GetRect() );
06289     wxRect ScreenWin( GetRect() );
06290     
06291     DWORD TopCol = GetSysColor(COLOR_BTNHIGHLIGHT);
06292     DWORD BottomCol = GetSysColor(COLOR_BTNSHADOW);
06293     DWORD LeftCol = GetSysColor(COLOR_BTNHIGHLIGHT);
06294     DWORD RightCol = GetSysColor(COLOR_BTNSHADOW);
06295 
06296     // Get a context onto the entire window area
06297     wxDC *DC = GetWindowDC();
06298     WinRect.Inflate(1,1);   
06299     if(!IS_CHICAGO)
06300     {
06301         switch(ParentDockBarType)
06302         {
06303         case DOCKBAR_LEFT:
06304 
06305             break;
06306         case DOCKBAR_RIGHT:
06307            if(ScreenWin.GetRight()==ParWin.GetRight())
06308                 RightCol = GetSysColor(COLOR_WINDOWFRAME);
06309             break;
06310         case DOCKBAR_TOP:
06311             if(ScreenWin.GetBottom()==ParWin.GetBottom())
06312                 BottomCol = GetSysColor(COLOR_WINDOWFRAME);
06313             break;
06314         case DOCKBAR_BOTTOM:
06315             
06316             break;
06317         }
06318     }
06319 
06320     PatB(DC,0,0,1,WinRect.GetBottom(),LeftCol);
06321     
06322     PatB(DC,0,0,WinRect.GetRight(),1,TopCol);
06323     
06324     PatB(DC,WinRect.GetRight(),0,1,WinRect.GetBottom(),RightCol);
06325     
06326     PatB(DC,0,WinRect.GetBottom() ,WinRect.GetRight()+1,1,BottomCol); */
06327 
06328 }
06329 
06330 
06331 /********************************************************************************************
06332 
06333 >   UINT32 BaseBar::OnNcHitTest(wxPoint point)
06334 
06335     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
06336     Created:    5/4/94
06337     Inputs:     -
06338     Outputs:    -
06339     Returns:    -
06340     Purpose:    
06341     Errors:     -
06342     SeeAlso:    -
06343 
06344 ********************************************************************************************/
06345 
06346 #pragma message( __LOCMSG__ "BaseBar::OnNcHitTest removed" )
06347 /*UINT32 BaseBar::OnNcHitTest(wxPoint point)
06348 {
06349 
06350     if (DragType != NONE)
06351         return HTCLIENT; 
06352 
06353     if (CurrentDlgBarMode == DIALOG)
06354     {
06355         // Get the window dimensions
06356         wxRect rect( GetRect() );
06357         wxRect InsideBorderRect = rect;
06358         InsideBorderRect.Inflate(-BorderWidth,-BorderWidth);
06359         wxPoint NonClientPoint (point.x - rect.GetLeft(), point.y - rect.GetTop()); 
06360   
06361         // Determine what active area the cursor is over
06362         if (SysMenuRect.PtInRect(NonClientPoint))
06363         {
06364             return HTSYSMENU; 
06365         }
06366         else if (TopBorderRect.PtInRect(NonClientPoint))
06367         {
06368             if (pOp->IsListEmpty())
06369                 return HTCLIENT;    
06370             return HTTOP; 
06371         }
06372         else if (BottomBorderRect.PtInRect(NonClientPoint))
06373         {
06374             if (pOp->IsListEmpty())
06375                 return HTCLIENT;    
06376             return HTBOTTOM; 
06377         }
06378         else if (LeftBorderRect.PtInRect(NonClientPoint))
06379         {
06380             if (pOp->IsListEmpty())
06381                 return HTCLIENT;    
06382             return HTLEFT; 
06383         }
06384         else if (RightBorderRect.PtInRect(NonClientPoint))
06385         {
06386             if (pOp->IsListEmpty())
06387                 return HTCLIENT;    
06388             return HTRIGHT; 
06389         }
06390         else if (CaptionBarRect.PtInRect(NonClientPoint))
06391         {
06392             return HTCAPTION; 
06393         }
06394         if( pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)) && !InsideBorderRect.PtInRect(point) )
06395         {
06396             if (TopLeftGrowRect.PtInRect(NonClientPoint))
06397                 return HTTOPLEFT;                             
06398             
06399             else if (TopRightGrowRect.PtInRect(NonClientPoint))
06400                 return HTTOPRIGHT; 
06401             
06402             else if (BottomLeftGrowRect.PtInRect(NonClientPoint))
06403                 return HTBOTTOMLEFT;     
06404             
06405             else if (BottomRightGrowRect.PtInRect(NonClientPoint))
06406                 return HTBOTTOMRIGHT;    
06407             
06408             return HTCLIENT; 
06409         
06410         }
06411         else
06412             // Normal client area hit 
06413             return HTCLIENT; 
06414     }
06415     else // The BaseBar is a bar
06416     {
06417         return (wxWindow::OnNcHitTest(point)); 
06418     } 
06419     
06420 } */
06421 
06422 /********************************************************************************************
06423 
06424 >   void BaseBar::OnNcRButtonDown(UINT32 nHitTest, wxPoint point)
06425 
06426     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
06427     Created:    5/4/94
06428     Inputs:     -
06429     Outputs:    -
06430     Returns:    -
06431     Purpose:    
06432     Errors:     -
06433     SeeAlso:    -
06434 
06435 ********************************************************************************************/
06436 
06437 #pragma message( __LOCMSG__ "BaseBar::OnNcRButtonDown removed" )
06438 /*void BaseBar::OnNcRButtonDown(UINT32 nHitTest, wxPoint point)
06439 {
06440 } */
06441 
06442 /********************************************************************************************
06443 
06444 >   void BaseBar::OnNcLButtonDown(UINT32 nHitTest, wxPoint point)
06445 
06446     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
06447     Created:    5/4/94
06448     Inputs:     -
06449     Outputs:    -
06450     Returns:    -
06451     Purpose:    
06452     Errors:     -
06453     SeeAlso:    -
06454 
06455 ********************************************************************************************/
06456 
06457 #pragma message( __LOCMSG__ "BaseBar::OnNcHitTest removed" )
06458 /*void BaseBar::OnNcHitTest(UINT32 nHitTest, wxPoint point)
06459 {
06460 
06461     ENSURE(FALSE,"BaseClass OnNcLButtonDown called");
06462 
06463 } */
06464 
06465 /********************************************************************************************
06466 
06467 >   void BaseBar::OnLButtonDown(UINT32 nFlags, wxPoint point)
06468 
06469     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
06470     Created:    5/4/94
06471     Inputs:     -
06472     Outputs:    -
06473     Returns:    -
06474     Purpose:    
06475     Errors:     -
06476     SeeAlso:    -
06477 
06478 ********************************************************************************************/
06479 
06480 #pragma message( __LOCMSG__ "BaseBar::OnLButtonDown removed" )
06481 /*void BaseBar::OnLButtonDown(UINT32 nFlags, wxPoint point)
06482 {
06483     // make sure we're not clicking on a disabled button
06484     if(this == ChildWindowFromPoint(point))
06485     {
06486         //Capture the mouse and go into "trying to start a drag" mode 
06487         SetCapture();
06488         DragType = TRYING;
06489 
06490         DragManagerOp::SetDragActive(TRUE);
06491 
06492         //record start point of drag
06493         ClientToScreen(&point);
06494         StartDragPoint = point;
06495     
06496         GetWindowRect(&OldDragRect);
06497         PaintDragRect(OldDragRect,wxRect(0,0,0,0),ParentDockBarType,ParentDockBarType); 
06498     
06499     }
06500     else
06501     {
06502         if(KeyPress::IsAlternativePressed())
06503         {
06504             wxWindow * OverWindow;
06505             OverWindow = ChildWindowFromPoint(point);
06506             
06507             if (OverWindow != this && OverWindow != NULL)
06508             {
06509                 ::SendMessage(GetSafeHwnd(),WM_START_CTLDRAG,(WPARAM) 0,
06510                                     (LPARAM)OverWindow->GetSafeHwnd() );
06511             }
06512         }
06513 
06514     }
06515 
06516 } */
06517 
06518 
06519 
06520 /********************************************************************************************
06521 
06522 >   void BaseBar::OnMouseWheel(UINT32 nFlags, short zDelta, wxPoint point)
06523                                                
06524     Author:     Priestley (Xara Group Ltd) <camelotdev@xara.com>
06525     Created:    26/10/2000
06526 
06527 ********************************************************************************************/
06528 
06529 #pragma message( __LOCMSG__ "BaseBar::OnMouseWheel removed" )
06530 /*BOOL BaseBar::OnMouseWheel(UINT32 nFlags, short zDelta, wxPoint pt)
06531 {
06532     TRACEUSER( "Matt", _T("MouseWheel Scroll In BaseBar!\n"));
06533     return TRUE;
06534 } */
06535 
06536 /********************************************************************************************
06537 
06538 >   void BaseBar::OnLButtonDblClk(UINT32 nFlags, wxPoint point)
06539                                                
06540     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06541     Created:    24/5/94
06542     Inputs:     -
06543     Outputs:    -
06544     Returns:    -
06545     Purpose:    
06546     Errors:     -
06547     SeeAlso:    -
06548 
06549 ********************************************************************************************/
06550 
06551 #pragma message( __LOCMSG__ "BaseBar::OnLButtonDblClk removed" )
06552 /*void BaseBar::OnLButtonDblClk( UINT32 nFlags, wxPoint point )
06553 {
06554     //MessageBeep(MB_OK);
06555 } */
06556 
06557 /********************************************************************************************
06558 
06559 >   static BOOL BaseBar::GetStatusLineText(String_256 * StatusText)
06560 
06561     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06562     Created:    22/11/94
06563     Inputs:     -
06564     Outputs:    -
06565     Returns:    TRUE if I have put text on the StatusLine FALSE otherwise
06566     Purpose:    called on idles to check whether I want to put some text on the status bar  
06567     Errors:     -
06568     SeeAlso:    -
06569 
06570 ********************************************************************************************/
06571 
06572 BOOL BaseBar::GetStatusLineText(String_256 * pStatusText)
06573 {
06574     ERROR2IF(pStatusText==NULL,FALSE,"BaseBar::GetStatusLineText() - pStatusText==NULL!");
06575 
06576     BOOL ReturnValue=FALSE;
06577     if (CurrentBar!=NULL)
06578         ReturnValue=CurrentBar->GetStatusText(pStatusText);
06579     return ReturnValue;
06580 }
06581 
06582 /********************************************************************************************
06583 
06584 >   virtual BOOL BaseBar::SetStatusLineText()
06585 
06586     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06587     Created:    22/11/94
06588     Inputs:     -
06589     Outputs:    -
06590     Returns:    FALSE 
06591     Purpose:    base virtual function should never be called
06592     Errors:     -
06593     SeeAlso:    -
06594 
06595 ********************************************************************************************/
06596 
06597 BOOL BaseBar::SetStatusLineText()
06598 {
06599     return FALSE;
06600 }
06601 
06602 
06603 /********************************************************************************************
06604 
06605 >   virtual BOOL BaseBar::GetStatusText(String_256 * StatusText)
06606 
06607     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06608     Created:    22/11/94
06609     Inputs:     -
06610     Outputs:    -
06611     Returns:    FALSE 
06612     Purpose:    base virtual function should never be called.
06613     Errors:     -
06614     SeeAlso:    -
06615 
06616 ********************************************************************************************/
06617 
06618 BOOL BaseBar::GetStatusText(String_256 * StatusText)
06619 {
06620     return FALSE;
06621 }
06622 
06623 /********************************************************************************************
06624 
06625 >   static void BaseBar::AltPressed(BOOL state)
06626 
06627     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06628     Created:    22/11/94
06629     Inputs:     Alt state
06630     Outputs:    -
06631     Returns:    -
06632     Purpose:    called from DialogBarOp message handler when Alt is pressed
06633                 allows user to enter control drag state
06634     Errors:     -
06635     SeeAlso:    -
06636 
06637 ********************************************************************************************/
06638 
06639 BOOL BaseBar::AltPressed(BOOL state)
06640 {
06641     //TRACEUSER( "chris", _T("Atl state %d\n"),state);
06642 
06643     if(state)
06644     {
06645         if(CtlDragState==NO_DRAG)
06646         {
06647             //CtlDragState=READY;
06648             return FALSE;
06649         }
06650     }
06651     else
06652     {
06653         if(CtlDragState==DRAGGING || CtlDragState == READY)
06654         {
06655             return TRUE;
06656         }
06657     }
06658     return FALSE;
06659 }
06660 
06661 /********************************************************************************************
06662 
06663 >   static void BaseBar::CancelAllDrags()
06664 
06665     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06666     Created:    22/11/94
06667     Inputs:     -
06668     Outputs:    -
06669     Returns:    -
06670     Purpose:    called from DialogBarOp message handler when Esc is pressed
06671                 will end any bar type drag
06672     Errors:     -
06673     SeeAlso:    -
06674 
06675 ********************************************************************************************/
06676 BOOL BaseBar::CancelAllDrags()
06677 {
06678     //TRACEUSER( "chris", _T("Esc state %d\n"),state);
06679     if(CurrentBar == NULL)
06680         return FALSE;
06681     if(CtlDragState==DRAGGING)
06682     {   
06683         CurrentBar->PaintDragRect(CurrentBar->OldDragRect,wxRect(0,0,0,0),DOCKBAR_FLOAT,DOCKBAR_FLOAT);
06684         CurrentBar->TidyUpControlDrag();
06685     }
06686     else if(DragType != NONE)
06687     {
06688         CurrentBar->FormatLineFeeds(CurrentBar->DragStartRect.GetWidth());
06689         CurrentBar->InitFormatRects();
06690         CurrentBar->TidyUpBarDrag();
06691     }
06692 
06693     CtlDragState = NO_DRAG;
06694     DragType = NONE;
06695     return FALSE;
06696 }
06697 
06698 /********************************************************************************************
06699 
06700 >   static void BaseBar::EscPressed(BOOL state)
06701 
06702     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06703     Created:    22/11/94
06704     Inputs:     Esc State
06705     Outputs:    -
06706     Returns:    -
06707     Purpose:    called from DialogBarOp message handler when Esc is pressed
06708                 will end any bar type drag
06709     Errors:     -
06710     SeeAlso:    -
06711 
06712 ********************************************************************************************/
06713 BOOL BaseBar::EscPressed(BOOL state)
06714 {
06715     //TRACEUSER( "chris", _T("Esc state %d\n"),state);
06716     if(CurrentBar == NULL)
06717         return FALSE;
06718     if(CtlDragState==DRAGGING)
06719     {   
06720 
06721         CurrentBar->PaintDragRect(CurrentBar->OldDragRect,wxRect(0,0,0,0),DOCKBAR_FLOAT,DOCKBAR_FLOAT);
06722         CurrentBar->TidyUpControlDrag();
06723     
06724         return TRUE;
06725     }
06726     else if(DragType != NONE)
06727     {
06728         CurrentBar->FormatLineFeeds(CurrentBar->DragStartRect.GetWidth());
06729         CurrentBar->InitFormatRects();
06730         CurrentBar->TidyUpBarDrag();
06731         return TRUE;
06732     }
06733     return FALSE;
06734 }
06735 
06736  
06737 /********************************************************************************************
06738 
06739 >   static void BaseBar::CtlPressed(BOOL state)
06740 
06741     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06742     Created:    22/11/94
06743     Inputs:     Clt State
06744     Outputs:    -
06745     Returns:    -
06746     Purpose:    called from DialogBarOp message handler when Clt is pressed
06747                 toggles between cut and copy drag control modes
06748     Errors:     -
06749     SeeAlso:    -
06750 
06751 ********************************************************************************************/
06752 BOOL BaseBar::CtlPressed(BOOL state)
06753 {
06754     //TRACEUSER( "chris", _T("Ctl state %d\n"),state);
06755     
06756     if(CtlDragState == NO_DRAG)
06757         return FALSE;
06758     if(state)
06759     {
06760         if(CtlDragMode==CUT)
06761         {
06762             // check we have a cursor to swap !
06763             if(pCurrentCursor)
06764                 SwapCursors( _R(IDC_BUTTONDRAGCOPY) );
06765             CtlDragMode=COPY;
06766         }
06767     }
06768     else
06769     {
06770         if(CtlDragMode==COPY)
06771         {
06772             if(pCurrentCursor)
06773                 SwapCursors( _R(IDC_BUTTONDRAGCUT) );
06774             CtlDragMode=CUT;
06775         }
06776     }
06777     return FALSE;
06778  }
06779 
06780  
06781 
06782 /********************************************************************************************
06783 
06784 >   BOOL BaseBar::HasOrientationChanged(DockBarType Old,DockBarType New);
06785                                                
06786     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06787     Created:    24/5/94
06788     Inputs:     Old Dock
06789                 New Dock
06790     Outputs:    -
06791     Returns:    -
06792     Purpose:    determine whether two docks have different orientation.
06793     Errors:     -
06794     SeeAlso:    -
06795 
06796 ********************************************************************************************/
06797 
06798 BOOL BaseBar::HasOrientationChanged(DockBarType Old,DockBarType New)
06799 {
06800     if(Old == New)
06801         return FALSE ;
06802     if(  (Old== DOCKBAR_RIGHT ||Old == DOCKBAR_LEFT) &&
06803          (New== DOCKBAR_RIGHT ||New == DOCKBAR_LEFT))
06804         return FALSE;
06805     if(  (Old== DOCKBAR_TOP ||Old == DOCKBAR_BOTTOM||Old == DOCKBAR_FLOAT) &&
06806          (New== DOCKBAR_TOP ||New == DOCKBAR_BOTTOM||New == DOCKBAR_FLOAT))
06807         return FALSE;       
06808     return TRUE;
06809 }
06810 
06811 /********************************************************************************************
06812 
06813 >   BOOL BaseBar::TidyUpControlDrag()
06814 
06815     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06816     Created:    16/11/94
06817     Inputs:     -
06818     Outputs:    -
06819     Returns:    -
06820     Purpose:    called to tidy up at the end of a control drag 
06821     Errors:     -
06822     
06823     SeeAlso:    -
06824 
06825 ********************************************************************************************/
06826 BOOL BaseBar::TidyUpControlDrag()
06827 {
06828 #pragma message( __LOCMSG__ "BaseBar::TidyUpControlDrag - do nothing" )
06829     TRACE( _T("Warning - BaseBar::TidyUpControlDrag called") );
06830 /*  CtlDragState = NO_DRAG;
06831     DragManagerOp::SetDragActive(FALSE);
06832 
06833     // if alt is still held down we should be ready to drag
06834     if(KeyPress::IsAlternativePressed())
06835         CtlDragState = READY;
06836     
06837     OldDragRect.SetRectEmpty();
06838     // release mouse
06839     ReleaseCapture();               
06840 
06841     InRecreate = FALSE;
06842 
06843     GetMainFrame()->SetActiveWindow();
06844 
06845     CurrentBar = NULL; 
06846     
06847     ERROR2IF(pCurrentCursor==NULL,FALSE,"Null last Cursor in TidyUpControlDrag");       
06848     
06849     if(pCurrentCursor!= NULL)
06850     {
06851         CursorStack::GPop(CurrentCursorID);
06852         delete pCurrentCursor;
06853         pCurrentCursor = NULL;
06854         CurrentCursorID = 0;
06855     } */
06856 
06857     return TRUE;
06858 }
06859 
06860 /********************************************************************************************
06861 
06862 >   BOOL BaseBar::TidyUpBarDrag()
06863 
06864     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06865     Created:    16/11/94
06866     Inputs:     -
06867     Outputs:    -
06868     Returns:    -
06869     Purpose:    called to tidy up at the end of a Bar drag 
06870     Errors:     -
06871     SeeAlso:    -
06872 
06873 ********************************************************************************************/
06874 BOOL BaseBar::TidyUpBarDrag()
06875 {
06876     PaintDragRect(OldDragRect,wxRect(0,0,0,0),OldDragBarType,DOCKBAR_FLOAT);
06877     InRecreate = TRUE;
06878     ReleaseMouse();
06879     DragType = NONE;
06880     InRecreate = FALSE;
06881     CurrentBar = NULL;
06882 
06883 #pragma message( __LOCMSG__ "Remove DragManagerOp::SetDragActive usage" )
06884 //  DragManagerOp::SetDragActive(FALSE); 
06885     return TRUE;
06886 }
06887 
06888 /********************************************************************************************
06889 
06890 >   BOOL BaseBar::DropControl(wxPoint point,HWND OverBar, BOOL InsertSep)
06891 
06892     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06893     Created:    16/11/94
06894     Inputs:     point Client coord at drop point
06895                 OverBar HWND of bar pointer is over
06896                 InsertSep Flags whether this control has an attached Separator
06897     Outputs:    -
06898     Returns:    BOOL - TRUE if we should delete the leading separator
06899     Purpose:    Drops a dragged control onto a given Window
06900     Errors:     -
06901     SeeAlso:    -
06902 
06903 ********************************************************************************************/
06904 BOOL BaseBar::DropControl(wxPoint point, wxWindow* OverBar,BOOL InsertSeparator)
06905 {
06906 #pragma message( __LOCMSG__ "BaseBar::DropControl - do nothing" )
06907     TRACE( _T("Warning - BaseBar::DropControl called") );
06908 /*  BOOL DeleteSeparator = FALSE;
06909 
06910     // get a wxWindow from this HWND
06911     BaseBar * DropBar = (BaseBar*)FromHandlePermanent(OverBar);
06912     DialogBarOp * DropOp;
06913     
06914     //Get the DialogOp for this HWND
06915     DropOp = DialogBarOp::FindDialogBarOp((UINT32)OverBar );
06916     if(DropOp)
06917     {
06918         // make a copy of the control we are dragging 
06919         BarControl * foundControl = (BarControl*)pOp->GetBarItem(DragCtlHwnd);
06920         BarControl * newControl = new BarControl(*foundControl);
06921         UINT32 NewID;
06922         
06923         ERROR2IF(foundControl == NULL,FALSE,"Can't find Bar Item");
06924         ERROR2IF(newControl == NULL,FALSE,"Can't create new Bar Control");
06925         
06926         // check orientation of the bar we are dropping on
06927         BOOL Horizontal = DropOp->IsHorizontal();
06928         
06929         // give the control a unique id in this bar
06930         newControl->SetUniqueGadgetID(NewID=DropOp->GetUniqueID());
06931 
06932         INT32 ControlIndex;
06933         wxPoint ClientPos = point;
06934         DropBar->ScreenToClient(&ClientPos);
06935         
06936         // find position for new control in bar
06937         ControlIndex = DropBar->GetNearestControl(ClientPos);
06938         
06939         // ****************************************************
06940         // Insertion / Deletion  of Separators
06941         
06942         //have we dropped this control back onto itself ?
06943         // if so should we 
06944             //  a) insert a new separator 
06945             //  b) delete an existing one
06946 
06947         
06948         // get the window rect of the control we are dragging
06949         // and convert to Client coords 
06950         wxRect DragWnd;
06951         ::GetWindowRect(DragCtlHwnd,&DragWnd);              
06952         ScreenToClient(&DragWnd);       
06953         
06954         // check the last item
06955         BarItem* pLastItem = NULL ;
06956         if((ControlIndex-1)>=0)
06957             pLastItem = DropOp->GetPtrBarItem(ControlIndex-1);
06958         
06959         // if the last item is a separator allow us to drop onto it 
06960         // by growing the hittest rectangle
06961         if(pLastItem)
06962         {
06963             if(pLastItem->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)))
06964             {
06965                 DragWnd.GetTop()  -= SeparatorWidth;
06966                 DragWnd.GetLeft() -= SeparatorWidth; 
06967             }               
06968         }
06969 
06970         // is the mouse over the dragged control or it's preceeding separator
06971         if(DragWnd.PtInRect(ClientPos))
06972         {
06973 
06974             wxPoint StartDrag(DragCtlOffset);
06975             ::ClientToScreen(DragCtlHwnd,&StartDrag);
06976             ScreenToClient(&StartDrag);
06977 
06978             INT32 CheckPos = ClientPos.x;
06979             INT32 StartPos = StartDrag.x;
06980 
06981             // if the control is at the fromt of a slot we want to use y movement
06982             // to determine insertion or deletion
06983             // this is the case if the prev item is a LF or the bar is vertical
06984             // or if the prev item is a SP and it's prev is a LF (!)
06985             if(pLastItem)
06986             {
06987                 if(pLastItem->IsKindOf(CC_RUNTIME_CLASS(BarLineFeed))|| !Horizontal)
06988                 {
06989                     CheckPos = ClientPos.y;
06990                     StartPos = StartDrag.y;
06991                 }
06992                 
06993                 if(pLastItem->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)))
06994                 {
06995                     BarItem* pPrevLastItem = NULL ;
06996                     if((ControlIndex -2)>=0)
06997                         pPrevLastItem = DropOp->GetPtrBarItem(ControlIndex-2);
06998                     if(pPrevLastItem)
06999                     {
07000                         if(pPrevLastItem->IsKindOf(CC_RUNTIME_CLASS(BarLineFeed))||!Horizontal)
07001                         {
07002                             CheckPos = ClientPos.y;
07003                             StartPos = StartDrag.y;
07004                         }
07005                     }
07006                     
07007                 //  StartPos -= SeparatorWidth;
07008                 }
07009             }
07010 
07011             // which way have we moved ?
07012             if(CheckPos>StartPos)
07013                 InsertSeparator = TRUE;
07014             else
07015                 DeleteSeparator = TRUE;
07016         }
07017         
07018         
07019         if(InsertSeparator && ControlIndex>0)     // don't insert a separator at the head of the bar
07020         {
07021             
07022         //  BarItem* LastItem = NULL ;
07023         //  LastItem = DropOp->GetPtrBarItem(ControlIndex-1);
07024             if(pLastItem!=NULL)
07025             {
07026                 if(!pLastItem->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)))
07027                 {
07028                     BarSeparator* newSep=NULL;
07029                     newSep = new BarSeparator;
07030                     if(newSep)
07031                     {
07032                         DropOp->InsertItemAfter(ControlIndex-1,newSep);
07033                 
07034                         //TRACEUSER( "chris", _T("Just added a separator at %d\n"),ControlNumber-1);
07035                         ControlIndex ++;  
07036                     }
07037                 }
07038             }
07039         }
07040         
07041         // insert the item
07042         DropOp->InsertItemAfter(ControlIndex-1,(BarItem *)newControl);  
07043 
07044         // create the windows control
07045         DropBar->CreateControlFromResource(newControl);
07046 
07047         // send a create message to allow the control to init itself
07048         OpDescControlCreateMsg op(newControl->GetOpDescriptor(Horizontal), 
07049                                     newControl->GetBarControlInfo(Horizontal).ControlID, 
07050                                     NewID,
07051                                     DropOp); 
07052         
07053         newControl->GetOpDescriptor(Horizontal)->Message(&op);
07054         if(pOp!=DropOp)
07055         {
07056             // format and size the bar we have dropped on
07057             switch(DropBar->GetDockBarType())
07058             {
07059             case DOCKBAR_FLOAT:
07060             {
07061                 DropBar->FormatFloatingBar(TRUE,USE_BAR);
07062             }
07063             break;
07064             case DOCKBAR_LEFT:
07065             case DOCKBAR_RIGHT:
07066                 DropBar->FormatVerticalBar(TRUE,USE_BAR);
07067                 break;
07068             case DOCKBAR_TOP:
07069             case DOCKBAR_BOTTOM:
07070                 DropBar->FormatHorizontalBar(TRUE,USE_BAR);
07071                 break;
07072             } 
07073             DropBar->SetBarSize(DropBar->GetDockBarType());
07074             DropBar->InvalidateRect(NULL,TRUE);
07075         }
07076     }   
07077     return DeleteSeparator; */
07078 
07079     return false;
07080 }
07081 
07082 /********************************************************************************************
07083 
07084 >   BOOL BaseBar::EndControlDrag(wxPoint point)
07085 
07086     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
07087     Created:    16/11/94
07088     Inputs:     point Client coordinate at end of drag
07089     Outputs:    -
07090     Returns:    TRUE if the bar has been deleted FALSE otherwise
07091     Purpose:    called at the end of a control drag 
07092                 decides where to drop the dragged control... does it and tidies up the drag.
07093     Errors:     -
07094     SeeAlso:    -
07095 
07096 ********************************************************************************************/
07097 BOOL BaseBar::EndControlDrag(wxPoint point)
07098 {
07099 #pragma message( __LOCMSG__ "BaseBar::EndControlDrag - do nothing" )
07100     TRACE( _T("Warning - BaseBar::EndControlDrag called") );
07101 /*  // go to screen co-ords - we may be dropping on a different bar
07102     wxPoint sPnt= point;
07103     ClientToScreen(&sPnt);
07104     BOOL MovingSeparator = FALSE;
07105     BOOL DeleteLineFeed = FALSE;
07106     
07107     BaseBar * DropBar=NULL;
07108 
07109     // check if the drag has finished over an existing bar
07110     HWND OverBar = GetMainFrame()->IsScreenPointInBar(sPnt);
07111 
07112     PaintDragRect(OldDragRect,wxRect(0,0,0,0),DOCKBAR_FLOAT,DOCKBAR_FLOAT);
07113     
07114     CtlDragState = NO_DRAG;
07115     if(OverBar)
07116     {
07117         DropBar = (BaseBar*)FromHandlePermanent(OverBar);
07118         
07119         // can't drop into an info bar
07120         // but as the user might think we can... we'll just cancel 
07121         // the drag
07122         if(DropBar->IsInfoBar())
07123         {
07124             TidyUpControlDrag();
07125             // we haven't deleted the bar so return FALSE
07126             return FALSE;
07127         }
07128         
07129         // can't drop on the control bank
07130         if(DropBar->IsBarAllCtlBar())
07131             OverBar = NULL ;
07132         
07133         // we don't want to copy a control onto the same bar !
07134         if(DropBar==this && CtlDragMode == COPY)
07135         {
07136             TidyUpControlDrag();
07137             // we haven't deleted the bar so return FALSE
07138             return FALSE;
07139         }
07140     }
07141     
07142     ERROR2IF(pOp==NULL,FALSE,"Null BarOp");
07143 
07144 
07145     BarItem * LastItem = NULL;
07146     BarItem * thisItem = pOp->GetBarItem((CWindowID)DragCtlHwnd);
07147         
07148      
07149     // Check if the control has an preceeding separator 
07150     LastItem = pOp->GetPtrBarPrev(thisItem);
07151     if ( LastItem )
07152         if ( LastItem->IsKindOf( CC_RUNTIME_CLASS(BarSeparator)))
07153             MovingSeparator = TRUE;
07154     
07155 
07156     // drop the control into the bar
07157     BOOL DeleteSeparator = FALSE;
07158     BOOL DoTidyOverlap=FALSE;
07159     
07160     if (OverBar)
07161         DeleteSeparator = DropControl(sPnt,OverBar,FALSE ); //MovingSeparator);
07162 
07163     // check for cut mode
07164     if (( CtlDragMode == CUT || DeleteSeparator == TRUE ) && !pOp->IsAllBarsOp() )
07165     {
07166         // delete the separator
07167         if (MovingSeparator && DeleteSeparator)
07168         {
07169             delete pOp->RemoveBarItem(LastItem);
07170         }
07171         
07172         // delete the item from the kernel list
07173         pOp->DeleteBarItem((CWindowID)DragCtlHwnd);
07174         
07175         // and destroy the window
07176         ::DestroyWindow(DragCtlHwnd);
07177         
07178         // inform subclassing
07179         ControlHelper::NotifyControlDeleted(DragCtlHwnd);
07180         
07181         // remove leading, trailing and multiple linefeeds
07182         TidyBarItemsAfterDrag(); 
07183 
07184 
07185     
07186         // no controls left on the bar so delete it
07187         if(pOp->IsListEmpty())
07188         {
07189             TidyUpControlDrag();
07190             
07191             BROADCAST_TO_CLASS(DialogMsg(GetSafeHwnd(), DIM_CANCEL, NULL), DialogOp); 
07192             
07193             return TRUE;
07194         }
07195         // else reformat and invalidate
07196         else 
07197         {
07198             switch(GetDockBarType())
07199             {
07200                 case DOCKBAR_FLOAT:
07201                     FormatFloatingBar(TRUE,USE_BAR);
07202                     break;
07203                 case DOCKBAR_LEFT:
07204                 case DOCKBAR_RIGHT:
07205                     DoTidyOverlap=TRUE;
07206                     FormatVerticalBar(TRUE,USE_BAR);
07207                     break;
07208                 case DOCKBAR_TOP:
07209                 case DOCKBAR_BOTTOM:
07210                     DoTidyOverlap=TRUE;
07211                     FormatHorizontalBar(TRUE,USE_BAR);
07212                     break;
07213             } 
07214             SetBarSize(GetDockBarType());
07215             InvalidateRect(NULL,TRUE);
07216         }
07217     }
07218     if(DropBar) 
07219     {
07220         OILDockingBar * ThisDock = GetMainFrame()->GetDockBar(DropBar->GetDockBarType() );
07221         switch(DropBar->GetDockBarType())
07222         {
07223             case DOCKBAR_LEFT:
07224             case DOCKBAR_RIGHT:
07225             case DOCKBAR_TOP:
07226             case DOCKBAR_BOTTOM:
07227                 ((OILFixedDockingBar*)ThisDock)->CheckAndCorrectOverlap();
07228                 break;
07229         } 
07230     }
07231     // tidy up and out of here  
07232     TidyUpControlDrag(); */
07233     return FALSE;
07234 }
07235 
07236 
07237 
07238 /********************************************************************************************
07239 
07240 >   void BaseBar::OnLButtonUp(UINT32 nFlags, wxPoint point)
07241 
07242     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
07243     Created:    5/4/94
07244     Inputs:     -
07245     Outputs:    -
07246     Returns:    -
07247     Purpose:    
07248     Errors:     -
07249     SeeAlso:    -
07250 
07251 ********************************************************************************************/
07252 #pragma message( __LOCMSG__ "BaseBar::OnLButtonUp removed" )
07253 /*void BaseBar::OnLButtonUp(UINT32 nFlags, wxPoint point)
07254 {
07255     if(CtlDragState == DRAGGING)
07256     {
07257         if(EndControlDrag(point))
07258             return;         // this bar has been deleted we must not call the base handler
07259     }
07260     // We never started the drag - just tidy up
07261     else if (DragType == TRYING)        
07262     {
07263         OldDragBarType = ParentDockBarType;
07264         TidyUpBarDrag();
07265     }
07266     else if (DragType != NONE )
07267     {
07268         
07269         DragManagerOp::SetDragActive(FALSE);
07270         
07271         InRecreate = TRUE;
07272         // End of a drag
07273         PaintDragRect(OldDragRect,wxRect(0,0,0,0),OldDragBarType,OldDragBarType);
07274     
07275         
07276         // Release the mouse 
07277         ReleaseCapture();
07278 
07279     
07280         // Remove this BaseBar from its current docking bar 
07281         GetMainFrame()->GetDockBar(ParentDockBarType)->ReleaseBar(this->GetSafeHwnd(),DONT_TIDY); 
07282 
07283         // If Bar has changed parent Docking Bar
07284         if ( ParentDockBarType != DragDockBarType )
07285         {   
07286             //Check whether we have moved between docks with different control sizes
07287             //if we have Recreate() will have to get controls from resources
07288             OILDockingBar * NewDock ;
07289             OILDockingBar * OldDock ;
07290             BOOL CanCopy;
07291 
07292             NewDock = GetMainFrame()->GetDockBar(DragDockBarType);
07293             OldDock = GetMainFrame()->GetDockBar(ParentDockBarType);
07294             CanCopy = NewDock->IsBigControls() == OldDock->IsBigControls();     
07295             if(HasOrientationChanged(ParentDockBarType,DragDockBarType))
07296                 CanCopy = FALSE;
07297             // dynamically create a new BaseBar/derived Bar
07298             BaseBar* NewBaseBar = (BaseBar *)GetRuntimeClass()->CreateObject(); 
07299             
07300             // Recreate the Dialog
07301             NewBaseBar->Recreate(DragDockBarType, this, pOp,CanCopy); 
07302         
07303             // The current BaseBar dies
07304             CCamApp::GetDlgManager()->Delete(GetSafeHwnd(),pOp);  
07305             //delete this;
07306         }
07307         else
07308         // just format and move the bar
07309         {
07310             
07311             ParentDockBarType = DragDockBarType;// Record the current dock bar
07312 
07313             // We are no longer dragging
07314             DragType = NONE; 
07315         
07316             // Reposition the controls and redraw the bar
07317             PositionControls(TRUE);
07318 
07319             wxRect TempRect = GetFormatRect(ParentDockBarType);
07320 
07321             // Attach the BaseBar to the docking bar and position the window 
07322             GetMainFrame()->GetDockBar(ParentDockBarType)->PlaceBar(GetSafeHwnd(),
07323                                          wxPoint(OldDragRect.GetLeft(), OldDragRect.GetTop()), wxSize(TempRect.GetRight(), TempRect.GetBottom()));
07324 
07325             // CGS (23/1/2001)
07326             // the following code allows camelot to remember where galleries were
07327             // dragged to, the next time camelot starts.
07328             // NOTE:  I'm only doing this for SuperGallery's ....
07329 
07330             if (pOp)
07331             {
07332                 if (pOp->IsKindOf (CC_RUNTIME_CLASS (SuperGallery)))
07333                 {
07334                     SuperGallery* pGallery = (SuperGallery*) pOp;
07335                     pOp->SetFloatingwxPoint (wxPoint (OldDragRect.GetLeft(), OldDragRect.GetTop()));
07336                 }
07337             }
07338         }
07339         InRecreate = FALSE;
07340         CurrentBar = NULL;
07341         return; 
07342     }
07343 
07344     wxWindow::OnLButtonUp(nFlags, point);
07345     
07346 } */
07347 
07348 
07349 /********************************************************************************************
07350 
07351 >   void BaseBar::ConvertToolbarOnStartup ()
07352 
07353     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
07354     Created:    23/5/2000
07355     Inputs:     -
07356     Outputs:    -
07357     Returns:    -
07358     Purpose:    Converts the toolbar from being docked to being floating.
07359     Errors:     An ERROR3 goes off in debug if this function is called for anything BUT
07360                 the toolbar.
07361     SeeAlso:    -
07362 
07363 ********************************************************************************************/
07364 
07365 void BaseBar::ConvertToolbarOnStartup ()
07366 {
07367 #pragma message( __LOCMSG__ "BaseBar::ConvertToolbarOnStartup - do nothing" )
07368     TRACE( _T("Warning - BaseBar::ConvertToolbarOnStartup called") );
07369 /*  ERROR3IF (pOp->GetName () != String_32 (TEXT ("Toolbar")), "BaseBar::ConvertToolbarOnStartup () - Call that a toolbar!");
07370     
07371     InRecreate = TRUE;
07372 
07373     // Remove this BaseBar from its current docking bar 
07374     GetMainFrame()->GetDockBar(ParentDockBarType)->ReleaseBar(this->GetSafeHwnd(),DONT_TIDY); 
07375     
07376     // dynamically create a new BaseBar/derived Bar
07377     BaseBar* NewBaseBar = (BaseBar *)GetClassInfo()->CreateObject();
07378 
07379     if (NewBaseBar)
07380     {       
07381         // Recreate the Dialog
07382         NewBaseBar->Recreate(DOCKBAR_FLOAT, this, pOp, FALSE);
07383         NewBaseBar->GetDialogBarOp ()->SetDockBarType (DOCKBAR_FLOAT);
07384             
07385         // The current BaseBar dies
07386         CCamApp::GetDlgManager()->Delete(GetSafeHwnd(),pOp);  
07387         //delete this;
07388 
07389         InRecreate = FALSE;
07390         CurrentBar = NULL;
07391         
07392         PtrToToolBar = NewBaseBar;
07393     } */
07394 }
07395 
07396 
07397 
07398 /********************************************************************************************
07399 
07400 >   void BaseBar::MoveBar(WPARAM Dock, LPARAM Pos)
07401 
07402     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
07403     Created:    24/10/94
07404     Inputs:     Dock - DockBarType
07405                 Pos  - KernelBarPos
07406     Outputs:    -
07407     Returns:    -
07408     Purpose:    allows bars to be move between docks on a WM_MOVEBAR message
07409     Errors:     -
07410     SeeAlso:    -
07411 
07412 ********************************************************************************************/
07413 
07414 #pragma message( __LOCMSG__ "BaseBar::MoveBar removed" )
07415 /*LRESULT BaseBar::MoveBar(WPARAM Dock, LPARAM Pos)
07416 {   
07417     DockBarType NewDockType = (DockBarType)Dock;
07418     KernelBarPos  NewPos;
07419     NewPos.Slot   =((KernelBarPos * )Pos)->Slot; 
07420     NewPos.Position =((KernelBarPos * )Pos)->Position; 
07421     OILDockingBar * NewDock ;
07422     OILDockingBar * OldDock ;
07423     BOOL CanCopy;
07424     wxPoint DropPoint;
07425 
07426     // get a pointer to the new dock
07427     NewDock = GetMainFrame()->GetDockBar(NewDockType);
07428 
07429     // get a screen coord for the new position
07430     if(NewDockType!= DOCKBAR_FLOAT)
07431     {
07432         ((OILFixedDockingBar * )NewDock)->BarPosToClient( NewPos,&DropPoint);
07433         ((OILFixedDockingBar * )NewDock)->ClientToScreen(&DropPoint);
07434     }
07435     else
07436     {
07437         DropPoint.x = NewPos.Slot;
07438         DropPoint.y = NewPos.Position;
07439     }
07440 
07441 
07442     // this will be used in recreate to position the bar
07443     OldDragRect.GetLeft() = DropPoint.x;
07444     OldDragRect.GetTop() = DropPoint.y;
07445 
07446     // if the new dock has different sized controls
07447     // we won't be able to copy the bar in Recreate
07448     OldDock = GetMainFrame()->GetDockBar(ParentDockBarType);
07449     CanCopy = NewDock->IsBigControls() == OldDock->IsBigControls();     
07450     if(HasOrientationChanged(ParentDockBarType,DragDockBarType))
07451         CanCopy = FALSE;
07452     
07453     // dynamically create a new BaseBar/derived Bar
07454     BaseBar* NewBaseBar = (BaseBar *)GetRuntimeClass()->CreateObject(); 
07455 
07456     // Recreate the Dialog
07457     NewBaseBar->Recreate(NewDockType, this, pOp,CanCopy); 
07458 
07459     // The current BaseBar dies
07460     CCamApp::GetDlgManager()->Delete(GetSafeHwnd(),pOp);  
07461     return TRUE;
07462 } */
07463 
07464 
07465 /********************************************************************************************
07466 
07467 >   void BaseBar::OnMouseMove(UINT32 Flags, wxPoint Point)
07468      
07469     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
07470     Created:    5/4/94        
07471     Inputs:     -
07472     Outputs:    -
07473     Returns:    -
07474     Purpose:    
07475     Errors:     -
07476     SeeAlso:    -
07477 
07478 ********************************************************************************************/
07479 #pragma message( __LOCMSG__ "BaseBar::OnMouseMove removed" )
07480 /*void BaseBar::OnMouseMove(UINT32 Flags, wxPoint Point)
07481 {
07482     if(CtlDragState == DRAGGING)
07483     {
07484     
07485         // mouse to screen
07486         ClientToScreen(&Point);
07487 
07488         // control client window size
07489         wxRect ScreenRect= DragCtlClientRect;
07490         
07491         // offset by mouse pos
07492         ScreenRect.OffsetRect(Point);
07493         
07494         // account for initial offset in control
07495         ScreenRect.OffsetRect(-DragCtlOffset.x,-DragCtlOffset.y);
07496         
07497         
07498         PaintDragRect(ScreenRect,OldDragRect,DOCKBAR_FLOAT,DOCKBAR_FLOAT);
07499     
07500         // keep copy
07501         OldDragRect = ScreenRect;
07502     }
07503     // Route MouseMove back to disabled controls to allow status bar help
07504     else if (DragType == NONE)
07505     {
07506         wxWindow * OverWindow;
07507         OverWindow = ChildWindowFromPoint(Point);
07508         if (OverWindow != this && OverWindow != NULL)
07509         {
07510             ClientToScreen(&Point);
07511             ::ScreenToClient(OverWindow->GetSafeHwnd(),&Point);
07512             ::SendMessage(OverWindow->GetSafeHwnd(),WM_MOUSEMOVE,(WPARAM)Flags,
07513                                 MAKELPARAM((short)Point.y,(short)Point.x));
07514         }
07515     }
07516 } */
07517 
07518 /********************************************************************************************
07519 
07520 >   void BaseBar::CacheAllDockRects()
07521 
07522     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
07523     Created:    19/5/94
07524     Inputs:     -
07525     Outputs:    -
07526     Returns:    -
07527     Purpose:    Sets all check rectangles for drop hit testing at start of drag
07528     Errors:     -
07529     SeeAlso:    -
07530 
07531 ********************************************************************************************/
07532 
07533 void BaseBar::CacheAllDockRects()
07534 {
07535 #pragma message( __LOCMSG__ "BaseBar::CacheAllDockRects - do nothing" )
07536     TRACE( _T("Warning - BaseBar::CacheAllDockRects called") );
07537 /*  OILFixedDockingBar* DockBar;
07538 
07539     DockBar = (OILFixedDockingBar*)GetMainFrame()->GetDockBar(DOCKBAR_TOP);
07540     DockBar->GetDockScreenRect(&TopRect);
07541 
07542     DockBar = (OILFixedDockingBar*)GetMainFrame()->GetDockBar(DOCKBAR_BOTTOM);
07543     DockBar->GetDockScreenRect(&BottomRect);
07544 
07545     DockBar = (OILFixedDockingBar*)GetMainFrame()->GetDockBar(DOCKBAR_LEFT);
07546     DockBar->GetDockScreenRect(&LeftRect);
07547 
07548     DockBar = (OILFixedDockingBar*)GetMainFrame()->GetDockBar(DOCKBAR_RIGHT);
07549     DockBar->GetDockScreenRect(&RightRect); */
07550 }
07551 
07552 /********************************************************************************************
07553 
07554 >   DockBarType BaseBar::BarCloseToDock(wxPoint CursorPos)
07555 
07556     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
07557     Created:    19/5/94
07558     Inputs:     CursorPos:  The position of the mouse cursor on screen
07559     Outputs:    -
07560     Returns:    -
07561     Purpose:    Tests whether the cursor and its surrounding bar shape rectangle is close
07562                 enough to a docking bar that the bar will stick onto that dock.
07563                 NOTE! This function has the side effect that it adjusts the DragOffset
07564                 before returning TRUE.
07565                 NOTE ALSO! This routine uses SimpleIntersect instead of wxRect::Intersect
07566                 because SimpleIntersect works how I want it to (I wrote it).
07567     Errors:     -
07568     Scope:      private
07569     SeeAlso:    -
07570 
07571 ********************************************************************************************/
07572 
07573 DockBarType BaseBar::BarCloseToDock(wxPoint CursorPos)
07574 {
07575     wxRect Blobby;
07576     
07577     // if the user is holding down the Constrain key ( Clt ) we will not allow docking
07578     
07579     if(KeyPress::IsConstrainPressed())
07580         return DOCKBAR_INVALID;
07581     
07582     if(pOp->IsAllBarsOp())
07583         return DOCKBAR_INVALID; 
07584     
07585     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
07586     // This Block is an attempt to fix a problem with the general drag algorithm
07587     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
07588 
07589     if (DragDockBarType == DOCKBAR_FLOAT)
07590     {
07591         BOOL  FromLeft = CursorPos.x > LeftRect.GetLeft() ;
07592         BOOL  FromTop = CursorPos.y > TopRect.GetTop() ;
07593 
07594         if (!pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
07595         {
07596             Blobby = GetDragFormatRect(DOCKBAR_TOP, CursorPos,FromLeft, FromTop);
07597             if (SimpleIntersect(Blobby,TopRect))
07598             {
07599                 return(DOCKBAR_TOP);
07600             }                                                              
07601 
07602             // Test whether a horizontal shape bar would touch the bottom dock
07603             Blobby = GetDragFormatRect(DOCKBAR_BOTTOM, CursorPos,FromLeft,FromTop);
07604             if (SimpleIntersect(Blobby,BottomRect))
07605             {
07606                 return(DOCKBAR_BOTTOM);
07607             }
07608         }
07609 
07610         // Don't allow infobars to be dropped on the vertical docking bars...
07611         if (!ThisIsAnInfoBar)
07612         {
07613             // Test whether a vertical shape bar would touch the left dock
07614             Blobby = GetDragFormatRect(DOCKBAR_LEFT, CursorPos,FromLeft,FromTop);
07615             if (SimpleIntersect(Blobby,LeftRect))
07616             {
07617                 return(DOCKBAR_LEFT);
07618             }
07619 
07620             // Test whether a vertical shape bar would touch the right dock
07621             Blobby = GetDragFormatRect(DOCKBAR_RIGHT, CursorPos,FromLeft,FromTop);
07622             if (SimpleIntersect(Blobby,RightRect))
07623             {
07624                 return(DOCKBAR_RIGHT);
07625             }
07626         }
07627 
07628     }
07629     else
07630     {
07631         if (!pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
07632         {
07633             // Test whether a horizontal shape bar would touch the top dock
07634             Blobby = GetDragFormatRect(DOCKBAR_TOP, CursorPos, DragOffsetFromLeft, CursorPos.y > TopRect.GetBottom());
07635             if (SimpleIntersect(Blobby,TopRect))
07636             {
07637                 return(DOCKBAR_TOP);
07638             }                                                              
07639 
07640             // Test whether a horizontal shape bar would touch the bottom dock
07641             Blobby = GetDragFormatRect(DOCKBAR_BOTTOM, CursorPos, DragOffsetFromLeft, CursorPos.y > BottomRect.GetTop());
07642             if (SimpleIntersect(Blobby,BottomRect))
07643             {
07644                 return(DOCKBAR_BOTTOM);
07645             }
07646         }
07647 
07648         // Don't allow infobars to be dropped on the vertical docking bars...
07649         if (!ThisIsAnInfoBar)
07650         {
07651             // Test whether a vertical shape bar would touch the left dock
07652             Blobby = GetDragFormatRect(DOCKBAR_LEFT, CursorPos, CursorPos.x > LeftRect.GetRight(), DragOffsetFromTop);
07653             if (SimpleIntersect(Blobby,LeftRect))
07654             {
07655                 return(DOCKBAR_LEFT);
07656             }
07657 
07658             // Test whether a vertical shape bar would touch the right dock
07659             Blobby = GetDragFormatRect(DOCKBAR_RIGHT, CursorPos, CursorPos.x > RightRect.GetLeft(), DragOffsetFromTop);
07660             if (SimpleIntersect(Blobby,RightRect))
07661             {
07662                 return(DOCKBAR_RIGHT);
07663             }
07664         }
07665     } 
07666     return(DOCKBAR_INVALID);
07667 }
07668 
07669 
07670 
07671 
07672 /********************************************************************************************
07673 
07674 >   void BaseBar::CalcDragOffsetDirection(DockBarType BarType, wxPoint CursorPos)
07675 
07676     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
07677     Created:    19/5/94
07678     Inputs:     BarType:    Which type of bar we are dealing with
07679                 CursorPos:  The position of the mouse cursor on screen
07680     Outputs:    -
07681     Returns:    -
07682     Purpose:    Resets the two drag offset flags which record which edges of the dragged
07683                 outline should not move when the bar outline changes shape.
07684     Errors:     -
07685     Scope:      private
07686     SeeAlso:    -
07687 
07688 ********************************************************************************************/
07689 
07690 void BaseBar::CalcDragOffsetDirection(DockBarType BarType, wxPoint CursorPos)
07691 {
07692     wxRect Blobby;
07693 
07694     switch (BarType)
07695     {
07696         case DOCKBAR_TOP:
07697             DragOffsetFromTop = CursorPos.y > TopRect.GetBottom();
07698 //          DragOffsetFromLeft = TRUE;
07699             break;
07700         case DOCKBAR_BOTTOM:
07701             DragOffsetFromTop = CursorPos.y > BottomRect.GetTop();
07702 //          DragOffsetFromLeft = TRUE;
07703             break;
07704         case DOCKBAR_LEFT:
07705             DragOffsetFromLeft = CursorPos.x > LeftRect.GetRight();
07706             break;
07707         case DOCKBAR_RIGHT:
07708             DragOffsetFromLeft = CursorPos.x > RightRect.GetLeft();
07709             break;
07710         default:
07711             ENSURE(FALSE,"CalcDragOffsetDirection called with invalid bar type");
07712             break;
07713     }
07714 }
07715 
07716 
07717 
07718 
07719 /********************************************************************************************
07720 
07721 >   BOOL BaseBar::SimpleIntersect(LPRECT rect1, LPRECT rect2)
07722 
07723     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
07724     Created:    20/5/94
07725     Inputs:     rect1,rect2:    rectangles to intersect
07726     Outputs:    -
07727     Returns:    -
07728     Purpose:    Replaces the brain-damaged wxRect::Intersect routine which insists on
07729                 actually comuting the intersection in another rectangle, and most
07730                 worryingly, returns FALSE when one of the rectangles is 0 pixels wide.
07731 
07732                 This routine simply tests whether two rectangles intersect and returns TRUE
07733                 if they do. It also returns true no matter what the size of the
07734                 intersection!!! (IE. when it's 0 pixels wide/high).
07735 
07736                 Algorithm is: check whether rect1 is completely to left or right of rect2
07737                                 and
07738                               check whether rect1 is completely above or below rect2
07739     Errors:     -
07740     Scope:      private
07741     SeeAlso:    -
07742 
07743 ********************************************************************************************/
07744 
07745 BOOL BaseBar::SimpleIntersect( const wxRect &rect1, const wxRect &rect2)
07746 {
07747     return( !( ( rect1.GetRight() < rect2.GetLeft() ) ||
07748                ( rect1.GetLeft() >= rect2.GetRight() )
07749               ) &&
07750             !( ( rect1.GetBottom() < rect2.GetTop() ) ||
07751                ( rect1.GetTop() >= rect2.GetBottom() )
07752               )
07753            );
07754 }
07755 
07756 
07757 
07758 /********************************************************************************************
07759 
07760 >   void BaseBar::PaintDragRect(wxRect Rect)
07761 
07762     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
07763     Created:    5/4/94
07764     Inputs:     Rect: The rectangle to draw (screen coords)
07765     Outputs:    -
07766     Returns:    -
07767     Purpose:    Draws an XOR drag rectangle anywhere on the display
07768     Errors:     -
07769     Scope:      private
07770     SeeAlso:    -
07771 
07772 ********************************************************************************************/
07773 
07774 void BaseBar::PaintDragRect(wxRect Rect,wxRect OldRect,DockBarType DockBar,DockBarType OldBarType)
07775 {
07776     wxScreenDC  DisplayDC;
07777     
07778     wxSize NewSize(1,1);
07779     wxSize OldSize(1,1);
07780 
07781     if (DockBar == DOCKBAR_FLOAT)
07782     {
07783         NewSize.x = NewSize.y = BorderWidth;
07784     }
07785 
07786     if (OldBarType == DOCKBAR_FLOAT)
07787     {
07788         OldSize.x = OldSize.y = BorderWidth;
07789     }
07790 
07791     // MFC DrawDragRect function
07792 #pragma message( __LOCMSG__ "Remove DrawDragRect usage" )
07793 //  pDisplayDC->DrawDragRect( &Rect, NewSize, &OldRect, OldSize );
07794     
07795     /*
07796     // paint a + to the right side of the box if we are doing a control copy drag
07797     if(CtlDragState != NO_DRAG)
07798     {
07799         if(CtlDragMode == COPY)
07800         {
07801             
07802             pDragBrush  =  new wxBrush(RGB(255,255,255)) ;
07803             
07804             // Select into the DC
07805             pOldBrush = pDisplayDC->SelectObject(pDragBrush);
07806             
07807 
07808             pDisplayDC->PatBlt(OldRect.GetRight()+2, OldRect.GetBottom()-8, 5, 1,PATINVERT); 
07809             pDisplayDC->PatBlt(OldRect.GetRight()+4, OldRect.GetBottom()-10, 1, 5,PATINVERT);
07810 
07811             // draw the +
07812             pDisplayDC->PatBlt(Rect.GetRight()+2, Rect.GetBottom()-8, 5, 1,PATINVERT); 
07813             pDisplayDC->PatBlt(Rect.GetRight()+4, Rect.GetBottom()-10, 1, 5,PATINVERT);
07814     
07815             pDisplayDC->SelectObject(pOldBrush);
07816             
07817             pDragBrush->DeleteObject(); 
07818             delete pDragBrush; 
07819         }
07820     
07821     }
07822 
07823     */
07824 
07825     delete pDisplayDC;
07826 }
07827 
07828 
07829 
07830 
07831 
07832 /********************************************************************************************
07833 
07834 >   void BaseBar::PaintXORDragRect(wxRect Rect)
07835 
07836     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
07837     Created:    5/4/94
07838     Inputs:     Rect: The rectangle to draw (screen coords)
07839     Outputs:    -
07840     Returns:    -
07841     Purpose:    Draws an XOR drag rectangle anywhere on the display
07842     Errors:     -
07843     Scope:      private
07844     SeeAlso:    -
07845 
07846 ********************************************************************************************/
07847 
07848 void BaseBar::PaintXORDragRect(wxRect Rect,DockBarType DockBar)
07849 {
07850 #pragma message( __LOCMSG__ "Remove DC::PatBlt usage" )
07851 /*  DWORD dwRop = PATINVERT;
07852 
07853     wxScreenDC  DisplayDC;
07854     
07855     // Create a pattern brush from our gray bitmap
07856     wxBrush     DragBrush( BrushBitmap );
07857 
07858     // Select these into the DC
07859     DisplayDC.SetBrush( DragBrush );
07860 
07861     if (DockBar==DOCKBAR_FLOAT)
07862     {
07863         // left vertical
07864         pDisplayDC->PatBlt(Rect.GetLeft(), Rect.GetTop(), BorderWidth, Rect.GetHeight(),dwRop); 
07865         // top horizontal
07866         pDisplayDC->PatBlt(Rect.GetLeft()+BorderWidth, Rect.GetTop(),
07867                            Rect.GetWidth()-(BorderWidth*2), BorderWidth,dwRop); 
07868         // right vertical
07869         pDisplayDC->PatBlt(Rect.GetRight()-BorderWidth, Rect.GetTop(),
07870                            BorderWidth, Rect.GetHeight(), dwRop); 
07871         // bottom horizontal
07872         pDisplayDC->PatBlt(Rect.GetLeft()+BorderWidth, Rect.GetBottom()-BorderWidth,
07873                            Rect.GetWidth()-(BorderWidth*2), BorderWidth, dwRop); 
07874     }
07875     else
07876     {
07877         // left vertical
07878         pDisplayDC->PatBlt(Rect.GetLeft(), Rect.GetTop(), 1, Rect.GetHeight(), dwRop); 
07879         // top horizontal
07880         pDisplayDC->PatBlt(Rect.GetLeft()+1, Rect.GetTop(), Rect.GetWidth()-2, 1, dwRop); 
07881         // right vertical
07882         pDisplayDC->PatBlt(Rect.GetRight()-1, Rect.GetTop(), 1, Rect.GetHeight(), dwRop); 
07883         // bottom horizontal
07884         pDisplayDC->PatBlt(Rect.GetLeft()+1, Rect.GetBottom()-1, Rect.GetWidth()-2, 1, dwRop); 
07885     } */
07886 /*
07887     // paint a + to the right side of the box if we are doing a control copy drag
07888     if(CtlDragState != NO_DRAG)
07889     {
07890         if(CtlDragMode == COPY)
07891         {
07892             pDisplayDC->SelectObject(pOldBrush);
07893             pDragBrush->DeleteObject(); 
07894             delete pDragBrush; 
07895             
07896             pDragBrush  =  new wxBrush(RGB(255,255,255)) ;
07897             
07898             // Select into the DC
07899             pOldBrush = pDisplayDC->SelectObject(pDragBrush);
07900             
07901             // draw the +
07902             pDisplayDC->PatBlt(Rect.GetRight()+2, Rect.GetBottom()-8, 5, 1, dwRop); 
07903             pDisplayDC->PatBlt(Rect.GetRight()+4, Rect.GetBottom()-10, 1, 5, dwRop);
07904 
07905         }
07906     
07907     }
07908 
07909     DisplayDC.SetBrush( wxNullBrush ); */
07910 }
07911 
07912 
07913 
07914 
07915 /********************************************************************************************
07916 
07917 >   INT32 FAR PASCAL _export BaseBar::EnterSubclassProc(HWND hWnd,
07918                                                          UINT32 Message,
07919                                                          UINT32 wParam,
07920                                                          INT32 lParam)
07921 
07922 
07923     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
07924     Created:    24/8/93
07925     Inputs:     hwnd
07926                 message
07927                 wParam
07928                 lParam
07929     Outputs:    -
07930     Returns:    -
07931     Purpose:    This is the window procedure for all edit and combo controls on BaseBars
07932                 It changes the controls so that a commit message is generated whenever 
07933                 the user presses enter or tab in the control
07934 
07935     Errors:     -
07936     SeeAlso:    -
07937 
07938 ********************************************************************************************/
07939 /*
07940 INT32 FAR PASCAL _exportBaseBar::EnterSubclassProc(HWND hWnd,
07941                                                     UINT32 Message,
07942                                                     UINT32 wParam,
07943                                                     INT32 lParam)
07944 {
07945     HWND MyDaddy = GetParent(hwnd);
07946 
07947     switch (Message)
07948     {
07949 
07950         case WM_CHAR:
07951             // Process this message to avoid message beeps.
07952             if ((wParam == CAMKEY(RETURN)) || (wParam == CAMKEY(TAB)))
07953                 return FALSE;
07954             else
07955                 return (CallWindowProc(lpOldProc, hWnd, 
07956                                        Message, wParam, lParam));
07957     
07958         case WM_KEYDOWN:
07959             if ((wParam == CAMKEY(RETURN)) || (wParam == CAMKEY(TAB)))
07960             {
07961                 // PostMessage();
07962                 return FALSE;
07963             }
07964             else 
07965                 return (CallWindowProc(lpOldProc, hWnd, 
07966                                        Message, wParam, lParam));
07967             break;
07968 
07969     }
07970     return CallWindowProc((WNDPROC)(CurrentCntrl->lpfnOldProc), hwnd, message, wParam, lParam);
07971     
07972 }
07973 */

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