tooldlg.cpp

Go to the documentation of this file.
00001 // $Id: tooldlg.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 //
00099 // ToolDlg.CPP
00100 //
00101 // This file implements the dialog box that allows the user to configure which
00102 // toolbars are shown around the edges of the main frame window.
00103 
00104 /*
00105 */
00106 
00107 #include "camtypes.h"
00108 //#include "ensure.h"   - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "errors.h"  - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "dlgtypes.h"  - in camtypes.h [AUTOMATICALLY REMOVED]
00111 //#include "resource.h" // _R(IDB_WINDOWTOOLBARS)  
00112 //#include "barsdlgs.h"
00113 //#include "phil.h"
00114 //#include "mario.h"
00115 //#include "dialogop.h" // DialogOp header - in camtypes.h [AUTOMATICALLY REMOVED]
00116 #include "dlgmgr.h"   // Dialog manager class
00117 #include "tooldlg.h"
00118 //#include "pump.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00119 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00120 #include "mainfrm.h"
00121 #include "csrstack.h"
00122 //#include "infobar.h"
00123 //#include "msg.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00124 #include "progress.h"
00125 
00126 //#include "printdlg.h"
00127 #include "customlist.h"
00128 
00129 CC_IMPLEMENT_DYNCREATE(ToolbarDlg, DialogOp)
00130 CC_IMPLEMENT_DYNCREATE(ToolnameDlg, DialogOp)
00131 CC_IMPLEMENT_DYNCREATE(CustomizeBarDlg, DialogOp)
00132 
00133 #define new CAM_DEBUG_NEW
00134 
00135 
00136 
00137 const CDlgMode ToolbarDlg::Mode = MODELESS; // The dialog is modeless
00138 const INT32 ToolbarDlg::IDD = _R(IDD_TOOLBARS);
00139 ToolbarDlg* ToolbarDlg::CurrentToolbarDlg = NULL;
00140 
00141 
00142 String_16 ToolbarDlg::InfoBarName;          // Internationalised name of "infobar"
00143                                             // But don't init it here do that in ::Init
00144                                             // because it's too early to do it here.
00145 
00146 String_16 ToolbarDlg::ControlBankName;
00147 /******************************************************************************************
00148 
00149 >   ToolbarDlg::ToolbarDlg(): DialogOp(ToolbarDlg::IDD, ToolbarDlg::Mode) 
00150 
00151 
00152     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00153     Created:    31/03/94
00154     Inputs:     -
00155     Outputs:    -
00156     Returns:    -
00157     Purpose:    ToolbarDlg constructor. Creates a non-undoable operation
00158     Errors:     -
00159     SeeAlso:    -
00160 
00161 ******************************************************************************************/
00162 
00163 ToolbarDlg::ToolbarDlg(): DialogOp(ToolbarDlg::IDD, ToolbarDlg::Mode) 
00164 {
00165     CurrentToolbarDlg = this;
00166 }
00167 
00168 /******************************************************************************************
00169 
00170 >   ToolbarDlg::ToolbarDlg(): DialogOp() 
00171 
00172 
00173     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00174     Created:    31/03/94
00175     Inputs:     -
00176     Outputs:    -
00177     Returns:    -
00178     Purpose:    ToolbarDlg destructor sets CurrentToolbarDlg to NULL
00179     Errors:     -
00180     SeeAlso:    -
00181 
00182 ******************************************************************************************/
00183 
00184 ToolbarDlg::~ToolbarDlg() 
00185 {
00186     CurrentToolbarDlg = NULL;
00187 }
00188 
00189 
00190 /********************************************************************************************
00191 
00192 >   void ToolBarDlg::GetSelectedBarName(String_32 *Result)
00193 
00194     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00195     Created:    25/8/96
00196 
00197     Outputs:    Result - Will be filled in witht he name of the selected bar
00198     Purpose:    Get the selected item's name
00199 
00200 ********************************************************************************************/
00201 
00202 void ToolbarDlg::GetSelectedBarName(String_32 *Result)
00203 {
00204     ERROR3IF(Result == NULL, "Illegal NULL param");
00205     *Result = TEXT("");
00206 
00207     CCustomList* pListGadget = CCustomList::GetGadget(GetReadWriteWindowID(), _R(IDC_BARLIST));
00208     if (pListGadget == NULL)
00209         return;
00210 
00211     INT32 SelItem = pListGadget->GetSelectedItemIndex();
00212 
00213     if (SelItem >= 0)
00214         pListGadget->GetItemString(*Result, SelItem, 1);
00215 }
00216 
00217 
00218 
00219 /********************************************************************************************
00220 
00221 >   MsgResult ToolbarDlg::Message( CDlgMessage DlgMsg, CGadgetID Gadget)
00222 
00223     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00224     Created:    31/03/94
00225     Inputs:     -
00226     Outputs:    -
00227     Returns:    -
00228     Purpose:    Handles all the Toolbar dialog's messages 
00229     Errors:     -
00230     SeeAlso:    -
00231 
00232 ********************************************************************************************/
00233 
00234 MsgResult ToolbarDlg::Message(Msg* Message)
00235 {
00236     if (IS_OUR_DIALOG_MSG(Message))
00237     {
00238         DialogMsg* Msg = (DialogMsg*)Message;
00239         BOOL EndDialog = FALSE;
00240 
00241         switch (Msg->DlgMsg)
00242         {
00243             case DIM_CANCEL:
00244             case DIM_COMMIT:
00245                 // Cancel all changes the user wants to make to toolbars...
00246                 EndDialog = TRUE;
00247             break;
00248     
00249             case DIM_SELECTION_CHANGED:
00250             case DIM_SELECTION_CHANGED_COMMIT:
00251                 TakeToolbarDetails();
00252                 break;
00253     
00254             case DIM_LFT_BN_CLICKED:
00255             {   // A control in the Toolbars... dialog has been clicked...
00256                 CMainFrame* pFrame = GetMainFrame();
00257                 BOOL    check;
00258                 BOOL    VV;
00259                 switch (Msg->GadgetID)
00260                 {
00261                     case _R(IDC_BIGALL):
00262                         // Select all the large buttons...
00263                         SetLongGadgetValue(_R(IDC_BIGTOP),1);
00264                         SetLongGadgetValue(_R(IDC_BIGLEFT),1);
00265                         SetLongGadgetValue(_R(IDC_BIGRIGHT),1);
00266                         SetLongGadgetValue(_R(IDC_BIGBOTTOM),1);
00267                         SetLongGadgetValue(_R(IDC_BIGFLOAT),1);
00268                         TakeToolbarDetails();
00269                     break;
00270 
00271                     case _R(IDC_BIGNONE):
00272                         // Deselect all the large buttons...
00273                         SetLongGadgetValue(_R(IDC_BIGTOP),0);
00274                         SetLongGadgetValue(_R(IDC_BIGLEFT),0);
00275                         SetLongGadgetValue(_R(IDC_BIGRIGHT),0);
00276                         SetLongGadgetValue(_R(IDC_BIGBOTTOM),0);
00277                         SetLongGadgetValue(_R(IDC_BIGFLOAT),0);
00278                         TakeToolbarDetails();
00279                     break;
00280 
00281                     case _R(IDC_NEWBAR):
00282                         NewToolbar();
00283                         break;
00284 
00285                     case _R(IDC_BIGTOP):
00286                         check = (BOOL)GetLongGadgetValue(_R(IDC_BIGTOP),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
00287                         pFrame->GetDockBar(DOCKBAR_TOP)->SetBigControlState(check);
00288                         break;
00289                     case _R(IDC_BIGLEFT):
00290                         check = (BOOL)GetLongGadgetValue(_R(IDC_BIGLEFT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
00291                         pFrame->GetDockBar(DOCKBAR_LEFT)->SetBigControlState(check);
00292                         break;
00293                     case _R(IDC_BIGRIGHT):
00294                         check = (BOOL)GetLongGadgetValue(_R(IDC_BIGRIGHT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
00295                         pFrame->GetDockBar(DOCKBAR_RIGHT)->SetBigControlState(check);
00296                         break;
00297                     case _R(IDC_BIGBOTTOM):
00298                         check = (BOOL)GetLongGadgetValue(_R(IDC_BIGBOTTOM),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
00299                         pFrame->GetDockBar(DOCKBAR_BOTTOM)->SetBigControlState(check);
00300                         break;
00301                     case _R(IDC_BIGFLOAT):  
00302                         check = (BOOL)GetLongGadgetValue(_R(IDC_BIGFLOAT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
00303                         pFrame->GetDockBar(DOCKBAR_FLOAT)->SetBigControlState(check);
00304                         break;
00305                     
00306                 
00307                     case _R(IDC_DELETEBAR):     
00308                     {   
00309                         String_32 BarName;
00310                         GetSelectedBarName(&BarName);
00311 
00312                         if (BarName != String_8(TEXT("")))
00313                         {
00314                             // we can't delete the infoobar
00315                             if(BarName == String_32(TEXT("Infobar")))
00316                             {
00317                                 InformWarning(_R(IDS_CANTDELETEINFOBAR),_R(IDS_OK));
00318                                 break;
00319                             }
00320 
00321                             INT32 ButtonPressed = 1;
00322                             ButtonPressed = InformWarning(_R(IDS_WARNDELETEBAR), _R(IDS_OK),_R(IDS_CANCEL));
00323                             Error::ClearError();
00324                             if (ButtonPressed ==  1)
00325                                 DeleteSelectedBar();
00326                         }
00327                         break;  
00328                     }
00329 
00330                     case _R(IDC_RESETBARS):     
00331                     {   
00332                         INT32 ButtonPressed = 1;                        
00333                         ButtonPressed = InformWarning(_R(IDS_WARNRESETBARS), _R(IDS_OK),_R(IDS_CANCEL));
00334                         Error::ClearError();
00335 
00336                         if(ButtonPressed ==  1)
00337                         {
00338                             Progress::Start(FALSE);
00339                             // lock the window to avoid untidy layout recalcs
00340                             ::LockWindowUpdate(GetMainFrame()->GetSafeHwnd());
00341 
00342                             // tell the mainframe we are changing modes - this prevents
00343                             // some unnecessary work
00344                             GetMainFrame()->SetChangingMode(TRUE);
00345 
00346                             // kill all bars ( except infobar at the mo..)
00347                             BROADCAST_TO_CLASS(DialogMsg(NULL, DIM_BAR_DEATH, NULL ),DialogBarOp);
00348                             // hide the info bar
00349                             InformationBarOp::SetVisibility(FALSE,TRUE);
00350 
00351                             DialogBarOp::WipeBarFiles();
00352 
00353                             DialogBarOp::LoadDefaultBars();
00354                             
00355                             // force the info bar to the correct visible state
00356                             InformationBarOp::SetVisibility(InformationBarOp::IsVisible(),TRUE);
00357                             // All clear to Mainframe
00358                             GetMainFrame()->SetChangingMode(FALSE);
00359 
00360                             // Make sure everything is positioned correctly
00361                             GetMainFrame()->RecalcLayout();
00362 
00363                             // Now handle the toolbar ....
00364                             GetMainFrame ()->SetToolbarCreated (TRUE);
00365                             GetMainFrame ()->RelocateToolbar ();
00366 
00367                             // and unlock and show the window
00368                             ::LockWindowUpdate(NULL);
00369                             ShowToolbarList();
00370                             ShowToolbarSizes();
00371                             Progress::Stop();
00372                         }
00373                         break;          
00374                     }
00375                 }
00376                 break;
00377             }
00378         }
00379 
00380         if (EndDialog)  // Dialog communication over
00381         {
00382 
00383             Close();    // Close the dialog
00384             End();      // Destroy dialog
00385             return(OK); // After destroying this object, it's very dangerous to call base class!
00386         }
00387     }
00388     else if ( MESSAGE_IS_A(Message,BarMsg) )
00389     {
00390         switch ( ((BarMsg*)Message)->Reason )
00391         {
00392             case BAR_CHANGESTATE:
00393                 // A bar simply became horizontal, vertical or floating and we don't care
00394                 // about that so do nothing.
00395                 break;
00396 
00397             default:
00398                 // In most cases of BarMsg we want to show the user what happened...
00399                 ShowToolbarList();      // Show changes in bars to user
00400                                         // Note: it would be more optimal to use the pointer
00401                                         // to the bar that comes with this message to just
00402                                         // alter that item in the list.
00403                 break;
00404         }
00405     }
00406 
00407     return DialogOp::Message(Message);
00408 }
00409 
00410 
00411 
00412 
00413 /******************************************************************************************
00414 
00415 >   OpState ToolbarDlg::GetState(String_256*, OpDescriptor*)
00416 
00417     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00418     Created:    31/03/94
00419     Inputs:     -
00420     Outputs:    -
00421     Returns:    -
00422     Purpose:    ToolbarDlg GetState method
00423     Errors:     -
00424     SeeAlso:    -
00425 
00426 ******************************************************************************************/
00427 
00428 OpState ToolbarDlg::GetState(String_256*, OpDescriptor*)
00429 {    
00430     OpState OpSt;
00431     return(OpSt);
00432 }
00433 
00434 
00435 
00436 
00437 /******************************************************************************************
00438 
00439 >   BOOL ToolbarDlg::Init()
00440 
00441     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00442     Created:    31/03/94
00443     Inputs:     -
00444     Outputs:    -
00445     Returns:    -
00446     Purpose:    ToolbarDlg Init method
00447     Errors:     -
00448     SeeAlso:    -
00449 
00450 ******************************************************************************************/
00451 
00452 BOOL ToolbarDlg::Init()
00453 {
00454     BOOL InitOK;
00455 
00456     // Initialise the contents of the static InfoBarName variable here...
00457     String_16 Blobby(_R(IDS_INFOBARNAME));
00458     InfoBarName = Blobby;
00459 
00460     String_16 Noel(_R(IDS_CONTROLBANKNAME));
00461     ControlBankName = Noel;
00462 
00463     InitOK = RegisterOpDescriptor(
00464                                 0,  /* Tool ID */
00465                                 _R(IDS_TOOLBARS_DLG),
00466                                 CC_RUNTIME_CLASS(ToolbarDlg),
00467                                 OPTOKEN_TOOLBARDLG,
00468                                 ToolbarDlg::GetState,
00469                                 0,                  /* help ID */
00470                                 0,                  /* bubble help ID _R(IDBBL_LAYERDLG), */
00471                                 _R(IDB_WINDOWTOOLBARS), /* resource ID */
00472                                 0,                  /* control ID */
00473                                 SYSTEMBAR_ILLEGAL,              // Bar ID
00474                                 FALSE,                          // Recieve system messages
00475                                 FALSE,                          // Smart duplicate operation
00476                                 TRUE,                           // Clean operation
00477                                 0,                              // No vertical counterpart
00478                                 _R(IDS_BARSINFO_ONE)                // String for one copy only
00479                                 
00480                                 )
00481             && RegisterOpDescriptor(
00482                                 0,
00483                                 _R(IDS_TOOLBARNAME_DLG),
00484                                 CC_RUNTIME_CLASS(ToolnameDlg),
00485                                 OPTOKEN_TOOLBARNAMEDLG,
00486                                 ToolnameDlg::GetState,
00487                                 0,  /* help ID */
00488                                 0,  /* bubble help ID _R(IDBBL_LAYERDLG), */
00489                                 0   /* bitmap ID */
00490                                 )
00491             && RegisterOpDescriptor(
00492                                 0,
00493                                 _R(IDS_CUSTOMIZE_BAR_DLG),
00494                                 CC_RUNTIME_CLASS(CustomizeBarDlg),
00495                                 OPTOKEN_CUSTOMIZEBARDLG,
00496                                 CustomizeBarDlg::GetState,
00497                                 0,  /* help ID */
00498                                 0,  /* bubble help ID _R(IDBBL_LAYERDLG), */
00499                                 0   /* bitmap ID */
00500                                 )
00501 
00502             ;
00503 
00504     return (InitOK);
00505 }
00506 
00507 
00508 
00509 
00510 /********************************************************************************************
00511 
00512 >   BOOL ToolbarDlg::Create()
00513 
00514     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00515     Created:    31/03/94
00516     Inputs:     -
00517     Outputs:    -
00518     Returns:    TRUE if successful, else FALSE
00519     Purpose:    ToolbarDlg create method 
00520     Errors:     -
00521     SeeAlso:    -
00522 
00523 ********************************************************************************************/
00524 
00525        
00526 BOOL ToolbarDlg::Create()
00527 {                            
00528     if (DialogOp::Create())
00529     { 
00530         // Set the initial control values 
00531         InitDialog();
00532         return TRUE; 
00533     }
00534     else
00535     {
00536         return FALSE; 
00537     }
00538 }
00539 
00540 
00541 
00542 
00543 /******************************************************************************************
00544 
00545 >   void ToolbarDlg::Do(OpDescriptor*)
00546 
00547     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00548     Created:    31/03/94
00549     Inputs:     -
00550     Outputs:    -
00551     Returns:    -
00552     Purpose:    Creates then opens the dialog in response to a request from the user.
00553     Errors:     -
00554     SeeAlso:    -
00555 
00556 ******************************************************************************************/
00557 
00558 void ToolbarDlg::Do(OpDescriptor*)
00559 {
00560     if (Create())
00561     {
00562         Open();
00563     }
00564     else              // Could not create 
00565     {
00566         InformError();
00567         End();         // End the operation
00568     }
00569 }
00570 
00571 
00572 
00573 
00574 /******************************************************************************************
00575 
00576 >   BOOL ToolbarDlg::InitDialog()
00577 
00578     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00579     Created:    31/03/94
00580     Inputs:     -
00581     Outputs:    -
00582     Returns:    -
00583     Purpose:    Sets initial dialog values 
00584     Errors:     -
00585     SeeAlso:    -
00586 
00587 ******************************************************************************************/
00588 
00589 BOOL ToolbarDlg::InitDialog()
00590 {
00591     // Make the OK button dual function
00592 //  DualFunctionButton(IDOK);
00593 
00594     ShowToolbarList();
00595     ShowToolbarSizes();
00596 
00597     return TRUE;
00598 }
00599 
00600 
00601 
00602 
00603 /******************************************************************************************
00604 
00605 >   void ToolbarDlg::ShowToolbarList()
00606 
00607     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00608     Created:    31/04/94
00609     Inputs:     - 
00610     Outputs:    -
00611     Returns:    -
00612     Purpose:    Shows Toolbar info in the Toolbars... dialog.
00613                 Ignores all SystemBarOps and all InformationBarOps.
00614                 Adds one line specifically to cover all InformationBarOps.
00615     Errors:     -
00616     SeeAlso:    -
00617 
00618 ******************************************************************************************/
00619 
00620 void ToolbarDlg::ShowToolbarList()
00621 {
00622     if (!WindowID)
00623         return;
00624 
00625     // set the custom list gadget 
00626     CCustomList* pListGadget = CCustomList::GetGadget(GetReadWriteWindowID(), _R(IDC_BARLIST));
00627     if(!pListGadget)
00628     {
00629         ERROR2RAW("No list gadget");
00630         return;
00631     }
00632     pListGadget->SetColumnWidth(0,GetSystemMetrics(SM_CXMENUCHECK) + 10);
00633 
00634     CMainFrame* pFrame = GetMainFrame();
00635     ERROR3IF(pFrame == NULL, "Can't find Main Frame in ShowToolBarList");
00636 
00637     if(pFrame->IsChangingViewMode())
00638         return ;
00639 
00640     // Fetch the names and states of all defined bars...
00641     List* pBarList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogBarOp));
00642     ENSURE(pBarList,"Can't find list of DialogBarOps in ShowToolBarList");
00643 
00644     // Delete any existing list items...
00645     pListGadget->DeleteAllItems();
00646 
00647     // Add names of all bars to the list...
00648     // First do the infobar...
00649     pListGadget->AddItem(InfoBarName);
00650     pListGadget->SetSwitchState(InformationBarOp::IsVisible(), (pListGadget->GetItemCount() - 1), 0);
00651 
00652     // Scan the list of all barops and add the names of those which should be shown
00653     // to the user to the scrollable list.
00654     DialogBarOp* pBar = (DialogBarOp*)pBarList->GetHead();
00655     
00656     BOOL FoundControlBank = FALSE;
00657     BOOL ControlBankVisible = FALSE;
00658     while (pBar)
00659     {
00660         // Show any bar that's NOT a system bar and NOT an information bar
00661         // and NOT a Super Gallery put the Controlbank at the end
00662         if ( IS_A(pBar,DialogBarOp) )
00663         {
00664             // Put its name in the list
00665             String_32 BarName = pBar->GetName();
00666             if (BarName != ControlBankName)
00667             {   
00668                 pListGadget->AddItem(BarName);
00669                 pListGadget->SetSwitchState(pBar->IsVisible(), (pListGadget->GetItemCount() - 1), 0);
00670             }
00671             else
00672             {
00673                 FoundControlBank = TRUE;
00674                 ControlBankVisible = pBar->IsVisible();
00675             }
00676         }
00677         pBar = (DialogBarOp*)pBarList->GetNext(pBar);
00678     }
00679     
00680     if (FoundControlBank)
00681     {
00682         pListGadget->AddItem(ControlBankName);
00683         pListGadget->SetSwitchState(ControlBankVisible, (pListGadget->GetItemCount() - 1), 0);
00684     }
00685 }
00686 
00687 
00688 
00689 /******************************************************************************************
00690 
00691 >   void ToolbarDlg::ShowToolbarSizes()
00692 
00693     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00694     Created:    29/04/94
00695     Inputs:     - 
00696     Outputs:    -
00697     Returns:    -
00698     Purpose:    Shows Toolbar info in the Toolbars... dialog.
00699     Errors:     -
00700     SeeAlso:    -
00701 
00702 ******************************************************************************************/
00703 
00704 void ToolbarDlg::ShowToolbarSizes()
00705 {
00706     CMainFrame* pFrame = GetMainFrame();
00707     ENSURE(pFrame,"Can't find Main Frame in ShowToolBarSizes");
00708 
00709     // Only attempt to redisplay things if the toolbars dlg exists...
00710     if (WindowID)
00711     {
00712         // Fetch the states of all the docking bars...
00713         SetLongGadgetValue(_R(IDC_BIGTOP),      (INT32) pFrame->GetDockBar(DOCKBAR_TOP)->IsBigControls());
00714         SetLongGadgetValue(_R(IDC_BIGLEFT),     (INT32) pFrame->GetDockBar(DOCKBAR_LEFT)->IsBigControls());
00715         SetLongGadgetValue(_R(IDC_BIGRIGHT),    (INT32) pFrame->GetDockBar(DOCKBAR_RIGHT)->IsBigControls());
00716         SetLongGadgetValue(_R(IDC_BIGBOTTOM),   (INT32) pFrame->GetDockBar(DOCKBAR_BOTTOM)->IsBigControls());
00717         SetLongGadgetValue(_R(IDC_BIGFLOAT),    (INT32) pFrame->GetDockBar(DOCKBAR_FLOAT)->IsBigControls());
00718     }
00719 }
00720 
00721 
00722 
00723 /******************************************************************************************
00724 
00725 >   BOOL ToolbarDlg::CanDeleteSelection()
00726 
00727     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00728     Created:    25/8/96
00729 
00730     Returns:    TRUE if it is safe to delete the current selection
00731     Purpose:    -
00732 
00733 ******************************************************************************************/
00734 
00735 BOOL ToolbarDlg::CanDeleteSelection()
00736 {
00737     String_32 BarName;
00738     GetSelectedBarName(&BarName);
00739 
00740     if (BarName == String_8(TEXT("")))      // No selection to delete
00741         return(FALSE);
00742 
00743     if (BarName == InfoBarName)             // Don't delete InfoBar
00744         return(FALSE);
00745 
00746     if (BarName == ControlBankName)         // Don't delete button palette
00747         return(FALSE);
00748 
00749     return(TRUE);
00750 }
00751 
00752 
00753 
00754 /******************************************************************************************
00755 
00756 >   void ToolbarDlg::DeleteSelectedBar()
00757 
00758     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00759     Created:    06/04/94
00760     Inputs:     - 
00761     Outputs:    -
00762     Returns:    -
00763     Purpose:    Delete the Bar that is currently selected in the bar listbox 
00764     Errors:     -
00765     SeeAlso:    -
00766 
00767 ******************************************************************************************/
00768 
00769 void ToolbarDlg::DeleteSelectedBar()
00770 {
00771     // we can't delete the control bank !!
00772     if (!CanDeleteSelection())
00773         return;
00774 
00775     String_32 BarName;
00776     GetSelectedBarName(&BarName);
00777 
00778     // If nothing is selected, we can't do anything
00779     if (BarName == String_8(TEXT("")))
00780         return;
00781     
00782     // we can't delete the infoobar
00783     if (BarName == String_32(TEXT("Infobar")))
00784         return;
00785 
00786     DialogBarOp* pBar = DialogBarOp::FindDialogBarOp(BarName);
00787 
00788     ENSURE(pBar,"Cannot find named bar in TakeToolbarDetails");
00789 
00790     // If bar is of correct type then adjust its visibility according to the
00791     // check mark...
00792     if ( !( pBar->IsKindOf(CC_RUNTIME_CLASS(SystemBarOp)) ||
00793             pBar->IsKindOf(CC_RUNTIME_CLASS(InformationBarOp))
00794            )
00795         )
00796     {
00797         pBar->Delete();
00798         pBar->End();
00799         ShowToolbarList();
00800     }
00801 }
00802 
00803 
00804 
00805 /******************************************************************************************
00806 
00807 >   void ToolbarDlg::TakeToolbarDetails()
00808 
00809     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00810     Created:    06/04/94
00811     Inputs:     - 
00812     Outputs:    -
00813     Returns:    -
00814     Purpose:    Take current state from the Toolbars... dialog.
00815     Errors:     -
00816     SeeAlso:    -
00817 
00818 ******************************************************************************************/
00819 
00820 void ToolbarDlg::TakeToolbarDetails()
00821 {
00822     EnableGadget(_R(IDC_DELETEBAR), CanDeleteSelection());
00823 
00824     CMainFrame* pFrame = GetMainFrame();
00825 
00826     BOOL    check;
00827     BOOL    VV;
00828 
00829     check = (BOOL)GetLongGadgetValue(_R(IDC_BIGTOP),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
00830     pFrame->GetDockBar(DOCKBAR_TOP)->SetBigControlState(check);
00831 
00832     check = (BOOL)GetLongGadgetValue(_R(IDC_BIGLEFT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
00833     pFrame->GetDockBar(DOCKBAR_LEFT)->SetBigControlState(check);
00834 
00835     check = (BOOL)GetLongGadgetValue(_R(IDC_BIGRIGHT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
00836     pFrame->GetDockBar(DOCKBAR_RIGHT)->SetBigControlState(check);
00837 
00838     check = (BOOL)GetLongGadgetValue(_R(IDC_BIGBOTTOM),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
00839     pFrame->GetDockBar(DOCKBAR_BOTTOM)->SetBigControlState(check);
00840 
00841     check = (BOOL)GetLongGadgetValue(_R(IDC_BIGFLOAT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
00842     pFrame->GetDockBar(DOCKBAR_FLOAT)->SetBigControlState(check);
00843 
00844 
00845     CCustomList* pListGadget = CCustomList::GetGadget(GetReadWriteWindowID(), _R(IDC_BARLIST));
00846     if (pListGadget == NULL)
00847         return;
00848     
00849     // Adjust the visibility of the bars...
00850     INT32 listitem = 0;
00851     INT32 listcount = pListGadget->GetItemCount();
00852     String_32 BarName;
00853         
00854     // variables control the dynamic relocation of the 'floating' toolbar ....
00855 //  INT32 ToolbarIndex = -1;
00856 //  BOOL BeenHidden = FALSE;
00857 //  BOOL ToolbarCurrentState = FALSE;
00858     
00859     while (listitem < listcount)
00860     {
00861         // Find bar by name...
00862         pListGadget->GetItemString(BarName, listitem, 1);
00863 
00864         // If name is "Infobar" deal with it specially...
00865         if (BarName == InfoBarName)
00866             InformationBarOp::SetVisibility(pListGadget->GetSwitchState(listitem, 0));
00867         else if (BarName == String_32 (TEXT ("Toolbar")))
00868         {
00869             // do special stuff now ....
00870 
00871             DialogBarOp* pBar = DialogBarOp::FindDialogBarOp(BarName);
00872             ERROR3IF(pBar == NULL, "Cannot find named bar in TakeToolbarDetails");
00873 
00874             // If bar is of correct type then adjust its visibility according to the
00875             // check mark...
00876             if (!pBar->IsKindOf(CC_RUNTIME_CLASS(SystemBarOp)) ||
00877                 !pBar->IsKindOf(CC_RUNTIME_CLASS(InformationBarOp)) )
00878             {
00879                 //ToolbarIndex = listitem;
00880                 
00881                 BOOL CurrentState = pBar->IsVisible ();
00882                 //ToolbarCurrentState = CurrentState;
00883                 pBar->SetVisibility(pListGadget->GetSwitchState(listitem, 0));
00884 
00885                 if (pListGadget->GetSwitchState(listitem, 0) != CurrentState)
00886                 {   
00887                     if (pListGadget->GetSwitchState(listitem, 0))
00888                     {
00889                         GetMainFrame ()->SetToolbarCreated (TRUE);
00890                         GetMainFrame ()->RelocateToolbar ();
00891                     }
00892                     else
00893                     {
00894                         // so that we can lock out the toolbar 'onmove' and 'onsize' code
00895                         // from being executed when there is no toolbar
00896                         GetMainFrame ()->SetToolbarCreated (FALSE);
00897                     }
00898                 }
00899             //  else
00900             //  {
00901             //      BeenHidden = TRUE;
00902             //  }
00903             }
00904         }
00905         else
00906         {
00907             // Look for the named bar in the barops list...
00908             DialogBarOp* pBar = DialogBarOp::FindDialogBarOp(BarName);
00909             ERROR3IF(pBar == NULL, "Cannot find named bar in TakeToolbarDetails");
00910 
00911             // If bar is of correct type then adjust its visibility according to the
00912             // check mark...
00913             if (!pBar->IsKindOf(CC_RUNTIME_CLASS(SystemBarOp)) ||
00914                 !pBar->IsKindOf(CC_RUNTIME_CLASS(InformationBarOp)) )
00915             {
00916                 pBar->SetVisibility(pListGadget->GetSwitchState(listitem, 0));
00917             }
00918         }
00919 
00920         listitem++;
00921     }
00922 
00923     // dynamically reposition the toolbar when the above options are changed ....
00924     
00925 /*  if ((ToolbarIndex != -1) && (!BeenHidden))
00926     {
00927         if (pListGadget->GetSwitchState(ToolbarIndex, 0) != ToolbarCurrentState)
00928         if (pListGadget->GetSwitchState(ToolbarIndex, 0))
00929         {
00930             GetMainFrame ()->SetToolbarCreated (TRUE);
00931             GetMainFrame ()->RelocateToolbar ();
00932         }
00933     }*/
00934 }
00935 
00936 
00937 
00938 
00939 /******************************************************************************************
00940 
00941 >   void ToolbarDlg::NewToolbar()
00942 
00943     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00944     Created:    07/04/94
00945     Inputs:     - 
00946     Outputs:    -
00947     Returns:    -
00948     Purpose:    Make a new toolbar...
00949     Errors:     -
00950     SeeAlso:    -
00951 
00952 ******************************************************************************************/
00953 
00954 void ToolbarDlg::NewToolbar()
00955 {
00956     // Invoke the new toolbar name operation
00957     // Obtain a pointer to the op descriptor for the new toolbar name operation
00958     OpDescriptor* pOpDesc =
00959         OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(ToolnameDlg));
00960     ENSURE(pOpDesc,"Can't find ToolnameDlg Op.");
00961     // Invoke the operation.
00962     pOpDesc->Invoke();
00963 }
00964 
00965 
00966 
00967 /******************************************************************************************
00968 
00969 >   ToolbarDlg* ToolbarDlg::GetToolbarDlg()
00970 
00971     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00972     Created:    29/04/94
00973     Inputs:     - 
00974     Outputs:    -
00975     Returns:    -
00976     Purpose:    Make a new toolbar...
00977     Errors:     -
00978     SeeAlso:    -
00979 
00980 ******************************************************************************************/
00981 
00982 ToolbarDlg* ToolbarDlg::GetToolbarDlg()
00983 {
00984     return(CurrentToolbarDlg);
00985 }
00986 
00987 
00988 
00989 
00990 
00991 
00992 
00993 
00994 
00995 
00996 
00997 
00998 
00999 /******************************************************************************************
01000 ******************************************************************************************/
01001 
01002 const CDlgMode ToolnameDlg::Mode = MODAL; // The dialog is modeless
01003 const INT32 ToolnameDlg::IDD = _R(IDD_NEWTOOLBAR);
01004 
01005 /******************************************************************************************
01006 
01007 >   ToolnameDlg::ToolnameDlg(): DialogOp(ToolnameDlg::IDD, ToolnameDlg::Mode) 
01008 
01009 
01010     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01011     Created:    07/04/94
01012     Inputs:     -
01013     Outputs:    -
01014     Returns:    -
01015     Purpose:    ToolnameDlg constructor. Creates a non-undoable operation
01016     Errors:     -
01017     SeeAlso:    -
01018 
01019 ******************************************************************************************/
01020 
01021 ToolnameDlg::ToolnameDlg()
01022   : DialogOp(ToolnameDlg::IDD, ToolnameDlg::Mode) 
01023 {
01024 //  pToolbarDlg = NULL;
01025 }
01026 
01027 
01028 
01029 
01030 /********************************************************************************************
01031 
01032 >   MsgResult ToolnameDlg::Message( CDlgMessage DlgMsg, CGadgetID Gadget)
01033 
01034     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01035     Created:    07/04/94
01036     Inputs:     -
01037     Outputs:    -
01038     Returns:    -
01039     Purpose:    Handles all the Toolbar dialog's messages 
01040     Errors:     -
01041     SeeAlso:    -
01042 
01043 ********************************************************************************************/
01044 
01045 MsgResult ToolnameDlg::Message(Msg* Message)
01046 {
01047     if (IS_OUR_DIALOG_MSG(Message))
01048     {
01049 
01050         DialogMsg* Msg = (DialogMsg*)Message; 
01051         BOOL EndDialog = FALSE; 
01052         switch (Msg->DlgMsg)
01053         {
01054             case DIM_CREATE:
01055                 SetKeyboardFocus (_R(IDC_EDITNEWBARNAME)) ;
01056                 HighlightText    (_R(IDC_EDITNEWBARNAME)) ;
01057                 break ;
01058 
01059             case DIM_COMMIT:
01060             {
01061                 // Accept all changes that the user wants to make to toolbars...
01062                 BOOL VV;
01063                 String_32 NewBarName = GetStringGadgetValue(_R(IDC_EDITNEWBARNAME),&VV);
01064                 if(NewBarName.Length()==0)
01065                 {
01066                     UINT32 Number = DialogBarOp::FindUniqueBarNumber(); 
01067                     NewBarName._MakeMsg(TEXT("Bar #1%ld"),Number); 
01068                 }
01069                 DialogBarOp* pNewBar = new DialogBarOp(NewBarName);
01070                 if (pNewBar)
01071                 {
01072                     pNewBar->SetDockBarType(DOCKBAR_FLOAT);
01073                     pNewBar->Create();
01074                     // The Create function sends a message which we intercept to update
01075                     // the list of bars in the Toolbars... dialog.
01076                     // this is very dangerous in fact it blows up..
01077                     // so I have removed it .. chris.
01078                     /*  if (pNewBar)
01079                     {
01080                         // Find toolbar dialog and close it...
01081                         ToolbarDlg* pToolbarDlg = ToolbarDlg::GetToolbarDlg();
01082                         if (pToolbarDlg)
01083                         {
01084                             pToolbarDlg->Close();
01085                             pToolbarDlg->End();
01086                         }
01087                     }
01088                     */
01089                     ToolbarDlg* pToolbarDlg = ToolbarDlg::GetToolbarDlg();
01090                     pToolbarDlg->ShowToolbarList();
01091                 }
01092                 EndDialog = TRUE;
01093             
01094             }
01095             break;
01096 
01097             case DIM_CANCEL:
01098                 // Cancel all changes the user wants to make to toolbars...
01099                 EndDialog = TRUE;
01100                 break;
01101 
01102 //          default:
01103         }
01104 
01105         if (EndDialog)  // Dialog communication over 
01106         {
01107             Close();    // Close the dialog 
01108             End();      // Destroy dialog 
01109         }
01110 
01111 //      return (DLG_EAT_IF_HUNGRY(Msg)); 
01112     }
01113 
01114 //  return OK; 
01115 
01116     // Pass everything on to the base-class . . .
01117     return DialogOp::Message(Message);
01118 }
01119 
01120 
01121 
01122 
01123 /******************************************************************************************
01124 
01125 >   OpState ToolnameDlg::GetState(String_256*, OpDescriptor*)
01126 
01127     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01128     Created:    07/04/94
01129     Inputs:     -
01130     Outputs:    -
01131     Returns:    -
01132     Purpose:    ToolnameDlg GetState method
01133     Errors:     -
01134     SeeAlso:    -
01135 
01136 ******************************************************************************************/
01137 
01138 OpState ToolnameDlg::GetState(String_256*, OpDescriptor*)
01139 {    
01140     OpState OpSt;
01141     return(OpSt);
01142 }
01143 
01144 
01145 
01146 
01147 /******************************************************************************************
01148 
01149 >   BOOL ToolnameDlg::Init()
01150 
01151     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01152     Created:    07/04/94
01153     Inputs:     -
01154     Outputs:    -
01155     Returns:    -
01156     Purpose:    ToolnameDlg Init method
01157     Errors:     -
01158     SeeAlso:    -
01159 
01160 ******************************************************************************************/
01161 
01162 BOOL ToolnameDlg::Init()
01163 {  
01164     return (RegisterOpDescriptor(
01165                                 0,
01166                                 _R(IDS_TOOLBARNAME_DLG),
01167                                 CC_RUNTIME_CLASS(ToolnameDlg),
01168                                 OPTOKEN_TOOLBARNAMEDLG,
01169                                 ToolnameDlg::GetState,
01170                                 0,  /* help ID */
01171                                 0,  /* bubble help ID _R(IDBBL_LAYERDLG), */
01172                                 0   /* bitmap ID */));
01173 }
01174 
01175 
01176 
01177 
01178 /********************************************************************************************
01179 
01180 >   BOOL ToolnameDlg::Create()
01181 
01182     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01183     Created:    07/04/94
01184     Inputs:     -
01185     Outputs:    -
01186     Returns:    TRUE if successful, else FALSE
01187     Purpose:    ToolnameDlg create method 
01188     Errors:     -
01189     SeeAlso:    -
01190 
01191 ********************************************************************************************/
01192 
01193        
01194 BOOL ToolnameDlg::Create()
01195 {                            
01196     if (DialogOp::Create())
01197     { 
01198         // Set the initial control values 
01199         InitDialog();
01200 
01201         return TRUE; 
01202     }
01203     else
01204     {
01205         return FALSE; 
01206     }
01207 }
01208 
01209 
01210 
01211 
01212 /******************************************************************************************
01213 
01214 >   void ToolnameDlg::Do(OpDescriptor* pOpDesc)
01215 
01216     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01217     Created:    07/04/94
01218     Inputs:     -
01219     Outputs:    -
01220     Returns:    -
01221     Purpose:    Creates then opens the dialog in response to a request from the user.
01222     Errors:     -
01223     SeeAlso:    -
01224 
01225 ******************************************************************************************/
01226 
01227 void ToolnameDlg::Do(OpDescriptor* pOpDesc)
01228 {
01229     if (Create())   
01230     {
01231 //      pToolbarDlg = pDlg;
01232     //  Open();
01233     }
01234     else              // Could not create 
01235     {
01236         InformError();
01237         End();         // End the operation 
01238     }
01239 }
01240 
01241 
01242 
01243 
01244 /******************************************************************************************
01245 
01246 >   BOOL ToolnameDlg::InitDialog()
01247 
01248     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01249     Created:    07/04/94
01250     Inputs:     -
01251     Outputs:    -
01252     Returns:    -
01253     Purpose:    Sets initial dialog values 
01254     Errors:     -
01255     SeeAlso:    -
01256 
01257 ******************************************************************************************/
01258 
01259 BOOL ToolnameDlg::InitDialog()
01260 {
01261     return TRUE;
01262 }
01263 
01264 
01265 
01266 
01267 
01268 
01269 
01270 
01271 
01272 
01273 
01274 
01275 
01276 /******************************************************************************************
01277 ******************************************************************************************/
01278 
01279 const CDlgMode CustomizeBarDlg::Mode = MODELESS; // The dialog is modeless
01280 const INT32 CustomizeBarDlg::IDD = _R(IDD_CUSTOMIZEBAR);
01281 
01282 /******************************************************************************************
01283 
01284 >   CustomizeBarDlg::CustomizeBarDlg(): DialogOp(CustomizeBarDlg::IDD, CustomizeBarDlg::Mode) 
01285 
01286 
01287     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01288     Created:    07/04/94
01289     Inputs:     -
01290     Outputs:    -
01291     Returns:    -
01292     Purpose:    CustomizeBarDlg constructor. Creates a non-undoable operation
01293     Errors:     -
01294     SeeAlso:    -
01295 
01296 ******************************************************************************************/
01297 
01298 CustomizeBarDlg::CustomizeBarDlg()
01299   : DialogOp(CustomizeBarDlg::IDD, CustomizeBarDlg::Mode) 
01300 {
01301     // Empty.
01302 }
01303 
01304 
01305 
01306 
01307 /********************************************************************************************
01308 
01309 >   MsgResult CustomizeBarDlg::Message( CDlgMessage DlgMsg, CGadgetID Gadget)
01310 
01311     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01312     Created:    07/04/94
01313     Inputs:     -
01314     Outputs:    -
01315     Returns:    -
01316     Purpose:    Handles all the Toolbar dialog's messages 
01317     Errors:     -
01318     SeeAlso:    -
01319 
01320 ********************************************************************************************/
01321 
01322 MsgResult CustomizeBarDlg::Message(Msg* Message)
01323 {
01324     if (IS_OUR_DIALOG_MSG(Message))
01325     {
01326         DialogMsg* Msg = (DialogMsg*)Message; 
01327         BOOL EndDialog = FALSE; 
01328 
01329         switch (Msg->DlgMsg)
01330         {
01331             case DIM_COMMIT:
01332             {
01333                 EndDialog = TRUE;
01334             }
01335             break;
01336 
01337             case DIM_CANCEL:
01338                 // Cancel all changes the user wants to make to toolbars...
01339                 EndDialog = TRUE;
01340             break;
01341 
01342 //          default:
01343         }
01344 
01345         if (EndDialog)  // Dialog communication over 
01346         {
01347             Close(); // Close the dialog 
01348             End();  // Destroy dialog 
01349         }
01350 //      return (DLG_EAT_IF_HUNGRY(Msg)); 
01351     }
01352 //  return OK;
01353 
01354     // Pass all messages on to the base class for final handling . . .
01355     return DialogOp::Message(Message);
01356 }
01357 
01358 
01359 
01360 
01361 /******************************************************************************************
01362 
01363 >   OpState CustomizeBarDlg::GetState(String_256*, OpDescriptor*)
01364 
01365     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01366     Created:    07/04/94
01367     Inputs:     -
01368     Outputs:    -
01369     Returns:    -
01370     Purpose:    CustomizeBarDlg GetState method
01371     Errors:     -
01372     SeeAlso:    -
01373 
01374 ******************************************************************************************/
01375 
01376 OpState CustomizeBarDlg::GetState(String_256*, OpDescriptor*)
01377 {    
01378     OpState OpSt;
01379     return(OpSt);
01380 }
01381 
01382 
01383 
01384 
01385 /******************************************************************************************
01386 
01387 >   BOOL CustomizeBarDlg::Init()
01388 
01389     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01390     Created:    07/04/94
01391     Inputs:     -
01392     Outputs:    -
01393     Returns:    -
01394     Purpose:    CustomizeBarDlg Init method
01395     Errors:     -
01396     SeeAlso:    -
01397 
01398 ******************************************************************************************/
01399 
01400 BOOL CustomizeBarDlg::Init()
01401 {  
01402     return (RegisterOpDescriptor(
01403                                 0,
01404                                 _R(IDS_CUSTOMIZE_BAR_DLG),
01405                                 CC_RUNTIME_CLASS(CustomizeBarDlg),
01406                                 OPTOKEN_CUSTOMIZEBARDLG,
01407                                 CustomizeBarDlg::GetState,
01408                                 0,  /* help ID */
01409                                 0,  /* bubble help ID _R(IDBBL_LAYERDLG), */
01410                                 0   /* bitmap ID */));
01411 }
01412 
01413 
01414 
01415 
01416 /********************************************************************************************
01417 
01418 >   BOOL CustomizeBarDlg::Create()
01419 
01420     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01421     Created:    07/04/94
01422     Inputs:     -
01423     Outputs:    -
01424     Returns:    TRUE if successful, else FALSE
01425     Purpose:    CustomizeBarDlg create method 
01426     Errors:     -
01427     SeeAlso:    -
01428 
01429 ********************************************************************************************/
01430 
01431        
01432 BOOL CustomizeBarDlg::Create()
01433 {                            
01434     if (DialogOp::Create())
01435     { 
01436         // Set the initial control values 
01437         InitDialog();
01438 
01439         return TRUE; 
01440     }
01441     else
01442     {
01443         return FALSE; 
01444     }
01445 }
01446 
01447 
01448 
01449 
01450 /******************************************************************************************
01451 
01452 >   void CustomizeBarDlg::Do(OpDescriptor* pOpDesc)
01453 
01454     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01455     Created:    07/04/94
01456     Inputs:     -
01457     Outputs:    -
01458     Returns:    -
01459     Purpose:    Creates then opens the dialog in response to a request from the user.
01460     Errors:     -
01461     SeeAlso:    -
01462 
01463 ******************************************************************************************/
01464 
01465 void CustomizeBarDlg::Do(OpDescriptor* pOpDesc)
01466 {
01467     if (Create())
01468     {
01469 //      pToolbarDlg = pDlg;
01470         Open();
01471     }
01472     else              // Could not create 
01473     {
01474         InformError();
01475         End();         // End the operation 
01476     }
01477 }
01478 
01479 
01480 
01481 
01482 /******************************************************************************************
01483 
01484 >   BOOL CustomizeBarDlg::InitDialog()
01485 
01486     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01487     Created:    07/04/94
01488     Inputs:     -
01489     Outputs:    -
01490     Returns:    -
01491     Purpose:    Sets initial dialog values 
01492     Errors:     -
01493     SeeAlso:    -
01494 
01495 ******************************************************************************************/
01496 
01497 BOOL CustomizeBarDlg::InitDialog()
01498 {
01499     ShowOpsList();
01500     return TRUE;
01501 }
01502 
01503 
01504 
01505 
01506 /******************************************************************************************
01507 
01508 >   void CustomizeBarDlg::ShowOpsList()
01509 
01510     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01511     Created:    07/04/94
01512     Inputs:     -
01513     Outputs:    -
01514     Returns:    -
01515     Purpose:    Sets initial dialog values 
01516     Errors:     -
01517     SeeAlso:    -
01518 
01519 ******************************************************************************************/
01520 
01521 void CustomizeBarDlg::ShowOpsList()
01522 {
01523     OpListItem* pOpListItem = OpDescriptor::GetFirstDescriptor();
01524     OpDescriptor* pCurrentOpDesc;
01525 
01526     ENSURE(pOpListItem,"Wot, no OpDescriptors?");
01527 
01528     while (pOpListItem)
01529     {
01530         pCurrentOpDesc = pOpListItem->pOpDesc;
01531         ENSURE(pCurrentOpDesc,"OpListitem doesn't point to OpDescriptor in ShowOpsList");
01532 
01533         SetStringGadgetValue(_R(IDC_OPSLIST),&(pCurrentOpDesc->Token),TRUE,0);
01534 
01535         pOpListItem = OpDescriptor::GetNextDescriptor(pOpListItem);
01536     }
01537 
01538 }

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