bars.cpp

Go to the documentation of this file.
00001 // $Id: bars.cpp 1386 2006-06-28 17:49:55Z 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 // The kernel implementation of bars
00099 
00100 /*
00101 */
00102 
00103 
00104 #include "camtypes.h"
00105 #include "camelot.h"
00106 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "ensure.h"
00108 #include "oilfiles.h"
00109 //#include "ccfile.h"
00110 //#include "markn.h"
00111 #include "camframe.h"
00112 //#include "dockbar.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 //#include "mario.h"      // read as "menu.h", gets the bindings for menu strings
00114 //#include "msg.h"
00115 //#include "simon.h"
00116 //#include "fixst256.h"
00117 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00118 //#include "prefs.h"
00119 #include "camelot.h"
00120 #include "gallery.h"
00121 //#include "sgallery.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00122 //#include "resource.h"
00123 //#include "barsdlgs.h"
00124 //#include "chris.h"
00125 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00126 #include "keymsg.h"
00127 #include "keypress.h"
00128 #include "basebar.h"
00129 #include "product.h"
00130 #include "selector.h"
00131 #include "bubbleid.h"
00132 #include "vkextra.h"
00133 #include "ctrllist.h"
00134 //#include "camsdkfn.h"     // for equivalent winoil 'mappings' of standard OS calls
00135                         // (e.g.  MoveWindow, GetClientRect, etc.)
00136 
00137 //#include "will2.h"
00138 
00139 //#include "registry.h" // SaveRegistryEntries
00140 #include "cversion.h"   // CAMELOT_VERSION_MAJOR CAMELOT_VERSION_MINOR
00141 
00142 #include "biasdlg.h"    // for CBiasGainDialog ()
00143 
00144 CC_IMPLEMENT_DYNCREATE( DialogBarOp , DialogOp )
00145 //CC_IMPLEMENT_DYNCREATE( HiddenBarOp , DialogBarOp )
00146 CC_IMPLEMENT_DYNCREATE( InformationBarOp, DialogBarOp)
00147 CC_IMPLEMENT_DYNCREATE( SystemBarOp , DialogBarOp )
00148 
00149 CC_IMPLEMENT_DYNAMIC( BarMsg, Msg )
00150 CC_IMPLEMENT_DYNAMIC( BarItem, ListItem )
00151 CC_IMPLEMENT_DYNAMIC( BarControlBase, BarItem )
00152 CC_IMPLEMENT_DYNAMIC( BarControl, BarControlBase )
00153 CC_IMPLEMENT_DYNAMIC( BarSeparator, BarItem )
00154 CC_IMPLEMENT_DYNAMIC( BarNewPage, BarItem )
00155 
00156 CC_IMPLEMENT_DYNAMIC( BarLineFeed, BarItem )
00157 CC_IMPLEMENT_DYNAMIC( BarToolButton, BarControlBase)
00158 CC_IMPLEMENT_DYNAMIC( DDeckerTop, BarItem )
00159 CC_IMPLEMENT_DYNAMIC( DDeckerBottom, BarItem )
00160 CC_IMPLEMENT_DYNAMIC( DDeckerEnd, BarItem )
00161 
00162 #define new CAM_DEBUG_NEW
00163 
00164 DockBarType         InformationBarOp::Dock   = DOCKBAR_TOP;
00165 UINT32              InformationBarOp::Slot   = DEFAULT_TOOL_INFOBAR_SLOT;
00166 UINT32              InformationBarOp::Offset = 0;                                     
00167 wxPoint             InformationBarOp::FloatPos;
00168 InformationBarOp*   InformationBarOp::CurrentInfoBarOp = NULL;
00169 BOOL                InformationBarOp::Visible = TRUE;
00170 BOOL                InformationBarOp::Hidden = FALSE;
00171 BOOL                DialogBarOp::SystemStateChanged = TRUE; 
00172 PathName            DialogBarOp::ValidPath;
00173 DialogBarOp *       DialogBarOp::AllBarsOp = NULL;
00174 
00175 static String_256 DefaultBarsConfigPath;
00176 static BOOL ShowSystemBars = FALSE;
00177 static String_64 BarsVersion;
00178 
00179 static struct
00180 {
00181     TCHAR*  Token;
00182 } TokenTable[] = 
00183 {
00184     {_T("Bar")},
00185     {_T("EndBar")},
00186     {_T("Control")},
00187     {_T("H")},
00188     {_T("V")},
00189     {_T("B")},
00190     {_T("Separator")},
00191     {_T("LineFeed")},
00192     {_T("Left")},
00193     {_T("Right")},
00194     {_T("Top")},
00195     {_T("Bottom")},
00196     {_T("Float")},
00197     {_T("DockingBar")},
00198     {_T("Big")},
00199     {_T("Small")},
00200     {_T("Gallery")},
00201     {_T("EndGallery")},
00202     {_T("DDeckerTop")},
00203     {_T("DDeckerBottom")},
00204     {_T("DDeckerEnd")},
00205     {_T("Visible")},
00206     {_T("Invisible")},
00207     {_T("StatusBar")},
00208     {_T("ColourBar")},
00209     {_T("ScrollBars")},
00210     {_T("FullScreen")},
00211     {_T("On")},
00212     {_T("Off")},
00213     {_T("InfoBar")},
00214     {_T("NewPage")}
00215 };
00216 
00217 
00218 /********************************************************************************************
00219 
00220 >   static TokenIndex FindToken(const TCHAR* Token)
00221 
00222     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00223     Created:    6/4/94
00224     Inputs:     Token= token that we want to read up to.
00225     Outputs:    -
00226     Returns:    Token index represented by Token, or TOKEN_NONE if no match found
00227     Purpose:    Looks up the token index for the given string in the token table
00228     Errors:     -
00229     SeeAlso:    -
00230 
00231 ********************************************************************************************/
00232 
00233 static TokenIndex FindToken(const TCHAR* Token)
00234 {
00235     for (INT32 i=0;i<NUM_TOKENS;i++)
00236     {
00237         if (camStrcmp(TokenTable[i].Token,Token) == 0)
00238             return ((TokenIndex)i);
00239     }
00240 
00241     return (TOKEN_NONE);
00242 }
00243 
00244 
00245 /********************************************************************************************
00246 
00247 >   void DialogBarOp::SetSystemStateChanged(BOOL State = TRUE) 
00248 
00249     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00250     Created:    28/3/94
00251     Inputs:     New SystemChangedState.
00252     Outputs:    -
00253     Returns:    -
00254     Purpose:    Constructor
00255     Errors:     -
00256     SeeAlso:    -
00257 
00258 ********************************************************************************************/
00259 
00260 void DialogBarOp::SetSystemStateChanged(BOOL State) 
00261 {
00262     SystemStateChanged = State;
00263     if (State)
00264         ControlList::Get()->Changed();
00265 } 
00266 
00267 /********************************************************************************************
00268 
00269 >BOOL DialogBArOp::ShouldUpdateBarState()
00270 
00271     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00272     Created:    28/3/94
00273     Inputs:     Class = the message handler class list to add this object to.
00274     Outputs:    -
00275     Returns:    SystemStateChanged
00276     Purpose:    -
00277     Errors:     -
00278     SeeAlso:    -
00279 
00280 ********************************************************************************************/
00281 
00282 BOOL DialogBarOp::ShouldUpdateBarState()
00283 {
00284  return SystemStateChanged == TRUE;
00285  
00286 }
00287 
00288 /********************************************************************************************
00289 
00290 >   DialogBarOp::DialogBarOp(CCRuntimeClass* Class = CC_RUNTIME_CLASS(DialogBarOp))
00291 
00292     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00293     Created:    28/3/94
00294     Inputs:     Class = the message handler class list to add this object to.
00295     Outputs:    -
00296     Returns:    -
00297     Purpose:    Constructor
00298     Errors:     -
00299     SeeAlso:    -
00300 
00301 ********************************************************************************************/
00302 
00303 
00304 DialogBarOp::DialogBarOp(CCRuntimeClass* Class): DialogOp(_R(IDD_BLANKBAR), MODELESS,0,SAFECLASS(Class))
00305 {
00306     String_32 str = String_32(_R(IDS_K_BARS_NONAME));
00307     DialogBarOpInit(str);
00308 }
00309 
00310 
00311 /********************************************************************************************
00312 
00313 >   DialogBarOp::DialogBarOp(UINT32 StringID, CCRuntimeClass* Class = CC_RUNTIME_CLASS(DialogBarOp))
00314 
00315     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00316     Created:    28/3/94
00317     Inputs:     StringID    = ID of name of the dialog bar op.
00318                 Class       = the message handler class list to add this object to.
00319     Outputs:    -
00320     Returns:    -
00321     Purpose:    Constructor
00322     Errors:     -
00323     SeeAlso:    -
00324 
00325 ********************************************************************************************/
00326 
00327 DialogBarOp::DialogBarOp(UINT32 StringID, CCRuntimeClass* Class): DialogOp(_R(IDD_BLANKBAR), MODELESS,0,SAFECLASS(Class))
00328 {
00329     String_32 str = String_32(StringID);
00330     DialogBarOpInit(str);
00331 }
00332 
00333 
00334 /********************************************************************************************
00335 
00336 >   DialogBarOp::DialogBarOp(String_32& NewName,CCRuntimeClass* Class = CC_RUNTIME_CLASS(DialogBarOp))
00337 
00338     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00339     Created:    28/3/94
00340     Inputs:     NewName = Name of this bar
00341                 Class = the message handler class list to add this object to.
00342     Outputs:    -
00343     Returns:    -
00344     Purpose:    Constructor
00345     Errors:     -
00346     SeeAlso:    -
00347 
00348 ********************************************************************************************/
00349 
00350 DialogBarOp::DialogBarOp(String_32& NewName,CCRuntimeClass* Class): DialogOp(_R(IDD_BLANKBAR), MODELESS,0,SAFECLASS(Class))
00351 {
00352     DialogBarOpInit(NewName);
00353 }
00354 
00355 
00356 /********************************************************************************************
00357 
00358 >   void DialogBarOp::DialogBarOpInit(String_32& NewName)
00359 
00360     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00361     Created:    26/4/94
00362     Inputs:     NewName = Name of this bar
00363     Outputs:    -
00364     Returns:    -
00365     Purpose:    Common routine called by all Constructors
00366     Errors:     -
00367     SeeAlso:    -
00368 
00369 ********************************************************************************************/
00370 
00371 void DialogBarOp::DialogBarOpInit(String_32& NewName)
00372 {
00373     Name = NewName;
00374     Dock = DOCKBAR_TOP;
00375     Slot = 0;
00376     Offset = 0;
00377     FloatPos = wxPoint(100,100);
00378     BarRect = wxRect(0, 0, 0, 0);
00379     BarOrientation = Horizontal; 
00380     InitiallyVisible = TRUE;
00381 
00382     // Report new bar to any dialog ops...
00383     BROADCAST_TO_CLASS( BarMsg(BAR_CREATE,this), DialogOp );
00384 }
00385 
00386 
00387 /********************************************************************************************
00388 
00389 >   DialogBarOp::~DialogBarOp()
00390 
00391     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00392     Created:    28/3/94
00393     Inputs:     -
00394     Outputs:    -
00395     Returns:    -
00396     Purpose:    Destructor
00397     Errors:     -
00398     SeeAlso:    -
00399 
00400 ********************************************************************************************/
00401 
00402 DialogBarOp::~DialogBarOp()
00403 {
00404 //  if (IsUserName("MarkN")) TRACE( _T("~DialogBarOp\n"));
00405     DeleteAllBarItems();
00406 }
00407 
00408 
00409 /********************************************************************************************
00410 
00411 >   LISTPOS DialogBarOp::AddBarItem(BarItem* pBarItem)
00412 
00413     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00414     Created:    28/3/94
00415     Inputs:     pBarItem = ptr to a bar item to add to the dialog bar
00416     Outputs:    -
00417     Returns:    The position of the new bar item in the bar
00418     Purpose:    Adding a bar item to a bar.
00419     Errors:     -
00420     SeeAlso:    -
00421 
00422 ********************************************************************************************/
00423 
00424 LISTPOS DialogBarOp::AddBarItem(BarItem* pBarItem)
00425 {
00426     BarItemList.AddTail(pBarItem);
00427     return (BarItemList.FindPosition(pBarItem));
00428 }
00429 
00430 /********************************************************************************************
00431 
00432 >   BarItem* DialogBarOp::RemoveBarItem(LISTPOS here)
00433 
00434     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00435     Created:    28/3/94
00436     Inputs:     here = position of the bar item to be removed from the list
00437     Outputs:    -
00438     Returns:    pBarItem = ptr to the bar item that has been removed.
00439     Purpose:    Removes the bar item from the list of bar items n the bar.
00440                 This does NOT delete the item, or any memory associated with it.  It is just delinked.
00441     Errors:     Debug build     - An ENSURE failure if the bar item is not found.
00442                 Retail build    - NULL is returned if the bar item is not found.
00443     SeeAlso:    -
00444 
00445 ********************************************************************************************/
00446 
00447 BarItem* DialogBarOp::RemoveBarItem(LISTPOS here)
00448 {
00449     BarItem* pBarItem = (BarItem*) BarItemList.FindItem(here);
00450     ENSURE(pBarItem != NULL,"Couldn't remove bar item. Item not found.");
00451     
00452     BarItemList.RemoveItem(pBarItem);
00453 
00454     return (pBarItem);
00455 }
00456 
00457 /********************************************************************************************
00458 
00459 >   BarItem* DialogBarOp::RemoveBarItem(BarItem * thisItem)
00460 
00461     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00462     Created:    28/3/94
00463     Inputs:     here = position of the bar item to be removed from the list
00464     Outputs:    -
00465     Returns:    pBarItem = ptr to the bar item that has been removed.
00466     Purpose:    Removes the bar item from the list of bar items n the bar.
00467                 This does NOT delete the item, or any memory associated with it.  It is just delinked.
00468     Errors:     Debug build     - An ENSURE failure if the bar item is not found.
00469                 Retail build    - NULL is returned if the bar item is not found.
00470     SeeAlso:    -
00471 
00472 ********************************************************************************************/
00473 
00474 BarItem* DialogBarOp::RemoveBarItem(BarItem * thisItem)
00475 {
00476     return (BarItem *)BarItemList.RemoveItem(thisItem);
00477 }
00478 
00479 /********************************************************************************************
00480 
00481 >   void DialogBarOp::InsertItemAfter(LISTPOS here,BarItem * thisItem)
00482 
00483     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00484     Created:    28/3/94
00485     Inputs:     here    = position of the bar item to be moved.
00486                 newpos  = the new pos of the bar item
00487     Outputs:    -
00488     Returns:    -
00489     Purpose:    .
00490     Errors:     -
00491     SeeAlso:    -
00492 
00493 ********************************************************************************************/
00494 
00495 void DialogBarOp::InsertItemAfter(LISTPOS here,BarItem * thisItem)
00496 {
00497 
00498     UINT32 NoItems = GetNumBarItems();
00499     if(here == -1)
00500         BarItemList.AddHead(thisItem);
00501     else if ((unsigned)here >= NoItems)
00502         BarItemList.AddTail(thisItem);
00503     else
00504         BarItemList.InsertAfter(here,thisItem);
00505 }
00506 
00507 /********************************************************************************************
00508 
00509 >   BOOL DialogBarOp::HideDisableGadgetAndResuffleBar (CWindowID WinID)
00510 
00511     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00512     Created:    30/9/99
00513     Inputs:     WinID - the handle to the control that this operation is to be performed on
00514     Outputs:    -
00515     Returns:    TRUE - if operation successful (i.e.  could be applied to this infobar)
00516                 FALSE - if operation was NOT successful
00517     Purpose:    This function is the saviour of camelots GUI infobars - several of which
00518                 have become too crowded, and as such; their controls no longer fit into
00519                 the 'static' docked infobar.  The function hides the requested control
00520                 and automatically resuffles those controls that occur after it.
00521                 For example:    Combo1, Combo2, Combo3;  call on Combo1 gives:
00522                                 Combo2, Combo3
00523                 If you are calling this operation - you MUST ensure that the infobar
00524                 (which is WinID's parent) has been handled within winoil\basebar2.cpp.
00525                 Refer (basebar2.cpp) line 1311 for the code that MUST be checked/edited
00526                 (or search on DialogBarOp::HideDisableGadgetAndResuffleBar).
00527                 If you want to see an example of how to use this function correctly,
00528                 consult tool\filltool.cpp - since this is the first place the function
00529                 was used within camelot.  TIP:  I would recommend that you hide the
00530                 controls in a left to right order (i.e.  leftmost first).
00531     Errors:     -
00532     SeeAlso:    BOOL DialogBarOp::ShowEnableGadgetAndResuffleBar (CWindowID WinID)
00533                 BOOL DialogBarOp::ResetHiddenGadgetStates ()
00534 
00535 ********************************************************************************************/
00536 
00537 BOOL DialogBarOp::HideDisableGadgetAndResuffleBar (CWindowID WinID)
00538 {   
00539     /*KernelBarPos*     pKernelBarPos;
00540     DockBarType     Dock;
00541     
00542     if (GetMainFrame()->GetBarPosInfo(GetParent ((HWND) WinID),&Dock,&pKernelBarPos))
00543     {
00544         SetDockBarType(Dock);
00545         if (Dock == DOCKBAR_FLOAT)
00546             SetFloatingCPoint(wxPoint(pKernelBarPos->x,pKernelBarPos->y));
00547         else
00548         {
00549             SetSlot(pKernelBarPos->Slot);
00550             SetOffset(pKernelBarPos->Position);
00551         }
00552     }
00553 
00554     // Save this info bar's data in the static vars
00555     // These vars are used by
00556     DialogBarOp::Dock           = GetDockBarType();
00557     DialogBarOp::Slot           = GetSlot();
00558     DialogBarOp::Offset         = GetOffset();
00559     DialogBarOp::FloatPos       = GetFloatingCPoint();
00560     
00561     switch (GetDockBarType ())
00562     {
00563         case DOCKBAR_LEFT:      // This should not be possible for infobars
00564         return (FALSE);         // NOT a chance!
00565         case DOCKBAR_RIGHT:     // This should not be possible for infobars
00566         return (FALSE);         // NOT a chance!
00567         case DOCKBAR_TOP:       
00568             // handle internally - so that caller does NOT have to worry ....
00569             EnableGadget (CamalotSDKGetDlgCtrlID (WinID), FALSE);
00570         break;                  // will process this one (cause its of static size)
00571         case DOCKBAR_BOTTOM:
00572             // handle internally - so that caller does NOT have to worry ....
00573             EnableGadget (CamalotSDKGetDlgCtrlID (WinID), FALSE);
00574         break;                  // will process this one (cause its of static size)
00575         case DOCKBAR_FLOAT:
00576             // handle internally - so that caller does NOT have to worry ....
00577             EnableGadget (CamalotSDKGetDlgCtrlID (WinID), FALSE);
00578         return (FALSE);         // we will NOT process this because of the problems
00579                                 // it causes
00580         case DOCKBAR_INVALID:   // god knows !!!!
00581         return (FALSE);
00582     }
00583     
00584     RECT windowRect;
00585 
00586     CamalotSDKGetWindowRect (WinID, &windowRect);
00587 
00588     POINT topLeft;
00589     topLeft.x = windowRect.left;
00590     topLeft.y = windowRect.top;
00591 
00592     CamalotSDKScreenToClient (CamalotSDKGetParent (WinID), &topLeft);
00593 
00594     INT32 xLength = windowRect.right - windowRect.left;
00595 
00596     BarItem* hideControl = GetBarItem ((HWND) WinID);
00597     BarControl* hideBControl = NULL;
00598 
00599     if (hideControl->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
00600     {
00601         hideBControl = (BarControl*) hideControl;
00602     }
00603     
00604     // firstly, lets hide the gadget that this operation has been requested for ....
00605 
00606     if (hideBControl->IsVisible () == TRUE)
00607     {
00608         hideBControl->SetVisibleState (FALSE);
00609 
00610         CamalotSDKShowWindow (WinID, SW_HIDE);
00611 
00612         //BarItem* hideControl = GetBarItem ((HWND) WinID);
00613         BarItem* prevControl = GetPtrBarPrev (hideControl);
00614         BarItem* nextControl = GetPtrBarNext (hideControl);
00615 
00616         if (prevControl->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)))
00617         {   
00618             if (!(GetMainFrame()->GetDockBar(GetDockBarType ())->IsBigControls()))
00619             {
00620                 xLength += SMALL_SEPARATOR;
00621             }
00622             else
00623             {
00624                 xLength += LARGE_SEPARATOR;
00625             }
00626         }
00627 
00628         while (nextControl != NULL)
00629         {
00630             CWindowID barCtrlID  = NULL;
00631             BarControl* barCtrl = NULL;
00632 
00633             if (nextControl->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
00634             {
00635                 barCtrl = (BarControl*) nextControl;
00636                 barCtrlID = barCtrl->GetWinID ();
00637 
00638                 CamalotSDKGetWindowRect (barCtrlID, &windowRect);
00639                 topLeft.x = windowRect.left;
00640                 topLeft.y = windowRect.top;
00641             
00642                 CamalotSDKScreenToClient (CamalotSDKGetParent (WinID), &topLeft);
00643                 topLeft.x -= xLength;
00644                 //windowRect.right -= xLength;
00645 
00646                 BarItem* controlSep = GetPtrBarPrev (nextControl);
00647                 
00648                 INT32 sepLength = 0;
00649 
00650                 if (controlSep->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)))
00651                 {   
00652                     if (!(GetMainFrame()->GetDockBar(GetDockBarType ())->IsBigControls()))
00653                     {
00654                         sepLength += SMALL_SEPARATOR;
00655                     }
00656                     else
00657                     {
00658                         sepLength += LARGE_SEPARATOR;
00659                     }
00660                 }
00661 
00662                 //InvalidateRect (GetParent ((HWND) WinID), &windowRect, TRUE);
00663 
00664                 CamalotSDKMoveWindow ((HWND) barCtrlID, topLeft.x, topLeft.y,
00665                                       windowRect.right - windowRect.left,
00666                                       windowRect.bottom - windowRect.top, TRUE);*/
00667 
00668                 /*RECT sepRect;
00669                 sepRect.right = windowRect.left;
00670                 sepRect.left = sepRect.right - sepLength;
00671                 sepRect.top = windowRect.top;
00672                 sepRect.bottom = windowRect.bottom;
00673 
00674                 InvalidateRect (GetParent ((HWND) WinID), &sepRect, TRUE);*/
00675 
00676             // need to do this - cause camelots bubble help system sometimes gets
00677             // broken otherwise ....
00678 
00679             //InvalidateRect (GetParent ((HWND) hideControl), NULL, TRUE);
00680             //BringWindowToTop ((HWND) barCtrlID);
00681 
00682 /*          }
00683 
00684             nextControl = (BarItem*) BarItemList.GetNext(nextControl);
00685         }
00686         return (TRUE);
00687     }
00688     else
00689     {
00690         return (FALSE);
00691     }*/
00692     
00693     return (TRUE);//FALSE);
00694 }
00695 
00696 /********************************************************************************************
00697 
00698 >   BOOL DialogBarOp::ShowEnableGadgetAndResuffleBar (CWindowID WinID)
00699 
00700     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00701     Created:    30/9/99
00702     Inputs:     WinID - the handle to the control that this operation is to be performed on
00703     Outputs:    -
00704     Returns:    TRUE - if operation successful (i.e.  could be applied to this infobar)
00705                 FALSE - if operation was NOT successful
00706     Purpose:    Does the opposite of
00707                 BOOL DialogBarOp::HideDisableGadgetAndResuffleBar (CWindowID WinID)
00708     Errors:     -
00709     SeeAlso:    BOOL DialogBarOp::ShowDisableGadgetAndResuffleBar (CWindowID WinID)
00710                 BOOL DialogBarOp::ResetHiddenGadgetStates ()
00711 
00712 ********************************************************************************************/
00713 
00714 BOOL DialogBarOp::ShowEnableGadgetAndResuffleBar (CWindowID WinID)
00715 {
00716     // firstly - we need to check to see if the control is of the bar is of the
00717     // correct docking type - BEFORE we continue ....
00718 
00719 /*  KernelBarPos*   pKernelBarPos;
00720     DockBarType     Dock;
00721 
00722     if (GetMainFrame()->GetBarPosInfo(GetParent ((HWND) WinID),&Dock,&pKernelBarPos))
00723     {
00724         SetDockBarType(Dock);
00725         if (Dock == DOCKBAR_FLOAT)
00726             SetFloatingCPoint(wxPoint(pKernelBarPos->x,pKernelBarPos->y));
00727         else
00728         {
00729             SetSlot(pKernelBarPos->Slot);
00730             SetOffset(pKernelBarPos->Position);
00731         }
00732     }
00733 
00734     // Save this info bar's data in the static vars
00735     // These vars are used by
00736     DialogBarOp::Dock           = GetDockBarType();
00737     DialogBarOp::Slot           = GetSlot();
00738     DialogBarOp::Offset         = GetOffset();
00739     DialogBarOp::FloatPos       = GetFloatingCPoint();
00740 
00741     RECT windowRect;
00742 
00743     CamalotSDKGetWindowRect ((HWND) WinID, &windowRect);
00744 
00745     switch (GetDockBarType ())
00746     {
00747         case DOCKBAR_LEFT:      // This should not be possible for infobars
00748         return (FALSE);         // NOT a chance!
00749         case DOCKBAR_RIGHT:     // This should not be possible for infobars
00750         return (FALSE);         // NOT a chance!
00751         case DOCKBAR_TOP:
00752             // handle internally - so that caller does NOT have to worry ....
00753             EnableGadget (CamalotSDKGetDlgCtrlID (WinID), TRUE);
00754         break;                  // will process this one (cause its of static size)
00755         case DOCKBAR_BOTTOM:
00756             // handle internally - so that caller does NOT have to worry ....
00757             EnableGadget (CamalotSDKGetDlgCtrlID (WinID), TRUE);
00758         break;                  // will process this one (cause its of static size)
00759         case DOCKBAR_FLOAT:
00760             // handle internally - so that caller does NOT have to worry ....
00761             EnableGadget (CamalotSDKGetDlgCtrlID (WinID), TRUE);
00762         return (FALSE);         // we will NOT process this because of the problems
00763                                 // it causes
00764         case DOCKBAR_INVALID:   // god knows !!!!
00765         return (FALSE);
00766     }
00767 
00768     POINT topLeft;
00769     topLeft.x = windowRect.left;
00770     topLeft.y = windowRect.top;
00771 
00772     CamalotSDKScreenToClient (CamalotSDKGetParent (WinID), &topLeft);
00773 
00774     INT32 xLength = windowRect.right - windowRect.left;
00775 
00776     BarItem* hideControl = GetBarItem ((HWND) WinID);
00777     BarControl* hideBControl = NULL;
00778 
00779     if (hideControl->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
00780     {
00781         hideBControl = (BarControl*) hideControl;
00782     }
00783     
00784     // firstly, lets hide the gadget that this operation has been requested for ....
00785 
00786     if (hideBControl->IsVisible () == FALSE)
00787     {
00788         hideBControl->BarControl::SetVisibleState (TRUE);
00789         
00790         CamalotSDKShowWindow (WinID, SW_SHOW);
00791 
00792         //BarItem* hideControl = GetBarItem ((HWND) WinID);
00793         BarItem* prevControl = GetPtrBarPrev (hideControl);
00794         BarItem* nextControl = GetPtrBarNext (hideControl);
00795 
00796         if (prevControl->IsKindOf(CC_RUNTIME_CLASS(BarSeparator)))
00797         {   
00798             if (!(GetMainFrame()->GetDockBar(GetDockBarType ())->IsBigControls()))
00799             {
00800                 xLength += SMALL_SEPARATOR;
00801             }
00802             else
00803             {
00804                 xLength += LARGE_SEPARATOR;
00805             }
00806         }
00807 
00808         while (nextControl != NULL)
00809         {
00810             CWindowID barCtrlID  = NULL;
00811             BarControl* barCtrl = NULL;
00812 
00813             if (nextControl->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
00814             {
00815                 barCtrl = (BarControl*) nextControl;
00816                 barCtrlID = barCtrl->GetWinID ();
00817 
00818             CamalotSDKGetWindowRect (barCtrlID, &windowRect);
00819             topLeft.x = windowRect.left;
00820             topLeft.y = windowRect.top;
00821             
00822             CamalotSDKScreenToClient (CamalotSDKGetParent (WinID), &topLeft);
00823             topLeft.x += xLength;
00824             //windowRect.right -= xLength;
00825 
00826             MoveWindow ((HWND) barCtrlID, topLeft.x, topLeft.y,
00827                         windowRect.right - windowRect.left,
00828                         windowRect.bottom - windowRect.top, TRUE);
00829 
00830             }
00831 
00832             nextControl = (BarItem*) BarItemList.GetNext(nextControl);
00833         }
00834         return (TRUE);
00835     }
00836     else
00837     {
00838         return (FALSE);
00839     }*/
00840     
00841     return (TRUE);//FALSE);
00842 }
00843 
00844 /********************************************************************************************
00845 
00846 >   BOOL DialogBarOp::ResetHiddenGadgetStates ()
00847 
00848     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00849     Created:    15/10/99
00850     Inputs:     WinID - the handle to the control that this operation is to be performed on
00851     Outputs:    -
00852     Returns:    TRUE - if function traversed all controls in the dialogbar
00853                 FALSE - if operation contains NO controls
00854     Purpose:    This function is required to fix the errors that originate on 'dynamic'
00855                 infobars when we change to another tool - or drag the infobar into a floating
00856                 one; and then make it dockable again.  The problems result from the fact that
00857                 we need to reset our visibility flags (in these cases) in order for the
00858                 HideDisableGadgetAndResuffleBar and ShowDisableGadgetAndResuffleBar to do
00859                 their stuff correctly.  This function handles this ....
00860 
00861                 This function should only be called from the following places:
00862 
00863                 1)  Inside of BaseBar::Recreate (DockBarType DockBarTyp, BaseBar* BaseBar,
00864                     DialogBarOp* Op,BOOL CanCopy ).  Although (in this file) this is the
00865                     only place the function needs to be called, YOU MUST UPDATE THE LOGIC
00866                     THAT IS RESPONSIBLE FOR CALLING THE FUNCTION.  This is located at about
00867                     line 1248.
00868 
00869                 2)  Inside of your InfoBars Tool::SelectChange(BOOL isSelected) - within
00870                     the isSelected FALSE part of this code, you need to add the following
00871                     line:
00872 
00873                     (your infobar op)->ResetHiddenGadgetStates ();
00874     
00875     Errors:     -
00876     SeeAlso:    BOOL DialogBarOp::HideDisableGadgetAndResuffleBar (CWindowID WinID)
00877                 BOOL DialogBarOp::ShowDisableGadgetAndResuffleBar (CWindowID WinID)
00878 
00879 ********************************************************************************************/
00880 
00881 BOOL DialogBarOp::ResetHiddenGadgetStates ()
00882 {
00883     /*BarItem* theItem = GetPtrBarHead ();
00884 
00885     if (theItem != NULL)
00886     {
00887         while (theItem != NULL)
00888         {
00889             if (theItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
00890             {
00891                 BarControl* theBCItem = (BarControl*) theItem;
00892 
00893                 if (theBCItem->IsVisible () == FALSE)
00894                 {
00895                     theBCItem->SetVisibleState (TRUE);
00896                     //theBCItem->SetRequireResetOfVisibleState (TRUE);
00897                 }
00898             }
00899             theItem = (BarItem*) BarItemList.GetNext (theItem);
00900         }
00901         //SetRequireResetOfHiddenControls (TRUE);
00902         return (TRUE);
00903     }
00904     else
00905     {
00906         return (FALSE);
00907     }*/
00908     return (TRUE);//FALSE);
00909 }
00910 
00911 /********************************************************************************************
00912 
00913 >   void DialogBarOp::MoveBarItem(LISTPOS here,LISTPOS newpos)
00914 
00915     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00916     Created:    28/3/94
00917     Inputs:     here    = position of the bar item to be moved.
00918                 newpos  = the new pos of the bar item
00919     Outputs:    -
00920     Returns:    -
00921     Purpose:    Moves the bar item at 'here' to a new position in the bar. All items that were
00922                 at positions from 'newpos' onwards before the call and shuffled along one position
00923                 to accommodate the move.
00924     Errors:     -
00925     SeeAlso:    -
00926 
00927 ********************************************************************************************/
00928 
00929 void DialogBarOp::MoveBarItem(LISTPOS here,LISTPOS newpos)
00930 {
00931     if (here == newpos) return;
00932 
00933     BarItem* pBarItem = RemoveBarItem(here);
00934 
00935     if (pBarItem == NULL) return;
00936 
00937     if ((unsigned)newpos >= GetNumBarItems())
00938         BarItemList.AddTail(pBarItem);
00939     else
00940         BarItemList.InsertBefore(newpos,pBarItem);
00941 }
00942 
00943 /********************************************************************************************
00944 
00945 >   void DialogBarOp::DeleteAllBarItems()
00946 
00947     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00948     Created:    7/4/94
00949     Inputs:     -
00950     Outputs:    -
00951     Returns:    -
00952     Purpose:    Removes and deletes all bar items attached to this bar.
00953                 It's main function is for tidying up after errors during the
00954                 reconstruction of the bars system when the tokenised ASCII
00955                 file is read in.
00956     Errors:     -
00957     SeeAlso:    -
00958 
00959 ********************************************************************************************/
00960 
00961 void DialogBarOp::DeleteAllBarItems()
00962 {
00963 //  if (IsUserName("MarkN")) TRACE( _T("DeleteAllBarItems()\n"));
00964 
00965     BarItem* pNextBarItem = (BarItem*) BarItemList.GetHead();
00966     BarItem* pThisBarItem;
00967     
00968     while (pNextBarItem != NULL)
00969     {
00970         pThisBarItem = pNextBarItem;
00971         pNextBarItem = (BarItem*) BarItemList.GetNext(pThisBarItem);
00972 
00973         BarItemList.RemoveItem(pThisBarItem);
00974         //if (IsUserName("MarkN")) TRACE( _T("deleting pThisBarItem (%p)\n"),pThisBarItem);
00975         delete pThisBarItem;
00976     }
00977 }
00978 
00979 /********************************************************************************************
00980 
00981 >   BarItem * DialogBarOp::GetBarItem(CWindowID WinID)
00982 
00983     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00984     Created:    7/4/94
00985     Inputs:     -
00986     Outputs:    -
00987     Returns:    -
00988     Purpose:    Removes and deletes all bar items attached to this bar.
00989                 It's main function is for tidying up after errors during the
00990                 reconstruction of the bars system when the tokenised ASCII
00991                 file is read in.
00992     Errors:     -
00993     SeeAlso:    -
00994 
00995 ********************************************************************************************/
00996 
00997 BarItem * DialogBarOp::GetBarItem(CWindowID WinID)
00998 {
00999 //  if (IsUserName("MarkN")) TRACE( _T("DeleteAllBarItems()\n"));
01000 
01001     BarItem* pNextBarItem = (BarItem*) BarItemList.GetHead();
01002     BarItem* pThisBarItem;
01003     
01004     while (pNextBarItem != NULL)
01005     {
01006         pThisBarItem = pNextBarItem;
01007         pNextBarItem = (BarItem*) BarItemList.GetNext(pThisBarItem);
01008         if (pThisBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
01009         {
01010             BarControl* BarCtrl = (BarControl*)pThisBarItem;
01011             if(WinID == BarCtrl->GetWinID())
01012             {
01013                 return pThisBarItem;
01014             }
01015         }
01016     }
01017 
01018     return (NULL);
01019     
01020 //  ERROR2(NULL,"Can't find bar item");
01021 }
01022 
01023 
01024 /********************************************************************************************
01025 
01026 >   BOOL DialogBarOp::DeleteBarItem(CWindowID WinID)
01027 
01028     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01029     Created:    7/4/94
01030     Inputs:     -
01031     Outputs:    -
01032     Returns:    -
01033     Purpose:    Removes and deletes all bar items attached to this bar.
01034                 It's main function is for tidying up after errors during the
01035                 reconstruction of the bars system when the tokenised ASCII
01036                 file is read in.
01037     Errors:     -
01038     SeeAlso:    -
01039 
01040 ********************************************************************************************/
01041 
01042 BOOL DialogBarOp::DeleteBarItem(CWindowID WinID)
01043 {
01044 //  if (IsUserName("MarkN")) TRACE( _T("DeleteAllBarItems()\n"));
01045 
01046     BarItem* pNextBarItem = (BarItem*) BarItemList.GetHead();
01047     BarItem* pThisBarItem;
01048     
01049     while (pNextBarItem != NULL)
01050     {
01051         pThisBarItem = pNextBarItem;
01052         pNextBarItem = (BarItem*) BarItemList.GetNext(pThisBarItem);
01053         if (pThisBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
01054         {
01055             BarControl* BarCtrl = (BarControl*)pThisBarItem;
01056             if(WinID == BarCtrl->GetWinID())
01057             {
01058                 BarItemList.RemoveItem(pThisBarItem);
01059                 delete pThisBarItem;
01060                 return TRUE;
01061             }
01062         }
01063     }
01064     
01065     ERROR2(FALSE,"Can't find bar item to delete");
01066 }
01067 /********************************************************************************************
01068 
01069 >   BarItem* DialogBarOp::GetPtrBarItem(LISTPOS here)
01070 
01071     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01072     Created:    28/3/94
01073     Inputs:     here    = position of the bar item.
01074     Outputs:    -
01075     Returns:    ptr to the bar item at position 'here'
01076     Purpose:    Allows you to get your mits on a bar item.
01077     Errors:     Debug build     - An ENSURE failure if a bar item is not found.
01078                 Retail build    - NULL is returned if a bar item is not found.
01079     SeeAlso:    -
01080 
01081 ********************************************************************************************/
01082 
01083 BarItem* DialogBarOp::GetPtrBarItem(LISTPOS here)
01084 {
01085     BarItem* pBarItem = (BarItem*) BarItemList.FindItem(here);
01086     ENSURE(pBarItem != NULL,"Couldn't get ptr bar item. Item not found.");
01087     
01088     return (pBarItem);
01089 }
01090 
01091 /********************************************************************************************
01092 
01093 >   BarItem* DialogBarOp::GetPtrBarHead()
01094 
01095     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
01096     Created:    20/5/94
01097     Inputs:     -
01098     Outputs:    -
01099     Returns:    ptr to the head of baritem list
01100     Purpose:    Allows you to get your mits on a bar item.
01101     Errors:     Debug build     - An ENSURE failure if a bar item is not found.
01102                 Retail build    - NULL is returned if a bar item is not found.
01103     SeeAlso:    -
01104 
01105 ********************************************************************************************/
01106 
01107 BarItem* DialogBarOp::GetPtrBarHead()
01108 {
01109     BarItem* pBarItem = (BarItem*) BarItemList.GetHead();
01110     //ENSURE(pBarItem != NULL,"Couldn't get ptr bar item. Item not found.");
01111 
01112     return (pBarItem);
01113 }
01114 
01115 /********************************************************************************************
01116 
01117 >   BarItem* DialogBarOp::IsListEmpty()
01118 
01119     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
01120     Created:    20/5/94
01121     Inputs:     -
01122     Outputs:    -
01123     Returns:    TRUE if List is empty FALSE otherwise
01124     Purpose:    -
01125     Errors:     -
01126     SeeAlso:    -
01127 
01128 ********************************************************************************************/
01129 
01130 BOOL DialogBarOp::IsListEmpty()
01131 {
01132     return (BarItemList.IsEmpty());
01133 }
01134 
01135 /********************************************************************************************
01136 
01137 >   BarItem* DialogBarOp::GetPtrBarNext(BarItem * ThisItem )
01138 
01139     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
01140     Created:    20/5/94
01141     Inputs:     -
01142     Outputs:    -
01143     Returns:    ptr to the next item in baritem list
01144     Purpose:    Allows you to get your mits on a bar item.
01145     Errors:     -
01146     SeeAlso:    -
01147 
01148 ********************************************************************************************/
01149 
01150 BarItem* DialogBarOp::GetPtrBarNext(BarItem * ThisItem)
01151 {
01152     BarItem* pBarItem = (BarItem*) BarItemList.GetNext(ThisItem);
01153     return (pBarItem);
01154 }
01155 /********************************************************************************************
01156 
01157 >   BarItem* DialogBarOp::GetPtrBarPrev(BarItem * ThisItem )
01158 
01159     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
01160     Created:    20/5/94
01161     Inputs:     -
01162     Outputs:    -
01163     Returns:    ptr to the previous item in baritem list
01164     Purpose:    Allows you to get your mits on a bar item.
01165     Errors:     -
01166     SeeAlso:    -
01167 
01168 ********************************************************************************************/
01169 
01170 BarItem* DialogBarOp::GetPtrBarPrev(BarItem * ThisItem)
01171 {
01172     BarItem* pBarItem = (BarItem*) BarItemList.GetPrev(ThisItem);
01173     return (pBarItem);
01174 }
01175 
01176 
01177 /********************************************************************************************
01178 
01179 >   BarItem* DialogBarOp::InsertItemBefore(BarItem * ThisItem ,BarItem * newItem)
01180 
01181     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
01182     Created:    20/5/94
01183     Inputs:     -
01184     Outputs:    -
01185     Returns:    -
01186     Purpose:    Allows you to insert a bar item.
01187     Errors:     -
01188     SeeAlso:    -
01189 
01190 ********************************************************************************************/
01191 
01192 BarItem * DialogBarOp::InsertItemBefore(BarItem * here ,BarItem * newItem)
01193 {
01194     ListItem * item;
01195     item = BarItemList.InsertBefore((ListItem*) here, (ListItem*) newItem); 
01196     return (BarItem *)item;
01197 }
01198 
01199 /********************************************************************************************
01200 
01201 >   DWORD DialogBarOp::GetNumBarItems() const
01202 
01203     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01204     Created:    28/3/94
01205     Inputs:     -
01206     Outputs:    -
01207     Returns:    Num bar items in the bar
01208     Purpose:    You can find out just how many pesky bar items are in this bar with this call.
01209     Errors:     -
01210     SeeAlso:    -
01211 
01212 ********************************************************************************************/
01213 
01214 DWORD DialogBarOp::GetNumBarItems() const
01215 {
01216     return (BarItemList.GetCount());
01217 }
01218 
01219 
01220 /********************************************************************************************
01221 
01222 >   void DialogBarOp::SetName(String_32& str)
01223 
01224     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (& Phil)
01225     Created:    12/4/94
01226     Inputs:     Reference to string containing new name for bar
01227     Outputs:    -
01228     Returns:    -
01229     Purpose:    "I name this bar..."
01230     Errors:     -
01231     SeeAlso:    -
01232 
01233 ********************************************************************************************/
01234 
01235 void DialogBarOp::SetName(String_32& str)
01236 {
01237     Name = str;
01238 
01239     // Report changes to bar to any dialog ops...
01240     BROADCAST_TO_CLASS( BarMsg(BAR_CHANGESTATE,this), DialogOp );
01241 
01242 }
01243 
01244 
01245 /********************************************************************************************
01246 
01247    BOOL Gallery::Write(CCLexFile& file)
01248 
01249     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
01250     Created:    12/10/94
01251     Inputs:     file = a file to Write the dialog bar to.
01252     Outputs:    -
01253     Returns:    TRUE if successful, FALSE otherwise
01254     Purpose:    Write the Gallery to the file in a tokenized form
01255     Errors:     -
01256     SeeAlso:    bars.ini
01257 
01258 ********************************************************************************************/
01259 
01260 /*  The old Gallery class is defunct - now replaced by SuperGallery
01261 BOOL Gallery::Write(CCLexFile& file)
01262 {
01263     BOOL ok = TRUE;
01264 
01265     String_256 str;
01266     if (ok) ok = file.PutToken(TokenTable[TOKEN_GALLERY].Token);
01267     
01268     if (ok) ok = file.PutString((String_256)GetRuntimeClass()->m_lpszClassName);
01269 
01270     if (ok) ok = file.PutString(GetName());
01271 
01272     if (ok) ok = file.PutToken(TokenTable[TOKEN_DOCKBAR_FLOAT].Token);
01273 
01274     if (ok) ok = file.PutToken(FloatPos.x);
01275     if (ok) ok = file.PutToken(FloatPos.y);
01276     
01277     file.IncIndent();
01278     
01279     BarItem* pBarItem = (BarItem*) BarItemList.GetHead();
01280     while (pBarItem != NULL && ok)
01281     {
01282         if (ok) ok = file.PutNewLine();
01283     
01284         if (ok) ok = pBarItem->Write(file);
01285     
01286         pBarItem = (BarItem*)BarItemList.GetNext(pBarItem);
01287     }
01288     
01289     file.DecIndent();
01290     
01291     if (ok) ok = file.PutNewLine();
01292 
01293     if (ok) ok = file.PutToken(TokenTable[TOKEN_GALLERY_END].Token);
01294 
01295     if (ok) ok = file.PutNewLine();
01296     if (ok) ok = file.PutNewLine();
01297     return ok;
01298 }
01299 */
01300 
01301 
01302 #ifndef EXCLUDE_GALS
01303 /********************************************************************************************
01304 
01305 >   BOOL SuperGallery::Write(CCLexFile& file)
01306 
01307     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
01308     Created:    12/10/94
01309     Inputs:     file = a file to Write the dialog bar to.
01310     Outputs:    -
01311     Returns:    TRUE if successful, FALSE otherwise
01312     Purpose:    Write the SuperGallery to the file in a tokenized form
01313     Errors:     -
01314     SeeAlso:    bars.ini
01315 
01316 ********************************************************************************************/
01317 
01318 BOOL SuperGallery::Write(CCLexFile& file)
01319 {
01320     BOOL ok = TRUE;
01321 #ifndef EXCLUDE_FROM_XARALX
01322 PORTNOTE("galleries", "Disable Lexfile writing")
01323     String_256 str;
01324     if (ok) ok = file.PutToken(TokenTable[TOKEN_GALLERY].Token);
01325     
01326     if (ok) ok = file.PutString((String_256)GetRuntimeClass()->GetClassName());
01327 
01328     if (ok) ok = file.PutString(GetName());
01329 
01330     if (ok) ok = file.PutToken(TokenTable[TOKEN_DOCKBAR_FLOAT].Token);
01331 
01332     if (ok) ok = file.PutToken(FloatPos.x);
01333     if (ok) ok = file.PutToken(FloatPos.y);
01334     
01335     file.IncIndent();
01336     
01337     BarItem* pBarItem = (BarItem*) BarItemList.GetHead();
01338     while (pBarItem != NULL && ok)
01339     {
01340         if (ok) ok = file.PutNewLine();
01341     
01342         if (ok) ok = pBarItem->Write(file);
01343     
01344         pBarItem = (BarItem*)BarItemList.GetNext(pBarItem);
01345     }
01346     
01347     file.DecIndent();
01348     
01349     if (ok) ok = file.PutNewLine();
01350 
01351     if (ok) ok = file.PutToken(TokenTable[TOKEN_GALLERY_END].Token);
01352 
01353     if (ok) ok = file.PutNewLine();
01354     if (ok) ok = file.PutNewLine();
01355 #endif
01356     return ok;
01357 }
01358 
01359 #endif
01360 
01361 /********************************************************************************************
01362 
01363 >   BOOL DialogBarOp::Write(CCLexFile& file)
01364 
01365     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01366     Created:    28/3/94
01367     Inputs:     file = a file to Write the dialog bar to.
01368     Outputs:    -
01369     Returns:    TRUE if successful, FALSE otherwise
01370     Purpose:    Write the dialog bar to the file in a tokenized form
01371     Errors:     -
01372     SeeAlso:    -
01373 
01374 ********************************************************************************************/
01375 
01376 BOOL DialogBarOp::Write(CCLexFile& file)
01377 {
01378 #pragma message( __LOCMSG__ "DialogBarOp::Write(CCLexFile& file) - do nothing" )
01379     TRACE( _T("Warning - DialogBarOp::Write(CCLexFile& file) called") );
01380 /*  BOOL ok = TRUE;
01381     // we don't want to write out the control bank
01382     if(IsAllBarsOp())
01383         return ok;
01384     String_256 str;
01385 
01386     if (ok) ok = file.PutToken(TokenTable[TOKEN_BAR].Token);
01387     if (ok) ok = file.PutString(Name);
01388     KernelBarPos*   pKernelBarPos = NULL;
01389     
01390     if(IsVisible())
01391         GetMainFrame()->GetBarPosInfo(WindowID,&Dock,&pKernelBarPos);
01392     
01393     switch (Dock)
01394     {
01395         case DOCKBAR_TOP    : str = TokenTable[TOKEN_DOCKBAR_TOP].Token;    break;
01396         case DOCKBAR_BOTTOM : str = TokenTable[TOKEN_DOCKBAR_BOTTOM].Token; break;
01397         case DOCKBAR_LEFT   : str = TokenTable[TOKEN_DOCKBAR_LEFT].Token;   break;
01398         case DOCKBAR_RIGHT  : str = TokenTable[TOKEN_DOCKBAR_RIGHT].Token;  break;
01399         case DOCKBAR_FLOAT  : str = TokenTable[TOKEN_DOCKBAR_FLOAT].Token;  break;
01400         default             : ok  = FALSE;                break;
01401     }
01402 
01403     if (ok) ok = file.PutToken(str);
01404     
01405     if(IsVisible())
01406     {
01407         SetDockBarType(Dock);
01408         if(pKernelBarPos)
01409         {
01410             if (Dock == DOCKBAR_FLOAT)
01411                 SetFloatingCPoint(wxPoint(pKernelBarPos->x,pKernelBarPos->y));
01412             else
01413             {
01414                 SetSlot(pKernelBarPos->Slot);
01415                 SetOffset(pKernelBarPos->Position);
01416             }
01417         }
01418     }
01419     if (Dock == DOCKBAR_FLOAT)
01420     {
01421         if (ok) ok = file.PutToken(FloatPos.x);
01422         if (ok) ok = file.PutToken(FloatPos.y);
01423     }
01424     else
01425     {
01426         if (ok) ok = file.PutToken(Slot);
01427         if (ok) ok = file.PutToken(Offset);
01428     }
01429 
01430     if(IsVisible())
01431     {
01432         if (ok) ok = file.PutToken(TokenTable[TOKEN_VISIBLE].Token);
01433     }
01434     else
01435     {
01436         if (ok) ok = file.PutToken(TokenTable[TOKEN_INVISIBLE].Token);
01437     }
01438 
01439 
01440     file.IncIndent();
01441 
01442     BarItem* pBarItem = (BarItem*) BarItemList.GetHead();
01443     while (pBarItem != NULL && ok)
01444     {
01445         if (ok) ok = file.PutNewLine();
01446         if (ok) ok = pBarItem->Write(file);
01447         pBarItem = (BarItem*)BarItemList.GetNext(pBarItem);
01448     }
01449 
01450     file.DecIndent();
01451     if (ok) ok = file.PutNewLine();
01452 
01453     if (ok) ok = file.PutToken(TokenTable[TOKEN_BAR_END].Token);
01454     if (ok) ok = file.PutNewLine();
01455     if (ok) ok = file.PutNewLine();
01456 
01457     return ok; */
01458 
01459     return false;
01460 }
01461 
01462 
01463 
01464 /********************************************************************************************
01465 
01466 >   BOOL DialogBarOp::Read(CCLexFile& file)
01467 
01468     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01469     Created:    7/4/94
01470     Inputs:     file = a file to read the dialog bar from.
01471     Outputs:    -
01472     Returns:    TRUE if successful, FALSE otherwise
01473     Purpose:    Read the dialog bar from the file in a tokenized form
01474     Errors:     -
01475     SeeAlso:    -
01476 
01477 ********************************************************************************************/
01478 
01479 BOOL DialogBarOp::Read(CCLexFile& file)
01480 {
01481     TokenIndex Token;
01482     const TCHAR* TokenBuf = file.GetTokenBuf();
01483     BOOL ok;
01484 
01485     // Read the bar's name
01486     ok = file.GetSimpleToken();
01487 
01488     if (ok)
01489     {
01490         // The token is either a string or an ID...
01491         LexTokenType TokenType = file.GetTokenType();
01492 
01493         switch (TokenType)
01494         {
01495             case TOKEN_NORMAL:
01496                 {
01497                     INT32 ID = 0;
01498                     ok = (camSscanf(TokenBuf, _T("%li"), &ID) == 1);
01499                     if(ID == 0)
01500                     {
01501                         Name.operator=((const TCHAR*) TokenBuf);
01502                     }
01503                     else
01504                     {
01505                         Name=ID;
01506                     }
01507                 }
01508                 break;
01509     
01510             case TOKEN_STRING:
01511             default:
01512                 Name.operator=((const TCHAR*) TokenBuf);
01513                 break;
01514         }
01515     }
01516 
01517     // Read the bar's docking position
01518     if (ok) ok = file.GetSimpleToken();
01519 
01520     if (ok)
01521     {
01522         Token = FindToken(TokenBuf);
01523         switch (Token)
01524         {
01525             case TOKEN_DOCKBAR_TOP    : Dock = DOCKBAR_TOP;    break;
01526             case TOKEN_DOCKBAR_BOTTOM : Dock = DOCKBAR_BOTTOM; break;
01527             case TOKEN_DOCKBAR_LEFT   : Dock = DOCKBAR_LEFT;   break;
01528             case TOKEN_DOCKBAR_RIGHT  : Dock = DOCKBAR_RIGHT;  break;
01529             case TOKEN_DOCKBAR_FLOAT  : Dock = DOCKBAR_FLOAT;  break;
01530 
01531             default : 
01532                 ok = FALSE;
01533                 TRACE( _T("Unrecognised docking bar position : '%s'"),TokenBuf);
01534                 break;
01535         }
01536 
01537         if (ok)
01538         {
01539             // If the bar is floating, then read in the floating X and Y coords
01540             // Otherwise, read in the bar's docked slot and offset.
01541             if (Dock == DOCKBAR_FLOAT)
01542             {
01543                 ok = file.GetSimpleToken();
01544                 if (ok)
01545                 {   
01546                     ok = (camSscanf(TokenBuf, _T("%li"),&FloatPos.x) == 1);
01547                     if (!ok) TRACE( _T("Expected the bar's floating x pos, but got '%s'\n"),TokenBuf);
01548                 }
01549 
01550                 if (ok) ok = file.GetSimpleToken();
01551                 if (ok)
01552                 {
01553                     ok = (camSscanf(TokenBuf, _T("%li"),&FloatPos.y) == 1);
01554                     if (!ok) TRACE( _T("Expected the bar's floating y pos, but got '%s'\n"),TokenBuf);
01555                 }
01556             }
01557             else
01558             {
01559                 ok = file.GetSimpleToken();
01560                 if (ok)
01561                 {
01562                     ok = (camSscanf(TokenBuf, _T("%li"),&Slot) == 1);
01563                     if (!ok) TRACE( _T("Expected the bar's slot, but got '%s'\n"),TokenBuf);
01564                 }
01565 
01566                 if (ok) ok = file.GetSimpleToken();
01567                 if (ok)
01568                 {
01569                     ok = (camSscanf(TokenBuf, _T("%li"),&Offset) == 1);
01570                     if (!ok) TRACE( _T("Expected the bar's offset, but got '%s'\n"),TokenBuf);
01571                 }
01572             }
01573         }
01574 
01575 
01576         if (ok)
01577         {
01578             // Default to being invisible (stop galleries opening by default)
01579             InitiallyVisible = FALSE;
01580             if ( (GetRuntimeClass() == CC_RUNTIME_CLASS(DialogBarOp)) ||
01581                  (GetRuntimeClass() == CC_RUNTIME_CLASS(SystemBarOp)) )
01582             {   
01583                 ok = file.GetSimpleToken();
01584                 if (ok)
01585                 {
01586                     Token = FindToken(TokenBuf);
01587                     switch (Token)
01588                     {
01589                         case TOKEN_VISIBLE   : InitiallyVisible = TRUE;  break;
01590                         case TOKEN_INVISIBLE : break;
01591                         default : 
01592                             ok = FALSE;
01593                             TRACE( _T("Expected '%s' or '%s', but got '%s'\n"),TokenTable[TOKEN_VISIBLE].Token,TokenTable[TOKEN_INVISIBLE].Token,TokenBuf);
01594                             break;
01595                     }
01596                 }
01597             }
01598 
01599             BOOL finished = FALSE;
01600             while (!finished && ok)
01601             {
01602                 BarItem* pBarItem=NULL;
01603 
01604                 ok = file.GetSimpleToken();
01605                 if (ok)
01606                 {
01607                     Token = FindToken(TokenBuf);
01608 
01609                     switch (Token)
01610                     {
01611                         case TOKEN_BAR_CONTROL   : pBarItem = new BarControl;    break;
01612                         case TOKEN_BAR_SEPARATOR : pBarItem = new BarSeparator;  break;
01613                         case TOKEN_BAR_NEWPAGE   : pBarItem = new BarNewPage;  break;
01614                         case TOKEN_BAR_LINEFEED  : pBarItem = new BarLineFeed;   break;
01615                         case TOKEN_DDECKER_TOP   : pBarItem = new DDeckerTop;   break;
01616                         case TOKEN_DDECKER_BOTTOM: pBarItem = new DDeckerBottom;break;
01617                         case TOKEN_DDECKER_END   : pBarItem = new DDeckerEnd;   break;
01618                         case TOKEN_BAR_END       : // NB! RUNS ON!!!     
01619                         case TOKEN_GALLERY_END   : finished = TRUE;              break;
01620                         default : 
01621                             ok = FALSE;
01622                             TRACE( _T("Unexpected token string : '%s'\n"),TokenBuf);
01623                             break;
01624                     }
01625 
01626                     if (!finished && ok)
01627                     {
01628                         ok = (pBarItem != NULL);
01629                         if (ok) ok = pBarItem->Read(file);
01630                         if (ok) AddBarItem(pBarItem);
01631 
01632                         if (!ok) 
01633                         {
01634                             if (pBarItem != NULL) delete pBarItem;
01635                             DeleteAllBarItems();
01636                             return FALSE;
01637                         }
01638                     }
01639                 }
01640             }
01641         }
01642     }
01643 
01644     if (!ok)
01645     {
01646         // If something when wrong, tell the debug dudes and give as much info as possible
01647         TRACE( _T("\n\nError reading a bar : \n"));
01648         TRACE( _T(" Token buffer = %s\n"),TokenBuf);
01649         TRACE( _T(" Line buffer  = %s\n"),file.GetLineBuf());
01650     }
01651 
01652 
01653     return (ok);
01654 }
01655 
01656 
01657 /********************************************************************************************
01658 
01659 >   BOOL DialogBarOp::Read(LoadRegistryEntries& Loader)
01660 
01661     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01662     Created:    20/2/97
01663     Inputs:     Loader = the class to use to load the data from the registry.
01664     Outputs:    -
01665     Returns:    TRUE if successful, FALSE otherwise
01666     Purpose:    Read the dialog bar or super gallery definition from the registry
01667     Errors:     -
01668     SeeAlso:    -
01669 
01670 ********************************************************************************************/
01671 
01672 BOOL DialogBarOp::Read(LoadRegistryEntries& Loader)
01673 {
01674 #pragma message( __LOCMSG__ "BaseTextClass::PreOpProcessing - do nothing" )
01675     TRACE( _T("Warning - BaseTextClass::PreOpProcessing called") );
01676 /*  BOOL ok = TRUE;
01677 
01678     HKEY hRegKey = Loader.GetRegKey();
01679     if (hRegKey == NULL)
01680     {
01681         //ERROR3("DialogBarOp::Read failed to get registry key");
01682         return FALSE;
01683     }
01684 
01685     // Read the name of the bar from the registry
01686     String_256 BarName;
01687     ok = GetRegString(hRegKey, TEXT("Name"), &BarName);
01688     Name = BarName;
01689 
01690     DockBarType ReadDock = (DockBarType)GetRegInt(hRegKey, TEXT("Dock"));
01691     // check that the value read in is ok
01692     switch (ReadDock)
01693     {
01694         case DOCKBAR_TOP:
01695         case DOCKBAR_BOTTOM:
01696         case DOCKBAR_LEFT:
01697         case DOCKBAR_RIGHT:
01698         case DOCKBAR_FLOAT:
01699             Dock = ReadDock;
01700             break;
01701         default : 
01702             ok = FALSE;
01703             TRACE( _T("Unrecognised bar position : '%d'"),ReadDock);
01704             break;
01705     }
01706 
01707     if (Dock == DOCKBAR_FLOAT)
01708     {
01709         FloatPos.x = GetRegDword(hRegKey, TEXT("x"));
01710         FloatPos.y = GetRegDword(hRegKey, TEXT("y"));
01711     }
01712     else
01713     {
01714         Slot = GetRegDword(hRegKey, TEXT("Slot"));
01715         Offset = GetRegDword(hRegKey, TEXT("Offset"));
01716     }
01717 
01718     INT32 Width = GetRegDword(hRegKey, TEXT("Width"));
01719     INT32 Height = GetRegDword(hRegKey, TEXT("Height"));
01720     if (Width > 0 && Height > 0)
01721     {
01722         BarRect.width  = Width;
01723         BarRect.height = Height;
01724     }
01725 
01726     // Visibility applies to all bars so get the visibility of the bar
01727     InitiallyVisible = GetRegBool(hRegKey, TEXT("Visibility"));
01728 
01729     // Now read in the controls for that bar
01730     String_256 data;
01731     BOOL finished = FALSE;
01732     BarItem* pBarItem = NULL;
01733     while (!finished && ok)
01734     {
01735         // blank our reading string
01736         data.Empty();
01737 
01738         // get the next line from the registry
01739         ok = Loader.LoadNextEntry(&data);
01740         if (ok)
01741         {
01742             // Get the first word up to the next white space character from the string
01743             String_256 FoundToken;
01744             INT32 index = data.FindNextChar(' ', 0);
01745             if (index == -1)
01746             {
01747                 // There is no white space character so use whole word
01748                 FoundToken = data;
01749             }
01750             else
01751             {
01752                 // stick the word into our string
01753                 data.Left(&FoundToken, index);
01754             }
01755 
01756             // cant do a switch, must do it the hard way
01757             if (FoundToken == String_256(TokenTable[TOKEN_BAR_CONTROL].Token))
01758                 pBarItem = new BarControl;
01759             else if (FoundToken == String_256(TokenTable[TOKEN_BAR_SEPARATOR].Token))
01760                 pBarItem = new BarSeparator;
01761             else if (FoundToken == String_256(TokenTable[TOKEN_BAR_NEWPAGE].Token))
01762                 pBarItem = new BarNewPage;
01763             else if (FoundToken == String_256(TokenTable[TOKEN_BAR_LINEFEED].Token))
01764                 pBarItem = new BarLineFeed;
01765             else if (FoundToken == String_256(TokenTable[TOKEN_DDECKER_TOP].Token))
01766                 pBarItem = new DDeckerTop;
01767             else if (FoundToken == String_256(TokenTable[TOKEN_DDECKER_BOTTOM].Token))
01768                 pBarItem = new DDeckerBottom;
01769             else if (FoundToken == String_256(TokenTable[TOKEN_DDECKER_END].Token))
01770                 pBarItem = new DDeckerEnd;
01771             else if (FoundToken == String_256(TokenTable[TOKEN_BAR_END].Token))
01772                 finished = TRUE;  
01773             else if (FoundToken == String_256(TokenTable[TOKEN_GALLERY_END].Token))
01774                 finished = TRUE;
01775             else
01776             {
01777                 ok = FALSE;
01778                 TRACE( _T("Unexpected token string : '%s'\n"),(TCHAR*)FoundToken);
01779             }
01780 
01781             if (!finished && ok && pBarItem != NULL)
01782             {
01783                 // Ask the bar item to parse the rest of its details from the string
01784                 // First transfer the remainder of the string into a new one skipping
01785                 // the space after the details
01786                 String_256 BarItemDef;
01787                 data.Mid(&BarItemDef, index + 1, data.Length() - (index + 1));
01788                 // and now ask the bar item to parse it
01789                 if (ok) ok = pBarItem->Read(&BarItemDef);
01790                 if (ok) AddBarItem(pBarItem);
01791 
01792                 if (!ok) 
01793                 {
01794                     if (pBarItem != NULL) delete pBarItem;
01795                     DeleteAllBarItems();
01796                     return FALSE;
01797                 }
01798             }
01799         }
01800         else
01801             finished = TRUE;
01802     }
01803 
01804     return TRUE; */
01805 
01806     return true;
01807 }
01808 
01809 /********************************************************************************************
01810 
01811 >   BOOL DialogBarOp::Write(SaveRegistryEntries& Saver)
01812 
01813     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01814     Created:    20/2/97
01815     Inputs:     Saver = the class to use to save the data into the registry.
01816     Outputs:    -
01817     Returns:    TRUE if successful, FALSE otherwise
01818     Purpose:    Write the dialog bar to the registry
01819     Errors:     -
01820     SeeAlso:    -
01821 
01822 ********************************************************************************************/
01823 
01824 BOOL DialogBarOp::Write(SaveRegistryEntries& Saver)
01825 {
01826 #pragma message( __LOCMSG__ "DialogBarOp::Write(SaveRegistryEntries& Saver) - do nothing" )
01827     TRACE( _T("Warning - DialogBarOp::Write(SaveRegistryEntries& Saver) called") );
01828 /*  //ERROR2IF(hSubKey == NULL,FALSE,"DialogBarOp::Write bad sub key");
01829 
01830     BOOL ok = TRUE;
01831     // we don't want to write out the control bank
01832     if (IsAllBarsOp())
01833         return ok;
01834 
01835     HKEY hRegKey = Saver.GetRegKey();
01836     if (hRegKey == NULL)
01837     {
01838         ERROR3("DialogBarOp::Write failed to get registry key");
01839         return FALSE;
01840     }
01841 
01842     // save out the name into the registry
01843     ok = ok && SetRegString(hRegKey, TEXT("Name"), Name);
01844 
01845     ok = ok && SetRegString(hRegKey, TEXT("Type"), TokenTable[TOKEN_BAR].Token);
01846 
01847     KernelBarPos* pKernelBarPos = NULL;
01848     if(IsVisible())
01849         GetMainFrame()->GetBarPosInfo(WindowID,&Dock,&pKernelBarPos);
01850 
01851     ok = ok && SetRegInt(hRegKey, TEXT("Dock"), Dock);
01852 
01853     if (IsVisible())
01854     {
01855         SetDockBarType(Dock);
01856         if (pKernelBarPos)
01857         {
01858             if (Dock == DOCKBAR_FLOAT)
01859                 SetFloatingCPoint(wxPoint(pKernelBarPos->x,pKernelBarPos->y));
01860             else
01861             {
01862                 SetSlot(pKernelBarPos->Slot);
01863                 SetOffset(pKernelBarPos->Position);
01864             }
01865         }
01866     }
01867 
01868     if (Dock == DOCKBAR_FLOAT)
01869     {
01870         ok = ok && SetRegDword(hRegKey, TEXT("x"), FloatPos.x);
01871         ok = ok && SetRegDword(hRegKey, TEXT("y"), FloatPos.y);
01872     }
01873     else
01874     {
01875         ok = ok && SetRegDword(hRegKey, TEXT("Slot"), Slot);
01876         ok = ok && SetRegDword(hRegKey, TEXT("Offset"), Offset);
01877     }
01878 
01879     // save the visibility of the bar
01880     ok = ok && SetRegBool(hRegKey, TEXT("Visibility"), IsVisible());
01881 
01882     // save out the items on the bar
01883     // get the first control on this bar
01884     BarItem* pBarItem = (BarItem*) BarItemList.GetHead();
01885     String_256 data;
01886     while (pBarItem != NULL && ok)
01887     {
01888         data.Empty();
01889         // get the bar control to put its details into a string for us
01890         if (ok) ok = pBarItem->Write(&data);
01891         // now write that out to the registry
01892         Saver.SaveNextEntry(&data);
01893 
01894         // get the next control on this bar
01895         pBarItem = (BarItem*)BarItemList.GetNext(pBarItem);
01896     }
01897 
01898     // The saver will automatically shut down our use of the key
01899     // so just return the result of the saving to the user
01900     return ok; */
01901 
01902     return false;
01903 }
01904 
01905 #ifndef EXCLUDE_GALS
01906 /********************************************************************************************
01907 
01908 >   BOOL SuperGallery::Write(SaveRegistryEntries& Saver)
01909 
01910     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01911     Created:    20/2/97
01912     Inputs:     Saver = the class to use to save the data into the registry.
01913     Outputs:    -
01914     Returns:    TRUE if successful, FALSE otherwise
01915     Purpose:    Write the SuperGallery to the registry
01916     Errors:     -
01917     SeeAlso:    -
01918 
01919 ********************************************************************************************/
01920 
01921 BOOL SuperGallery::Write(SaveRegistryEntries& Saver)
01922 {
01923 #pragma message( __LOCMSG__ "SuperGallery::Write(SaveRegistryEntries& Saver) - do nothing" )
01924     TRACE( _T("Warning - SuperGallery::Write(SaveRegistryEntries& Saver) called") );
01925 /*  BOOL ok = TRUE;
01926 
01927     HKEY hRegKey = Saver.GetRegKey();
01928     if (hRegKey == NULL)
01929     {
01930         ERROR3("SuperGallery::Write failed to get registry key");
01931         return FALSE;
01932     }
01933 
01934     // save out the name into the registry
01935     ok = ok && SetRegString(hRegKey, TEXT("Name"), GetName());
01936 
01937     String_256 str = GetRuntimeClass()->m_lpszClassName;
01938     ok = ok && SetRegString(hRegKey, TEXT("ClassName"), str);
01939 
01940     ok = ok && SetRegString(hRegKey, TEXT("Type"), TokenTable[TOKEN_GALLERY].Token);
01941 
01942     KernelBarPos* pKernelBarPos = NULL;
01943     GetMainFrame()->GetBarPosInfo(WindowID,&Dock,&pKernelBarPos);
01944     SetDockBarType(Dock);
01945     if (pKernelBarPos)
01946     {
01947         if (Dock == DOCKBAR_FLOAT)
01948             SetFloatingCPoint(wxPoint(pKernelBarPos->x,pKernelBarPos->y));
01949         else
01950         {
01951             SetSlot(pKernelBarPos->Slot);
01952             SetOffset(pKernelBarPos->Position);
01953         }
01954     }
01955 
01956     ok = ok && SetRegInt(hRegKey, TEXT("Dock"), Dock);
01957 
01958     if (Dock == DOCKBAR_FLOAT)
01959     {
01960         ok = ok && SetRegDword(hRegKey, TEXT("x"), FloatPos.x);
01961         ok = ok && SetRegDword(hRegKey, TEXT("y"), FloatPos.y);
01962     }
01963     else
01964     {
01965         ok = ok && SetRegDword(hRegKey, TEXT("Slot"), Slot);
01966         ok = ok && SetRegDword(hRegKey, TEXT("Offset"), Offset);
01967     }
01968 
01969     wxRect BarRect = GetMainFrame()->GetDockBar(Dock)->GetBarRect(WindowID);
01970 
01971     if (BarRect.width > 0 && BarRect.height > 0)
01972     {
01973         ok = ok && SetRegDword(hRegKey, TEXT("Width"), BarRect.width);
01974         ok = ok && SetRegDword(hRegKey, TEXT("Height"), BarRect.height);
01975     }
01976     else if (GallerySize.x > 0 && GallerySize.y > 0)
01977     {
01978         ok = ok && SetRegDword(hRegKey, TEXT("Width"), GallerySize.x);
01979         ok = ok && SetRegDword(hRegKey, TEXT("Height"), GallerySize.y);
01980     }
01981 
01982     // save the visibility of the bar
01983     ok = ok && SetRegBool(hRegKey, TEXT("Visibility"), IsVisible());
01984     
01985     // save out the items on the bar
01986     // get the first control on this bar
01987     BarItem* pBarItem = (BarItem*) BarItemList.GetHead();
01988     String_256 data;
01989     while (pBarItem != NULL && ok)
01990     {
01991         data.Empty();
01992         // get the bar control to put its details into a string for us
01993         if (ok) ok = pBarItem->Write(&data);
01994         // now write that out to the registry
01995         Saver.SaveNextEntry(&data);
01996     
01997         // get the next control on this bar
01998         pBarItem = (BarItem*)BarItemList.GetNext(pBarItem);
01999     }
02000     
02001     // The saver will automatically shut down our use of the key
02002     // so just return the result of the saving to the user
02003     return ok; */
02004 
02005     return false;
02006 }
02007 
02008 #endif // EXCLUDE_GALS
02009 
02010 /********************************************************************************************
02011 
02012 >   BOOL DialogBarOp::MakeControlBank()
02013 
02014     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
02015     Created:    24/5/95
02016     Inputs:     -
02017     Outputs:    -
02018     Returns:    TRUE if successful, FALSE otherwise
02019     Purpose:    Build a control bar that contains all the controls defined in the bars.ini
02020                 resource
02021     Errors:     -
02022     SeeAlso:    -
02023 
02024 ********************************************************************************************/
02025 
02026 BOOL DialogBarOp::MakeControlBank()
02027 {
02028 #pragma message( __LOCMSG__ "DialogBarOp::MakeControlBank - do nothing" )
02029     TRACE( _T("Warning - DialogBarOp::MakeControlBank called") );
02030 /*  // create the bar
02031     if(DialogBarOp::AllBarsOp == NULL)
02032     {
02033         AllBarsOp = new DialogBarOp(String_32(_R(IDS_CONTROLBANKNAME)));
02034         AllBarsOp->SetDockBarType(DOCKBAR_FLOAT);
02035         AllBarsOp->InitiallyVisible = FALSE;
02036     }
02037     ERROR2IF(AllBarsOp==NULL,FALSE,"NULL AllBarsOp");
02038     
02039     BOOL ok = TRUE,open=FALSE,finished=FALSE,InBar= FALSE; 
02040     INT32 Count = 0 ;
02041 
02042     CCResTextFile file; // Resource File
02043     DialogBarOpCreate BarCreate;
02044 
02045     if (ok) ok = open = file.open(_R(IDM_DEFAULT_BARS), _R(IDT_CAM_BARS_RES));
02046     if(!open)
02047         return FALSE;
02048     
02049     file.InitLexer();                   // Initialise lexing routines
02050     file.SetDelimiters("\r\n");         // Set token delimiting characters
02051     file.SetCommentMarker(';');         // Set comment marker char
02052     file.SetWhitespace(" \t");          // Set whitespace chars
02053     file.SetStringDelimiters("\"\"");   // Set string delimiters
02054 
02055     TokenIndex Token;
02056     const TCHAR* TokenBuf = file.GetTokenBuf();
02057     BarItem* pBarItem;
02058 
02059     while (ok)
02060     {
02061         pBarItem = NULL;
02062         ok = file.GetSimpleToken();
02063 
02064         if (ok)
02065         {
02066             Token = FindToken(TokenBuf);
02067             switch (Token)
02068             {
02069                 case TOKEN_BAR           : 
02070                     InBar = TRUE; break;
02071                 case TOKEN_BAR_CONTROL   : 
02072                     if(InBar)
02073                         pBarItem = new BarControl; Count ++;  break;
02074                 case TOKEN_BAR_SEPARATOR : 
02075                     if(InBar)                   
02076                         pBarItem = new BarSeparator;  break;
02077                 case TOKEN_BAR_END       :
02078                     InBar = FALSE ; break;
02079             }
02080 
02081 
02082             if (pBarItem && InBar)
02083             {
02084                 if( Count == 11 )
02085                 {
02086                     BarLineFeed* pBarItem = new BarLineFeed;
02087                     AllBarsOp->AddBarItem(pBarItem);
02088                     Count =0;
02089                 }
02090             
02091                 if (ok) ok = pBarItem->Read(file);
02092                 if (ok) AllBarsOp->AddBarItem(pBarItem);
02093                 if (!ok) 
02094                 {
02095                     if (pBarItem != NULL) delete pBarItem;
02096                     AllBarsOp->DeleteAllBarItems();
02097                     if (open) file.close();
02098                     return FALSE;
02099                 }
02100             }
02101         
02102         }// end if ok
02103     }// end while
02104     
02105     if(open) file.DeinitLexer();
02106     
02107     if (open) file.close();
02108     return TRUE; */
02109 
02110     return false;
02111 }
02112 
02113 /********************************************************************************************
02114 
02115 >   static BOOL DialogBarOp::Init()
02116 
02117     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02118     Created:    18/2/94
02119     Returns:    TRUE if all went OK, FALSE otherwise
02120     Purpose:    Adds the operation to the list of all known operations
02121 
02122 ********************************************************************************************/
02123 
02124 BOOL DialogBarOp::Init()
02125 {
02126     BOOL ok;
02127     ok = (RegisterOpDescriptor(
02128                                 0, 
02129                                 _R(IDS_MARKN_EMPTY),
02130                                 CC_RUNTIME_CLASS(DialogBarOp), 
02131                                 OPTOKEN_DLGBAROP,
02132                                 NULL,       // No GetState fn
02133                                 0,          /* help ID */
02134                                 _R(IDBBL_NOOP), /* bubble ID */
02135                                 0           /* bitmap ID */
02136                                 )
02137             ); 
02138 
02139     if (Camelot.DeclareSection( _T("DebugFlags"), 10))
02140         Camelot.DeclarePref( NULL, _T("ShowSystemBars"), &ShowSystemBars, FALSE, TRUE );
02141     if (Camelot.DeclareSection(_T("BarsPath"),2))
02142         Camelot.DeclarePref(_T("BarsPath"), _T("DefaultBarsConfigPath"), &DefaultBarsConfigPath);
02143     if (Camelot.DeclareSection(_T("BarsVer"),2))
02144         Camelot.DeclarePref(_T("BarsVer"), _T("BarsVersion"), &BarsVersion);
02145     return (ok);
02146 }
02147 
02148 
02149 /********************************************************************************************
02150 
02151 >   static OpState DialogBarOp::GetState(String_256* Description, OpDescriptor*)
02152 
02153     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02154     Created:    18/2/94
02155     Outputs:    Description - GetState fills this string with an approriate description
02156                 of the current state of the push tool
02157     Returns:    The state of the operation, so that menu items (ticks and greying can be
02158                 done properly
02159     Purpose:    Find out the state of the operation at the specific time
02160 
02161 ********************************************************************************************/
02162 
02163 OpState DialogBarOp::GetState(String_256* Description, OpDescriptor*)
02164 {
02165     OpState State;
02166     
02167     return State;
02168 }
02169 
02170 /********************************************************************************************
02171 
02172 >   static BOOL DialogBarOp::WriteBars(CCLexFile& file)
02173 
02174     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02175     Created:    6/4/94
02176     Inputs:     file = a file object
02177     Outputs:    -
02178     Returns:    TRUE if successful, FALSE otherwise
02179     Purpose:    Writes all the bars in tokenized form to the given file
02180     Errors:     -
02181     SeeAlso:    -
02182 
02183 ********************************************************************************************/
02184 
02185 BOOL DialogBarOp::WriteBars(CCLexFile& file)
02186 {
02187     BOOL            ok = TRUE;
02188     List*           pList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogBarOp));
02189     DialogBarOp*    pDialogBarOp = (DialogBarOp*)pList->GetHead();
02190 
02191     while (pDialogBarOp != NULL && ok)
02192     {
02193         if (!pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(SystemBarOp))
02194             &&!pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(InformationBarOp)))
02195             if(!pDialogBarOp->IsListEmpty())
02196                 ok = pDialogBarOp->Write(file);
02197         pDialogBarOp = (DialogBarOp*)pList->GetNext(pDialogBarOp);
02198     }
02199 
02200     return (ok);
02201 }
02202 
02203 /********************************************************************************************
02204 
02205 >   void DialogBarOp::SetCurrentOrientation(Orientation BarDirection) 
02206 
02207     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02208     Created:    16/4/94
02209     Inputs:     BarDirection: The orientation of the bar 
02210     Outputs:    -
02211     Returns:    -
02212     Purpose:    To inform the DialogBarOp of its current orientation (horizontal or vertical)
02213     Errors:     -
02214     SeeAlso:    -
02215 
02216 ********************************************************************************************/
02217 
02218 
02219 void DialogBarOp::SetCurrentOrientation(Orientation Orient) 
02220 {
02221     BarOrientation = Orient;    
02222 }
02223 
02224 /********************************************************************************************
02225 
02226 >   MsgResult DialogBarOp::Message(Msg* Msg)
02227 
02228     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02229     Created:    16/4/94
02230     Inputs:     Msg: The message to handle
02231     Outputs:    -                  
02232     Returns:    -
02233     Purpose:    The default DialogBarOp Message handler 
02234                 This should be overriden for InformationBar DialogBarOps which will have a
02235                 structure identical to DialogOps. 
02236     Errors:     -
02237     SeeAlso:    -
02238 
02239 ********************************************************************************************/
02240 
02241 MsgResult DialogBarOp::Message(Msg* Msg)
02242 {
02243     BOOL DestroyWindow = FALSE; // Set to TRUE if we should destroy the bars window  
02244     // allow Cancel / BarDeath messages through even for ops with no window
02245     if(MESSAGE_IS_A(Msg,KeyMsg))
02246     {
02247         KeyMsg* KMsg = (KeyMsg*)Msg;
02248         if( KMsg->pKeyPress->GetVirtKey() == CAMKEY(ESCAPE) || 
02249             KMsg->pKeyPress->GetVirtKey() == CAMKEY(CANCEL) )
02250         {
02251             if(BaseBar::EscPressed( KMsg->pKeyPress->IsPress() ))
02252                 return EAT_MSG;
02253         }
02254         else if( KMsg->pKeyPress->GetVirtKey() == CAMKEY(CONTROL) )
02255         {
02256             if(BaseBar::CtlPressed( KMsg->pKeyPress->IsPress() ))
02257                 return EAT_MSG;
02258         }
02259         else if( KMsg->pKeyPress->GetVirtKey() == CAMKEY(MENU) )
02260         {
02261             if(BaseBar::AltPressed( KMsg->pKeyPress->IsPress() ))
02262                 return EAT_MSG;
02263         }
02264         
02265     }   
02266 
02267     else if (IS_OUR_DIALOG_MSG(Msg)||
02268          Msg->IsKindOf(CC_RUNTIME_CLASS(DialogMsg)) &&
02269             ((DialogMsg*)Msg)->DlgMsg == DIM_BAR_DEATH )
02270 
02271     {
02272         
02273         // It's a dialog message 
02274         DialogMsg* DlgMsg = (DialogMsg*)Msg; 
02275         if(DlgMsg->DlgMsg==DIM_BAR_DEATH)
02276         {
02277             if(IS_KIND_OF(InformationBarOp))
02278                 return (DLG_EAT_IF_HUNGRY(DlgMsg)); 
02279         
02280             if(IsAllBarsOp())
02281                 return (DLG_EAT_IF_HUNGRY(DlgMsg)); 
02282         }            
02283 
02284 // The equivalend of the following now done in DialogOp so "bar" controls (i.e. ones with
02285 // associated OpDescriptors can live in classes derived from DialogOp (not DialogBarOp)
02286 #if 0
02287         OpDescriptor* OpDesc = NULL;
02288         BarControl* BarCtrl = NULL;
02289 
02290         // Traverse the list of all BarItems
02291         for (BarItem* CurrentBarItem = (BarItem*)BarItemList.GetHead();
02292              CurrentBarItem != NULL; 
02293              CurrentBarItem = (BarItem*)BarItemList.GetNext((ListItem*)CurrentBarItem ))
02294         {
02295             if (CurrentBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
02296             {
02297                 BarCtrl = (BarControl*)CurrentBarItem;
02298                 BarControlInfo BarCtrlInfo = BarCtrl->GetBarControlInfo(BarOrientation == Horizontal);  
02299                    
02300                 // Obtain the OpDescriptor
02301                 OpDesc = (BarCtrl)->
02302                         GetOpDescriptor(BarOrientation == Horizontal);
02303                 
02304                 //ENSURE(OpDesc != NULL, "DialogBarOp has a NULL OpDescriptor"); 
02305                 if (OpDesc != NULL)
02306                 {
02307                     OpDesc->SetBarControlInfo(BarCtrlInfo);
02308                     SendMessageToBarControl(OpDesc, DlgMsg, BarCtrlInfo.ControlID, BarCtrl->GetUniqueGadgetID() );
02309                 }
02310             }
02311         }
02312 #endif
02313         
02314         if (DlgMsg->DlgMsg == DIM_CANCEL||DlgMsg->DlgMsg == DIM_BAR_DEATH)
02315         {
02316 PORTNOTE("other", "Removed GetBarPosInfo usage")
02317 #ifndef EXCLUDE_FROM_XARALX
02318             KernelBarPos*   pKernelBarPos;
02319             DockBarType     Dock;
02320             if (GetMainFrame()->GetBarPosInfo(WindowID,&Dock,&pKernelBarPos))
02321             {
02322                 SetDockBarType(Dock);
02323                 if (Dock == DOCKBAR_FLOAT)
02324                     SetFloatingCPoint(wxPoint(pKernelBarPos->x,pKernelBarPos->y));
02325                 else
02326                 {
02327                     SetSlot(pKernelBarPos->Slot);
02328                     SetOffset(pKernelBarPos->Position);
02329                 }
02330             }
02331 #endif
02332             
02333             // This is new and may cause problems - it used to only be set on
02334             // a cancel message to a control but now overides default close handling
02335             // allowing bars and galleries to be closed on a single click
02336 
02337             DestroyWindow = TRUE;
02338         }
02339         
02340         if (DestroyWindow && WindowID != NULL)
02341         {
02342             // Destroy the bar window                            
02343             CCamApp::GetDlgManager()->Delete(WindowID, this);
02344             WindowID = NULL;
02345         }
02346 
02347         if (DlgMsg->DlgMsg == DIM_CANCEL||DlgMsg->DlgMsg == DIM_BAR_DEATH)
02348         {
02349             // Report bar is closing to interested parties
02350             BROADCAST_TO_CLASS(BarMsg(BAR_CLOSE,this),DialogOp);
02351             // This should only be called if we really want to destroy the bar list
02352             // So far only used when we are about to read in another *.ini file 
02353         }
02354         if(DlgMsg->DlgMsg == DIM_BAR_DEATH)
02355         {
02356         
02357             End();
02358             return(OK);
02359         }
02360         return DialogOp::Message(Msg);
02361     
02362     //  return (DLG_EAT_IF_HUNGRY(DlgMsg));  
02363     
02364     }
02365         
02366     // We must destroy the dialog if the application is dying
02367     else if (MESSAGE_IS_A(Msg,DeathMsg))
02368     {
02369         // Camelot is ending, so end the Op
02370         End();
02371         return OK;
02372         // ** Note: We do not need to send an OpDescControlDestroyMsg to all OpDescriptors on
02373         // receipt of a DeathMsg as a DIM_CANCEL message should have already sent these !
02374     }
02375 
02376     return DialogOp::Message(Msg);
02377 }
02378 
02379 /********************************************************************************************
02380 
02381 >   UINT32 DialogBarOp::GetUniqueID()
02382 
02383     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
02384     Created:    23/4/94
02385     Inputs:     -
02386     Outputs:    -
02387     Returns:    -
02388     Purpose:    This function returns a uniqueID  i.e. highest + 1. 
02389     Errors:     -
02390     SeeAlso:    DialogBarOp::UpdateStateOfAllBars
02391 
02392 
02393 ********************************************************************************************/
02394 
02395 UINT32 DialogBarOp::GetUniqueID()
02396 {
02397     UINT32 HighestSoFar = 100;
02398     UINT32 FoundID =0;
02399 
02400     if (WindowID != NULL)  // If the WindowID is NULL then the DialogBar has not been created
02401     {
02402         for (BarItem* CurrentBarItem = (BarItem*)BarItemList.GetHead();
02403                  CurrentBarItem != NULL; 
02404                  CurrentBarItem = (BarItem*)BarItemList.GetNext( (ListItem*)CurrentBarItem ))
02405         {
02406             if (CurrentBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
02407             {
02408                 BarControl* BarCtrl = (BarControl*)CurrentBarItem;
02409                 FoundID = BarCtrl->GetUniqueGadgetID();
02410                 if(FoundID >HighestSoFar)
02411                     HighestSoFar = FoundID;                 
02412                 
02413             }
02414         }
02415     } 
02416     return HighestSoFar + 1;
02417 }
02418 
02419 /********************************************************************************************
02420 
02421 >   virtual void DialogBarOp::UpdateState()
02422 
02423     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02424     Created:    23/4/94
02425     Inputs:     -
02426     Outputs:    -
02427     Returns:    -
02428     Purpose:    This function gets called during idle time. It calls the GetState fn associated
02429                 with each controls OpDescriptor. The button gets disabled if the operation
02430                 is not executable. 
02431     Errors:     -
02432     SeeAlso:    DialogBarOp::UpdateStateOfAllBars
02433 
02434 
02435 ********************************************************************************************/
02436 
02437 void DialogBarOp::UpdateState()
02438 {
02439     if (WindowID != NULL)  // If the WindowID is NULL then the DialogBar has not been created
02440     {
02441         String_256 Desc; 
02442         // Call the GetState fn for all controls
02443         for (BarItem* CurrentBarItem = (BarItem*)BarItemList.GetHead();
02444                  CurrentBarItem != NULL; 
02445                  CurrentBarItem = (BarItem*)BarItemList.GetNext( (ListItem*)CurrentBarItem ))
02446         {
02447             if (CurrentBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
02448             {
02449                 BarControl* BarCtrl = (BarControl*)CurrentBarItem;
02450                
02451                 // Obtain the OpDescriptor
02452                 OpDescriptor* OpDesc = (BarCtrl)->
02453                         GetOpDescriptor(BarOrientation == Horizontal);
02454 
02455                 if (OpDesc != NULL)
02456                 {
02457                     OpState NewState = OpDesc->GetOpsState(&Desc); 
02458 
02459                     // if a description has been returned
02460                     /*
02461                     // Special disabled string description stuff cannot be implemented yet
02462                     // it requires shield technology
02463                     if (!ButtonDesc.IsEmpty() && (newState.Greyed))
02464                     {
02465                         String_256 disabledStub(_R(IDS_DISABLED_BECAUSE));
02466             
02467                         WhyDisabled = disabledStub;
02468 
02469                         // Set up reason why item is disabled
02470                         WhyDisabled += ButtonDesc;
02471                     }
02472                     */
02473                     // Set the controls greyed state
02474                     if (BarCtrl->IsEnabled() != !NewState.Greyed)
02475                     {
02476                         // The controls state has changed 
02477                         EnableGadget(BarCtrl->
02478                             GetUniqueGadgetID(), !NewState.Greyed);
02479                         BarCtrl->SetEnabledState(!NewState.Greyed); 
02480                     }
02481                     // set the control's ticked state
02482                     // First determine if the control can be ticked
02483                     if (IsGadgetTickable(BarCtrl->GetUniqueGadgetID()))
02484                     {
02485                         // All tickable gadget's must have a BOOL value (TRUE = ticked)
02486                         BOOL Selected = GetLongGadgetValue(BarCtrl->GetUniqueGadgetID(),0,1);
02487                         if(Selected != NewState.Ticked)
02488                         {
02489                             // We need to change the ticked state
02490                             SetBoolGadgetSelected(BarCtrl->GetUniqueGadgetID(),NewState.Ticked!=0);
02491                         }
02492                     }
02493  
02494                 }
02495             }
02496         }
02497     }
02498 }
02499 
02500 
02501 /********************************************************************************************
02502 
02503 >   static void DialogBarOp::UpdateStatesOfAllBars()
02504 
02505 
02506     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02507     Created:    23/4/94
02508     Inputs:     -
02509     Outputs:    -
02510     Returns:    -
02511     Purpose:    This static function gets called during idle time
02512                 If the system state has changed then it updates the enabled state of all 
02513                 visible DialogBars 
02514     Errors:     -
02515     SeeAlso:    DialogBarOp::UpdateState
02516     SeeAlso:    DialogBarOp::SetSystemStateChanged
02517 
02518 ********************************************************************************************/
02519 
02520 void DialogBarOp::UpdateStateOfAllBars()
02521 {
02522     // Determine if we need to update the state of the bars.
02523     if (ShouldUpdateBarState())
02524     {
02525     /*  if (IsUserName("Simon"))
02526         {
02527             TRACE( _T("The state of the bars is being updated")); 
02528         }
02529       */
02530         List* pBarList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogBarOp));
02531         ListItem*  pCurrentBar = pBarList->GetHead();
02532         while (pCurrentBar != NULL)
02533         {
02534             ((DialogBarOp*)pCurrentBar)->UpdateState(); 
02535             pCurrentBar = pBarList->GetNext(pCurrentBar);
02536         }
02537         // The bars now reflect the system state 
02538         SetSystemStateChanged(FALSE); 
02539     }           
02540 }
02541 
02542 
02543 
02544 /********************************************************************************************
02545 
02546 >   void DialogBarOp::Delete()
02547 
02548     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (using Simon code)
02549     Created:    29/4/94
02550     Inputs:     -
02551     Outputs:    -
02552     Returns:    -
02553     Purpose:    The DialogBarOp Delete method
02554                 Deletes the window and resets WindowID to NULL.
02555     Errors:     -
02556     SeeAlso:    -
02557 
02558 ********************************************************************************************/
02559 
02560 
02561 void DialogBarOp::Delete()
02562 {
02563     if (WindowID != NULL)
02564     {
02565         PORTNOTETRACE("dialog","Warning - DialogBarOp::Delete called and disabled");
02566 #ifndef EXCLUDE_FROM_XARALX
02567         KernelBarPos*   pKernelBarPos;
02568         DockBarType     Dock;
02569 
02570         if (GetMainFrame()->GetBarPosInfo(WindowID,&Dock,&pKernelBarPos))
02571         {
02572             SetDockBarType(Dock);
02573             if (Dock == DOCKBAR_FLOAT)
02574                 SetFloatingCPoint(wxPoint(pKernelBarPos->x,pKernelBarPos->y));
02575             else
02576             {
02577                 SetSlot(pKernelBarPos->Slot);
02578                 SetOffset(pKernelBarPos->Position);
02579             }
02580         }
02581 #endif
02582         CCamApp::GetDlgManager()->Delete(WindowID, this);
02583         WindowID = NULL;
02584     }
02585 }
02586 /********************************************************************************************
02587 
02588 >   static BOOL DialogBarOp::SetValidPath(String_256 FileName)
02589 
02590     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
02591     Created:    20/10/94
02592     Inputs:     FileName    This dictates whether we look for the full screen or normal
02593                             mode file. Should be either "Normal" or "Clean" when "Clear"
02594                             corresponds to the full screen operation.
02595     Outputs:    -
02596     Returns:    TRUE if successful
02597     Purpose:    looks for bars.con files  first in prefs path then in windows dir
02598                 if found sets ValidPath and return TRUE else return FALSE 
02599     Errors:     
02600 
02601     Note : These functions will fail badly with path names > 255
02602 
02603 ********************************************************************************************/
02604 
02605  BOOL DialogBarOp::SetValidPath(String_256 FileName)
02606  {
02607 #pragma message( __LOCMSG__ "DialogBarOp::SetValidPath - do nothing" )
02608     TRACE( _T("Warning - DialogBarOp::SetValidPath called") );
02609 /*   // new naming convention = PRODUCT_BASENAME.cle/nor
02610     // I've left the above intact as I can't get hold of the files 
02611     // I need to do this properly - this function is called with either "normal" or "clean"
02612 
02613     // Updated for doing the CorelXARA product 28/9/95
02614     // File was called XStudio.nor or .cle (or XViewer.nor or .cle)
02615     // We will now call them all CorelX##.ini where #### in this case is either BN or BF 
02616     String_256 File( _T("") );
02617     if(!FileName.CompareTo( _T("normal") ))
02618         File = PRODUCT_BARSNORMAL_INIFILE;
02619     else
02620         File = PRODUCT_BARSFULL_INIFILE;
02621 
02622 #if defined(__WXMSW__)
02623     const UINT32 cchMaxPath = _MAX_PATH;
02624 #else
02625     const UINT32 cchMaxPath = 1 + pathconf( "/", _PC_PATH_MAX );
02626 #endif
02627     TCHAR *szBuff = static_cast<TCHAR *>( alloca( cchMaxPath * sizeof(TCHAR) ) );
02628     CCDiskFile file;
02629     BOOL ok = FALSE;
02630 
02631     // first check prefs path
02632 
02633     ok = DefaultBarsConfigPath.Length() > 0;
02634     if (ok)
02635     {
02636         String_256 Temp = DefaultBarsConfigPath;
02637         Temp += _T("\\");
02638         Temp += File;
02639         camStrcpy( szBuff, Temp );
02640         TRACEUSER( "chris", _T("Loading Bars from Prefs path\n"));
02641         if (_taccess(szBuff, 0) == 0)
02642         {
02643             // yes - use this name
02644             ValidPath.SetPathName(szBuff);
02645             return TRUE;
02646         }
02647     }
02648     
02649     // either there is no pref or we can't find the file . try windows directory
02650 
02651     UINT32 Len = GetWindowsDirectory((LPSTR)szBuff, cchMaxPath - 1);
02652     if ((Len > 0) && (Len < cchMaxPath))
02653     {
02654         String_256 Temp = _T("\\") + File;
02655         camStrcat(szBuff, Temp );
02656         TRACEUSER( "chris", _T("Loading Bars from Windows path\n"));
02657         if (_taccess(szBuff, 0) == 0)
02658         {
02659             // yes - use this name
02660             ValidPath.SetPathName(szBuff);
02661             return TRUE;
02662         }
02663     }
02664 
02665     // oops .. Can't find a bars file anywhere !!! */
02666     return FALSE;
02667  }
02668 
02669 /********************************************************************************************
02670 
02671 >   static BOOL DialogBarOp::LoadDefaultBars()
02672 
02673     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> & MarkN
02674     Created:    20/4/94
02675     Inputs:     -
02676     Outputs:    -
02677     Returns:    TRUE if successful
02678     Purpose:    loads in, and then creates initial bars
02679                 This function must get called after the docking bars have been created 
02680     Errors:     -
02681     SeeAlso:    LoadBarsFromFile,LoadBarsFromRes,CreateBars
02682 
02683 ********************************************************************************************/
02684 
02685 BOOL DialogBarOp::LoadDefaultBars()
02686 {  
02687     BOOL ok=TRUE;
02688     if (ok)  ok = LoadBarsFromRes();    // When we are able to read BARS.INI from file, delete
02689                                         // this line and uncomment the two above
02690     if (ok)  ok = CreateBars();
02691     return ok;
02692 
02693 }
02694 
02695 /********************************************************************************************
02696 
02697 >   static BOOL DialogBarOp::LoadNamedBars(String_256 FileName)
02698 
02699     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> & MarkN
02700     Created:    20/4/94
02701     Inputs:     FileName    This dictates whether we look for the full screen or normal
02702                             mode file. Should be either "Normal" or "Clean" when "Clear"
02703                             corresponds to the full screen operation.
02704     Outputs:    -
02705     Returns:    TRUE if successful
02706     Purpose:    loads in, and then creates initial bars
02707                 This function must get called after the docking bars have been created 
02708     Errors:     -
02709     SeeAlso:    LoadBarsFromFile,LoadBarsFromRes,CreateBars
02710 
02711 ********************************************************************************************/
02712 
02713 BOOL DialogBarOp::LoadNamedBars(String_256 FileName)
02714 {  
02715 #pragma message( __LOCMSG__ "DialogBarOp::LoadNamedBars - do nothing" )
02716     TRACE( _T("Warning - DialogBarOp::LoadNamedBars called") );
02717 /*  // Simon - In dire emergency please uncomment this back in - Chris.
02718         
02719 //  if (ok)  ok = LoadBarsFromRes();    // When we are able to read BARS.INI from file, delete
02720 //                                      // this line and uncomment the two above
02721 //  if (ok)  ok = CreateBars();
02722 //  return ok;
02723     
02724     BOOL ok=FALSE;
02725     BOOL LoadFromRes =FALSE;
02726     BOOL BadBarsFile=FALSE;
02727     BOOL FileOpened = FALSE;
02728     
02729     #ifndef STANDALONE
02730     if(!ReadResVersion())
02731     {
02732         // look for bars config file
02733         ok = LoadNamedBarFile((TCHAR *)FileName,&FileOpened);
02734 
02735         if(FileOpened)
02736             // Note if it's a bad bars file
02737             BadBarsFile=!ok;
02738     }
02739     else
02740         ok = FALSE;
02741     #endif
02742 
02743     // Failed so we'd better load from resources !!
02744     if(!ok)
02745     {
02746         // kill all bars ( except infobar at the mo..) in case any were created with a bad bars file
02747         if (BadBarsFile)
02748         {
02749             BROADCAST_TO_CLASS(DialogMsg(NULL, DIM_BAR_DEATH, NULL ),DialogBarOp);
02750         }
02751 
02752         // load default bars from the bound in resource files
02753         LoadFromRes = ok = LoadBarsFromRes();
02754         ERROR2IF(!ok,FALSE,"Serious error - unable to load bars from bound in resource files");
02755     }
02756 
02757     if (ok) ok = CreateBars();
02758 
02759     // I dont like this very much but it gets round the need to distribute 2 config files
02760     // we can probably lose this for the release - note it should also go if we shift up 
02761     // to multiple config files Chris. 
02762     if(ok)
02763     {
02764         if(!(FileName.CompareTo("clean")))
02765         {
02766             if(!GetMainFrame()->IsFullScreenMode())
02767             {
02768                 GetMainFrame()->DoFullScreenMode(TRUE);
02769                 if(LoadFromRes)
02770                 {
02771                     GetMainFrame()->ShowStatusBar(FALSE);
02772                     GetMainFrame()->ShowScrollBars(FALSE);  
02773                 }
02774             }
02775         }
02776     }
02777 
02778     // If we come across a bad bars file, tell the user
02779     ERROR1IF(BadBarsFile,ok,_R(IDE_BADBARSFILE));
02780 
02781     return (ok); */
02782 
02783     return false;
02784 }
02785 
02786 
02787 
02788 /********************************************************************************************
02789 
02790 >   static BOOL DialogBarOp::LoadBars()
02791 
02792     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> & MarkN
02793     Created:    20/4/94
02794     Inputs:     -
02795     Outputs:    -
02796     Returns:    TRUE if successful
02797     Purpose:    loads in, and then creates initial bars
02798                 This function must get called after the docking bars have been created 
02799     Errors:     -
02800     SeeAlso:    LoadBarsFromFile,LoadBarsFromRes,CreateBars
02801 
02802 ********************************************************************************************/
02803 
02804 BOOL DialogBarOp::LoadBars()
02805 {  
02806 #pragma message( __LOCMSG__ "DialogBarOp::LoadBars - do nothing" )
02807     TRACE( _T("Warning - DialogBarOp::LoadBars called") );
02808 //  return LoadNamedBars(GetMainFrame()->InFullScreenMode() ? "clean" : "normal");
02809 
02810     return false;
02811 }
02812 
02813 /********************************************************************************************
02814 
02815 >   static BOOL DialogBarOp::WipeRegistrySettingsForBar(String_256 * pBarName)
02816 
02817     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
02818     Created:    28/2/97
02819     Inputs:     -
02820     Outputs:    -
02821     Returns:    TRUE if successful
02822     Purpose:    Wipes bar registry settings for the named section.
02823                 Called if the user selects default settings.
02824     Errors:     -
02825 
02826 
02827 ********************************************************************************************/
02828 
02829 BOOL DialogBarOp::WipeRegistrySettingsForBar(TCHAR * pBarName)
02830 {
02831 #pragma message( __LOCMSG__ "DialogBarOp::WipeRegistrySettingsForBar - do nothing" )
02832     TRACE( _T("Warning - DialogBarOp::WipeRegistrySettingsForBar called") );
02833 /*  ERROR2IF(pBarName == NULL,FALSE,"WipeRegistrySettingsForBar bar section name");
02834     // Wipe all the bars settings from the registry.
02835     // We need to do sub-directories first as you cannot wipe a directory which has sub-directories
02836     // (well it is rumoured that you cannot do this on NT but it works on 95!)
02837     
02838     // Wipe the named sub sections
02839     String_256 MainKeyName = pBarName;
02840     HKEY hRegKey = OpenRegKey(hAppStateRegKey, MainKeyName);
02841     // Was that section there?
02842     if (hRegKey != NULL)
02843     {
02844         // yes so wipe the named sub-sections
02845         DeleteRegKey(hRegKey, PRODUCT_REGISTRYKEY_BARSETTINGS );
02846         DeleteRegKey(hRegKey, TokenTable[TOKEN_INFO_BAR].Token );
02847 
02848         // delete all the numbered sections which contain the bar definitions
02849         BOOL Finished = FALSE;
02850         INT32 i = 0;
02851         TCHAR buf[10];
02852         while (!Finished)
02853         { 
02854             // Make up the bar number for this index
02855             wsprintf(buf, TEXT("%d"), i + 1);
02856             String_256 name(buf);
02857             if (!DeleteRegKey(hRegKey, name))
02858                 Finished = TRUE;
02859 
02860             i++;
02861         }
02862 
02863         CloseRegKey(hRegKey);
02864 
02865         // Wipe the main key
02866         DeleteRegKey(hAppStateRegKey, MainKeyName);
02867     }
02868 
02869     return TRUE; */
02870 
02871     return true;
02872 }
02873 
02874 /********************************************************************************************
02875 
02876 >   static BOOL DialogBarOp::WipeBarFiles()
02877 
02878     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
02879     Created:    26/10/94
02880     Inputs:     -
02881     Outputs:    -
02882     Returns:    TRUE if successful
02883     Purpose:    Wipes bar config files from disc - called if the user selects default settings.
02884     Errors:     -
02885 
02886 
02887 ********************************************************************************************/
02888 
02889 BOOL DialogBarOp::WipeBarFiles()
02890 {  
02891 //  BOOL ok = TRUE;
02892     BOOL UnlinkOK = TRUE;
02893 
02894 #pragma message( __LOCMSG__ "DialogBarOp::WipeBarFiles - do nothing" )
02895     TRACE( _T("Warning - DialogBarOp::WipeBarFiles called") );
02896 /*#ifdef SAVE_PREFS_TO_REGISTRY
02897     // Wipe all the bars settings from the registry.
02898     // We need to do sub-directories first as you cannot wipe a directory which has sub-directories
02899     // (well it is rumoured that you cannot do this on NT but it works on 95!)
02900     WipeRegistrySettingsForBar(PRODUCT_REGISTRYKEY_BARSFULL);
02901     WipeRegistrySettingsForBar(PRODUCT_REGISTRYKEY_BARSNORMAL);
02902 
02903     // We must wipe the ini file as well as otherwise when the code checks to 
02904     // see if the registry settings and then falls back on the ini file if they
02905     // are not there, then we wont be using the default settings.
02906 #endif
02907 
02908     String_256 FilePath;
02909     //Find the path to a valid xstudio.nor file
02910     ok = SetValidPath("normal");
02911     // the file must exist... so we can delete it
02912     if(ok)
02913     {   
02914         FilePath = ValidPath.GetPath();
02915         // delete the file
02916         if(_unlink(FilePath) !=0)
02917             UnlinkOK = FALSE;
02918     }
02919 
02920     //Find the path to a valid xstudio.cle file
02921     ok = SetValidPath("clean");
02922     if(ok)
02923     {
02924         FilePath = ValidPath.GetPath();
02925         // delete the file
02926         if(_unlink(FilePath) !=0)
02927             UnlinkOK = FALSE;
02928     
02929     }
02930     
02931     ERROR2IF(UnlinkOK==FALSE,FALSE,"Couldn't delete a bars config file"); */
02932     
02933     return UnlinkOK;
02934 }
02935 
02936 /********************************************************************************************
02937 
02938 >   static BOOL DialogBarOp::LoadNamedBarFile(String_256 FileName ,BOOL * Opened)
02939 
02940     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
02941     Created:    26/10/94
02942     Inputs:     FileName - file to load
02943                 Opened   - flag.. did we open the file
02944     Outputs:    -
02945     Returns:    TRUE if successful
02946     Purpose:    loads in bar defs from *.confile.
02947                 This function must get called after the docking bars have been created 
02948     Errors:     -
02949     SeeAlso:    LoadBars,LoadBarsFromRes,CreateBars
02950 
02951 
02952 ********************************************************************************************/
02953 
02954 BOOL DialogBarOp::LoadNamedBarFile(String_256 FileName ,BOOL * Opened)
02955 {  
02956 #pragma message( __LOCMSG__ "DialogBarOp::LoadNamedBarFile - do nothing" )
02957     TRACE( _T("Warning - DialogBarOp::LoadNamedBarFile called") );
02958 /*  BOOL ok = TRUE;
02959     BOOL open = FALSE;
02960     UINT32 NumBars = 0;
02961     UINT32 NumDockingBars = 0; 
02962     
02963 #ifdef SAVE_PREFS_TO_REGISTRY
02964     // Try and read the separate bars settings from the registry
02965     // First work out the section name we require and then open it up ready for reading
02966     String_256 KeySectionName;
02967     if (!FileName.CompareTo("normal"))
02968         KeySectionName = PRODUCT_REGISTRYKEY_BARSNORMAL;
02969     else
02970         KeySectionName = PRODUCT_REGISTRYKEY_BARSFULL;
02971 
02972     HKEY hRegKey = OpenRegKey(hAppStateRegKey, KeySectionName);
02973     // Was that section there?
02974     // If we failed then read bars from the ini file
02975     if (hRegKey != NULL)
02976     {
02977         // Say that we have opened the file and try to read in definitions
02978         // so if we fail then the caller gets a chance to destruct things.
02979         *Opened = TRUE;
02980         // We opened the key so its present. Read all the sub sections from there.
02981         ok = ok && ReadDockingBarsFromRegistry(hRegKey);
02982         ok = ok && ReadWorkSpaceInfoFromRegistry(hRegKey);
02983         ok = ok && ReadBarsFromRegistry(hRegKey);
02984         CloseRegKey(hRegKey);
02985     }
02986     else
02987 #endif
02988     {
02989         // If the main ini file is in the registry then don't even think about using ini files.
02990         // This is because the version number of the bars is stored in the ini file!!!! We will
02991         // have already checked the one stored in the registry rather than the one in the
02992         // ini file. So this would be an unsafe operation.
02993         // If we are not using the registry then we will have used the ini file version number
02994         // and so it is safer.
02995         if (CCamApp::AreWeUsingTheRegistry())
02996             return FALSE;
02997         
02998         // Read all of the data from the ini file
02999 
03000         //Find the path to a valid *.con file
03001         ok = SetValidPath((TCHAR *)FileName);
03002         
03003         if(!ok)
03004             return ok;
03005 
03006         PathName path  = ValidPath;
03007         CCDiskFile file;
03008         DialogBarOpCreate BarCreate;
03009         if (ok) ok = open = file.open(path,ios::in);
03010         if (ok) ok = ReadBarsFromFile(file,BarCreate,&NumBars,&NumDockingBars);
03011         if (ok) ok = ((NumBars > 0) && (NumDockingBars == NUM_DOCKBARS));
03012         if (open) file.close();
03013         if(!ok)
03014             TRACEUSER( "Neville", _T("Can't find a bars file - loading from resources\n"));
03015         * Opened = open;
03016     }
03017 
03018     return ok; */
03019 
03020     return false;
03021 }
03022 
03023 /********************************************************************************************
03024 
03025 >   static BOOL DialogBarOp::ReadResVersion()
03026 
03027     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
03028     Created:    26/4/94
03029     Inputs:     -
03030     Outputs:    -
03031     Returns:    TRUE if bars.ini is a new revision
03032     Purpose:    Reads Revision number of bars.ini checks whether this is the same as
03033                 the version in prefs 
03034     Errors:     -
03035     SeeAlso:    LoadBarsFromFile,LoadBars,CreateBars
03036 
03037 ********************************************************************************************/
03038 
03039 BOOL DialogBarOp::ReadResVersion()
03040 {  
03041 #pragma message( __LOCMSG__ "DialogBarOp::ReadResVersion- do nothing" )
03042     TRACE( _T("Warning - DialogBarOp::ReadResVersion called") );
03043 /*  BOOL ok = TRUE,open=FALSE; 
03044     BOOL NewVersion = FALSE;
03045     CCResTextFile file; // Resource File
03046 
03047     if (ok) ok = open = file.open(_R(IDM_DEFAULT_BARS), _R(IDT_CAM_BARS_RES));
03048     String_64 Version;
03049     String_64 Temp;
03050     ok = file.InitLexer();              // Initialise lexing routine
03051     file.SetStringDelimiters("$$");
03052     const TCHAR* TokenBuf = file.GetTokenBuf();
03053     if (ok) ok = file.GetSimpleToken();
03054     if (ok) Temp=((const TCHAR*) TokenBuf);
03055     // this is a bit naff but RCS adds an extra white space at the end of the
03056     // the string when it substitutes
03057     Temp.Left(&Version,Temp.Length()-1);
03058     if(Version.CompareTo(BarsVersion))
03059     {
03060         camStrcpy(BarsVersion,Version);
03061         NewVersion = TRUE;
03062     }
03063     if (open) file.close();
03064 
03065     return NewVersion; */
03066 
03067     return false;
03068 }
03069 
03070 /********************************************************************************************
03071 
03072 >   static BOOL DialogBarOp::LoadBarsFromRes()
03073 
03074     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03075     Created:    26/4/94
03076     Inputs:     -
03077     Outputs:    -
03078     Returns:    TRUE if successful
03079     Purpose:    loads in bars from the bars.ini  resource that's bound into the exe.
03080                 This function must get called after the docking bars have been created 
03081     Errors:     -
03082     SeeAlso:    LoadBarsFromFile,LoadBars,CreateBars
03083 
03084 ********************************************************************************************/
03085 
03086 BOOL DialogBarOp::LoadBarsFromRes()
03087 {  
03088     BOOL ok = TRUE;
03089 //if (IsUserName("MarkN")) TRACE( _T("DialogBarOp::LoadBarsFromRes()\n"));
03090 #pragma message( __LOCMSG__ "DialogBarOp::ReadResVersion- do nothing" )
03091     TRACE( _T("Warning - DialogBarOp::ReadResVersion called") );
03092 /*
03093     BOOL open=FALSE; 
03094     UINT32 NumBars;
03095     UINT32 NumDockingBars;
03096     CCResTextFile file; // Resource File
03097     DialogBarOpCreate BarCreate;
03098 
03099     if (ok) ok = open = file.open(_R(IDM_DEFAULT_BARS), _R(IDT_CAM_BARS_RES));
03100     if (ok) ok = ReadBarsFromFile(file,BarCreate,&NumBars,&NumDockingBars);
03101     if (ok) ok = ((NumBars > 0) && (NumDockingBars == NUM_DOCKBARS));
03102     
03103     if (open) file.close(); */
03104 
03105     return ok; 
03106 }
03107 
03108 /********************************************************************************************
03109 
03110 >   static BOOL DialogBarOp::CreateBars()
03111 
03112     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03113     Created:    26/4/94
03114     Inputs:     -
03115     Outputs:    -
03116     Returns:    TRUE if successful
03117     Purpose:    Creates initial bars loaded in using either LoadBarsFromFile or
03118                 LoadBarsFromRes.
03119                 Only DialogBarOps are created. All derived classes are ignored, such
03120                 as InformationBarOps and SystemBarOps.
03121                 This function must get called after the docking bars have been created 
03122     Errors:     -
03123     SeeAlso:    LoadBarsFromFile,LoadBarsFromRes,LoadBars
03124 
03125 ********************************************************************************************/
03126 
03127 BOOL DialogBarOp::CreateBars()
03128 {
03129 
03130 
03131     List*       pList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogBarOp));
03132     ListItem*   pListItem = pList->GetHead();
03133 //  ListItem*   pListItem = pList->GetTail();
03134 
03135     OILFixedDockingBar::DoNotTidyBars ();
03136 
03137     while (pListItem != NULL)
03138     {
03139         DialogBarOp* pDialogBarOp = (DialogBarOp*)pListItem;
03140 
03141         
03142 //      TCHAR* p=pDialogBarOp->Name;
03143 
03144         if  (   (pDialogBarOp->GetRuntimeClass() == CC_RUNTIME_CLASS(DialogBarOp))
03145     /*      #ifdef _DEBUG
03146             ||  (   pDialogBarOp->GetRuntimeClass() == CC_RUNTIME_CLASS(SystemBarOp)
03147                     && ShowSystemBars
03148                 )
03149             #endif*/
03150             || (pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
03151             )                                   
03152         {
03153             if ((pDialogBarOp->GetNumBarItems() > 0) && pDialogBarOp->InitiallyVisible)
03154             {
03155                 if (!pDialogBarOp->Create())
03156                 {
03157                     ENSURE(FALSE, "Failed to create bar"); 
03158                     return FALSE; 
03159                 }
03160             }
03161         }
03162 //      pListItem = pList->GetPrev(pListItem);
03163         pListItem = pList->GetNext(pListItem);
03164     }
03165 
03166     OILFixedDockingBar::AllowTidyBars ();
03167 
03168     return TRUE; 
03169 }
03170 
03171 /********************************************************************************************
03172 
03173 >   static DialogBarOp* DialogBarOp::FindDialogBarOp(String_32& DialogBarOpName, INT32 limit = -1)
03174 
03175     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03176     Created:    26/4/94
03177     Inputs:     DialogBarOpName = Name of op to find
03178                 limit   if -1 then it means use the whole name for the check (default)
03179                         if > 0 then limit the check to the limit number of characters
03180     Outputs:    -
03181     Returns:    ptr to DialogBarOp
03182                 NULL is returned if not found
03183     Purpose:    Looks for a given DialogBarOp by using its name 
03184     Errors:     -
03185     SeeAlso:    -
03186 
03187 ********************************************************************************************/
03188 
03189 DialogBarOp* DialogBarOp::FindDialogBarOp(String_32& DialogBarOpName, INT32 limit)
03190 {
03191     List*           pList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogBarOp));
03192     DialogBarOp*    pDialogBarOp = (DialogBarOp*)pList->GetHead();
03193     
03194     String_32       OpName;
03195     while (pDialogBarOp != NULL)
03196     {
03197         if (limit > 0)
03198             pDialogBarOp->Name.Left(&OpName, limit);
03199         else
03200             OpName = pDialogBarOp->Name;
03201         
03202         if (OpName == DialogBarOpName)
03203             return (pDialogBarOp);
03204 
03205         pDialogBarOp = (DialogBarOp*)pList->GetNext(pDialogBarOp);
03206     }
03207 
03208     return NULL;
03209 }
03210 
03211 
03212 /********************************************************************************************
03213 
03214     static UINT32 DialogBarOp::FindUniqueBarNumber()
03215 
03216     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
03217     Created:    26/4/94
03218     Inputs:     DialogBarOpName = Name of op to find
03219     Outputs:    -
03220     Returns:    unique nuber to put in new bar name
03221     Purpose:    - 
03222     Errors:     -
03223     SeeAlso:    -
03224 
03225 ********************************************************************************************/
03226 
03227 UINT32 DialogBarOp::FindUniqueBarNumber()
03228 {
03229     List*           pList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogBarOp));
03230     DialogBarOp*    pDialogBarOp = (DialogBarOp*)pList->GetHead();
03231     UINT32 Highest = 0;
03232     String_32 name;
03233     String_32 prefix;
03234     String_32 number;
03235     while (pDialogBarOp != NULL)
03236     {
03237         name = pDialogBarOp->GetName();
03238         name.Left(&prefix,3);
03239         if(!prefix.CompareTo(_T("Bar")))
03240         {   
03241             //Highest ++;
03242             name.Right(&number,name.Length()-4);
03243             TCHAR *pszMark;
03244             UINT32 SoFar = camStrtol( (const TCHAR *)number, &pszMark, 10 );
03245             if(SoFar>=Highest)
03246                 Highest = SoFar;
03247         }
03248         pDialogBarOp = (DialogBarOp*)pList->GetNext(pDialogBarOp);
03249     }
03250 
03251     return Highest+1;
03252 } 
03253 
03254 /********************************************************************************************
03255 
03256 >   static DialogBarOp* DialogBarOp::FindDialogBarOp(String_32& DialogBarOpName)
03257 
03258     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03259     Created:    26/4/94
03260     Inputs:     DialogBarOpName = Name of op to find
03261     Outputs:    -
03262     Returns:    ptr to DialogBarOp
03263                 NULL is returned if not found
03264     Purpose:    Looks for a given DialogBarOp by using its name 
03265     Errors:     -
03266     SeeAlso:    -
03267 
03268 ********************************************************************************************/
03269 
03270 DialogBarOp* DialogBarOp::FindDialogBarOp( UINT_PTR ID )
03271 {
03272     List*           pList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogBarOp));
03273     DialogBarOp*    pDialogBarOp = (DialogBarOp*)pList->GetHead();
03274 
03275     while (pDialogBarOp != NULL)
03276     {
03277         if (pDialogBarOp->WindowID == (CWindowID)ID)
03278             return (pDialogBarOp);
03279 
03280         pDialogBarOp = (DialogBarOp*)pList->GetNext(pDialogBarOp);
03281     }
03282 
03283     return NULL;
03284 } 
03285 
03286 
03287 //-----
03288 
03289 #ifdef _DEBUG
03290 
03291 #include "speedtst.h"
03292 
03293 #define MY_FILE_NAME "C:\\bars.ini"
03294 
03295 void DialogBarOp::TestStart()
03296 {
03297 /*
03298     if (!IsUserName("MarkN")) return;
03299 
03300     TRACE( _T("DialogBarOp::TestStart()\n"));
03301 
03302     BOOL ok = TRUE;
03303     String_256 str = MY_FILE_NAME;
03304     PathName path;
03305     CCDiskFile file;
03306 
03307     if (ok) ok = path.SetPathName(str);
03308     if (ok) ok = file.open(path,ios::in);
03309     if (ok) ok = ReadBarsFromFile(file);
03310     if (ok) file.close();
03311 
03312     {
03313         List*       pList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogBarOp));
03314         ListItem*   pListItem = pList->GetHead();
03315         INT32         c=0;
03316         while (pListItem != NULL)
03317         {
03318             c++;
03319             ((DialogBarOp *)pListItem )->Create();
03320             TRACE( _T("pListItem = %p\n"),pListItem);
03321             pListItem = pList->GetNext(pListItem);
03322         }
03323 
03324         TRACE( _T("Num dialogbarops = %d\n"),c);
03325     }
03326 */
03327 }
03328 
03329 
03330 
03331 void DialogBarOp::TestEnd()
03332 {
03333 #pragma message( __LOCMSG__ "DialogBarOp::TestEnd - do nothing" )
03334     TRACE( _T("Warning - DialogBarOp::TestEnd called") );
03335 /*  if( !Error::IsUserName("MarkN") )
03336         return;
03337 
03338     TRACE( _T("DialogBarOp::TestEnd()\n"));
03339 
03340     BOOL ok = TRUE;
03341     String_256 str = MY_FILE_NAME;
03342     PathName path;
03343     CCDiskFile file;
03344     if (ok) ok = path.SetPathName(str);
03345     if (ok) ok = file.open(path,ios::out);
03346     if (ok) ok = DialogBarOp::WriteBarsToFile(file);
03347     if (ok) file.close(); */
03348 }
03349 
03350 /*
03351     DialogBarOp* pTestBar = new DialogBarOp;
03352     if (pTestBar == NULL) return;
03353 
03354     String_32 str = "xxxxxx";
03355     pTestBar->SetName(str);
03356     pTestBar->SetDockBarType(DOCKBAR_BOTTOM);
03357 
03358     BarControl*   pBarCtrl1=NULL;
03359     BarControl*   pBarCtrl2=NULL;
03360     BarControl*   pBarCtrl3=NULL;
03361     BarSeparator* pBarSep=NULL;
03362     BarLineFeed*  pBarLF=NULL;
03363 
03364     pBarCtrl1   = new BarControl;
03365     pBarCtrl2   = new BarControl;
03366     pBarCtrl3   = new BarControl;
03367     pBarSep     = new BarSeparator;
03368     pBarLF      = new BarLineFeed;
03369 
03370     if (pBarCtrl1!=NULL && pBarCtrl2!=NULL && pBarCtrl3!=NULL && pBarSep!=NULL && pBarLF!=NULL)
03371     {
03372         SimpleBarControl SBCtrl;
03373         SBCtrl.BarCtrlInfo.ResourceID   = 0;
03374         SBCtrl.BarCtrlInfo.ControlID    = 0;
03375         SBCtrl.BarCtrlInfo.ToolID       = 0;
03376 
03377         SBCtrl.pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SNAPTOGRID);    
03378         pBarCtrl1->SetHorzControl(SBCtrl);
03379         pBarCtrl1->SetVertControl(SBCtrl);
03380         pTestBar->AddBarItem(pBarCtrl1);
03381 
03382         pTestBar->AddBarItem(pBarSep);
03383 
03384         SBCtrl.pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SNAPTOGRID);    
03385         pBarCtrl2->SetHorzControl(SBCtrl);
03386         pBarCtrl2->SetVertControl(SBCtrl);
03387         pTestBar->AddBarItem(pBarCtrl2);
03388 
03389         pTestBar->AddBarItem(pBarLF);
03390 
03391         SBCtrl.pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHOWGRID);  
03392         pBarCtrl3->SetHorzControl(SBCtrl);
03393         pBarCtrl3->SetVertControl(SBCtrl);
03394         pTestBar->AddBarItem(pBarCtrl3);
03395     }
03396 
03397     if (pBarCtrl1 != NULL) delete pBarCtrl1;
03398     if (pBarCtrl2 != NULL) delete pBarCtrl2;
03399     if (pBarCtrl3 != NULL) delete pBarCtrl3;
03400     if (pBarSep   != NULL) delete pBarSep;
03401     if (pBarLF    != NULL) delete pBarLF;
03402 
03403     pTestBar->End();
03404 */
03405 
03406 /*
03407 
03408     if (IsUserName("MarkN"))
03409     {
03410         BOOL ok = TRUE;
03411     
03412         CCDiskFile file(256);
03413         String_256 pathnamestr = "C:\\bars.ini";
03414         PathName pathname(pathnamestr);
03415 
03416         ok = file.open(pathname,ios::out,filebuf::sh_write);
03417     
03418         if (ok)
03419         {
03420             String_256 str = "Case 3453657\n";
03421             file.write(str,str.Length());
03422         }
03423         else
03424         {
03425             TRACE( _T("Unable to open %s\n"),(TCHAR*)pathnamestr);
03426         }
03427         file.close();
03428     }
03429 
03430 }
03431 */
03432 
03433 #endif // _DEBUG
03434 
03435 
03436 /********************************************************************************************
03437 
03438 >   static BOOL DialogBarOp::WriteNamedBars(String_256 str)
03439 
03440     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
03441     Created:    26/4/94
03442     Inputs:     File name
03443     Outputs:    -
03444     Returns:    Error condition
03445     Purpose:    writes current bars set up to *.ini file 
03446     Errors:     write failed
03447     SeeAlso:    -
03448 
03449 ********************************************************************************************/
03450 
03451 BOOL DialogBarOp::WriteNamedBars(String_256 FileName)
03452 {
03453 
03454 #ifdef STANDALONE
03455 
03456     // Standalone doesn't need to write any bars out
03457     return TRUE;
03458 
03459 #else
03460     BOOL ok = TRUE;
03461 
03462 #ifdef SAVE_PREFS_TO_REGISTRY
03463     // Check to see which section we are trying to access and then open the relevant key
03464     // for that section
03465     String_256 KeySectionName;
03466     if (!FileName.CompareTo("normal"))
03467         KeySectionName = PRODUCT_REGISTRYKEY_BARSNORMAL;
03468     else
03469         KeySectionName = PRODUCT_REGISTRYKEY_BARSFULL;
03470 
03471     HKEY hRegKey = CreateRegKey(hAppStateRegKey, KeySectionName);
03472     if (hRegKey != NULL)
03473     {
03474         // Write the workspace settings into the registry
03475         // These use the BarSettings sections
03476         ok = ok && WriteWorkSpaceInfoToRegistry(hRegKey);
03477         ok = ok && WriteDockingBarsToRegistry(hRegKey);
03478         // These write out to their own sections
03479         ok = ok && WriteBarsToRegistry(hRegKey);
03480     }
03481     CloseRegKey(hRegKey);
03482 
03483 #else   
03484     // File was called XStudio.nor or .cle (or XViewer.nor or .cle)
03485     // We will now call them all CorelX##.ini where #### in this case is either BN or BF
03486     String_256 File("");
03487 
03488     if(!FileName.CompareTo( _T("normal") ))
03489         File = PRODUCT_BARSNORMAL_INIFILE;
03490     else
03491         File = PRODUCT_BARSFULL_INIFILE;
03492 
03493     // first look for a prefs path
03494 #if defined(__WXMSW__)
03495     const UINT32 cchMaxPath = _MAX_PATH;
03496 #else
03497     const UINT32 cchMaxPath = 1 + pathconf( "/", _PC_PATH_MAX );
03498 #endif
03499     TCHAR *szBuff = static_cast<TCHAR *>(alloca( cchMaxPath * sizeof(TCHAR) ));
03500     if (DefaultBarsConfigPath.Length() > 0)
03501     {
03502         camStrcpy( szBuff, DefaultBarsConfigPath );
03503         camStrcpy( szBuff, _T("\\") );
03504         camStrcpy( szBuff, File );
03505     }
03506     // no entry use windows dir
03507     else
03508     {
03509 #if defined(__WXMSW__)
03510         UINT32 Len = GetWindowsDirectory(szBuff, cchMaxPath - 1);
03511 #else
03512         camStrcpy( szBuff, _T("~/.XaraLX") );
03513         UINT32 Len = camStrlen( szBuff );
03514 #endif
03515         
03516         if ((Len > 0) && (Len < cchMaxPath))
03517         {
03518             camStrcat( szBuff, _T("\\") );
03519             camStrcat( szBuff, File );
03520         }   
03521     }
03522 
03523     PathName path;
03524 
03525     CCDiskFile file;
03526     if (ok) ok = path.SetPathName(szBuff);
03527     if (ok) ok = file.open(path,ios::out);
03528     if (ok) ok = DialogBarOp::WriteBarsToFile(file);
03529     if (ok) file.close();
03530     
03531     // the write has failed probably due to  disc full
03532     // we'll delete the corrupt file and set an error.
03533 #pragma message( __LOCMSG__ "Removed _tremove on non-Windows OS" )
03534     #if defined(__WXMSW__)
03535     if(!ok)
03536         _tremove(szBuff);
03537     #endif
03538     
03539     ERROR1IF(!ok,FALSE,_R(IDE_CANT_SAVE_BARS));
03540 #endif
03541 
03542     // return the result to the caller
03543     return ok;
03544 #endif
03545 }
03546 
03547 //------------------------------------------------------------------------------------------
03548 //------------------------------------------------------------------------------------------
03549 //------------------------------------------------------------------------------------------
03550 //------------------------------------------------------------------------------------------
03551 //------------------------------------------------------------------------------------------
03552 
03553 // -----------------------------------------------------------------------------------------
03554 // BarControlBaseMethods
03555 // Called to obtain the bar item's BubbleID
03556 
03557 /********************************************************************************************
03558 
03559 >   UINT32 BarControlBase::GetBubbleID(BOOL Horz)
03560 
03561     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
03562     Created:    19/5/94
03563     Inputs:     Horz: The orientation of the bar
03564     Outputs:    The controls current BubbleID
03565     Returns:    Bubble help resource string associated with the control
03566     Purpose:    In derived classes will return the bubble help resource string currently
03567                 associated with the control. In the base class an ENSURE occurs.
03568     Errors:     -
03569     SeeAlso:    -
03570 
03571 ********************************************************************************************/
03572 
03573 UINT32 BarControlBase::GetBubbleID(BOOL Horz)
03574 {
03575     ENSURE(FALSE, "Pure virtual BarControlBase::GetBubbleID called"); 
03576     return 0;   
03577 }
03578   
03579 
03580 // ( Bodge) Don't no what this is (If it's the status bar description then it will
03581 //  be required) ?  (Mark could you confirm this)
03582 
03583 /********************************************************************************************
03584 
03585 >   UINT32 BarControlBase::GetStatusID(BOOL Horz)
03586 
03587     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
03588     Created:    19/5/94
03589     Inputs:     Horz: The orientation of the bar
03590     Outputs:    -
03591     Returns:    -
03592     Purpose:    
03593     Errors:     -
03594     SeeAlso:    -
03595 
03596 ********************************************************************************************/
03597 
03598 UINT32 BarControlBase::GetStatusID(BOOL Horz)
03599 {
03600     ENSURE(FALSE, "Pure virtual BarControlBase::GetStatusID called"); 
03601     return 0;
03602 } 
03603 
03604 // -----------------------------------------------------------------------------------------
03605 // BarControlMethods
03606 
03607 /********************************************************************************************
03608 
03609 >   void BarControl::SetHorzOpDesc(OpDescriptor* pOpDesc)
03610 
03611     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03612     Created:    19/4/94
03613     Inputs:     pOpDesc = ptr to op desc to use for horizontal control
03614     Outputs:    -
03615     Returns:    -
03616     Purpose:    Sets the info regarding the horizontal version of this control
03617     Errors:     -
03618     SeeAlso:    -
03619 
03620 ********************************************************************************************/
03621 
03622 void BarControl::SetHorzOpDesc(OpDescriptor* pOpDesc)
03623 {
03624     SetOpDesc(&Horizontal,pOpDesc);
03625 }
03626 
03627 /********************************************************************************************
03628 
03629 >   void BarControl::SetVertOpDesc(OpDescriptor* pOpDesc)
03630 
03631     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03632     Created:    19/4/94
03633     Inputs:     pOpDesc = ptr to op desc to use for vertical control
03634     Outputs:    -
03635     Returns:    -
03636     Purpose:    Sets the info regarding the vertical version of this control
03637     Errors:     -
03638     SeeAlso:    -
03639 
03640 ********************************************************************************************/
03641 
03642 void BarControl::SetVertOpDesc(OpDescriptor* pOpDesc)
03643 {
03644     SetOpDesc(&Vertical,pOpDesc);
03645 }
03646 
03647 
03648 /********************************************************************************************
03649 
03650 >   void BarControl::SetOpDesc(SimpleBarControl* pSimpleBC, OpDescriptor* pOpDesc)
03651 
03652     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03653     Created:    19/4/94
03654     Inputs:     pSimpleBC = the simple bar control that should be updated      
03655                 pOpDesc = ptr to op desc to use for given control 
03656     Outputs:    -
03657     Returns:    -
03658     Purpose:    Sets the info for this control using the given op desc
03659                 It's intended that this be called when a bar control is added
03660                 to a bar via the toolbar dialogue interface.
03661     Errors:     -
03662     SeeAlso:    -
03663 
03664 ********************************************************************************************/
03665 
03666 void BarControl::SetOpDesc(SimpleBarControl* pSimpleBC, OpDescriptor* pOpDesc)
03667 {
03668     // Get ptr to default control info
03669     const BarControlInfo* pBarCtrlInfo = pOpDesc->GetBarControlInfo();
03670 
03671     // Copy the default info stored in the OpDesc bar ctrl info into
03672     // this bar control.
03673     pSimpleBC->BarCtrlInfo.ResourceID   = pBarCtrlInfo->ResourceID;
03674     pSimpleBC->BarCtrlInfo.ControlID    = pBarCtrlInfo->ControlID;
03675     pSimpleBC->BarCtrlInfo.ToolID       = pBarCtrlInfo->ToolID;
03676 
03677     // Copy ptr to the OpDesc.
03678     pSimpleBC->pOpDesc                  = pOpDesc;
03679 }
03680 
03681 
03682 /********************************************************************************************
03683 
03684 >   BarControlInfo BarControl::GetBarControlInfo(BOOL horz)
03685 
03686     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03687     Created:    28/3/94
03688     Inputs:     horz - if TRUE  = the info on the horz version of this control is returned
03689                      - if FALSE = the info on the vert version of this control is returned
03690     Outputs:    -
03691     Returns:    A BarControlInfo class describing the horz/vert control completely
03692     Purpose:    Allows you to get hold of all the info you need about the required control
03693     Errors:     -
03694     SeeAlso:    -
03695 
03696 ********************************************************************************************/
03697 
03698 BarControlInfo BarControl::GetBarControlInfo(BOOL horz)
03699 {
03700     if (horz)
03701         return Horizontal.BarCtrlInfo;
03702     else
03703         return Vertical.BarCtrlInfo;
03704 }
03705 
03706 /********************************************************************************************
03707 
03708 >   OpDescriptor* BarControl::GetOpDescriptor(BOOL horz)
03709 
03710     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
03711     Created:    28/3/94
03712     Inputs:     horz - if TRUE  = the OpDescriptor on the horz version of this control is returned
03713                      - if FALSE = the OpDescriptor on the vert version of this control is returned
03714     Outputs:    -
03715     Returns:    BarControl's OpDescriptor
03716 
03717     Purpose:    For finding the BarControl's opDescriptor
03718     Errors:     -
03719     SeeAlso:    -
03720 
03721 ********************************************************************************************/
03722 
03723 OpDescriptor* BarControl::GetOpDescriptor(BOOL horz)
03724 {
03725     if (horz)
03726         return Horizontal.pOpDesc; 
03727     else
03728         return Vertical.pOpDesc;
03729 }
03730 
03731 /********************************************************************************************
03732 
03733 >   UINT32 BarControl::GetBubbleID(BOOL horz)
03734 
03735     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03736     Created:    10/5/94
03737     Inputs:     horz - if TRUE  = the BubbleID on the horz version of this control is returned
03738                      - if FALSE = the BubbleID on the vert version of this control is returned
03739     Outputs:    -
03740     Returns:    BarControl's BubbleID
03741 
03742     Purpose:    For finding the BarControl's BubbleID
03743     Errors:     -
03744     SeeAlso:    -
03745 
03746 ********************************************************************************************/
03747 
03748 UINT32 BarControl::GetBubbleID(BOOL horz)
03749 {
03750     if (horz)
03751         return Horizontal.BubbleID; 
03752     else
03753         return Vertical.BubbleID;
03754 }
03755 
03756 /********************************************************************************************
03757 
03758 >   UINT32 BarControl::GetStatusID(BOOL horz)
03759 
03760     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03761     Created:    10/5/94
03762     Inputs:     horz - if TRUE  = the StatusID on the horz version of this control is returned
03763                      - if FALSE = the StatusID on the vert version of this control is returned
03764     Outputs:    -
03765     Returns:    BarControl's StatusID
03766 
03767     Purpose:    For finding the BarControl's StatusID
03768     Errors:     -
03769     SeeAlso:    -
03770 
03771 ********************************************************************************************/
03772 
03773 UINT32 BarControl::GetStatusID(BOOL horz)
03774 {
03775     if (horz)
03776         return Horizontal.StatusID; 
03777     else
03778         return Vertical.StatusID;
03779 }
03780 
03781 
03782 
03783 /********************************************************************************************
03784 
03785 >   BOOL BarControl::Write(String_256 * pString)
03786 
03787     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
03788     Created:    20/2/97
03789     Outputs:    pString = string to put the data for this control into 
03790     Returns:    TRUE if successful, FALSE otherwise
03791     Purpose:    Writes the control to the given string
03792                 This will be in the form of:-
03793                     Control H "BreakShapes" 0 126 220 V "BreakShapes" 0 126 220
03794     Errors:     -
03795     SeeAlso:    -
03796 
03797 ********************************************************************************************/
03798 
03799 #define QUOTE "\""
03800 
03801 BOOL BarControl::Write(String_256 * pString)
03802 {
03803     ERROR2IF(pString == NULL,FALSE,"Write given null string");
03804 
03805     BOOL ok = TRUE;
03806     TCHAR buf[10];
03807 
03808     // Add that its a bar control
03809     *pString += TokenTable[TOKEN_BAR_CONTROL].Token;
03810     *pString += _T(" ");
03811 
03812     // save out the horizontal state starting with the horizontal token
03813     *pString += TokenTable[TOKEN_BAR_CONTROL_HORZ].Token;
03814     *pString += _T(" ");
03815 
03816     if (Horizontal.pOpDesc)
03817     {
03818         *pString += wxT(QUOTE);
03819         *pString += Horizontal.pOpDesc->Token;
03820         *pString += wxT(QUOTE) wxT(" ");
03821     }
03822     else
03823     {
03824         camSnprintf(buf, 9, TEXT("%d "), Horizontal.BubbleID);
03825         *pString += buf;
03826         camSnprintf(buf, 9, TEXT("%d "), Horizontal.StatusID);
03827         *pString += buf;
03828     }
03829     camSnprintf(buf, 9, TEXT("%d "), Horizontal.BarCtrlInfo.ToolID);
03830     *pString += buf;
03831     camSnprintf(buf, 9, TEXT("%d "), Horizontal.BarCtrlInfo.ResourceID);
03832     *pString += buf;
03833     camSnprintf(buf, 9, TEXT("%d "), Horizontal.BarCtrlInfo.ControlID);
03834     *pString += buf;
03835 
03836     *pString += TokenTable[TOKEN_BAR_CONTROL_VERT].Token;
03837     *pString += _T(" ");
03838     if(Vertical.pOpDesc)
03839     {
03840         *pString += wxT(QUOTE);
03841         *pString += Vertical.pOpDesc->Token;
03842         *pString += wxT(QUOTE) wxT(" ");
03843     }
03844     else
03845     {
03846         camSnprintf(buf, 9, TEXT("%d "), Vertical.BubbleID);
03847         *pString += buf;
03848         camSnprintf(buf, 9, TEXT("%d "), Vertical.StatusID);
03849         *pString += buf;
03850     }
03851     camSnprintf(buf, 9, TEXT("%d "), Vertical.BarCtrlInfo.ToolID);
03852     *pString += buf;
03853     camSnprintf(buf, 9, TEXT("%d "), Vertical.BarCtrlInfo.ResourceID);
03854     *pString += buf;
03855     camSnprintf(buf, 9, TEXT("%d "), Vertical.BarCtrlInfo.ControlID);
03856     *pString += buf;
03857 
03858     return ok;
03859 }
03860 
03861 /********************************************************************************************
03862 
03863 >   BOOL BarControl::Read(String_256 * pString)
03864 
03865     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
03866     Created:    20/2/97
03867     Inputs:     pString = string to read the data for this control out of 
03868     Returns:    TRUE if successful, FALSE otherwise
03869     Purpose:    Reads the control from the given string
03870                 This will be in the form of:-
03871                     Control H "BreakShapes" 0 126 220 V "BreakShapes" 0 126 220
03872                 
03873                 Code ideas taken from PrintMarksCache::DecodeMarkFormat. Thanks Mike!
03874     Errors:     -
03875     SeeAlso:    PrintMarksCache::DecodeMarkFormat;
03876 
03877 ********************************************************************************************/
03878 
03879 BOOL BarControl::Read(String_256 * pString)
03880 {
03881     ERROR2IF(pString == NULL,FALSE,"BarControl::Read given null parameters!");
03882 
03883     // We will enter here having read in the Control section of the string so we just
03884     // need to decode the following sections.
03885     // This can consist of an H section and/or a V section.
03886 
03887     // This text must not be internationalised
03888     //const TCHAR SPACE = TEXT(' ');
03889     const TCHAR H       = TEXT('H');
03890     const TCHAR V       = TEXT('V');
03891     const TCHAR B       = TEXT('B');
03892 
03893     INT32 pos = 0;
03894 
03895     // Everything is hunky dory at the moment! ER NOT!
03896     BOOL AllIsWell = FALSE;
03897 
03898     // Turn on the exceptions function in the string reading class
03899     StringBase::EnableExceptionHandler();
03900 
03901     String_256 Name(*pString);
03902 
03903     try 
03904     {
03905         // See if we have an H or B as the descriptor of the control
03906         // B defines both controls at the same time
03907         if (Name[pos] == H)
03908         {
03909             // See if there is an H command and then toast it and the supposed trailing space
03910             // if that is successful
03911             pos = Name.FindNextChar(H);
03912             Name.Remove(0, pos+2);
03913 
03914             AllIsWell = ReadSimpleBarControl(&Name, &Horizontal);
03915 
03916             if (AllIsWell)
03917             {
03918                 // See if there is an V command and then toast it and the supposed trailing space
03919                 // if that is successful
03920                 pos = Name.FindNextChar(V);
03921                 Name.Remove(0, pos+2);
03922 
03923                 AllIsWell = ReadSimpleBarControl(&Name, &Vertical);
03924             }
03925         }
03926         else
03927         {
03928             // Read in both controls as one
03929             pos = Name.FindNextChar(B);
03930             Name.Remove(0, pos+2);
03931 
03932             AllIsWell = ReadSimpleBarControl(&Name, &Horizontal);
03933 
03934             // if horz and vert defs are the same, make vert = horz version.
03935             Vertical = Horizontal;
03936         }
03937     }
03938     catch( ... )
03939     {
03940         // An exception has been thrown which means
03941         // we failed to parse this string, so simply report failure
03942         AllIsWell = FALSE;
03943     }
03944 
03945     // Switch off the exception state finally, (and of course pop it)!
03946     StringBase::DisableExceptionHandler();
03947 
03948     return AllIsWell;
03949 }
03950 
03951 /********************************************************************************************
03952 
03953 >   BOOL BarControl::ReadSimpleBarControl(String_256 *pString, SimpleBarControl* pSBC)
03954 
03955     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
03956     Created:    20/2/97
03957     Inputs:     pString = string to read the data for this control out of 
03958                 pSBC = ptr to a SimpleBarControl to fill using tokens from 'file'
03959     Outputs:    -
03960     Returns:    TRUE if successful, FALSE otherwise
03961     Purpose:    Reads a tokenized form of the simple bar control from the given string
03962     Errors:     -
03963     SeeAlso:    -
03964 
03965 ********************************************************************************************/
03966 
03967 BOOL BarControl::ReadSimpleBarControl(String_256 *pString, SimpleBarControl* pSBC)
03968 {
03969     ERROR2IF(pString == NULL || pSBC == NULL,FALSE,"ReadSimpleBarControl given null parameters!");
03970 
03971     String_256 OpName;
03972     INT32 pos = 0;
03973     // This text must not be internationalised
03974     const TCHAR QUOTES  = TEXT('"');
03975 
03976     // See if a string follows or if a bubble and status ids follow
03977     if ((*pString)[pos] == QUOTES)
03978     {
03979         // Go to the first quote of the first string
03980         pos = pString->FindNextChar(QUOTES, pos);
03981         pString->Remove(0, pos+1);
03982 
03983         // Now find the last quote of the first string
03984         pos = pString->FindNextChar(QUOTES);
03985         // Read the operation name into OpName
03986         pString->Left(&OpName, pos);
03987         pString->Remove(0, pos+1);
03988         pos = 0;
03989 
03990         // Try and find the OpDescriptor that should be in the system
03991         pSBC->pOpDesc  = OpDescriptor::FindOpDescriptor(OpName);
03992         pSBC->BubbleID = _R(IDBBL_NOOP);
03993         pSBC->StatusID = 0;
03994         if ((OpName.Length() > 0) && (pSBC->pOpDesc == NULL))
03995         {
03996             // If there is an op desc token string, but no op desc was found, fail
03997             TRACE( _T("Can't find op descriptor! OpToken of missing op = %s\n"),(TCHAR*)OpName);
03998             return FALSE;
03999         }
04000     }
04001     else
04002     {
04003         // Its as simple control
04004         // No op descriptor associated with this control
04005         pSBC->pOpDesc  = NULL;      
04006 
04007         // Read the bubble and status bar text IDs
04008         pSBC->BubbleID = pString->ConvertToInteger(pos);
04009         pSBC->StatusID = pString->ConvertToInteger(pos);
04010         pString->Remove(0,pos);
04011         pos = 0;
04012     }
04013 
04014     // The next three tokens are the tool ID, resource ID, and the control ID
04015     pSBC->BarCtrlInfo.ToolID = pString->ConvertToInteger(pos);
04016     pSBC->BarCtrlInfo.ResourceID = pString->ConvertToInteger(pos);
04017     pSBC->BarCtrlInfo.ControlID = pString->ConvertToInteger(pos);
04018     pString->Remove(0,pos);
04019     pos = 0;
04020 
04021     return TRUE;
04022 }
04023 
04024 /********************************************************************************************
04025 
04026 >   BOOL BarControl::Write(CCLexFile& file)
04027 
04028     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04029     Created:    28/3/94
04030     Inputs:     file = a file object
04031     Outputs:    -
04032     Returns:    TRUE if successful, FALSE otherwise
04033     Purpose:    Writes a tokenized form of the control to the given file
04034     Errors:     -
04035     SeeAlso:    -
04036 
04037 ********************************************************************************************/
04038 
04039 BOOL BarControl::Write(CCLexFile& file)
04040 {
04041     BOOL ok = TRUE;
04042 
04043         if (ok) ok = file.PutToken(TokenTable[TOKEN_BAR_CONTROL].Token);
04044 
04045         if (ok) ok = file.PutToken(TokenTable[TOKEN_BAR_CONTROL_HORZ].Token);
04046 
04047         if(Horizontal.pOpDesc)
04048         {
04049             if (ok) ok = file.PutString(Horizontal.pOpDesc->Token);
04050         }
04051         else
04052         {
04053             if (ok) ok = file.PutToken(Horizontal.BubbleID);
04054             if (ok) ok = file.PutToken(Horizontal.StatusID);
04055         }
04056         if (ok) ok = file.PutToken(Horizontal.BarCtrlInfo.ToolID);
04057         if (ok) ok = file.PutToken(Horizontal.BarCtrlInfo.ResourceID);
04058         if (ok) ok = file.PutToken(Horizontal.BarCtrlInfo.ControlID);
04059 
04060         if (ok) ok = file.PutToken(TokenTable[TOKEN_BAR_CONTROL_VERT].Token);
04061         if(Vertical.pOpDesc)
04062         {
04063             if (ok) ok = file.PutString(Vertical.pOpDesc->Token);
04064         }
04065         else
04066         {
04067             if (ok) ok = file.PutToken(Vertical.BubbleID);
04068             if (ok) ok = file.PutToken(Vertical.StatusID);
04069         }
04070         if (ok) ok = file.PutToken(Vertical.BarCtrlInfo.ToolID);
04071         if (ok) ok = file.PutToken(Vertical.BarCtrlInfo.ResourceID);
04072         if (ok) ok = file.PutToken(Vertical.BarCtrlInfo.ControlID);
04073     return (ok);
04074 }
04075 
04076 
04077 
04078 /********************************************************************************************
04079 
04080 >   BOOL BarControl::Read(CCLexFile& file)
04081 
04082     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04083     Created:    7/4/94
04084     Inputs:     file = a file object
04085     Outputs:    -
04086     Returns:    TRUE if successful, FALSE otherwise
04087     Purpose:    Reads a tokenized form of the control from the given file
04088     Errors:     -
04089     SeeAlso:    -
04090 
04091 ********************************************************************************************/
04092 
04093 
04094 BOOL BarControl::Read(CCLexFile& file)
04095 {
04096     TokenIndex Token = TOKEN_NONE;
04097     const TCHAR* TokenBuf = file.GetTokenBuf();
04098     BOOL ok;
04099 
04100     ok = file.GetSimpleToken();     // Read the first token
04101     if (ok)
04102     {
04103         Token = FindToken(TokenBuf);    
04104         // Check that next token defines either the horz or both versions of the control
04105         ok = ((Token == TOKEN_BAR_CONTROL_HORZ) || (Token == TOKEN_BAR_CONTROL_BOTH));
04106         if (!ok) TRACE( _T("Expected a '%s' or a '%s', but found '%s'."),TokenTable[TOKEN_BAR_CONTROL_HORZ].Token,TokenTable[TOKEN_BAR_CONTROL_BOTH].Token,TokenBuf);
04107 
04108         if (ok) ok = ReadSimpleBarControl(file,&Horizontal);
04109     }
04110 
04111     if (ok && Token == TOKEN_BAR_CONTROL_BOTH)
04112         // if horz and vert defs are the same, make vert = horz version.
04113         Vertical = Horizontal;
04114     else if (ok)
04115     {
04116         // otherwise, read the vert definition
04117         ok = file.GetSimpleToken();
04118         if (ok)
04119         {
04120             Token = FindToken(TokenBuf);
04121             ok = (Token == TOKEN_BAR_CONTROL_VERT);
04122             if (!ok) TRACE( _T("Expected a '%s', but found '%s'."),TokenTable[TOKEN_BAR_CONTROL_VERT].Token,TokenBuf);
04123 
04124             if (ok) ok = ReadSimpleBarControl(file,&Vertical);
04125         }
04126     }
04127 
04128     if (!ok)
04129     {
04130         // If something when wrong, tell the debug dudes and give as much info as possible
04131         //ENSURE(FALSE,"Error reading a bar control. See TRACE output for details");
04132         TRACE( _T("\n\nError reading a bar control:\n"));
04133         TRACE( _T(" Token buffer = %s\n"),TokenBuf);
04134         TRACE( _T(" Line buffer  = %s\n"),file.GetLineBuf());
04135     }
04136 
04137     return (ok);
04138 }
04139 
04140 /********************************************************************************************
04141 
04142 >   BOOL BarControl::ReadSimpleBarControl(CCLexFile& file,SimpleBarControl* pSBC)
04143 
04144     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04145     Created:    7/4/94
04146     Inputs:     file = a file object
04147                 pSBC = ptr to a SimpleBarControl to fill using tokens from 'file'
04148     Outputs:    -
04149     Returns:    TRUE if successful, FALSE otherwise
04150     Purpose:    Reads a tokenized form of the simple bar control from the given file
04151     Errors:     -
04152     SeeAlso:    -
04153 
04154 ********************************************************************************************/
04155 
04156 BOOL BarControl::ReadSimpleBarControl(CCLexFile& file,SimpleBarControl* pSBC)
04157 {
04158     const TCHAR* TokenBuf = file.GetTokenBuf();
04159     BOOL ok;
04160 
04161     ok = file.GetSimpleToken();
04162 
04163     if (ok)
04164     {
04165         // The first token is either a string describing the op descriptor or
04166         // the ID for the bubble help message
04167         LexTokenType TokenType = file.GetTokenType();
04168 
04169         switch (TokenType)
04170         {
04171             case TOKEN_STRING :
04172                 pSBC->pOpDesc  = OpDescriptor::FindOpDescriptor( const_cast<TCHAR*>(TokenBuf) );
04173                 pSBC->BubbleID = _R(IDBBL_NOOP);
04174                 pSBC->StatusID = 0;
04175 
04176                 if ((TokenBuf[0] != 0) && (pSBC->pOpDesc == NULL))
04177                 {
04178                     // If there is an op desc token string, but no op desc was found, fail
04179                     TRACE( _T("Can't find op descriptor! OpToken of missing op = %s\n"),TokenBuf);
04180                     ok = FALSE;
04181                 }
04182 
04183                 break;
04184 
04185             case TOKEN_NORMAL :
04186                 pSBC->pOpDesc  = NULL;      // No op descriptor associated with this control
04187 
04188                 // Read the bubble and status bar text IDs
04189                 ok = (camSscanf(TokenBuf, _T("%li"),&pSBC->BubbleID) == 1);
04190                 if (!ok) TRACE( _T("Expected a bubble ID, but got '%s'\n"),TokenBuf);
04191 
04192                 if (ok) ok = file.GetSimpleToken();
04193                 if (ok)
04194                 {
04195                     ok = (camSscanf(TokenBuf,_T("%li"),&pSBC->StatusID) == 1);
04196                     if (!ok) TRACE( _T("Expected a status ID, but got '%s'\n"),TokenBuf);
04197                 }
04198 
04199                 break;
04200 
04201             default :
04202                 ok = FALSE; // What kind of token is this? Get out of here!
04203                 TRACE( _T("Don't recognise this token '%s'. Wrong type\n"),TokenBuf);
04204                 break;
04205         }
04206 
04207         // The next three tokens are the tool ID, resource ID, and the control ID
04208         if (ok) ok = file.GetSimpleToken();
04209         if (ok)
04210         {
04211             // Interpret the next token as an INT32 (dec,hex, or oct)
04212             ok = (camSscanf(TokenBuf, _T("%li"),&pSBC->BarCtrlInfo.ToolID) == 1);
04213             if (!ok) TRACE( _T("Expected a tool ID, but got '%s'\n"),TokenBuf);
04214 
04215             if (ok) ok = file.GetSimpleToken();
04216             if (ok)
04217             {
04218                 // Interpret the next token as an INT32 (dec,hex, or oct)
04219                 ok = (camSscanf(TokenBuf, _T("%li"),&pSBC->BarCtrlInfo.ResourceID) == 1);
04220                 if (!ok) TRACE( _T("Expected a resource ID, but got '%s'\n"),TokenBuf);
04221 
04222                 if (ok) ok = file.GetSimpleToken();
04223                 if (ok)
04224                 {
04225                     // Interpret the next token as an INT32 (dec,hex, or oct)
04226                     ok = (camSscanf(TokenBuf,_T("%li"),&pSBC->BarCtrlInfo.ControlID) == 1);
04227                     if (!ok) TRACE( _T("Expected a control ID, but got '%s'\n"),TokenBuf);
04228                 }
04229             }
04230         }
04231     }
04232 
04233     return ok;
04234 }
04235 
04236 
04237 //--------
04238 //--------
04239 //--------
04240 
04241 /********************************************************************************************
04242 
04243 >   BOOL BarNewPage::Write(CCLexFile& file)
04244 
04245     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04246     Created:    28/3/94
04247     Inputs:     file = a file object
04248     Outputs:    -
04249     Returns:    TRUE if successful, FALSE otherwise
04250     Purpose:    Writes a tokenized form of the separator to the given file
04251     Errors:     -
04252     SeeAlso:    -
04253 
04254 ********************************************************************************************/
04255 
04256 BOOL BarNewPage::Write(CCLexFile& file)
04257 {
04258     return (file.PutToken(TokenTable[TOKEN_BAR_NEWPAGE].Token));
04259 }
04260 
04261 /********************************************************************************************
04262 
04263 >   BOOL BarNewPage::Write(String_256 * pString)
04264 
04265     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
04266     Created:    20/2/97
04267     Outputs:    pString = string to put the data for this control into 
04268     Returns:    TRUE if successful, FALSE otherwise
04269     Purpose:    Writes the control to the given string
04270     Errors:     -
04271     SeeAlso:    -
04272 
04273 ********************************************************************************************/
04274 
04275 BOOL BarNewPage::Write(String_256 * pString)
04276 {
04277     ERROR2IF(pString == NULL,FALSE,"Write given null string");
04278     *pString += TokenTable[TOKEN_BAR_NEWPAGE].Token;
04279     return TRUE;
04280 }
04281 
04282 /********************************************************************************************
04283 
04284 >   BOOL BarSeparator::Write(CCLexFile& file)
04285 
04286     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04287     Created:    28/3/94
04288     Inputs:     file = a file object
04289     Outputs:    -
04290     Returns:    TRUE if successful, FALSE otherwise
04291     Purpose:    Writes a tokenized form of the separator to the given file
04292     Errors:     -
04293     SeeAlso:    -
04294 
04295 ********************************************************************************************/
04296 
04297 BOOL BarSeparator::Write(CCLexFile& file)
04298 {
04299     return (file.PutToken(TokenTable[TOKEN_BAR_SEPARATOR].Token));
04300 }
04301 
04302 /********************************************************************************************
04303 
04304 >   BOOL BarSeparator::Write(String_256 * pString)
04305 
04306     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
04307     Created:    20/2/97
04308     Outputs:    pString = string to put the data for this control into 
04309     Returns:    TRUE if successful, FALSE otherwise
04310     Purpose:    Writes the control to the given string
04311     Errors:     -
04312     SeeAlso:    -
04313 
04314 ********************************************************************************************/
04315 
04316 BOOL BarSeparator::Write(String_256 * pString)
04317 {
04318     ERROR2IF(pString == NULL,FALSE,"Write given null string");
04319     *pString += TokenTable[TOKEN_BAR_SEPARATOR].Token;
04320     return TRUE;
04321 }
04322 
04323 /********************************************************************************************
04324 
04325 >   BOOL DDeckerTop::Write(CCLexFile& file)
04326 
04327     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04328     Created:    28/3/94
04329     Inputs:     file = a file object
04330     Outputs:    -
04331     Returns:    TRUE if successful, FALSE otherwise
04332     Purpose:    Writes a tokenized form of a DDeckerTop to the given file
04333     Errors:     -
04334     SeeAlso:    -
04335 
04336 ********************************************************************************************/
04337 
04338 BOOL DDeckerTop::Write(CCLexFile& file)
04339 {
04340     return (file.PutToken(TokenTable[TOKEN_DDECKER_TOP].Token));
04341 }
04342 
04343 /********************************************************************************************
04344 
04345 >   BOOL DDeckerTop::Write(String_256 * pString)
04346 
04347     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
04348     Created:    20/2/97
04349     Outputs:    pString = string to put the data for this control into 
04350     Returns:    TRUE if successful, FALSE otherwise
04351     Purpose:    Writes the control to the given string
04352     Errors:     -
04353     SeeAlso:    -
04354 
04355 ********************************************************************************************/
04356 
04357 BOOL DDeckerTop::Write(String_256 * pString)
04358 {
04359     ERROR2IF(pString == NULL,FALSE,"Write given null string");
04360     *pString += TokenTable[TOKEN_DDECKER_TOP].Token;
04361     return TRUE;
04362 }
04363 
04364 /********************************************************************************************
04365 
04366 >   BOOL DDeckerBottom::Write(CCLexFile& file)
04367 
04368     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04369     Created:    28/3/94
04370     Inputs:     file = a file object
04371     Outputs:    -
04372     Returns:    TRUE if successful, FALSE otherwise
04373     Purpose:    Writes a tokenized form of a DDeckerBottom to the given file
04374     Errors:     -
04375     SeeAlso:    -
04376 
04377 ********************************************************************************************/
04378 
04379 BOOL DDeckerBottom::Write(CCLexFile& file)
04380 {
04381     return (file.PutToken(TokenTable[TOKEN_DDECKER_BOTTOM].Token));
04382 }
04383 
04384 /********************************************************************************************
04385 
04386 >   BOOL DDeckerBottom::Write(String_256 * pString)
04387 
04388     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
04389     Created:    20/2/97
04390     Outputs:    pString = string to put the data for this control into 
04391     Returns:    TRUE if successful, FALSE otherwise
04392     Purpose:    Writes the control to the given string
04393     Errors:     -
04394     SeeAlso:    -
04395 
04396 ********************************************************************************************/
04397 
04398 BOOL DDeckerBottom::Write(String_256 * pString)
04399 {
04400     ERROR2IF(pString == NULL,FALSE,"Write given null string");
04401     *pString += TokenTable[TOKEN_DDECKER_BOTTOM].Token;
04402     return TRUE;
04403 }
04404 
04405 /********************************************************************************************
04406 
04407 >   BOOL DDeckerEnd::Write(CCLexFile& file)
04408 
04409     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04410     Created:    28/3/94
04411     Inputs:     file = a file object
04412     Outputs:    -
04413     Returns:    TRUE if successful, FALSE otherwise
04414     Purpose:    Writes a tokenized form of a DDeckerEnd to the given file
04415     Errors:     -
04416     SeeAlso:    -
04417 
04418 ********************************************************************************************/
04419 
04420 BOOL DDeckerEnd::Write(CCLexFile& file)
04421 {
04422     return (file.PutToken(TokenTable[TOKEN_DDECKER_END].Token));
04423 }
04424 
04425 /********************************************************************************************
04426 
04427 >   BOOL DDeckerEnd::Write(String_256 * pString)
04428 
04429     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
04430     Created:    20/2/97
04431     Outputs:    pString = string to put the data for this control into 
04432     Returns:    TRUE if successful, FALSE otherwise
04433     Purpose:    Writes the control to the given string
04434     Errors:     -
04435     SeeAlso:    -
04436 
04437 ********************************************************************************************/
04438 
04439 BOOL DDeckerEnd::Write(String_256 * pString)
04440 {
04441     ERROR2IF(pString == NULL,FALSE,"Write given null string");
04442     *pString += TokenTable[TOKEN_DDECKER_END].Token;
04443     return TRUE;
04444 }
04445 
04446 //--------
04447 //--------
04448 //--------
04449 
04450 /********************************************************************************************
04451 
04452 >   BOOL BarLineFeed::Write(CCLexFile& file)
04453 
04454     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04455     Created:    28/3/94
04456     Inputs:     file = a file object
04457     Outputs:    -
04458     Returns:    TRUE if successful, FALSE otherwise
04459     Purpose:    Writes a tokenized form of the linefeed to the given file
04460     Errors:     -
04461     SeeAlso:    -
04462 
04463 ********************************************************************************************/
04464 
04465 BOOL BarLineFeed::Write(CCLexFile& file)
04466 {
04467     return (file.PutToken(TokenTable[TOKEN_BAR_LINEFEED].Token));
04468 }
04469 
04470 /********************************************************************************************
04471 
04472 >   BOOL DDeckerEnd::Write(String_256 * pString)
04473 
04474     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
04475     Created:    20/2/97
04476     Outputs:    pString = string to put the data for this control into 
04477     Returns:    TRUE if successful, FALSE otherwise
04478     Purpose:    Writes the control to the given string
04479     Errors:     -
04480     SeeAlso:    -
04481 
04482 ********************************************************************************************/
04483 
04484 BOOL BarLineFeed::Write(String_256 * pString)
04485 {
04486     ERROR2IF(pString == NULL,FALSE,"Write given null string");
04487     *pString += TokenTable[TOKEN_BAR_LINEFEED].Token;
04488     return TRUE;
04489 }
04490 
04491 //--------
04492 //--------
04493 //--------
04494 
04495 
04496 /********************************************************************************************
04497 
04498 >   BarToolButton::BarToolButton()
04499 
04500     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04501     Created:    25/5/94
04502     Inputs:     -
04503     Outputs:    -
04504     Returns:    -
04505     Purpose:    Inits BarToolButton member vars
04506     Errors:     -
04507     SeeAlso:    -
04508 
04509 ********************************************************************************************/
04510 
04511 BarToolButton::BarToolButton()
04512 {
04513     ToolID          = 0;
04514     Bitmap          = 0;
04515     BitmapActive    = 0;
04516     BubbleID        = 0;
04517     StatusID        = 0;
04518 }
04519     
04520 
04521 /********************************************************************************************
04522 
04523 >   UINT32 BarToolButton::GetBitmap(BitmapType Type)
04524 
04525     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04526     Created:    10/5/94
04527     Inputs:     Type = the type of bitmap you want (Active or Inactive)
04528     Outputs:    -
04529     Returns:    The Bitmap ID of the desired bitmap
04530     Purpose:    Lets you get hold of the bitmaps within a BarToolButton.
04531     Errors:     -
04532     SeeAlso:    -
04533 
04534 ********************************************************************************************/
04535 
04536 UINT32 BarToolButton::GetBitmap(BitmapType Type)
04537 { 
04538     if (Type == Active) 
04539         return BitmapActive; 
04540     else
04541         return Bitmap;
04542 }
04543 
04544 /********************************************************************************************
04545 
04546 >   void BarToolButton::SetBitmap(BitmapType Type, UINT32 ThisBitmap)
04547 
04548     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04549     Created:    10/5/94
04550     Inputs:     Type       = the type of bitmap you want to set (Active or Inactive)
04551                 ThisBitmap = the bitmap ID you want to set
04552     Outputs:    -
04553     Returns:    -
04554     Purpose:    Lets you set the bitmap IDs within a BarToolButton.
04555     Errors:     -
04556     SeeAlso:    -
04557 
04558 ********************************************************************************************/
04559 
04560 void BarToolButton::SetBitmap(BitmapType Type, UINT32 ThisBitmap)
04561 { 
04562     switch (Type)
04563     {
04564         case Active   : BitmapActive = ThisBitmap; break;
04565         case Inactive : Bitmap       = ThisBitmap; break;
04566     }
04567 }
04568 
04569 //------------------------------------------------------------------------------------------
04570 //------------------------------------------------------------------------------------------
04571 //------------------------------------------------------------------------------------------
04572 //------------------------------------------------------------------------------------------
04573 
04574 
04575 /********************************************************************************************
04576 
04577 >   DockingBar::DockingBar()
04578 
04579     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04580     Created:    5/4/94
04581     Inputs:     -
04582     Outputs:    -
04583     Returns:    -
04584     Purpose:    The constructor
04585     Errors:     -
04586     SeeAlso:    -
04587                   
04588 ********************************************************************************************/
04589 
04590 /*DockingBar::DockingBar()
04591 {
04592     DockingBarList.AddTail(this);
04593 }
04594 */
04595 
04596 /********************************************************************************************
04597 
04598 >   DockingBar::~DockingBar()
04599 
04600     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04601     Created:    5/4/94
04602     Inputs:     -
04603     Outputs:    -
04604     Returns:    -
04605     Purpose:    The destructor
04606     Errors:     -
04607     SeeAlso:    -
04608 
04609 ********************************************************************************************/
04610 
04611 /*DockingBar::~DockingBar()
04612 {
04613     DockingBarList.RemoveItem(this);
04614 }
04615 */
04616 /********************************************************************************************
04617 
04618 >   BOOL DockingBar::HasBigControls()
04619 
04620     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04621     Created:    5/4/94
04622     Inputs:     -
04623     Outputs:    -
04624     Returns:    -
04625     Purpose:    Find out the size of controls used by all bars docked with this docking bar
04626     Errors:     -
04627     SeeAlso:    -
04628 
04629 ********************************************************************************************/
04630 
04631 /*BOOL DockingBar::HasBigControls()
04632 {
04633     return DockingBarFlags.Big;
04634 }
04635 */
04636 /********************************************************************************************
04637 
04638 >   void DockingBar::SetBigControlsState(BOOL Big)
04639 
04640     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04641     Created:    5/4/94
04642     Inputs:     Big - if TRUE,  controls should be big in this docking bar.
04643                     - if FALSE, they should be small in this docking bar
04644     Outputs:    -
04645     Returns:    -
04646     Purpose:    Sets the size of controls used by all bars docked with this docking bar
04647     Errors:     -
04648     SeeAlso:    -
04649 
04650 ********************************************************************************************/
04651 
04652 /*void DockingBar::SetBigControlsState(BOOL Big)
04653 {
04654     DockingBarFlags.Big = Big;
04655 }
04656 */
04657 /********************************************************************************************
04658 
04659 >   BOOL DockingBar::Write(CCLexFile& file)
04660 
04661     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04662     Created:    5/4/94
04663     Inputs:     file = a file object
04664     Outputs:    -
04665     Returns:    TRUE if successful, FALSE otherwise
04666     Purpose:    Writes a tokenized form of the docking bar to the given file
04667     Errors:     -
04668     SeeAlso:    -
04669 
04670 ********************************************************************************************/
04671 
04672 /*BOOL DockingBar::Write(CCLexFile& file)
04673 {
04674     String_256 str;
04675     BOOL ok;
04676 
04677     ok = file.PutToken(TOKEN_DOCKING_BAR);
04678 
04679     switch (Dock)
04680     {
04681         case DOCKBAR_TOP    : str = TOKEN_DOCKBAR_TOP;    break;
04682         case DOCKBAR_BOTTOM : str = TOKEN_DOCKBAR_BOTTOM; break;
04683         case DOCKBAR_LEFT   : str = TOKEN_DOCKBAR_LEFT;   break;
04684         case DOCKBAR_RIGHT  : str = TOKEN_DOCKBAR_RIGHT;  break;
04685         case DOCKBAR_FLOAT  : str = TOKEN_DOCKBAR_FLOAT;  break;
04686         default             : ok  = FALSE;                break;
04687     }
04688 
04689     if (ok) ok = file.PutToken(str);
04690 
04691     if (ok)
04692     {
04693         if (DockingBarFlags.Big)
04694             ok = file.PutToken(TOKEN_BIG);
04695         else
04696             ok = file.PutToken(TOKEN_SMALL);
04697     }
04698 
04699     return (ok);
04700 }
04701 */
04702 /********************************************************************************************
04703 
04704 >   static BOOL DockingBar::WriteDockingBars(CCLexFile& file)
04705 
04706     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04707     Created:    6/4/94
04708     Inputs:     file = a file object
04709     Outputs:    -
04710     Returns:    TRUE if successful, FALSE otherwise
04711     Purpose:    Writes all the docking bars in tokenized form to the given file
04712     Errors:     -
04713     SeeAlso:    -
04714 
04715 ********************************************************************************************/
04716 
04717 /*BOOL DockingBar::WriteDockingBars(CCLexFile& file)
04718 {
04719     BOOL ok;
04720 
04721     ok = file.InitLexer();
04722 
04723     DockingBar* pDockingBar = (DockingBar*)DockingBarList.GetHead();
04724 
04725     while (pDockingBar != NULL && ok)
04726     {
04727         ok = pDockingBar->Write(file);
04728         if (ok) ok = file.PutNewLine();
04729         pDockingBar = (DockingBar*)DockingBarList.GetNext(pDockingBar);
04730     }
04731 
04732     file.DeinitLexer();
04733 
04734     return (ok);
04735 }
04736 */
04737 
04738 //-----------------------------------------------------------------
04739 //-----------------------------------------------------------------
04740 //-----------------------------------------------------------------
04741 
04742 /********************************************************************************************
04743 
04744 >   BOOL DialogBarOp::WriteBarsToRegistry(HKEY hSubKey)
04745 
04746     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
04747     Created:    19/2/97
04748     Inputs:     hSubKey     the parent key to use in the registry
04749     Outputs:    -
04750     Returns:    -
04751     Purpose:    Asks each relevent kernel bar representation to write its definition out.
04752                 Each bar is written into a numbered section which is a sub-section of the
04753                 supplied key. The numbering is 1..n. Each bar should write out some standard
04754                 named sections and then write out any bar items as separate numbered lines
04755                 into their section. The helper class SaveRegistryEntries can be used to handle
04756                 this automatically.
04757     Errors:     -
04758     SeeAlso:    SaveRegistryEntries;
04759 
04760 ********************************************************************************************/
04761 
04762 BOOL DialogBarOp::WriteBarsToRegistry(HKEY hSubKey)
04763 {
04764 #pragma message( __LOCMSG__ "DialogBarOp::WriteBarsToRegistry - do nothing" )
04765     TRACE( _T("Warning - DialogBarOp::WriteBarsToRegistry called") );
04766 /*  ERROR2IF(hSubKey == NULL,FALSE,"WriteBarsToRegistry bad registry key!");
04767 
04768     BOOL ok = TRUE;
04769 
04770     //if (ok) ok = DialogBarOp::WriteDockingBarsToRegistry();
04771     //if (ok) ok = DialogBarOp::WriteWorkSpaceInfoToFile();
04772 
04773     // save out a version number of the bars, the current build number
04774     // the hSubKey should be opened and ready for writing
04775     ok = ok && SetRegDword(hSubKey, TEXT("VersionMajor"), CAMELOT_VERSION_MAJOR);
04776     ok = ok && SetRegDword(hSubKey, TEXT("VersionMinor"), CAMELOT_VERSION_MINOR);
04777 
04778     ok = ok && InformationBarOp::Write(hSubKey);
04779 
04780     // Go through all the bars and if they are the correct type then ask them to write
04781     // themselves out to the registry.
04782     List* pList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogBarOp));
04783     
04784     // Get the first bar in the list
04785     DialogBarOp* pDialogBarOp = (DialogBarOp*)pList->GetHead();
04786     // Loop through all bars
04787     INT32 i = 0;
04788     TCHAR buf[10];
04789     while (pDialogBarOp != NULL && ok)
04790     {
04791         // Use the same method as before, nasty but should ensure we do everything as intended
04792         if (!pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(SystemBarOp)) &&
04793             !pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(InformationBarOp)))
04794         {
04795             // we don't want to write out the control bank or any list items that are blank
04796             if (!pDialogBarOp->IsListEmpty() && !pDialogBarOp->IsAllBarsOp())
04797             {
04798                 // write out the data for that bar using the counter number as the key name
04799                 wsprintf(buf, TEXT("%d"), i + 1);
04800                 String_256 name(buf);
04801                 SaveRegistryEntries Saver;
04802                 Saver.StartSaving(&name, hSubKey);
04803                 
04804                 ok = pDialogBarOp->Write(Saver);
04805 
04806                 Saver.StopSaving();
04807 
04808                 // Only increment our count after we have written a valid bar definition section
04809                 i++;
04810             }
04811         }
04812 
04813         // Get the next bar in the list
04814         pDialogBarOp = (DialogBarOp*)pList->GetNext(pDialogBarOp);
04815     }
04816 
04817     return (ok); */
04818 
04819     return true;
04820 }
04821 
04822 /********************************************************************************************
04823 
04824 >   BOOL DialogBarOp::ReadBarsFromRegistry(HKEY hSubKey)
04825 
04826     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
04827     Created:    19/2/97
04828     Inputs:     hSubKey     the parent key to use in the registry
04829     Outputs:    -
04830     Returns:    -
04831     Purpose:    Reads the bar definitions from the specified section in the registry.
04832                 Each bar is written into a numbered section which is a sub-section of the
04833                 supplied key. The numbering is 1..n. So we need to search for these numbered
04834                 sections until we fail to find one.
04835     Errors:     -
04836     SeeAlso:    LoadRegistryEntries;
04837 
04838 ********************************************************************************************/
04839 
04840 BOOL DialogBarOp::ReadBarsFromRegistry(HKEY hSubKey)
04841 {
04842 #pragma message( __LOCMSG__ "DialogBarOp::ReadBarsFromRegistry - do nothing" )
04843     TRACE( _T("Warning - DialogBarOp::ReadBarsFromRegistry called") );
04844 /*  ERROR2IF(hSubKey == NULL,FALSE,"ReadBarsFromRegistry bad registry key!");
04845 
04846     BOOL ok = TRUE;
04847     INT32 NumBarsRead = 0;
04848 
04849     ok = ok && InformationBarOp::Read(hSubKey);
04850 
04851     // Now go through all the numbered bar entries and read in all the ones that exist
04852     // These will contain all the gallery and tool bar definitions
04853     DialogBarOpCreate BarCreate;
04854     BOOL Finished = FALSE;
04855     INT32 i = 0;
04856     TCHAR buf[10];
04857     while (!Finished && ok)
04858     { 
04859         // Make up the bar number for this index
04860         wsprintf(buf, TEXT("%d"), i + 1);
04861         String_256 name(buf);
04862         // check to see if the registry key exists
04863         LoadRegistryEntries Loader;
04864         if (Loader.StartLoading(&name, hSubKey))
04865         {
04866             // The key exists and so we must have a bars or a super gallery definition 
04867             HKEY hRegKey = Loader.GetRegKey();
04868             ERROR2IF(hRegKey == NULL, FALSE,"ReadBarsFromRegistry Failed to get reg key");
04869 
04870             // This is the dialog bar op that we are going to create
04871             DialogBarOp* pDialogBarOp = NULL;
04872 
04873             // Get the type of bar we are dealing with
04874             String_256 BarType;
04875             ok = GetRegString(hRegKey, TEXT("Type"), &BarType);
04876             if (BarType == String_256(TokenTable[TOKEN_BAR].Token))
04877             {
04878                 // Create DialogBarOp or derived class using BarCreate object
04879                 pDialogBarOp = BarCreate.Create();
04880             }
04881             else if (BarType == String_256(TokenTable[TOKEN_GALLERY].Token))
04882             {
04883                 // Its a super gallery so get the class name that was saved as well
04884                 String_256 ClassName;
04885                 ok = ok && GetRegString(hRegKey, TEXT("ClassName"), &ClassName);
04886                 // Use this to create the new class
04887                 CCRuntimeClass * pCCRuntimeClass = CCObject::GetRuntimeClassByName( ClassName );
04888                 if (pCCRuntimeClass != NULL)
04889                 {
04890                     // Go and create the object of the correct runtime class
04891                     pDialogBarOp = (DialogBarOp *) pCCRuntimeClass->CreateObject();
04892                     // Check it's a real gallery. We ensure on debug builds, but just ignore the
04893                     // entry in retail builds.
04894                     //
04895                     // This should only ever happen if ccobject.cpp is broken or someone's put an
04896                     // incorrectly derived, or non DYNA_CREATE class in BARS.INI
04897                     //
04898                     ok = (pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)));
04899                 }
04900                 else
04901                     TRACE( _T("Registry definition contains unknown gallery class : '%s'\n"),(TCHAR *)ClassName);
04902             }
04903             else
04904             {
04905                 ERROR3("Unknown bar type in DialogBarOp::Read");
04906                 return FALSE;
04907             }
04908 
04909             if (pDialogBarOp != NULL)
04910             {
04911                 // Read definition and inc num bars read
04912                 // ask the bar to extract all the details from this section
04913                 ok = ok && pDialogBarOp->Read(Loader);
04914                 
04915                 if (ok)
04916                     NumBarsRead++;
04917                 else
04918                     pDialogBarOp->End();
04919             }
04920             else
04921                 ok = FALSE;
04922 
04923             // stop the loader class, only required if the key was opened
04924             Loader.StopLoading();
04925         }
04926         else
04927         {
04928             // The key does not exist and so we must have reached the end of the list
04929             Finished = TRUE;
04930         }
04931 
04932         // increment out count to step onto the next bars definition
04933         i++;
04934     }
04935 
04936     return (ok); */
04937 
04938     return false;
04939 }
04940 
04941 /********************************************************************************************
04942 
04943 >   static BOOL DialogBarOp::WriteDockingBarsToRegistry(HKEY hSubKey)
04944 
04945     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
04946     Created:    19/2/97
04947     Inputs:     hSubKey     the registery section to save the data into
04948     Outputs:    -
04949     Returns:    -
04950     Purpose:    Writes the persistant docking data retrieved from the docking system.
04951     Errors:     -
04952     SeeAlso:    -
04953 
04954 ********************************************************************************************/
04955 
04956 BOOL DialogBarOp::WriteDockingBarsToRegistry(HKEY hSubKey)
04957 {
04958 #pragma message( __LOCMSG__ "DialogBarOp::WriteDockingBarsToRegistry - do nothing" )
04959     TRACE( _T("Warning - DialogBarOp::WriteDockingBarsToRegistry called") );
04960 /*  ERROR2IF(hSubKey == NULL,FALSE,"WriteDockingBarsToRegistry bad registry key!");
04961 
04962     BOOL                ok = TRUE;
04963     CCamFrame          *pMainFrame = GetMainFrame();
04964 
04965     if (pMainFrame == NULL)
04966         return FALSE;
04967 
04968     // Save it into the registry
04969     String_256 SectionName;
04970     // First open/create a new sub-key under the app-state key for holding the data.
04971     HKEY hRegKey = CreateRegKey(hSubKey, PRODUCT_REGISTRYKEY_BARSETTINGS);
04972     if (hRegKey == NULL)
04973     {
04974         ERROR3("DialogBarOp::WriteWorkSpaceInfoToRegistry failed to get registry key");
04975         return FALSE;
04976     }
04977 
04978     for (INT32 i = 0; i < NUM_DOCKBARS && ok; i++)
04979     {
04980         OILDockingBar* pDockBar = pMainFrame->GetDockBar((DockBarType)i);
04981         if (ok) ok = (pDockBar != NULL);
04982 
04983         // save out the details on that bar's status i.e. big or small
04984         ok = ok && SetRegBool(hRegKey, TokenTable[TOKEN_DOCKBAR_LEFT+i].Token, pDockBar->IsBigControls());
04985     }
04986 
04987     // Close down the key
04988     CloseRegKey(hRegKey);
04989 
04990     return (ok); */
04991 
04992     return false;
04993 }
04994 
04995 /********************************************************************************************
04996 
04997 >   static BOOL DialogBarOp::ReadDockingBarsFromRegistry(HKEY hSubKey)
04998 
04999     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
05000     Created:    19/2/97
05001     Inputs:     hSubKey     the registery section to read the data from
05002     Outputs:    -
05003     Returns:    -
05004     Purpose:    Reads in the persistant docking data retrieved from the docking system.
05005     Errors:     -
05006     SeeAlso:    -
05007 
05008 ********************************************************************************************/
05009 
05010 BOOL DialogBarOp::ReadDockingBarsFromRegistry(HKEY hSubKey)
05011 {
05012 #pragma message( __LOCMSG__ "DialogBarOp::ReadDockingBarsFromRegistry - do nothing" )
05013     TRACE( _T("Warning - DialogBarOp::ReadDockingBarsFromRegistry called") );
05014 /*  ERROR2IF(hSubKey == NULL,FALSE,"ReadDockingBarsFromRegistry bad registry key!");
05015 
05016     BOOL ok = TRUE;
05017     CCamFrame* pMainFrame = GetMainFrame();
05018 
05019     if (pMainFrame == NULL)
05020         return FALSE;
05021 
05022     // Save it into the registry
05023     // First open/create a new sub-key under the app-state key for holding the data.
05024     HKEY hRegKey = CreateRegKey(hSubKey, PRODUCT_REGISTRYKEY_BARSETTINGS);
05025     if (hRegKey == NULL)
05026     {
05027         //ERROR3("DialogBarOp::ReadDockingBarsFromRegistry failed to get registry key");
05028         return FALSE;
05029     }
05030 
05031     DockBarType DockType;
05032     for (INT32 i = 0; i < NUM_DOCKBARS && ok; i++)
05033     {
05034         OILDockingBar* pDockBar = pMainFrame->GetDockBar((DockBarType)i);
05035         if (ok) ok = (pDockBar != NULL);
05036 
05037         switch (i)
05038         {
05039             case 0: DockType = DOCKBAR_LEFT;        break;
05040             case 1: DockType = DOCKBAR_RIGHT;       break;
05041             case 2: DockType = DOCKBAR_TOP;         break;
05042             case 3: DockType = DOCKBAR_BOTTOM;      break;
05043             case 4: DockType = DOCKBAR_FLOAT;       break;
05044             default:
05045                 TRACEUSER( "Neville", _T("ReadDockingBarsFromRegistry bad dockbar type"));
05046                 ok = FALSE;
05047                 break;
05048         }
05049         
05050         if (ok)
05051         {
05052             // get the details on that bar's status i.e. big or small
05053             BOOL State = GetRegBool(hRegKey, TokenTable[TOKEN_DOCKBAR_LEFT+i].Token);
05054 
05055             OILDockingBar* pDockBar = pMainFrame->GetDockBar(DockType);
05056             // Set the dockbar control size - default to small
05057             pDockBar->SetBigControlState(State);
05058         }
05059     }
05060 
05061     // Close down the key
05062     CloseRegKey(hRegKey);
05063 
05064     return (ok); */
05065 
05066     return false;
05067 }
05068 
05069 /********************************************************************************************
05070 
05071 >   static BOOL DialogBarOp::WriteWorkSpaceInfoToRegistry(HKEY hSubKey)
05072 
05073     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
05074     Created:    19/2/97
05075     Inputs:     hSubKey     the registery section to save the data into
05076     Outputs:    -
05077     Returns:    -
05078     Purpose:    Writes workspace data to registry ( Full Screen Mode etc..) 
05079     Errors:     -
05080     SeeAlso:    -
05081 
05082 ********************************************************************************************/
05083 
05084 BOOL DialogBarOp::WriteWorkSpaceInfoToRegistry(HKEY hSubKey)
05085 {
05086 #pragma message( __LOCMSG__ "DialogBarOp::WriteWorkSpaceInfoToRegistry - do nothing" )
05087     TRACE( _T("Warning - DialogBarOp::WriteWorkSpaceInfoToRegistry called") );
05088 /*  ERROR2IF(hSubKey == NULL,FALSE,"WriteWorkSpaceInfoToRegistry bad registry key!");
05089 
05090     BOOL ok = TRUE;
05091     CCamFrame* pMainFrame = GetMainFrame();
05092 
05093     if (pMainFrame == NULL)
05094         return FALSE;
05095     
05096     // Save it into the registry
05097     // First open/create a new sub-key under the app-state key for holding the data.
05098     HKEY hRegKey = CreateRegKey(hSubKey, PRODUCT_REGISTRYKEY_BARSETTINGS);
05099     if (hRegKey == NULL)
05100     {
05101         ERROR3("DialogBarOp::WriteWorkSpaceInfoToRegistry failed to get registry key");
05102         return FALSE;
05103     }
05104 
05105     // Save the value
05106     ok = ok && SetRegBool(hRegKey, TokenTable[TOKEN_FULLSCREEN].Token, pMainFrame->IsFullScreenMode());
05107     ok = ok && SetRegBool(hRegKey, TokenTable[TOKEN_STATUS_BAR].Token, pMainFrame->IsStatusBarVisible());
05108     ok = ok && SetRegBool(hRegKey, TokenTable[TOKEN_COLOUR_BAR].Token, pMainFrame->IsColourBarVisible());
05109     ok = ok && SetRegBool(hRegKey, TokenTable[TOKEN_SCROLL_BARS].Token, pMainFrame->AreScrollBarsVisible());
05110 
05111     // Close down the key
05112     CloseRegKey(hRegKey);
05113 
05114     return (ok); */
05115 
05116     return false;
05117 }
05118 
05119 /********************************************************************************************
05120 
05121 >   static BOOL DialogBarOp::ReadWorkSpaceInfoFromRegistry()
05122 
05123     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
05124     Created:    19/2/97
05125     Inputs:     hSubKey     the registery section to read the data from
05126     Outputs:    -
05127     Returns:    -
05128     Purpose:    Reads workspace data from the registry ( Full Screen Mode etc..) 
05129     Errors:     -
05130     SeeAlso:    -
05131 
05132 ********************************************************************************************/
05133 
05134 BOOL DialogBarOp::ReadWorkSpaceInfoFromRegistry(HKEY hSubKey)
05135 {
05136 #pragma message( __LOCMSG__ "DialogBarOp::ReadWorkSpaceInfoFromRegistry - do nothing" )
05137     TRACE( _T("Warning - DialogBarOp::ReadWorkSpaceInfoFromRegistry called") );
05138 /*  ERROR2IF(hSubKey == NULL,FALSE,"ReadWorkSpaceInfoFromRegistry bad registry key!");
05139 
05140     BOOL ok = TRUE;
05141     CCamFrame* pMainFrame = GetMainFrame();
05142 
05143     if (pMainFrame == NULL)
05144         return FALSE;
05145     
05146     // Save it into the registry
05147     // First open/create a new sub-key under the app-state key for holding the data.
05148     HKEY hRegKey = OpenRegKey(hSubKey, PRODUCT_REGISTRYKEY_BARSETTINGS);
05149     if (hRegKey == NULL)
05150     {
05151         //ERROR3("DialogBarOp::ReadWorkSpaceInfoFromRegistry failed to get registry key");
05152         return FALSE;
05153     }
05154 
05155     // Save the value
05156     BOOL Show = TRUE;
05157     Show = GetRegBool(hRegKey, TokenTable[TOKEN_FULLSCREEN].Token);
05158     pMainFrame->DoFullScreenMode(Show);
05159     
05160     Show = GetRegBool(hRegKey, TokenTable[TOKEN_STATUS_BAR].Token);
05161     pMainFrame->ShowStatusBar(Show);
05162 
05163     Show = GetRegBool(hRegKey, TokenTable[TOKEN_COLOUR_BAR].Token);
05164     pMainFrame->ShowColourBar(Show);
05165 
05166     Show = GetRegBool(hRegKey, TokenTable[TOKEN_SCROLL_BARS].Token);
05167     pMainFrame->ShowScrollBars(Show);
05168 
05169     // Close down the key
05170     CloseRegKey(hRegKey);
05171 
05172     return (ok); */
05173 
05174     return false;
05175 }
05176 
05177 /********************************************************************************************
05178 // Old ini file related saving code
05179 ********************************************************************************************/
05180 
05181 /********************************************************************************************
05182 
05183 >   static BOOL DialogBarOp::WriteBarsToFile(CCLexFile& file)
05184 
05185     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
05186     Created:    6/4/94
05187     Inputs:     file = file to write bar tokens to
05188     Outputs:    -
05189     Returns:    -
05190     Purpose:    Writes the entire kernel's bar representation to the given file.
05191                 It is written in an ASCII tokenized form so that CCLexFile can be used
05192                 to read the file back in when reconstructing the bars system.
05193     Errors:     -
05194     SeeAlso:    -
05195 
05196 ********************************************************************************************/
05197 
05198 BOOL DialogBarOp::WriteBarsToFile(CCLexFile& file)
05199 {
05200     BOOL ok = TRUE;
05201 
05202 PORTNOTE("other","WriteBarsToFile - Removed")
05203 #if !defined(EXCLUDE_FROM_XARALX)
05204 
05205     ok = file.InitLexer();
05206 
05207     if (ok) ok = DialogBarOp::WriteDockingBarsToFile(file);
05208     if (ok) ok = DialogBarOp::WriteWorkSpaceInfoToFile(file);
05209     if (ok) ok = InformationBarOp::WriteStatic(file);
05210     if (ok) ok = DialogBarOp::WriteBars(file);
05211 
05212     file.DeinitLexer();
05213 #endif
05214 
05215     return (ok);
05216 }
05217 
05218 /********************************************************************************************
05219 
05220 >   static BOOL DialogBarOp::WriteDockingBarsToFile(CCLexFile& file)
05221 
05222     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
05223     Created:    7/4/94
05224     Inputs:     file = file to write persistant docking data to
05225     Outputs:    -
05226     Returns:    -
05227     Purpose:    Writes the persistant docking data retrieved from the docking system.
05228     Errors:     -
05229     SeeAlso:    -
05230 
05231 ********************************************************************************************/
05232 
05233 BOOL DialogBarOp::WriteDockingBarsToFile(CCLexFile& file)
05234 {
05235 #pragma message( __LOCMSG__ "DialogBarOp::WriteDockingBarsToFile - do nothing" )
05236     TRACE( _T("Warning - DialogBarOp::WriteDockingBarsToFile called") );
05237 /*  BOOL ok = TRUE;
05238     CCamFrame* pMainFrame = GetMainFrame();
05239 
05240     ok = (pMainFrame != NULL);
05241 
05242     for (INT32 i=0;i<NUM_DOCKBARS && ok;i++)
05243     {
05244         OILDockingBar* pDockBar = pMainFrame->GetDockBar((DockBarType)i);
05245         if (ok) ok = (pDockBar != NULL);
05246 
05247         if (ok) ok = file.PutToken(TokenTable[TOKEN_DOCKING_BAR].Token);
05248         if (ok) ok = file.PutToken(TokenTable[TOKEN_DOCKBAR_LEFT+i].Token);
05249         if (ok)
05250         {
05251             if (pDockBar->IsBigControls())
05252                 ok = file.PutToken(TokenTable[TOKEN_BIG].Token);
05253             else
05254                 ok = file.PutToken(TokenTable[TOKEN_SMALL].Token);
05255         }
05256         if (ok) ok = file.PutNewLine();
05257     }
05258 
05259     if (ok) ok = file.PutNewLine();
05260 
05261     return (ok); */
05262 
05263     return false;
05264 }
05265 
05266 /********************************************************************************************
05267 
05268 >   static BOOL DialogBarOp::WriteWorkSpaceInfoToFile(CCLexFile& file)
05269 
05270     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
05271     Created:    11/10/94
05272     Inputs:     file = file to write persistant docking data to
05273     Outputs:    -
05274     Returns:    -
05275     Purpose:    Writes workspace data to ini file ( Full Screen Mode etc..) 
05276     Errors:     -
05277     SeeAlso:    -
05278 
05279 ********************************************************************************************/
05280 
05281 BOOL DialogBarOp::WriteWorkSpaceInfoToFile(CCLexFile& file)
05282 {
05283 #pragma message( __LOCMSG__ "DialogBarOp::WriteWorkSpaceInfoToFile - do nothing" )
05284     TRACE( _T("Warning - DialogBarOp::WriteWorkSpaceInfoToFile called") );
05285 /*  BOOL ok = TRUE;
05286     CCamFrame* pMainFrame = GetMainFrame();
05287 
05288     ok = (pMainFrame != NULL);
05289     
05290     if (ok) ok = file.PutToken(TokenTable[TOKEN_FULLSCREEN].Token);
05291     if(pMainFrame->IsFullScreenMode())
05292     {
05293         if (ok) ok = file.PutToken(TokenTable[TOKEN_ON].Token);
05294     }
05295     else
05296     {
05297         if (ok) ok = file.PutToken(TokenTable[TOKEN_OFF].Token);
05298     }
05299     if (ok) ok = file.PutNewLine();
05300 
05301     if (ok) ok = file.PutToken(TokenTable[TOKEN_STATUS_BAR].Token);
05302     
05303     if(pMainFrame->IsStatusBarVisible())
05304     {
05305         if (ok) ok = file.PutToken(TokenTable[TOKEN_VISIBLE].Token);
05306     }
05307     else
05308     {
05309         if (ok) ok = file.PutToken(TokenTable[TOKEN_INVISIBLE].Token);
05310     }
05311     if (ok) ok = file.PutNewLine();
05312 
05313     if (ok) ok = file.PutToken(TokenTable[TOKEN_COLOUR_BAR].Token);
05314     if(pMainFrame->IsColourBarVisible())
05315     {
05316         if (ok) ok = file.PutToken(TokenTable[TOKEN_VISIBLE].Token);
05317     }
05318     else
05319     {
05320         if (ok) ok = file.PutToken(TokenTable[TOKEN_INVISIBLE].Token);
05321     }
05322     
05323     if (ok) ok = file.PutNewLine();
05324 
05325     if (ok) ok = file.PutToken(TokenTable[TOKEN_SCROLL_BARS].Token);
05326     if(pMainFrame->AreScrollBarsVisible())
05327     {
05328         if (ok) ok = file.PutToken(TokenTable[TOKEN_VISIBLE].Token);
05329     }
05330     else
05331     {
05332         if (ok) ok = file.PutToken(TokenTable[TOKEN_INVISIBLE].Token);
05333     }
05334     
05335     if (ok) ok = file.PutNewLine();
05336     if (ok) ok = file.PutNewLine();
05337 
05338     return (ok); */
05339 
05340     return false;
05341 }
05342 
05343 /********************************************************************************************
05344 
05345 >   static BOOL DialogBarOp::FlushUpToToken(CCLexFile& file,TokenIndex Token)
05346 
05347     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
05348     Created:    19/4/95
05349     Inputs:     file = file to read bar tokens from
05350                 Token= token that we want to read up to.
05351     Outputs:    -
05352     Returns:    TRUE  = Able to read upto token OR end of file
05353                 FALSE = Failed to read the bar info without error. The error cases are -
05354                         1. File error (e.g. file open, disk fault, etc)
05355 
05356     Purpose:    This reads the file until it finds the token given, or it finds the end of file.
05357                 This is used to skip over bar definitions that ReadBarsFromFile() knows it can ignore,
05358                 e.g. old versions of bars, extinct class names, etc
05359     Errors:     -
05360     SeeAlso:    DialogBarOp::ReadBarsFromFile()
05361 
05362 ********************************************************************************************/
05363 
05364 BOOL DialogBarOp::FlushUpToToken(CCLexFile& file,TokenIndex Token)
05365 {
05366     BOOL finished = FALSE,ok = TRUE;
05367 
05368     // Get ptr to token buffer. Guaranteed not to move until next
05369     // InitLexer() call
05370     const TCHAR* TokenBuf = file.GetTokenBuf();
05371 
05372     while (!finished && ok)
05373     {
05374         ok = file.GetSimpleToken();
05375 
05376         if (ok)
05377             finished = (file.GetTokenType() == TOKEN_EOF) || (FindToken(TokenBuf) == Token);
05378     }
05379 
05380     return ok;
05381 }
05382 
05383 /********************************************************************************************
05384 
05385 >   static BOOL DialogBarOp::ReadBarsFromFile(  CCLexFile& file,
05386                                                 BarCreate& BarCreate,
05387                                                 UINT32* pNumBarsRead = NULL,
05388                                                 UINT32* pNumDockingBarsRead = NULL)
05389 
05390     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
05391     Created:    6/4/94
05392     Inputs:     file                = file to read bar tokens from
05393                 BarCreate           = reference to class for creation of object to read
05394                 pNumBarsRead        = where to put num bars, galleries read on exit
05395                 pNumDockingBarsRead = where to put num dock bars read on exit
05396     Outputs:    Num bars read is stored in *pNumBarsRead if != NULL
05397                 Num dock bars read is stored in *pNumDockingBarsRead if != NULL
05398     Returns:    TRUE  = At least one bar and all docking bars have been read from
05399                         the file without error.
05400                 FALSE = Failed to read the bar info without error. The error cases are -
05401                         1. If a syntax error occurs during reading of file
05402                         2. File error (e.g. file open, disk fault, etc)
05403 
05404     Purpose:    Reads the bars represented in the given file.
05405                 It reads the file in an ASCII tokenized form using CCLexFile::GetSimpleToken(),
05406                 and reconstructs the bars defined.
05407 
05408                 This also reads galleries from your favorite bars.ini file (or equivalent).
05409                 They are (of course) created without reference to your BarCreate function as the
05410                 create function is cunningly encoded within the gallery definition itself.
05411 
05412     Errors:     -
05413     SeeAlso:    -
05414 
05415 ********************************************************************************************/
05416 
05417 BOOL DialogBarOp::ReadBarsFromFile( CCLexFile& file,
05418                                     BarCreate& BarCreate,
05419                                     UINT32* pNumBarsRead,
05420                                     UINT32* pNumDockingBarsRead)
05421 {
05422 #pragma message( __LOCMSG__ "DialogBarOp::ReadBarsFromFile - do nothing" )
05423     TRACE( _T("Warning - DialogBarOp::ReadBarsFromFile called") );
05424 /*  BOOL ok  = TRUE;                    // Indicates a serious error if FALSE
05425     BOOL eof = FALSE;                   // TRUE if end of file is found
05426     UINT32 NumBarsRead = 0;             // Count of number of bars read
05427     UINT32 NumDockingBarsRead = 0;      // Count of number of docking bars read
05428     
05429     ok = file.InitLexer();              // Initialise lexing routines
05430 
05431     file.SetDelimiters("\r\n");         // Set token delimiting characters
05432     file.SetCommentMarker(';');         // Set comment marker char
05433     file.SetWhitespace(" \t");          // Set whitespace chars
05434     file.SetStringDelimiters("\"\"");   // Set string delimiters
05435 
05436     // Get ptr to token buffer. Guaranteed not to move until next
05437     // InitLexer() call
05438     const TCHAR* TokenBuf = file.GetTokenBuf();
05439 
05440     while (ok && !eof)
05441     {
05442         // Get keyword token and token type
05443         BOOL main_token_ok     = file.GetSimpleToken();
05444         LexTokenType TokenType = file.GetTokenType();
05445 
05446         if (!main_token_ok)
05447         {
05448             // If no main token, check for EOF
05449             // If EOF then everything's ok
05450             eof = (TokenType == TOKEN_EOF);
05451             ok  = eof;
05452         }           
05453 
05454         if (main_token_ok)
05455         {
05456             // Get token index from our list of tokens
05457             TokenIndex Token = FindToken(TokenBuf);
05458 
05459             switch (Token)
05460             {
05461                 case TOKEN_BAR :
05462                 {
05463                     // Create DialogBarOp or derived class using BarCreate object
05464                     DialogBarOp* pDialogBarOp = BarCreate.Create();
05465 
05466                     // Read definition and inc num bars read
05467                     ok = (pDialogBarOp != NULL);
05468                     if (ok) ok = pDialogBarOp->Read(file);
05469                     if (ok) NumBarsRead++;
05470                     if (!ok && (pDialogBarOp != NULL)) pDialogBarOp->End();
05471                 }
05472                 break;
05473                 case TOKEN_INFO_BAR :
05474                 {
05475                     // Create DialogBarOp or derived class using BarCreate object
05476                                         // Read definition and inc num bars read
05477                      ok = InformationBarOp::Read(file);
05478                 }
05479                 break;
05480 
05481                 case TOKEN_GALLERY :
05482                 {
05483                     // New type by Alex; the only difference is where we get the type from
05484                     // (it's encoded in ASCII in BARS.INI)
05485                     CCRuntimeClass *pCCRuntimeClass;
05486 
05487                     ok = file.GetSimpleToken();
05488                     // Get a pointer to the corresponding runtime class object.
05489                     if (ok)
05490                     {
05491                         ok = ((pCCRuntimeClass = CCObject::GetRuntimeClassByName( TokenBuf )) != NULL);
05492                         if (!ok)
05493                         {
05494                             TRACE( _T("Resource file contains unknown gallery class : '%s'\n"),TokenBuf);
05495 //                          ok = FlushUpToToken(file,TOKEN_GALLERY_END);
05496 //                          break;
05497                         }
05498                     }
05499 
05500                     if (ok) 
05501                     {
05502                         // Go and create the object of the correct runtime class
05503                         DialogBarOp* pDialogBarOp = (DialogBarOp *) pCCRuntimeClass->CreateObject();
05504 
05505                         // Read definition and inc num bars read
05506                         ok = (pDialogBarOp != NULL);
05507                         if (!ok) TRACE( _T("Unable to create an object called '%s'\n"),TokenBuf);
05508 
05509                         // Check it's a real gallery. We ensure on debug builds, but just ignore the
05510                         // entry in retail builds.
05511                         //
05512                         // This should only ever happen if ccobject.cpp is broken or someone's put an
05513                         // incorrectly derived, or non DYNA_CREATE class in BARS.INI
05514                         //
05515                         if (ok) 
05516                         {
05517                             ok = (pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)));
05518 #ifdef _DEBUG
05519                             if (!ok) TRACE( _T("'%s' is not defined as an instance of a SuperGallery"));
05520 #endif
05521                         }
05522 
05523                         // Note that the read function is likely to be overridden so this can read
05524                         // gellery specific parameters
05525                         if (ok) ok = pDialogBarOp->Read(file);
05526                         if (ok) NumBarsRead++;
05527                         if (!ok && (pDialogBarOp != NULL)) pDialogBarOp->End();
05528                     } 
05529                 }
05530                 break;
05531                 
05532                 case TOKEN_STATUS_BAR :
05533                 {
05534                     ok = file.GetSimpleToken();
05535                     if (ok)
05536                     {
05537                         BOOL Show;
05538                         Token = FindToken(TokenBuf);
05539                         switch(Token)
05540                         {
05541                             case TOKEN_VISIBLE  :   Show = TRUE;        break;
05542                             case TOKEN_INVISIBLE:   Show = FALSE;       break; 
05543                          }
05544                          GetMainFrame()->ShowStatusBar(Show);                       
05545                     }
05546                  
05547 
05548                 }
05549                 break;
05550                 case TOKEN_COLOUR_BAR :
05551                 {
05552                     ok = file.GetSimpleToken();
05553                     if (ok)
05554                     {
05555                         BOOL Show;
05556                         Token = FindToken(TokenBuf);
05557                         switch(Token)
05558                         {
05559                             case TOKEN_VISIBLE  :   Show = TRUE;        break;
05560                             case TOKEN_INVISIBLE:   Show = FALSE;       break; 
05561                          }
05562                          GetMainFrame()->ShowColourBar(Show);                       
05563                     }
05564                  
05565 
05566                 }
05567                 break;
05568                 
05569                 case TOKEN_SCROLL_BARS :
05570                 {
05571                     ok = file.GetSimpleToken();
05572                     if (ok)
05573                     {
05574                         BOOL Show;
05575                         Token = FindToken(TokenBuf);
05576                         switch(Token)
05577                         {
05578                             case TOKEN_VISIBLE  :   Show = TRUE;        break;
05579                             case TOKEN_INVISIBLE:   Show = FALSE;       break; 
05580                          }
05581                          GetMainFrame()->ShowScrollBars(Show);                      
05582                     }
05583                  
05584 
05585                 }
05586                 break;
05587                 
05588                 case TOKEN_FULLSCREEN :
05589                 {
05590                     ok = file.GetSimpleToken();
05591                     if (ok)
05592                     {
05593                         BOOL Mode;
05594                         Token = FindToken(TokenBuf);
05595                         switch(Token)
05596                         {
05597                             case TOKEN_ON  :    Mode = TRUE;        break;
05598                             case TOKEN_OFF:     Mode = FALSE;       break; 
05599                          }
05600                          GetMainFrame()->DoFullScreenMode(Mode);                        
05601                     }
05602                 }
05603                 break;
05604                 
05605                 case TOKEN_DOCKING_BAR :
05606                 {
05607                     DockBarType DockType;
05608 
05609                     // Which bar are we refering to ??
05610                     ok = file.GetSimpleToken();
05611                     if (ok)
05612                     {
05613                         Token = FindToken(TokenBuf);
05614                         switch(Token)
05615                         {
05616                             case TOKEN_DOCKBAR_LEFT:    DockType=DOCKBAR_LEFT;      break;
05617                             case TOKEN_DOCKBAR_RIGHT:   DockType=DOCKBAR_RIGHT;     break;
05618                             case TOKEN_DOCKBAR_TOP:     DockType=DOCKBAR_TOP;       break;
05619                             case TOKEN_DOCKBAR_BOTTOM:  DockType=DOCKBAR_BOTTOM;    break;
05620                             case TOKEN_DOCKBAR_FLOAT:   DockType=DOCKBAR_FLOAT;     break;
05621 
05622                             default:
05623                                 TRACE( _T("No dockbar type in bars.ini"));
05624                                 ok = FALSE;
05625                                 break;
05626                         }
05627                         if (ok) ok = file.GetSimpleToken();
05628                         // Check for Small/Big controls
05629                         if (ok)
05630                         {
05631                             Token = FindToken(TokenBuf);
05632                 
05633                             OILDockingBar* pDockBar = GetMainFrame()->GetDockBar(DockType);
05634                             // Set the dockbar control size - default to small
05635                             pDockBar->SetBigControlState(Token == TOKEN_BIG);
05636 
05637                             // Inc num docking bars read
05638                             NumDockingBarsRead++;
05639                         }
05640                     }
05641                 }
05642                 break;
05643             }
05644         }
05645     }
05646 
05647     if (!ok)
05648     {
05649         // If something when wrong, tell the debug dudes and give as much info as possible
05650         //ENSURE(FALSE,"Error reading a bar control. See TRACE output for details");
05651         TRACE( _T("\n\nError reading bars from a file"));
05652         TRACE( _T(" Token buffer = %s\n"),TokenBuf);
05653         TRACE( _T(" Line buffer  = %s\n"),file.GetLineBuf());
05654     }
05655 
05656 
05657     // We are now finished with the lexer
05658     file.DeinitLexer();
05659 
05660     // Relay num bars and docking bars back to caller if they want the info
05661     if (pNumBarsRead        != NULL) *pNumBarsRead        = NumBarsRead;
05662     if (pNumDockingBarsRead != NULL) *pNumDockingBarsRead = NumDockingBarsRead;
05663 
05664     return (ok); */
05665 
05666     return false;
05667 }
05668 
05669 
05670 
05671 /********************************************************************************************
05672 
05673 >   BOOL DialogBarOp::AllowMulSelInListBox()
05674 
05675     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
05676     Created:    9/8/94
05677     Inputs:     -
05678     Outputs:    -
05679     Returns:    TRUE if the list box associated with the dialog bar op should allow multiple
05680                 selection or not
05681     Purpose:    Linked heavilly with the BaseBar class and the creation of list boxes associated
05682                 with the dialog bar op of a gallery.
05683                 This gives the derived dialog bar op the opportunity to have a say to whether the list
05684                 box should allow multiple selection or not.
05685                 This base version always returns TRUE
05686     Errors:     -
05687     SeeAlso:    -
05688 
05689 ********************************************************************************************/
05690 
05691 BOOL DialogBarOp::AllowMulSelInListBox()
05692 {
05693     return TRUE;
05694 }
05695 
05696  /********************************************************************************************
05697 
05698 >   BOOL DialogBarOp::IsAllBarsOp()
05699 
05700     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05701     Created:    22/5/95
05702     Inputs:     -
05703     Outputs:    -
05704     Returns:    TRUE if this is the special bar that contains all controls
05705     Purpose:    -
05706     Errors:     -
05707     SeeAlso:    -
05708 
05709 ********************************************************************************************/
05710 
05711 BOOL DialogBarOp::IsAllBarsOp()
05712 {
05713     
05714     return this == AllBarsOp;
05715         
05716     //return Name == String_32(_R(IDS_CONTROLBANKNAME));
05717 
05718 }
05719 /****************************************************************************************
05720 static BOOL DialogBarOp::AddOpToAll( OpDescriptor* pHorzOpDesc, 
05721                                      OpDescriptor* pVertOpDesc = NULL)
05722 
05723     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
05724     Created:    16/5/95
05725     Inputs:     Pointer to the Horz OpDescriptor to connect to a bar
05726                 Pointer to the Vert OpDescriptor to connect to a bar (should be NULL
05727                   if Vert is same as Horz op desc)
05728     Outputs:    -
05729     Returns:    TRUE if added OK.
05730                 FALSE otherwise.
05731     Purpose:    DEAD.
05732     Errors:     -
05733     SeeAlso:    -
05734 
05735 ******************************************************************************************/
05736 
05737 BOOL DialogBarOp::AddOpToAll(OpDescriptor* pHorzOpDesc,OpDescriptor* pVertOpDesc)
05738 {
05739     return FALSE;
05740 }
05741 
05742 
05743 
05744 
05745 //-----------------------------------------------------------------
05746 //-----------------------------------------------------------------
05747 //-----------------------------------------------------------------
05748 //-----------------------------------------------------------------
05749 // SystemBarOp methods
05750 
05751 
05752 /********************************************************************************************
05753 
05754 >   SystemBarOp::SystemBarOp()
05755 
05756     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
05757     Created:    26/4/94
05758     Inputs:     -
05759     Outputs:    -
05760     Returns:    -
05761     Purpose:    Dummy constructor for DYNCREATE
05762     Errors:     -
05763     SeeAlso:    -
05764 
05765 ********************************************************************************************/
05766 
05767 SystemBarOp::SystemBarOp()
05768 {
05769 
05770 }
05771 
05772 /********************************************************************************************
05773 
05774 >   SystemBarOp::SystemBarOp(UINT32 BarNameID, SystemBarType GrpBarID)
05775 
05776     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
05777     Created:    26/4/94
05778     Inputs:     BarNameID = ID of string used as the name of the bar (appears in
05779                             toolbars dialogue)
05780                 GrpBarID  = The group which this system belongs (e.g. File, Edit, etc)
05781     Outputs:    -
05782     Returns:    -
05783     Purpose:    Constructor
05784     Errors:     -
05785     SeeAlso:    -
05786 
05787 ********************************************************************************************/
05788 
05789 SystemBarOp::SystemBarOp(   UINT32 BarNameID, 
05790                             SystemBarType GrpBarID,
05791                             DockBarType DockType,
05792                             UINT32 Slot,
05793                             INT32 Offset) : 
05794                             DialogBarOp(BarNameID, CC_RUNTIME_CLASS(DialogBarOp) )
05795 {
05796     GroupBarID = GrpBarID;
05797 
05798     SetDockBarType(DockType);
05799     SetSlot(Slot);
05800     SetOffset(Offset);
05801 }
05802 
05803 /********************************************************************************************
05804 
05805 >   BOOL SystemBarOp::Write(CCLexFile& file)
05806 
05807     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
05808     Created:    15/4/94
05809     Inputs:     file = a file to Write the dialog bar to.
05810     Outputs:    -
05811     Returns:    FALSE always because system bars can't be serialised
05812     Purpose:    Trap calls to write out system bars
05813     Errors:     -
05814     SeeAlso:    -
05815 
05816 ********************************************************************************************/
05817 
05818 BOOL SystemBarOp::Write(CCLexFile& file)
05819 {
05820     return (FALSE);
05821 }
05822 
05823 
05824 /********************************************************************************************
05825 
05826 >   BOOL SystemBarOp::Read(CCLexFile& file)
05827 
05828     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
05829     Created:    15/4/94
05830     Inputs:     file = a file to read the dialog bar from.
05831     Outputs:    -
05832     Returns:    FALSE always because this routine should never be called!
05833     Purpose:    Trap call to read bars in the system bar class
05834     Errors:     -
05835     SeeAlso:    -
05836 
05837 ********************************************************************************************/
05838 
05839 BOOL SystemBarOp::Read(CCLexFile& file)
05840 {
05841     return (FALSE);
05842 }
05843 
05844 /********************************************************************************************
05845 
05846 >   BOOL SystemBarOp::Write(SaveRegistryEntries& Saver)
05847 
05848     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
05849     Created:    20/2/97
05850     Inputs:     Saver = the class to use to write out the registry data.
05851     Outputs:    -
05852     Returns:    FALSE always because system bars can't be serialised
05853     Purpose:    Trap calls to write out system bars
05854     Errors:     -
05855     SeeAlso:    -
05856 
05857 ********************************************************************************************/
05858 
05859 BOOL SystemBarOp::Write(SaveRegistryEntries& Saver)
05860 {
05861     return (FALSE);
05862 }
05863 
05864 
05865 /********************************************************************************************
05866 
05867 >   BOOL SystemBarOp::Read(LoadRegistryEntries& Loader)
05868 
05869     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
05870     Created:    20/2/97
05871     Inputs:     Loader = the class to use to load in the registry data.
05872     Outputs:    -
05873     Returns:    FALSE always because this routine should never be called!
05874     Purpose:    Trap call to read bars in the system bar class
05875     Errors:     -
05876     SeeAlso:    -
05877 
05878 ********************************************************************************************/
05879 
05880 BOOL SystemBarOp::Read(LoadRegistryEntries& Loader)
05881 {
05882     return (FALSE);
05883 }
05884 
05885 
05886 
05887 /******************************************************************************************
05888 
05889 >   static SystemBarOp* SystemBarOp::FindType(SystemBarType SystemBarID)
05890 
05891     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
05892     Created:    17/4/94
05893     Inputs:     Type of system bar to find
05894     Outputs:    -
05895     Returns:    Pointer to the system bar of the specified type.
05896                 NULL is returned if system bar is not found.
05897     Purpose:    To find one of the permanently created system bars which are used to group
05898                 OpDescriptors so that they can be presented to the user in a sensible way.
05899                 This routine searches the list of DialogBarOps created by the message 
05900                 manager to distribute messages to DialgBarOps.
05901     Errors:     -
05902     SeeAlso:    -
05903 
05904 ******************************************************************************************/
05905 
05906 SystemBarOp* SystemBarOp::FindType(SystemBarType SystemBarID)
05907 {
05908     // Search the list of DialogBarOps for the specified system bar...
05909     List* pBarList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogBarOp));
05910     ENSURE(pBarList,"Can't find list of DialogBarOps in SystemBarOp::FindType");
05911 
05912     DialogBarOp* pBar = (DialogBarOp*)pBarList->GetHead();      // Get ptr to head of list
05913     while (pBar)                                                // While there are BarOps
05914     {
05915         if (pBar->IsKindOf(CC_RUNTIME_CLASS(SystemBarOp)))      // test class
05916         {
05917             if (((SystemBarOp*)pBar)->GroupBarID == SystemBarID)// test type
05918             {
05919                 return ( (SystemBarOp*)pBar );                  // If they match then return
05920             }                                                   // a ptr to this BarOp
05921         }
05922         pBar = (DialogBarOp*)pBarList->GetNext(pBar);           // else skip to next bar
05923     }                                                           // and continue...
05924 
05925     return (NULL);                                              // If no match was found
05926 }
05927 
05928 
05929 
05930 
05931 /******************************************************************************************
05932 
05933 >   static BOOL SystemBarOp::Connect(SystemBarType SystemBarID,
05934                                      OpDescriptor* pHorzOpDesc, 
05935                                      OpDescriptor* pVertOpDesc = NULL)
05936 
05937     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> (& MarkN)
05938     Created:    17/4/94
05939     Inputs:     Type of system bar to find and connect OpDescriptor to.
05940                 Pointer to the Horz OpDescriptor to connect to a bar
05941                 Pointer to the Vert OpDescriptor to connect to a bar (should be NULL
05942                   if Vert is same as Horz op desc)
05943     Outputs:    -
05944     Returns:    TRUE if connection succeeded.
05945                 FALSE otherwise.
05946     Purpose:    To connect an OpDescriptor to the specified system bar.
05947     Errors:     -
05948     SeeAlso:    -
05949 
05950 ******************************************************************************************/
05951 
05952 BOOL SystemBarOp::Connect(SystemBarType SystemBarID,OpDescriptor* pHorzOpDesc,OpDescriptor* pVertOpDesc)
05953 {
05954     BOOL ConnectedOK = FALSE;                           // Setup return value
05955 
05956     SystemBarOp* pSystemBar = SystemBarOp::FindType(SystemBarID);   // Find the bar specified by the ID
05957     if (pSystemBar)
05958         ConnectedOK = SystemBarOp::Connect(pSystemBar,pHorzOpDesc,pVertOpDesc);
05959 
05960     return (ConnectedOK);                               // If no match was found
05961 }
05962 
05963 
05964 
05965 
05966 /******************************************************************************************
05967 
05968 >   static BOOL SystemBarOp::Connect(SystemBarOp*,  OpDescriptor* pHorzOpDesc, 
05969                                                     OpDescriptor* pVertOpDesc = NULL)
05970 
05971     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> (& MarkN)
05972     Created:    17/4/94
05973     Inputs:     Pointer to system bar to connect OpDescriptor to.
05974                 Pointer to the Horz OpDescriptor to connect to a bar
05975                 Pointer to the Vert OpDescriptor to connect to a bar (should be NULL
05976                   if Vert is same as Horz op desc)
05977     Outputs:    -
05978     Returns:    TRUE if connection succeeded.
05979                 FALSE otherwise.
05980     Purpose:    To connect an OpDescriptor to the specified system bar.
05981     Errors:     -
05982     SeeAlso:    -
05983 
05984 ******************************************************************************************/
05985 
05986 BOOL SystemBarOp::Connect(SystemBarOp* pSystemBar,OpDescriptor* pHorzOpDesc,OpDescriptor* pVertOpDesc)
05987 {
05988     BOOL ConnectedOK = FALSE;                           // Setup return value
05989 
05990     if (pSystemBar)
05991     {
05992         BarControl* pBarCtrl = new BarControl();
05993         if (pBarCtrl)
05994         {
05995             // Set horz op desc
05996             pBarCtrl->SetHorzOpDesc(pHorzOpDesc);
05997 
05998             // Set vert op desc depending on pVertOpDesc
05999             if (pVertOpDesc != NULL)
06000                 pBarCtrl->SetVertOpDesc(pVertOpDesc);
06001             else
06002                 pBarCtrl->SetVertOpDesc(pHorzOpDesc);
06003 
06004             // Add the BarControl to to the system bar 
06005             pSystemBar->AddBarItem(pBarCtrl);
06006 
06007             ConnectedOK = TRUE;
06008         }
06009     }
06010 
06011     return (ConnectedOK);                               // If no match was found
06012 }
06013 
06014 /******************************************************************************************
06015 
06016 >   static BOOL SystemBarOp::Separate(SystemBarType SystemBarID)
06017 
06018     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
06019     Created:    19/4/94
06020     Inputs:     Type of system bar to find and connect OpDescriptor to.
06021     Outputs:    -
06022     Returns:    TRUE if connection succeeded.
06023                 FALSE otherwise.
06024     Purpose:    To connect a separator to the specified system bar.
06025     Errors:     -
06026     SeeAlso:    -
06027 
06028 ******************************************************************************************/
06029 
06030 BOOL SystemBarOp::Separate(SystemBarType SystemBarID)
06031 {
06032     BOOL ConnectedOK = FALSE;                           // Setup return value
06033 
06034     SystemBarOp* pSystemBar = SystemBarOp::FindType(SystemBarID);   // Find the bar specified by the ID
06035     if (pSystemBar)
06036         ConnectedOK = SystemBarOp::Separate(pSystemBar);
06037 
06038     return (ConnectedOK);                               // If no match was found
06039 }
06040 
06041 
06042 
06043 
06044 /******************************************************************************************
06045 
06046 >   static BOOL SystemBarOp::Separate(SystemBarOp* pSystemBar)
06047 
06048     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
06049     Created:    19/4/94
06050     Inputs:     Pointer to system bar to connect OpDescriptor to.
06051     Outputs:    -
06052     Returns:    TRUE if connection succeeded.
06053                 FALSE otherwise.
06054     Purpose:    To connect a separator to the specified system bar.
06055     Errors:     -
06056     SeeAlso:    -
06057 
06058 ******************************************************************************************/
06059 
06060 BOOL SystemBarOp::Separate(SystemBarOp* pSystemBar)
06061 {
06062     BOOL ConnectedOK = FALSE;                           // Setup return value
06063 
06064     if (pSystemBar)
06065     {
06066         BarSeparator* pBarSep = new BarSeparator();
06067         if (pBarSep)
06068         {
06069             // Add the BarControl to to the system bar 
06070             pSystemBar->AddBarItem(pBarSep);
06071 
06072             ConnectedOK = TRUE;
06073         }
06074     }
06075 
06076     return (ConnectedOK);                               // If no match was found
06077 }
06078 
06079 /********************************************************************************************
06080 
06081 >   static BOOL SystemBarOp::Init()
06082 
06083     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
06084     Created:    25/4/94
06085     Inputs:     -
06086     Outputs:    -
06087     Returns:    -
06088     Purpose:    Registers SystemBarOp OpDescriptor
06089     Errors:     -
06090     SeeAlso:    -
06091 
06092 ********************************************************************************************/
06093 
06094 BOOL SystemBarOp::Init()
06095 {
06096     
06097     BOOL ok;
06098     ok =    (RegisterOpDescriptor(
06099                                 0, 
06100                                 _R(IDS_MARKN_EMPTY),
06101                                 CC_RUNTIME_CLASS(SystemBarOp), 
06102                                 OPTOKEN_DLGBAROP,
06103                                 NULL // No GetState
06104     
06105                                 )
06106     /*
06107             &&
06108             new SystemBarOp( _R(IDS_FILE_BAR), SYSTEMBAR_FILE )
06109             &&
06110             new SystemBarOp( _R(IDS_EDIT_BAR), SYSTEMBAR_EDIT )
06111             &&
06112             new SystemBarOp( _R(IDS_ATTRIBUTE_BAR), SYSTEMBAR_ATTRIBUTE )
06113             &&
06114             new SystemBarOp( _R(IDS_ARRANGE_BAR), SYSTEMBAR_ARRANGE )
06115             &&
06116             new SystemBarOp( _R(IDS_UTILS_BAR), SYSTEMBAR_UTILITIES )
06117             &&
06118             new SystemBarOp( _R(IDS_WINDOW_BAR), SYSTEMBAR_WINDOW )
06119             &&
06120             new SystemBarOp( _R(IDS_HELP_BAR), SYSTEMBAR_HELP )
06121     */
06122             ); 
06123 
06124     return ok; 
06125 }
06126 
06127 /********************************************************************************************
06128 
06129 >   MsgResult SystemBarOp::Message(Msg* Msg)
06130 
06131     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
06132     Created:    25/5/94
06133     Inputs:     Msg: The message to handle
06134     Outputs:    -                  
06135     Returns:    -
06136     Purpose:    The default SystemBarOp Message handler
06137     Errors:     -
06138     SeeAlso:    -
06139 
06140 ********************************************************************************************/
06141 
06142 MsgResult SystemBarOp::Message(Msg* Msg)
06143 {
06144     // We must destroy the dialog if the application is dying
06145 //  if (MESSAGE_IS_A(Msg,DeathMsg))
06146 //      End();                          // Camelot is ending, so end the Op
06147 
06148 //      return OK;
06149     return (DialogBarOp::Message(Msg));
06150 }
06151 
06152 
06153 /********************************************************************************************/
06154 // InformationBarOp methods 
06155 
06156 /********************************************************************************************
06157 
06158 >   InformationBarOp::InformationBarOp(CCRuntimeClass* Class = CC_RUNTIME_CLASS(DialogBarOp)): DialogBarOp(Class) 
06159                                                  
06160     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
06161     Created:    17/4/94
06162     Inputs:     -
06163     Outputs:    -
06164     Returns:    -
06165     Purpose:    InformationBarOp constructor (Identical to DialogOp)
06166     Errors:     -
06167     SeeAlso:    -
06168 
06169 ********************************************************************************************/
06170 
06171 InformationBarOp::InformationBarOp(CCRuntimeClass* Class): DialogBarOp(Class) 
06172 {
06173 }
06174 
06175 /********************************************************************************************
06176 
06177 >   InformationBarOp::InformationBarOp(String_32& NewName,CCRuntimeClass* Class = CC_RUNTIME_CLASS(DialogBarOp): 
06178     DialogBarOp(NewName, Class) 
06179 
06180     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
06181     Created:    17/4/94
06182     Inputs:     -
06183     Outputs:    -
06184     Returns:    -
06185     Purpose:    InformationBarOp constructor (Identical to DialogOp)
06186     Errors:     -
06187     SeeAlso:    -
06188 
06189 ********************************************************************************************/
06190 
06191 InformationBarOp::InformationBarOp(String_32& NewName,CCRuntimeClass* Class): 
06192     DialogBarOp(NewName, Class) 
06193 {
06194 }
06195 
06196 
06197 /********************************************************************************************
06198 
06199 >   virtual MsgResult InformationBarOp::Message(Msg* Message)
06200 
06201     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
06202     Created:    17/4/94
06203     Inputs:     Message
06204     Outputs:    -
06205     Returns:    -
06206     Purpose:    The InformationBars message handler is used to handle class wide events,
06207                 such as broadcasting a message when an infobar is closed, etc
06208     Errors:     -
06209     SeeAlso:    DialogOp::Message
06210 
06211 ********************************************************************************************/
06212 
06213 MsgResult InformationBarOp::Message(Msg* Message)
06214 {
06215 //  if (IsUserName("MarkN")) TRACE( _T("InformationBarOp::Message()\n"));
06216 
06217     if (IS_OUR_DIALOG_MSG(Message))
06218     {
06219         DialogMsg* Msg = (DialogMsg*)Message;
06220 
06221         // Check if the message is a CANCEL
06222         if (Msg->DlgMsg == DIM_CANCEL)
06223         {
06224             
06225             //if (IsUserName("MarkN")) TRACE( _T("InformationBarOp::Message(DIM_CANCEL)\n"));
06226             
06227             InformationBarOp::Visible = FALSE;
06228     
06229             // Report bar is closing to interested parties
06230             BROADCAST_TO_CLASS(BarMsg(BAR_CLOSE,this),DialogOp);
06231         }
06232         else if (Msg->DlgMsg == DIM_CREATE)
06233         {
06234         }
06235 
06236         return (DLG_EAT_IF_HUNGRY(Msg)); 
06237     }
06238     else if (MESSAGE_IS_A(Message,DeathMsg))    // We must destroy the dialog if the application is dying
06239     {
06240         End();
06241         return OK;
06242     }
06243 
06244     // Not a message for our dialog
06245     return OK; 
06246 }
06247 
06248 /********************************************************************************************
06249 
06250 >   virtual void HandleProfileButtonClick (CBiasGainGadget& Gadget, CGadgetID ProfileGadget)
06251 
06252     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06253     Created:    19/1/2000
06254     Inputs:     CBiasGainGadget& and its GadgetID (for added safety)
06255     Outputs:    -
06256     Returns:    -
06257     Purpose:    Handles the opening/closing of the profile gadgets corrensponding profile
06258                 dialog when clicked.
06259     Errors:     -
06260     SeeAlso:    -
06261 
06262 ********************************************************************************************/
06263 void InformationBarOp::HandleProfileButtonClick (CBiasGainGadget& Gadget, CGadgetID ProfileGadgetID)
06264 {
06265     if (!(Gadget.IsDialogOpen ()))
06266     {
06267         CBiasGainDlg* pDialog_m  =  new CBiasGainDlg();
06268         BOOL bMany = FALSE, bAllSameType = TRUE;
06269                                 
06270         CProfileBiasGain* appliedBiasGain = GetProfileFromSelection (ProfileGadgetID, &bMany, &bAllSameType);
06271 
06272         if (bAllSameType != FALSE)
06273         {
06274             pDialog_m->InvokeVia (Gadget, appliedBiasGain, bMany);
06275         }
06276     }
06277     else
06278     {
06279         Gadget.CloseDialog ();
06280     }
06281 }
06282 
06283 
06284 /********************************************************************************************
06285 
06286 >   virtual void HandleProfileSelChangingMsg (CBiasGainGadget& Gadget, CGadgetID ProfileGadgetID)
06287 
06288     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06289     Created:    19/1/2000
06290     Inputs:     CBiasGainGadget& and its GadgetID (for added safety)
06291     Outputs:    -
06292     Returns:    -
06293     Purpose:    Handles the updating/closing of the profile gadgets corrensponding profile
06294                 dialog when a SelChangingMsg is received.  This function does one of three
06295                 things:
06296                 
06297                 1)  If an object with a profile is selected, and we shift-select another such
06298                     object; then if the profiles are identical, updates the profile dialog to
06299                     reflect the common profile.
06300                 2)  If an object with a profile is selected, and we shift-select another such
06301                     object; then if the profiles are NOT identical, updates the profile dialog
06302                     to reflect the MANY profiles option.
06303                 3)  If an object with a profile is selected, and we shift-select another
06304                     DIFFERENT object (e.g.  we had a blend object selected, and shift-select a
06305                     trivial quickshape), closes down the profile dialog since the second
06306                     object does NOT contain a profile (thereby making it an undesirable to try
06307                     and apply a (common) profile to it).
06308 
06309                 These three things are also held when we are dealing with more than two objects.
06310 
06311                 The ability to detect these three cases is integrated within
06312                 GetProfileFromSelection () - which is called internally.
06313 
06314                 This function also posses the ability to close the profile dialog under the
06315                 following circumstances:
06316 
06317                 1)  Selecting no objects.
06318                 2)  Selecting a single object (of a different type to the previous).
06319 
06320                 WARNING:  this function behaves funny when trying to debug it!
06321                     
06322     Errors:     -
06323     SeeAlso:    InformationBarOp::GetProfileFromSelection ()
06324 
06325 ********************************************************************************************/
06326 
06327 void InformationBarOp::HandleProfileSelChangingMsg (CBiasGainGadget& Gadget, CGadgetID ProfileGadgetID)
06328 {
06329     BOOL bMany = FALSE, bAllSameType = TRUE;
06330     CProfileBiasGain* appliedBiasGain = GetProfileFromSelection (ProfileGadgetID, &bMany, &bAllSameType);
06331 
06332     if (Gadget.IsDialogOpen ())
06333     {
06334         if ((appliedBiasGain != NULL) || (bMany == TRUE))
06335         {
06336             if (bAllSameType == TRUE)
06337             {
06338                 // handles case where we click on another blend
06339                 Gadget.ReInitialiseDialog (appliedBiasGain, bMany);
06340             }
06341             else
06342             {
06343                 // handles case where we click on a non-blend object
06344                 Gadget.CloseDialog ();
06345                 EnableGadget (ProfileGadgetID, FALSE);
06346             }
06347         }
06348         else
06349         {   
06350             // CGS:  wo there!  when selecting another object, everything is deselected - and then just that node
06351             // selected.  This is a problem, since if we proceed regardless, the profile dialog closes (when it
06352             // possibly shouldn't have).  As such, I now check for this occurring ....
06353             
06354             if (bAllSameType)
06355             {
06356                 if (!SelectorTool::GetNormalClick_CheckProfileDialog ())
06357                 {
06358                     // user click on no object at all - close the profile dialog ....
06359                     Gadget.CloseDialog ();
06360                     EnableGadget (ProfileGadgetID, FALSE);
06361                 }
06362             }
06363             else
06364             {
06365                 // handles case where we click on a non-same type object
06366                 Gadget.CloseDialog ();
06367                 EnableGadget (ProfileGadgetID, FALSE);
06368             }
06369         }
06370     }
06371     else if (bAllSameType == TRUE)
06372     {
06373 //      EnableGadget (ProfileGadgetID, TRUE);
06374     }
06375     else if (bAllSameType == FALSE)
06376     {
06377         EnableGadget (ProfileGadgetID, FALSE);
06378     }
06379 }
06380 
06381 
06382 /********************************************************************************************
06383 
06384 >   virtual CProfileBiasGain* GetProfileFromSelection (CGadgetID ProfileGadgetID, BOOL* bMany, BOOL* bAllSameType)
06385 
06386     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06387     Created:    19/1/2000
06388     Inputs:     The GadgetID of the CBiasGainGadget that we are dealing with.
06389     Outputs:    bMany - returned as TRUE if we have MANY profiles selected.
06390                 bAllSameType - returned as TRUE if objects within selection are all of the
06391                 same type.
06392     Returns:    Ptr to common CProfileBiasGain, or NULL if there is NOT one.
06393     Purpose:    Is responsible for determining which of conditions 1-3 apply as detailed
06394                 within HandleProfileSelChangingMsg ().  The (correct) implementation of this
06395                 function is NOT trivial!!!!  This function MUST be overidden in every
06396                 derived InformationBarOp class that encorperates profiles since this base
06397                 class one ONLY returns NULL.
06398 
06399                 Now listen carefully, since I will now tell you the MUST HAVE requirements
06400                 for implementing an overide of this function.
06401 
06402                 1)  First things first, you MUST scan (in a loop) each object within the 
06403                     current selection.
06404                 2)  The first object scanned MUST have its profile stored (as a basis for
06405                     comparison).
06406                 3)  The first objects profile MUST be compared against each other objects
06407                     profile; AND if found to be different for ANY one, *bMany = TRUE.  If
06408                     the loop terminates successfully (i.e.  not executing *bMany = TRUE);
06409                     then *bMany = FALSE.  This requirement handles conditions 1-2.
06410                 4)  In parallel with 3), the function MUST also check to if the scanned
06411                     object is of the same type as the first; AND if they are different sets
06412                     *bAllSameType = FALSE.  Otherwise, upon successful loop termination,
06413                     *bAllSameType = TRUE.  This requirement handles condition 3.
06414 
06415                 Requirement 4, is non-trivial due to the fashion in which NodeShadow (and
06416                 like) exist within the Camelot tree.  Take a look at tools\blndtool.cpp
06417                 for a robust implementation of this function (which I also wrote).
06418 
06419                 The implementation of the function should also give some thought to the ID
06420                 of the gadget - so that you may distingush between the profile value to read
06421                 on infobars that have multiple profile gadgets.  Again take a look at
06422                 tools\blndtool.cpp for an example of this.
06423 
06424                 NOTE:  IF YOU DO NOT DO AS I HAVE OUTLAID ABOVE, THEN YOUR PROFILE GAGDET 
06425                 WILL NOT WORK AS DESIRED, AND TO BE HONEST I AM GETTING TIRED OF SEEING
06426                 CODE THAT DOES NOT FOLLOW ANY STANDARD APPROACH FOR COMMON FEATURES WITHIN
06427                 INFOBARS, WHICH I AM FORCING PEOPLE TO USE THESE FUNCTIONS WITHIN INFOBARS.
06428     Errors:     -
06429     SeeAlso:    -
06430 
06431 ********************************************************************************************/
06432 
06433 CProfileBiasGain* InformationBarOp::GetProfileFromSelection (CGadgetID ProfileGadgetID, BOOL* bMany, BOOL* bAllSameType)
06434 {
06435     return (NULL);
06436 }
06437 
06438 
06439 
06440 
06441 
06442 /********************************************************************************************
06443 
06444 >   void CloseProfileDialog (CBiasGainGadget& Gadget)
06445 
06446     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
06447     Created:    19/1/2000
06448     Inputs:     a CBiasGainGadget&
06449     Outputs:    -
06450     Returns:    -
06451     Purpose:    Handles the closing of the profile gadgets corrensponding profile
06452                 dialog.
06453     Errors:     -
06454     SeeAlso:    -
06455 
06456 ********************************************************************************************/
06457 
06458 void InformationBarOp::CloseProfileDialog (CBiasGainGadget& Gadget)
06459 {
06460     if (Gadget.IsDialogOpen ())
06461     {
06462         Gadget.CloseDialog ();
06463     }
06464 }
06465 
06466 /********************************************************************************************
06467 
06468 >   BOOL InformationBarOp::Create()
06469 
06470     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
06471     Created:    17/4/94
06472     Inputs:     -
06473     Outputs:    -
06474     Returns:    -
06475     Purpose:    The InformationBarOps Create method
06476                 This method has been overridden to de-specialize the DialogBarOp. 
06477     Errors:     -
06478     SeeAlso:    -
06479 
06480 ********************************************************************************************/
06481 
06482 
06483 BOOL InformationBarOp::Create()
06484 {
06485     if (Tool::IsToolChanging()||GetMainFrame()->IsChangingViewMode())
06486     {
06487         SetDockBarType(InformationBarOp::Dock);
06488         SetSlot(InformationBarOp::Slot);
06489         SetOffset(InformationBarOp::Offset);
06490         SetFloatingCPoint(InformationBarOp::FloatPos);
06491     }
06492 
06493     InformationBarOp::CurrentInfoBarOp = this;
06494 
06495     if (InformationBarOp::Visible)
06496         return (DialogOp::Create());
06497     else
06498         return TRUE;
06499 }
06500 
06501 /********************************************************************************************
06502 
06503 >   BOOL InformationBarOp::SetInfo()
06504 
06505     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (using Simon code)
06506     Created:    28/4/94
06507     Inputs:     -
06508     Outputs:    -
06509     Returns:    -
06510     Purpose:    Stores info bar data  
06511     Errors:     -
06512     SeeAlso:    InformationBarOp::Create(),DialogBarOp::Delete()
06513 
06514 ********************************************************************************************/
06515 
06516 
06517 void InformationBarOp::SetInfo()
06518 {
06519     
06520     SetDockBarType(InformationBarOp::Dock);
06521     SetSlot(InformationBarOp::Slot);
06522     SetOffset(InformationBarOp::Offset);
06523     SetFloatingCPoint(InformationBarOp::FloatPos);
06524  }
06525 
06526  /********************************************************************************************
06527 
06528 >   BOOL InformationBarOp::GetInfo()
06529 
06530     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (using Simon code)
06531     Created:    28/4/94
06532     Inputs:     -
06533     Outputs:    -
06534     Returns:    -
06535     Purpose:    Stores info bar data in Static variables
06536     Errors:     -
06537     SeeAlso:    InformationBarOp::Create(),DialogBarOp::Delete()
06538 
06539 ********************************************************************************************/
06540 
06541 
06542 void InformationBarOp::GetInfo()
06543 {
06544 #pragma message( __LOCMSG__ "InformationBarOp::GetInfo - do nothing" )
06545     TRACE( _T("Warning - InformationBarOp::GetInfo called") );
06546 /*  KernelBarPos*   pKernelBarPos;
06547     DockBarType     Dock;
06548     
06549     if (WindowID != NULL)
06550     {
06551         if (GetMainFrame()->GetBarPosInfo(WindowID,&Dock,&pKernelBarPos))
06552         {
06553             SetDockBarType(Dock);
06554             if (Dock == DOCKBAR_FLOAT)
06555                 SetFloatingCPoint(wxPoint(pKernelBarPos->x,pKernelBarPos->y));
06556             else
06557             {
06558                 SetSlot(pKernelBarPos->Slot);
06559                 SetOffset(pKernelBarPos->Position);
06560             }
06561         }
06562 
06563         // Save this info bar's data in the static vars
06564         // These vars are used by
06565         InformationBarOp::Dock          = GetDockBarType();
06566         InformationBarOp::Slot          = GetSlot();
06567         InformationBarOp::Offset        = GetOffset();
06568         InformationBarOp::FloatPos      = GetFloatingCPoint();
06569     } */
06570  }
06571 
06572 
06573 /********************************************************************************************
06574 
06575 >   BOOL InformationBarOp::Delete()
06576 
06577     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (using Simon code)
06578     Created:    28/4/94
06579     Inputs:     -
06580     Outputs:    -
06581     Returns:    -
06582     Purpose:    The InformationBarOps Delete method
06583                 Stores info bar data and calls DialogBarOp::Delete()
06584     Errors:     -
06585     SeeAlso:    InformationBarOp::Create(),DialogBarOp::Delete()
06586 
06587 ********************************************************************************************/
06588 
06589 
06590 void InformationBarOp::Delete()
06591 {
06592     if (WindowID != NULL)
06593     {
06594 
06595         PORTNOTETRACE("dialog", "Warning - InformationBarOp::Delete called");
06596 #ifndef EXCLUDE_FROM_XARALX
06597         KernelBarPos*   pKernelBarPos;
06598         DockBarType     Dock;
06599         if (GetMainFrame()->GetBarPosInfo(WindowID,&Dock,&pKernelBarPos))
06600         {
06601             SetDockBarType(Dock);
06602             if (Dock == DOCKBAR_FLOAT)
06603                 SetFloatingCPoint(wxPoint(pKernelBarPos->x,pKernelBarPos->y));
06604             else
06605             {
06606                 SetSlot(pKernelBarPos->Slot);
06607                 SetOffset(pKernelBarPos->Position);
06608             }
06609         }
06610 
06611         // Save this info bar's data in the static vars
06612         // These vars are used by
06613         InformationBarOp::Dock          = GetDockBarType();
06614         InformationBarOp::Slot          = GetSlot();
06615         InformationBarOp::Offset        = GetOffset();
06616         InformationBarOp::FloatPos      = GetFloatingCPoint();
06617 #endif      
06618         DialogBarOp::Delete();
06619     }
06620  }
06621 
06622 /********************************************************************************************
06623 
06624 >   static BOOL InformationBarOp::Read(CCLexFile& file)
06625 
06626     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
06627     Created:    20/10/94
06628     Inputs:     -
06629     Outputs:    -
06630     Returns:    TRUE If InfoBar Data read OK
06631     Purpose:    Read InfoBar Data from Ini file 
06632     Errors:     -
06633     SeeAlso:    -
06634 
06635 ********************************************************************************************/
06636 
06637 BOOL InformationBarOp::Read(CCLexFile& file)
06638 {
06639 #pragma message( __LOCMSG__ "InformationBarOp::Read - do nothing" )
06640     TRACE( _T("Warning - InformationBarOp::Read called") );
06641 /*  TokenIndex Token;
06642     const TCHAR* TokenBuf = file.GetTokenBuf();
06643     BOOL ok;
06644 
06645     // Read the bar's docking position
06646     ok = file.GetSimpleToken();
06647 
06648     if (ok)
06649     {
06650         Token = FindToken(TokenBuf);
06651         switch (Token)
06652         {
06653             case TOKEN_DOCKBAR_TOP    : InformationBarOp::Dock = DOCKBAR_TOP;    break;
06654             case TOKEN_DOCKBAR_BOTTOM : InformationBarOp::Dock = DOCKBAR_BOTTOM; break;
06655             case TOKEN_DOCKBAR_LEFT   : InformationBarOp::Dock = DOCKBAR_LEFT;   break;
06656             case TOKEN_DOCKBAR_RIGHT  : InformationBarOp::Dock = DOCKBAR_RIGHT;  break;
06657             case TOKEN_DOCKBAR_FLOAT  : InformationBarOp::Dock = DOCKBAR_FLOAT;  break;
06658 
06659             default : 
06660                 ok = FALSE;
06661                 TRACE( _T("Unrecognised Info bar position : '%s'"),TokenBuf);
06662                 break;
06663         }
06664 
06665         if (ok)
06666         {
06667             // If the bar is floating, then read in the floating X and Y coords
06668             // Otherwise, read in the bar's docked slot and offset.
06669             if (InformationBarOp::Dock == DOCKBAR_FLOAT)
06670             {
06671                 ok = file.GetSimpleToken();
06672                 if (ok)
06673                 {   
06674                     ok = (camSscanf(TokenBuf,"%li",&InformationBarOp::FloatPos.x) == 1);
06675                     if (!ok) TRACE( _T("Expected the Infobar's floating x pos, but got '%s'\n"),TokenBuf);
06676                 }
06677 
06678                 if (ok) ok = file.GetSimpleToken();
06679                 if (ok)
06680                 {
06681                     ok = (camSscanf(TokenBuf,"%li",&InformationBarOp::FloatPos.y) == 1);
06682                     if (!ok) TRACE( _T("Expected the Infobar's floating y pos, but got '%s'\n"),TokenBuf);
06683                 }
06684             }
06685             else
06686             {
06687                 ok = file.GetSimpleToken();
06688                 if (ok)
06689                 {
06690                     ok = (camSscanf(TokenBuf,"%li",&InformationBarOp::Slot) == 1);
06691                     if (!ok) TRACE( _T("Expected the Infobar's slot, but got '%s'\n"),TokenBuf);
06692                 }
06693 
06694                 if (ok) ok = file.GetSimpleToken();
06695                 if (ok)
06696                 {
06697                     ok = (camSscanf(TokenBuf,"%li",&InformationBarOp::Offset) == 1);
06698                     if (!ok) TRACE( _T("Expected the Infobar's offset, but got '%s'\n"),TokenBuf);
06699                 }
06700             }
06701         }
06702         if (ok)
06703         {
06704             ok = file.GetSimpleToken();
06705             if (ok)
06706             {
06707                 Token = FindToken(TokenBuf);
06708                 switch (Token)
06709                 {
06710                     case TOKEN_VISIBLE   : InformationBarOp::Visible = TRUE;  break;
06711                     case TOKEN_INVISIBLE : InformationBarOp::Visible = FALSE; break;
06712                     default : 
06713                         ok = FALSE;
06714                         TRACE( _T("Expected '%s' or '%s', but got '%s'\n"),TokenTable[TOKEN_VISIBLE].Token,TokenTable[TOKEN_INVISIBLE].Token,TokenBuf);
06715                         break;
06716                 }
06717             }
06718         }
06719     }
06720     if(ok)
06721         if(CurrentInfoBarOp)
06722             CurrentInfoBarOp->SetInfo();
06723     
06724     if(CurrentInfoBarOp && CurrentInfoBarOp->WindowID )
06725     {
06726         KernelBarPos NewPos;
06727         if (CurrentInfoBarOp->Dock == DOCKBAR_FLOAT)
06728         {
06729             NewPos.x=InformationBarOp::FloatPos.x;
06730             NewPos.y=InformationBarOp::FloatPos.y;
06731     
06732         }
06733         else
06734         {
06735             NewPos.Slot= InformationBarOp::Slot;
06736             NewPos.Position= InformationBarOp::Offset;
06737         }
06738         GetMainFrame()->MoveBar(CurrentInfoBarOp->WindowID,InformationBarOp::Dock,NewPos);      
06739     }
06740     return ok; */
06741 
06742     return false;
06743 }
06744 
06745 
06746 /********************************************************************************************
06747 
06748 >   static BOOL InformationBarOp::Write(CCLexFile& file)
06749 
06750     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
06751     Created:    20/10/94
06752     Inputs:     file = a file to Write the dialog bar to.
06753     Outputs:    -
06754     Returns:    TRUE if successful, FALSE otherwise
06755     Purpose:    Write the Infobar  static data to the file in a tokenized form
06756     Errors:     -
06757     SeeAlso:    -
06758 
06759 ********************************************************************************************/
06760 
06761 BOOL InformationBarOp::WriteStatic(CCLexFile& file)
06762 {
06763     BOOL ok = TRUE;
06764     String_256 str;
06765 
06766     if (ok) ok = file.PutToken(TokenTable[TOKEN_INFO_BAR].Token);
06767             
06768     if(IsVisible())
06769     {
06770         if(CurrentInfoBarOp)
06771             CurrentInfoBarOp->GetInfo();
06772     }
06773     switch (InformationBarOp::Dock)
06774     {
06775         case DOCKBAR_TOP    : str = TokenTable[TOKEN_DOCKBAR_TOP].Token;    break;
06776         case DOCKBAR_BOTTOM : str = TokenTable[TOKEN_DOCKBAR_BOTTOM].Token; break;
06777         case DOCKBAR_LEFT   : str = TokenTable[TOKEN_DOCKBAR_LEFT].Token;   break;
06778         case DOCKBAR_RIGHT  : str = TokenTable[TOKEN_DOCKBAR_RIGHT].Token;  break;
06779         case DOCKBAR_FLOAT  : str = TokenTable[TOKEN_DOCKBAR_FLOAT].Token;  break;
06780         default             : ok  = FALSE;                break;
06781     }
06782 
06783     if (ok) ok = file.PutToken(str);
06784 
06785     if (Dock == DOCKBAR_FLOAT)
06786     {
06787         if (ok) ok = file.PutToken(InformationBarOp::FloatPos.x);
06788         if (ok) ok = file.PutToken(InformationBarOp::FloatPos.y);
06789     }
06790     else
06791     {
06792         if (ok) ok = file.PutToken(InformationBarOp::Slot);
06793         if (ok) ok = file.PutToken(InformationBarOp::Offset);
06794     }
06795 
06796     if(IsVisible())
06797     {
06798         if (ok) ok = file.PutToken(TokenTable[TOKEN_VISIBLE].Token);
06799     }
06800     else
06801     {
06802         if (ok) ok = file.PutToken(TokenTable[TOKEN_INVISIBLE].Token);
06803     }
06804 
06805     if (ok) ok = file.PutNewLine();
06806     if (ok) ok = file.PutNewLine();
06807 
06808     return ok;
06809 }
06810 
06811 /********************************************************************************************
06812 
06813 >   static BOOL InformationBarOp::Read(HKEY hSubKey)
06814 
06815     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
06816     Created:    20/2/97
06817     Inputs:     hSubKey = the key to use as the parent key when reading from the registry.
06818     Outputs:    -
06819     Returns:    TRUE if successful, FALSE otherwise
06820     Purpose:    read the Infobar static data from the registry
06821     Errors:     -
06822     SeeAlso:    -
06823 
06824 ********************************************************************************************/
06825 
06826 BOOL InformationBarOp::Read(HKEY hSubKey)
06827 {
06828 #pragma message( __LOCMSG__ "InformationBarOp::Read - do nothing" )
06829     TRACE( _T("Warning - InformationBarOp::Read called") );
06830 /*  // Create our main token under the information bar name
06831     HKEY hRegKey = OpenRegKey(hSubKey, TokenTable[TOKEN_INFO_BAR].Token);
06832     if (hRegKey == NULL)
06833     {
06834         //ERROR3("InformationBarOp::Read failed to get registry key");
06835         return FALSE;
06836     }
06837 
06838     BOOL ok = TRUE;
06839     DockBarType Dock = (DockBarType)GetRegInt(hRegKey, TEXT("Dock"));
06840     // check that the value read in is ok
06841     switch (Dock)
06842     {
06843         case DOCKBAR_TOP:
06844         case DOCKBAR_BOTTOM:
06845         case DOCKBAR_LEFT:
06846         case DOCKBAR_RIGHT:
06847         case DOCKBAR_FLOAT:
06848             InformationBarOp::Dock = Dock;
06849             break;
06850         default : 
06851             ok = FALSE;
06852             TRACE( _T("Unrecognised Info bar position : '%d'"),Dock);
06853             break;
06854     }
06855 
06856     if (Dock == DOCKBAR_FLOAT)
06857     {
06858         InformationBarOp::FloatPos.x = GetRegDword(hRegKey, TEXT("x"));
06859         InformationBarOp::FloatPos.y = GetRegDword(hRegKey, TEXT("y"));
06860     }
06861     else
06862     {
06863         InformationBarOp::Slot = GetRegDword(hRegKey, TEXT("Slot"));
06864         InformationBarOp::Offset = GetRegDword(hRegKey, TEXT("Offset"));
06865     }
06866 
06867     // get the visibility of the bar
06868     InformationBarOp::Visible = GetRegBool(hRegKey, TEXT("Visibility"));
06869 
06870     // Shut down our use of the key
06871     CloseRegKey(hRegKey);
06872 
06873     // if things were ok then set this information as the current set
06874     if (ok && CurrentInfoBarOp)
06875         CurrentInfoBarOp->SetInfo();
06876 
06877     if (CurrentInfoBarOp && CurrentInfoBarOp->WindowID )
06878     {
06879         KernelBarPos NewPos;
06880         if (CurrentInfoBarOp->Dock == DOCKBAR_FLOAT)
06881         {
06882             NewPos.x = InformationBarOp::FloatPos.x;
06883             NewPos.y = InformationBarOp::FloatPos.y;
06884     
06885         }
06886         else
06887         {
06888             NewPos.Slot = InformationBarOp::Slot;
06889             NewPos.Position = InformationBarOp::Offset;
06890         }
06891         GetMainFrame()->MoveBar(CurrentInfoBarOp->WindowID, InformationBarOp::Dock,NewPos);     
06892     }
06893 
06894     return ok; */
06895 
06896     return false;
06897 }
06898 
06899 /********************************************************************************************
06900 
06901 >   static BOOL InformationBarOp::Write(HKEY hSubKey)
06902 
06903     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
06904     Created:    20/2/97
06905     Inputs:     hSubKey = the key to use as the parent key when writing to the registry under.
06906     Outputs:    -
06907     Returns:    TRUE if successful, FALSE otherwise
06908     Purpose:    Write the Infobar static data to the registry
06909     Errors:     -
06910     SeeAlso:    -
06911 
06912 ********************************************************************************************/
06913 
06914 BOOL InformationBarOp::Write(HKEY hSubKey)
06915 {
06916 #pragma message( __LOCMSG__ "InformationBarOp::Write - do nothing" )
06917     TRACE( _T("Warning - InformationBarOp::Write called") );
06918 /*  // Ensure the section is blank before we start saving any data
06919     DeleteRegKey(hSubKey, TokenTable[TOKEN_INFO_BAR].Token);
06920 
06921     // Create our main token under the information bar name
06922     HKEY hRegKey = CreateRegKey(hSubKey, TokenTable[TOKEN_INFO_BAR].Token);
06923     if (hRegKey == NULL)
06924     {
06925         ERROR3("InformationBarOp::Write failed to get registry key");
06926         return FALSE;
06927     }
06928             
06929     if (IsVisible())
06930     {
06931         if (CurrentInfoBarOp)
06932             CurrentInfoBarOp->GetInfo();
06933     }
06934 
06935     BOOL ok = TRUE;
06936     ok = ok && SetRegInt(hRegKey, TEXT("Dock"), InformationBarOp::Dock);
06937 
06938     if (Dock == DOCKBAR_FLOAT)
06939     {
06940         ok = ok && SetRegDword(hRegKey, TEXT("x"), InformationBarOp::FloatPos.x);
06941         ok = ok && SetRegDword(hRegKey, TEXT("y"), InformationBarOp::FloatPos.y);
06942     }
06943     else
06944     {
06945         ok = ok && SetRegDword(hRegKey, TEXT("Slot"), InformationBarOp::Slot);
06946         ok = ok && SetRegDword(hRegKey, TEXT("Offset"), InformationBarOp::Offset);
06947     }
06948 
06949     // save the visibility of the bar
06950     ok = ok && SetRegBool(hRegKey, TEXT("Visibility"), IsVisible());
06951 
06952     // Shut down our use of the key
06953     CloseRegKey(hRegKey);
06954 
06955     return ok; */
06956 
06957     return false;
06958 }
06959 
06960 /********************************************************************************************
06961 
06962 >   static BOOL InformationBarOp::IsVisible()
06963 
06964     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
06965     Created:    12/5/94
06966     Inputs:     -
06967     Outputs:    -
06968     Returns:    TRUE if a InformationBarOp is on screen
06969     Purpose:    Used by the tool bar customize system to find out if a tool info bar is
06970                 visible or not. 
06971     Errors:     -
06972     SeeAlso:    -
06973 
06974 ********************************************************************************************/
06975 
06976 BOOL InformationBarOp::IsVisible()
06977 {
06978     return (InformationBarOp::Visible);
06979 }
06980 
06981 /********************************************************************************************
06982 
06983 >   static void InformationBarOp::SetVisibility(BOOL Open)
06984 
06985     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
06986     Created:    12/5/94
06987     Inputs:     Open -  if TRUE then open current InformationBarOp in its last pos if it is
06988                         currently closed.
06989                         if FALSE, it is closed
06990     Outputs:    -
06991     Returns:    -
06992     Purpose:    Used by the tool bar customize system to open and close a tool bar.
06993     Errors:     -
06994     SeeAlso:    -
06995 
06996 ********************************************************************************************/
06997 /*
06998 void InformationBarOp::SetVisibility(BOOL Open)
06999 {
07000 
07001     if (Open)
07002     {
07003         if (!InformationBarOp::Hidden)
07004         {
07005             InformationBarOp::Hidden = TRUE;
07006             if (InformationBarOp::CurrentInfoBarOp != NULL)
07007             {
07008                 InformationBarOp::CurrentInfoBarOp->Create();
07009                 //InformationBarOp::CurrentInfoBarOp->Open();
07010             }
07011         }
07012     }
07013     else
07014     {
07015         if (InformationBarOp::Hidden)
07016         {
07017             SelectorTool::UnCacheInfoBar();
07018             if (InformationBarOp::CurrentInfoBarOp != NULL)
07019             {
07020                 InformationBarOp::CurrentInfoBarOp->Delete();
07021                 //InformationBarOp::CurrentInfoBarOp->Close();
07022             }
07023             InformationBarOp::Hidden = FALSE;
07024         }
07025     }
07026 }
07027 */
07028 
07029 void InformationBarOp::SetVisibility(BOOL Open,BOOL Force)
07030 {
07031 
07032     if (Open)
07033     {
07034         if (!InformationBarOp::Visible || Force)
07035         {
07036             InformationBarOp::Visible = TRUE;
07037             if (InformationBarOp::CurrentInfoBarOp != NULL)
07038             {
07039                 InformationBarOp::CurrentInfoBarOp->Create();
07040             }
07041         }
07042     }
07043     else
07044     {
07045         if (InformationBarOp::Visible || Force)
07046         {
07047         #ifndef STANDALONE
07048             SelectorTool::UnCacheInfoBar(TRUE);
07049         #endif
07050             if (InformationBarOp::CurrentInfoBarOp != NULL)
07051             {
07052                 InformationBarOp::CurrentInfoBarOp->Delete();
07053             }
07054             InformationBarOp::Visible = FALSE;
07055         }
07056     }
07057 }

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