BarCreationDlg Class Reference

Dialog to make building button bar rollovers easier. More...

#include <barcreationdlg.h>

Inheritance diagram for BarCreationDlg:

DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 BarCreationDlg ()
 Constructor.
 ~BarCreationDlg ()
 Destructor.
void Do (OpDescriptor *)
 Opens the dialog if it is closed. Closes it if it is open. Should no longer be called, but use the with param instead.
void DoWithParam (OpDescriptor *pOp, OpParam *pParam)
 Performs the BarCreationDlg operation.
virtual MsgResult Message (Msg *Message)
 This is the message handler for the BarCreationDlg. It simply takes the message and redirects it to one of our Message Handler functions.

Static Public Member Functions

static BOOL Init ()
 Creates an OpDescriptor for a HotLink Dialog and declares some preferences.
static OpState GetState (String_256 *, OpDescriptor *)
 Returns the OpState of the dialogue operation.

Static Public Attributes

static const UINT32 IDD = _R(IDD_BARCREATIONDLG)
static const CDlgMode Mode = MODELESS
static BOOL ms_WantMouse = FALSE
static BOOL ms_WantClicked = FALSE
static BOOL ms_WantSelected = FALSE
static BOOL ms_WantDefault = TRUE
static BOOL ms_IsVertical = TRUE
static BOOL ms_SuggestDesign = TRUE
static INT32 ms_NoOfButtons = 4
static INT32 ms_Mode = 0
static INT32 ms_SizeJustification = 0
static BOOL ms_Continuous = TRUE
static INT32 ms_Spacing = 0
static INT32 ms_Stretching = 0
static BOOL ms_FromSelection = TRUE
static INT32 ms_StateToCreate = 0
static BOOL ms_GroupsStretch = TRUE

Protected Member Functions

BOOL Create ()
 Creates a Web Address dialogue box. Fails if DialogOp::Create fails to create the box.
BOOL SetUpControls (BOOL DoScan=TRUE)
 Spookily enough it sets up all the controls in the dlg.
BOOL SetUpDynamicControls ()
 Sets up all the controls in the dlg that are dynamic and reviewed upon a timer. So this function is called on a poll, to read the states and set the controls.
BOOL CreateBar ()
void ReadBarProperties ()
void WriteBarProperties ()
INT32 GetBarNumber ()
void EnableAllMyControls (BOOL enable)

Protected Attributes

BOOL m_IsEditing
BOOL m_FirstIsEditing
String_256 m_BarName
String_256 m_FirstBarName
BOOL m_AlreadyInThisFunction
BOOL m_HasBackBar
BOOL m_ValidBar

Static Protected Attributes

static BarCreationDlgTheDialog = NULL

Private Member Functions

 CC_DECLARE_DYNCREATE (BarCreationDlg)

Detailed Description

Dialog to make building button bar rollovers easier.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/8/99

Definition at line 120 of file barcreationdlg.h.


Constructor & Destructor Documentation

BarCreationDlg::BarCreationDlg  ) 
 

Constructor.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> from Alex
Date:
13/8/99

Definition at line 177 of file barcreationdlg.cpp.

00177                                : DialogOp(BarCreationDlg::IDD, BarCreationDlg::Mode) 
00178 {
00179     //Set our member variable pointer so it points at ourself
00180     if (TheDialog == NULL)
00181         TheDialog = this;
00182 
00183     m_IsEditing = FALSE;
00184     m_FirstIsEditing = FALSE;
00185     m_AlreadyInThisFunction = FALSE;
00186     m_HasBackBar = FALSE;
00187     m_ValidBar = TRUE;
00188 }       

BarCreationDlg::~BarCreationDlg  ) 
 

Destructor.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> from Alex
Date:
13/8/99

Definition at line 202 of file barcreationdlg.cpp.

00203 {
00204     //Set our member variable pointer to NULL
00205     if (TheDialog == this)
00206         TheDialog = NULL;
00207 } 


Member Function Documentation

BarCreationDlg::CC_DECLARE_DYNCREATE BarCreationDlg   )  [private]
 

BOOL BarCreationDlg::Create void   )  [protected, virtual]
 

Creates a Web Address dialogue box. Fails if DialogOp::Create fails to create the box.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> after Jason
Date:
13/8/99
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
FALSE if it fails

Errors: -

See also:
-

Reimplemented from DialogOp.

Definition at line 664 of file barcreationdlg.cpp.

00665 {
00666 
00667     ReadBarProperties();    
00668 
00669     // manipulate the ticks if we are editing a state
00670     if (!m_IsEditing)
00671         // if we are creating we must create the default state
00672     {
00673         ms_StateToCreate = 0; // create the off state as default
00674         ms_FromSelection = TRUE; // from the selection of course
00675 
00676         ms_WantDefault = TRUE;
00677         ms_WantMouse = FALSE;
00678         ms_WantClicked = FALSE;
00679         ms_WantSelected = FALSE;
00680 
00681         ms_Spacing = 0; // reset the spacing to zero
00682         ms_GroupsStretch = TRUE;
00683     }
00684 
00685 
00686     if (TheDialog != this)      // Allow only one instance of this dialogue open at once
00687         return(FALSE);
00688 
00689     if (DialogOp::Create())
00690     { 
00691         return(TRUE);
00692     }
00693 
00694     return(FALSE);
00695 }

BOOL BarCreationDlg::CreateBar  )  [protected]
 

Definition at line 946 of file barcreationdlg.cpp.

00947 {
00948     BOOL Valid = TRUE;
00949     ms_NoOfButtons = GetLongGadgetValue(_R(IDC_BC_NO_OF_BUTTONS), 1, 20, 0 /*error id*/, &Valid);
00950     if (!Valid)
00951     {
00952         InformWarning(_R(IDS_TOO_MANY_BUTTONS));
00953         return FALSE;
00954     }
00955 
00956     // run the Op that does the copying of the selection / bar creation bit
00957 
00958     BOOL MakeBackBarAswell = !m_IsEditing && GetBoolGadgetSelected(_R(IDC_BC_CREATE_BACKBAR));
00959 
00960     ms_WantDefault = FALSE;
00961     ms_WantMouse = FALSE;
00962     ms_WantClicked = FALSE;
00963     ms_WantSelected = FALSE;
00964     switch(ms_StateToCreate)
00965     {
00966     case 0:
00967         ms_WantDefault = TRUE;
00968         break;
00969 
00970     case 1:
00971         ms_WantMouse = TRUE;
00972         break;
00973 
00974     case 2:
00975         ms_WantClicked = TRUE;
00976         break;
00977 
00978     case 3:
00979         ms_WantSelected = TRUE;
00980         break;
00981 
00982     }
00983 
00984     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BARCREATIONOP); 
00985     if (pOpDesc != NULL)
00986     {
00987         // set the mode of the create from
00988         // the editing flag for now
00989         if (m_IsEditing)
00990             ms_Mode = REPLACE_SOME_STATES;
00991         else
00992         {
00993             ms_Mode = NEW_BAR;
00994 
00995             // the text has changed for the spacing field
00996             INT32 spacing = 0;
00997             BOOL Valid=0; 
00998             MILLIPOINT ActualSpacing = GetUnitGadgetValue(_R(IDC_BC_SPACING), PIXELS, 0, 75000, 0, &Valid);
00999             String_256 ActualText = GetStringGadgetValue(_R(IDC_BC_SPACING));
01000             spacing = ActualSpacing;
01001 
01002             if (Valid && !ActualText.IsEmpty() && ms_Spacing != spacing)
01003             {
01004                 ms_Spacing = spacing;
01005             }
01006         }
01007 
01008         // add the bar details
01009         WriteBarProperties();
01010 
01011         BYTE ExtendFlags = 0; // dont extend
01012 
01013         if (ms_Stretching == 0)
01014             ExtendFlags = X_EXTEND | Y_EXTEND;
01015         else
01016             if (ms_Stretching == 1)
01017                 ExtendFlags = X_STRETCH | Y_STRETCH;
01018 
01019         OpParamBarCreation BarParam(ms_WantMouse,
01020                                     ms_WantClicked,
01021                                     ms_WantSelected,
01022                                     (ms_StateToCreate == BACKBAR) || MakeBackBarAswell,
01023                                     ms_IsVertical,
01024                                     ms_SuggestDesign,
01025                                     ms_NoOfButtons,
01026                                     ms_WantDefault,
01027                                     ms_Mode,
01028                                     ms_Spacing,
01029                                     ms_Continuous,
01030                                     ms_SizeJustification != 3, // are they the same size ?  0 = same centered 1 = same left 2 = same right 3 = independant
01031                                     m_BarName,
01032                                     (ms_StateToCreate == DEFAULT || ms_StateToCreate == BACKBAR) ? TRUE : ms_FromSelection,
01033                                     ExtendFlags);
01034         pOpDesc->Invoke(&BarParam);
01035     }
01036     else
01037     {
01038         ERROR3("Couldn't find OPTOKEN_BARCREATIONOP op descriptor");
01039     }
01040 
01041     return TRUE;
01042 }

void BarCreationDlg::Do OpDescriptor  )  [virtual]
 

Opens the dialog if it is closed. Closes it if it is open. Should no longer be called, but use the with param instead.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> after Jason
Date:
13/8/99

Reimplemented from Operation.

Definition at line 625 of file barcreationdlg.cpp.

00626 {
00627     m_IsEditing = FALSE;
00628     m_BarName = "Bar1";
00629     m_FirstBarName = m_BarName;
00630     ms_Spacing = 0; // reset the spacing to zero
00631 
00632     if (TheDialog==NULL || TheDialog==this)
00633     {
00634         if (Create())
00635             Open();
00636         else
00637             End();
00638     }
00639     else
00640     {
00641         TheDialog->Open();
00642         TheDialog->BringToTop();
00643 
00644         End();              // Kill ourself
00645     }
00646 }

void BarCreationDlg::DoWithParam OpDescriptor pOp,
OpParam pParam
[virtual]
 

Performs the BarCreationDlg operation.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> after Alex
Date:
13/8/99
Parameters:
OpDescriptor [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 712 of file barcreationdlg.cpp.

00713 {
00714     m_IsEditing = ((OpParamBarCreationDlg *)pParam)->m_IsEditing;
00715     m_BarName = ((OpParamBarCreationDlg *)pParam)->m_BarName;
00716     m_FirstBarName = m_BarName;
00717     m_FirstIsEditing = m_IsEditing;
00718 
00719     if (((OpParamBarCreationDlg *)pParam)->m_ButtonsToEdit)
00720         ms_NoOfButtons = ((OpParamBarCreationDlg *)pParam)->m_ButtonsToEdit;
00721 
00722     if (TheDialog==NULL || TheDialog==this)
00723     {
00724         if (Create())
00725         {
00726             Open();
00727             SetUpControls(TRUE);
00728         }
00729         else
00730             End();
00731     }
00732     else
00733     {
00734         TheDialog->Open();
00735         TheDialog->BringToTop();
00736 
00737         TheDialog->m_IsEditing = ((OpParamBarCreationDlg *)pParam)->m_IsEditing;
00738         TheDialog->m_BarName = ((OpParamBarCreationDlg *)pParam)->m_BarName;
00739         TheDialog->m_FirstBarName = m_BarName;
00740         TheDialog->m_FirstIsEditing = m_IsEditing;
00741         TheDialog->m_ValidBar = TRUE;
00742         TheDialog->ms_Spacing = 0; // reset the spacing to zero
00743         TheDialog->ms_GroupsStretch = TRUE;
00744 
00745         TheDialog->EnableAllMyControls(TRUE);
00746 
00747         TheDialog->SetUpControls(TRUE);
00748 
00749         End();              // Kill ourself
00750     }
00751 }

void BarCreationDlg::EnableAllMyControls BOOL  enable  )  [protected]
 

Definition at line 934 of file barcreationdlg.cpp.

00935 {
00936     EnableGadget(_R(IDC_BC_NO_OF_BUTTONS),  enable);
00937     EnableGadget(_R(IDC_BC_DIRECTION),      enable);
00938     EnableGadget(_R(IDC_BC_SPACING),        enable);
00939     EnableGadget(_R(IDC_BC_BUTTON_SIZE),    enable);
00940     EnableGadget(_R(IDC_BC_BUTTONS_SAME),   enable);
00941     EnableGadget(_R(IDC_BC_REDEF_BACKBAR),  enable);
00942     EnableGadget(_R(IDC_BC_CREATE),         enable);
00943 }

INT32 BarCreationDlg::GetBarNumber  )  [protected]
 

OpState BarCreationDlg::GetState String_256 ,
OpDescriptor
[static]
 

Returns the OpState of the dialogue operation.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> after Alex
Date:
13/8/99

Definition at line 557 of file barcreationdlg.cpp.

00558 {
00559     OpState OpSt;
00560 
00561     // if we don't allow it
00562     OpSt.Greyed = TRUE;
00563     Spread* pSpread = Document::GetSelectedSpread();
00564     if (pSpread && !pSpread->FindActiveLayer()->IsFrame())
00565         OpSt.Greyed = FALSE;
00566 
00567     // Tick the menu while the editor is open
00568     if (TheDialog != NULL)
00569         OpSt.Ticked = TRUE;
00570 
00571     return(OpSt);
00572 }

BOOL BarCreationDlg::Init void   )  [static]
 

Creates an OpDescriptor for a HotLink Dialog and declares some preferences.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> after Alex
Date:
13/8/99
Returns:
FALSE if it fails (due to lack of memory)

Reimplemented from SimpleCCObject.

Definition at line 587 of file barcreationdlg.cpp.

00588 {
00589     return (RegisterOpDescriptor(0,                             // Tool ID
00590                                 _R(IDS_BARCREATION),                    // String resource ID
00591                                 CC_RUNTIME_CLASS(BarCreationDlg),       // Runtime class
00592                                 OPTOKEN_BARCREATIONDLG,             // Token string
00593                                 BarCreationDlg::GetState,               // GetState function
00594                                 _R(IDH_NavBar_Create_Dialog_Box),                               // Help ID
00595                                 _R(IDBBL_BARCREATION),              // Bubble ID
00596                                 _R(IDD_BARCONTROLSTORE),            // Resource ID
00597                                 _R(IDC_BARCREATION),                // Control ID
00598                                 SYSTEMBAR_UTILITIES,            // Bar ID
00599                                 TRUE,                           // Recieve system messages
00600                                 FALSE,                          // Smart duplicate operation
00601                                 TRUE,                           // Clean operation
00602                                 0,                              // No vertical counterpart
00603                                 NULL,
00604                                 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC),
00605                                 TRUE
00606                                 )); 
00607                         
00608 }   

MsgResult BarCreationDlg::Message Msg Message  )  [virtual]
 

This is the message handler for the BarCreationDlg. It simply takes the message and redirects it to one of our Message Handler functions.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/8/99
Parameters:
Message,: The incoming message [INPUTS]
Returns:
DialogOp::Message (Message)

Reimplemented from DialogOp.

Definition at line 223 of file barcreationdlg.cpp.

00224 {
00225     BOOL fEndDialog=FALSE;
00226 
00227     //If the message is a dialog message
00228     if (IS_OUR_DIALOG_MSG(Message))
00229     {
00230         //Then work out what it says
00231         DialogMsg* pDialogMsg = ((DialogMsg*) Message); 
00232     
00233         switch (pDialogMsg->DlgMsg)
00234         {
00235             case DIM_CREATE:
00236                 SetStringGadgetValue(_R(IDC_BC_DIRECTION), _R(IDS_HORIZ), FALSE, 0);
00237                 SetStringGadgetValue(_R(IDC_BC_DIRECTION), _R(IDS_VERT), FALSE, 1);
00238                 SetStringGadgetValue(_R(IDC_BC_DIRECTION), _R(IDS_SCATTERED), TRUE, 2);
00239 
00240                 SetStringGadgetValue(_R(IDC_BC_BUTTON_SIZE), _R(IDS_EXTENDS), FALSE, 0);
00241                 SetStringGadgetValue(_R(IDC_BC_BUTTON_SIZE), _R(IDS_SCALES), FALSE, 1);
00242                 SetStringGadgetValue(_R(IDC_BC_BUTTON_SIZE), _R(IDS_IS_STATIC), TRUE, 2);
00243 
00244                 SetStringGadgetValue(_R(IDC_BC_BUTTONS_SAME), _R(IDS_BUTTONS_SAME_SIZE), FALSE, 0);
00245                 SetStringGadgetValue(_R(IDC_BC_BUTTONS_SAME), _R(IDS_BUTTONS_LEFT_SIZE), FALSE, 1);
00246                 SetStringGadgetValue(_R(IDC_BC_BUTTONS_SAME), _R(IDS_BUTTONS_RIGHT_SIZE), FALSE, 2);
00247                 SetStringGadgetValue(_R(IDC_BC_BUTTONS_SAME), _R(IDS_BUTTONS_DIFF_SIZE), TRUE, 3);
00248                 
00249                 SetUpControls();
00250 
00251                 // throw the keyboard focus
00252                 //DialogManager::DefaultKeyboardFocus();
00253                 break;
00254     
00255             // these two messages are used to throw the focus back to the main window
00256             case DIM_TITLEFOCUSWARN:
00257                 //DialogManager::DefaultKeyboardFocus();
00258                 break;
00259 
00260             // focus throw
00261             case DIM_LFT_BN_UP:
00262                 //DialogManager::DefaultKeyboardFocus();
00263                 break;
00264 
00265             case DIM_CANCEL:    
00266                 fEndDialog = TRUE;
00267                 break;
00268 
00269             // special case to find the one typed into the field
00270             case DIM_TIMER:
00271                 {
00272                     KillTimer(DLG_TIMER);
00273                     INT32 NewNoOfButtons = GetLongGadgetValue(_R(IDC_BC_NO_OF_BUTTONS), 1, MAX_BUTTONS_IN_A_BAR);
00274 
00275                     if (NewNoOfButtons == 1)
00276                     {
00277                         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHORTENBAROP); 
00278                         if (pOpDesc != NULL)
00279                         {
00280                             OpParamShortenBar ParamShortenBar(m_BarName, NewNoOfButtons);
00281                             pOpDesc->Invoke(&ParamShortenBar);
00282                             // update the dialog value
00283                             ms_NoOfButtons = NewNoOfButtons;
00284                             SetLongGadgetValue(_R(IDC_BC_NO_OF_BUTTONS), ms_NoOfButtons);
00285                         }
00286                         else
00287                         {
00288                             ERROR3("Couldn't find OPTOKEN_SHORTENBAROP op descriptor");
00289                         }
00290                     }
00291                 }
00292                 break;
00293 
00294             case DIM_TEXT_CHANGED:
00295                 if (m_IsEditing)
00296                     switch(pDialogMsg->GadgetID)
00297                 {
00298                 case _R(IDC_BC_SPACING):
00299                     {
00300                     // the text has changed for the spacing field
00301                         INT32 spacing = 0;
00302                         BOOL Valid=0;
00303                         MILLIPOINT ActualSpacing = GetUnitGadgetValue(_R(IDC_BC_SPACING), PIXELS, -75000, 75000, 0, &Valid);
00304                         String_256 ActualText = GetStringGadgetValue(_R(IDC_BC_SPACING));
00305                         spacing = ActualSpacing;
00306 
00307 
00308                         if (Valid && !ActualText.IsEmpty() && ms_Spacing != spacing)
00309                         {
00310                             ms_Spacing = spacing;
00311 
00312                             if (m_IsEditing)
00313                                 WriteBarProperties();
00314                         }
00315                     }
00316                     //DialogManager::DefaultKeyboardFocus(); // throws focus
00317                     break;
00318 
00319                 case _R(IDC_BC_NO_OF_BUTTONS):
00320                     {
00321                     // the text has changed for the spacing field
00322                         INT32 NewNoOfButtons = GetLongGadgetValue(_R(IDC_BC_NO_OF_BUTTONS), 1, MAX_BUTTONS_IN_A_BAR);
00323 
00324                         // get what the set abr props are then
00325                         ReadBarProperties();
00326 
00327                         if (NewNoOfButtons > ms_NoOfButtons && NewNoOfButtons <= MAX_BUTTONS_IN_A_BAR)
00328                         {
00329                             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BARDUPLICATIONOP); 
00330                             if (pOpDesc != NULL)
00331                             {
00332                                 OpParamBarDuplication AddButtonsParam(m_BarName, m_BarName, NewNoOfButtons - ms_NoOfButtons, ms_Spacing, !ms_IsVertical);
00333                                 pOpDesc->Invoke(&AddButtonsParam);
00334 
00335                                 // update the dialog value
00336                                 ms_NoOfButtons = NewNoOfButtons;
00337                                 SetLongGadgetValue(_R(IDC_BC_NO_OF_BUTTONS), ms_NoOfButtons);
00338                             }
00339                             else
00340                             {
00341                                 ERROR3("Couldn't find OPTOKEN_BARDUPLICATIONOP op descriptor");
00342                             }
00343                         }
00344                         else
00345                         if (NewNoOfButtons < ms_NoOfButtons && NewNoOfButtons > 1)
00346                         {
00347                             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHORTENBAROP); 
00348                             if (pOpDesc != NULL)
00349                             {
00350                                 OpParamShortenBar ParamShortenBar(m_BarName, NewNoOfButtons);
00351                                 pOpDesc->Invoke(&ParamShortenBar);
00352                                 // update the dialog value
00353                                 ms_NoOfButtons = NewNoOfButtons;
00354                                 SetLongGadgetValue(_R(IDC_BC_NO_OF_BUTTONS), ms_NoOfButtons);
00355                             }
00356                             else
00357                             {
00358                                 ERROR3("Couldn't find OPTOKEN_SHORTENBAROP op descriptor");
00359                             }
00360                         }
00361                         else
00362                         if (NewNoOfButtons < ms_NoOfButtons && NewNoOfButtons == 1)
00363                         {
00364                             SetTimer(DLG_TIMER, 1000, NULL);
00365                         }
00366 
00367                     }
00368                     //DialogManager::DefaultKeyboardFocus(); // throws focus
00369                     break;
00370 
00371                 } // end switch
00372 
00373                 break;
00374 
00375             // manage button controls
00376             case DIM_LFT_BN_CLICKED:
00377                 switch(pDialogMsg->GadgetID)
00378                 {
00379                 case _R(IDC_BC_CREATE):
00380                     if (m_IsEditing)
00381                     { // open up the states dlg
00382                         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BARSTATESDLG); 
00383                         if (pOpDesc != NULL)
00384                         {
00385                             OpParamBarStatesDlg ParamBarStatesDlg(m_BarName);
00386                             pOpDesc->Invoke(&ParamBarStatesDlg);
00387                         }
00388 
00389                     }
00390                     else
00391                     {
00392                         if(CreateBar()) // behave in a modal manner - close the dialog having done the deed.
00393                         {
00394                             fEndDialog = TRUE;
00395                             m_IsEditing = TRUE;
00396                             SetUpControls(TRUE);
00397                         }
00398                     }
00399                     break;
00400 
00401                 case _R(IDC_BC_REDEF_BACKBAR):
00402                     if (m_IsEditing)
00403                     {
00404                         // create a back bar
00405                         INT32 temp = ms_StateToCreate;
00406                         ms_StateToCreate = BACKBAR;
00407                         CreateBar();
00408                         ms_StateToCreate = temp;
00409                         SetUpControls(TRUE);
00410                     }
00411                     break;
00412 
00413                 case _R(IDC_BC_GROUPS_STRETCH):
00414                     ms_GroupsStretch = !GetBoolGadgetSelected(_R(IDC_BC_GROUPS_STRETCH));
00415                     if (m_IsEditing)
00416                         WriteBarProperties();
00417                     break;
00418                 }
00419                 //DialogManager::DefaultKeyboardFocus(); // throws focus
00420                 break;
00421 
00422             
00423                 //NB: This means someone has altered the combo box. It doesn't mean
00424                 //the selection has changed!
00425             case DIM_SELECTION_CHANGED: 
00426                 switch(pDialogMsg->GadgetID)
00427                 {
00428                     // changed the direction of the bar
00429                 case _R(IDC_BC_DIRECTION):
00430                     switch (GetSelectedValueIndex(_R(IDC_BC_DIRECTION)))
00431                     {
00432                     case 0: // horz
00433                         ms_IsVertical = FALSE;
00434                         ms_Continuous = TRUE;
00435                         break;
00436 
00437                     case 1: // vert
00438                         ms_IsVertical = TRUE;
00439                         ms_Continuous = TRUE;
00440                         break;
00441 
00442                     case 2: // scattered
00443                         ms_IsVertical = TRUE;
00444                         ms_Continuous = FALSE;
00445                         break;
00446                     }
00447 
00448                     EnableGadget(_R(IDC_BC_SPACING), ms_Continuous && m_ValidBar);
00449 
00450                     if (m_IsEditing) // update the bar direction now!
00451                         WriteBarProperties();
00452 
00453                     //DialogManager::DefaultKeyboardFocus(); // throws focus
00454                     break;
00455 
00456                 case _R(IDC_BC_BUTTONS_SAME):
00457                     ms_SizeJustification = GetSelectedValueIndex(_R(IDC_BC_BUTTONS_SAME));
00458 
00459                     if (m_IsEditing)
00460                         WriteBarProperties();
00461                     //DialogManager::DefaultKeyboardFocus(); // throws focus
00462                     break;
00463 
00464                 case _R(IDC_BC_BUTTON_SIZE):
00465                     ms_Stretching = GetSelectedValueIndex(_R(IDC_BC_BUTTON_SIZE));
00466                     EnableGadget(_R(IDC_BC_GROUPS_STRETCH), ms_Stretching ? 0 : 1);
00467                     if (m_IsEditing)
00468                     {
00469                         BYTE ExtendFlags = 0; // dont extend
00470 
00471                         if (ms_Stretching == 0)
00472                         {
00473                             ExtendFlags = X_EXTEND | Y_EXTEND;
00474                         }
00475                         else
00476                             if (ms_Stretching == 1)
00477                             {
00478                                 ExtendFlags = X_STRETCH | Y_STRETCH;
00479                             }
00480 
00481                         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_CHANGE_BAR_EXTENDS); 
00482                         if (pOpDesc != NULL)
00483                         {
00484                             OpParam BarStretchParam(SliceHelper::GetBarNumberFromBarName(m_BarName), ExtendFlags);
00485                             pOpDesc->Invoke(&BarStretchParam);
00486                         }
00487                         else
00488                         {
00489                             ERROR3("Couldn't find OPTOKEN_CHANGE_BAR_EXTENDS op descriptor");
00490                         }
00491 
00492                         WriteBarProperties();
00493                     }
00494                     //DialogManager::DefaultKeyboardFocus(); // throws focus
00495                     break;
00496 
00497                 }
00498                 break;
00499         }
00500     }
00501     else if (MESSAGE_IS_A(Message, OpMsg))
00502     {
00503         if (((OpMsg *)Message)->MsgType == OpMsg::AFTER_UNDO ||
00504             ((OpMsg *)Message)->MsgType == OpMsg::AFTER_REDO ||
00505             IS_A( ((OpMsg *)Message)->pOp, OpDelete) )
00506         {
00507             ReadBarProperties(); // set the controls from what the bar thinks it is
00508             SetUpControls(TRUE); // set all the controls
00509         }
00510     }
00511     // for whenever someone announces that they have changed the selection.
00512     else if (MESSAGE_IS_A(Message, SelChangingMsg))
00513     {
00514         SelChangingMsg* pSelChange = (SelChangingMsg*)Message;
00515 
00516         if (pSelChange->State == SelChangingMsg::SelectionState::SELECTIONCHANGED ||
00517             pSelChange->State == SelChangingMsg::SelectionState::NONCOLOURATTCHANGED)
00518         {
00519             SetUpDynamicControls();
00520         }
00521     }
00522     // If we've changed to a different document then get rid of the dlg.
00523     else if (MESSAGE_IS_A(Message, DocChangingMsg))
00524     {
00525         DocChangingMsg* TheMsg = (DocChangingMsg*) Message;
00526         if (TheMsg->State == DocChangingMsg::BORN || TheMsg->State == DocChangingMsg::SELCHANGED)
00527             Close();
00528     }
00529         
00530     if (fEndDialog) 
00531     {
00532         // read the number of buttons if the dlg is closed
00533         // so we don't have to re-type
00534         ms_NoOfButtons = GetLongGadgetValue(_R(IDC_BC_NO_OF_BUTTONS), 1, 20);
00535         if (ms_NoOfButtons > 20) ms_NoOfButtons = 20;
00536         if (ms_NoOfButtons < 1) ms_NoOfButtons = 1;
00537 
00538         // close the dlg
00539         Close();           
00540         End();
00541     }
00542 
00543 
00544     return DialogOp::Message(Message);
00545 } 

void BarCreationDlg::ReadBarProperties  )  [protected]
 

Definition at line 1048 of file barcreationdlg.cpp.

01049 {
01050     NodeBarProperty* pNodeBarProperty = (NodeBarProperty*) Document::GetCurrent()->GetSetSentinel()->FindBarProperty();
01051     INT32 BarNumber = SliceHelper::GetBarNumberFromBarName(m_BarName);
01052 
01053     if (pNodeBarProperty && BarNumber < pNodeBarProperty->HowMany())
01054     {
01055         BarDataType NewBarData = pNodeBarProperty->Bar(BarNumber);
01056         ms_IsVertical = NewBarData.IsHorizontal ? FALSE : TRUE;
01057         ms_Continuous = NewBarData.RequiresShuffle;
01058         ms_SizeJustification = NewBarData.SameSize;
01059         ms_Spacing = NewBarData.Spacing;
01060         ms_Stretching = 2; // static no stretching
01061         if (NewBarData.ButtonsExtend)
01062             ms_Stretching = 0;
01063         else if (NewBarData.ButtonsScale)
01064             ms_Stretching = 1;
01065         ms_GroupsStretch = NewBarData.GroupsStretch;
01066     }
01067 }

BOOL BarCreationDlg::SetUpControls BOOL  DoScan = TRUE  )  [protected]
 

Spookily enough it sets up all the controls in the dlg.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/8/99
Returns:
TRUE always at present!

Definition at line 765 of file barcreationdlg.cpp.

00766 {
00767     if (m_AlreadyInThisFunction)
00768         return TRUE;
00769 
00770     SetUpDynamicControls();
00771 
00772     m_AlreadyInThisFunction = TRUE;
00773     if (m_IsEditing)
00774     {
00775         if (DoScan)
00776         {
00777             // find out how many buttons there are
00778             INT32 NumberOfButtons = SliceHelper::CountButtonsInBar(m_BarName);
00779             if (NumberOfButtons > 0)
00780                 ms_NoOfButtons = NumberOfButtons;
00781 
00782             String_256 BackBarLayer(_R(IDS_BACK_BAR));
00783             m_HasBackBar = SliceHelper::BarExistsOnLayer(m_BarName, BackBarLayer);
00784         }
00785 
00786         if (m_HasBackBar)
00787         {
00788             SetStringGadgetValue(_R(IDC_BC_REDEF_BACKBAR), _R(IDS_REDEFINE_BACKBAR)); // Redefine
00789             SetStringGadgetValue(_R(IDC_BACKBAR_TEXT), _R(IDS_RECREATE_BACKBAR_TEXT));
00790         }
00791         else
00792         {
00793             SetStringGadgetValue(_R(IDC_BC_REDEF_BACKBAR), _R(IDS_CREATE_BACKBAR)); // Create
00794             SetStringGadgetValue(_R(IDC_BACKBAR_TEXT), _R(IDS_CREATE_BACKBAR_TEXT));
00795         }
00796     }
00797     else
00798     {
00799         // if we're creating a new bar, we must have the option for default to be ticked.
00800         ms_WantDefault = TRUE;
00801     }
00802 
00803     HideGadget(_R(IDC_BC_CREATE_BACKBAR), m_IsEditing);
00804     HideGadget(_R(IDC_BACKBAR_TEXT), !m_IsEditing);
00805     HideGadget(_R(IDC_BC_REDEF_BACKBAR), !m_IsEditing);
00806 
00807     SetSelectedValueIndex(_R(IDC_BC_BUTTONS_SAME), ms_SizeJustification);
00808     SetSelectedValueIndex(_R(IDC_BC_BUTTON_SIZE), ms_Stretching);
00809 
00810     SetStringGadgetValue(_R(IDC_BC_CREATE), m_IsEditing ? _R(IDS_CREATE_STATES) : _R(IDS_CREATE_STATE)); // States.. or Create
00811     HideGadget(_R(IDC_BC_CREATE), m_IsEditing); // actually hide the control if we are editing (remove states...)
00812     
00813     SetStringGadgetValue(IDCANCEL, m_IsEditing ? _R(IDS_DLG_DONE) : _R(IDS_CANCEL_DIALOG)); // Close or Cancel
00814 
00815     // grey the spacing if it is scattered
00816     EnableGadget(_R(IDC_BC_SPACING), ms_Continuous && m_ValidBar);
00817 
00818     if (!ms_Continuous)
00819         SetSelectedValueIndex(_R(IDC_BC_DIRECTION), 2);
00820     else
00821         SetSelectedValueIndex(_R(IDC_BC_DIRECTION), ms_IsVertical ? 1 : 0);
00822 
00823     SetLongGadgetValue(_R(IDC_BC_NO_OF_BUTTONS), ms_NoOfButtons);
00824     SetBoolGadgetSelected(_R(IDC_BC_GROUPS_STRETCH), !ms_GroupsStretch);
00825     EnableGadget(_R(IDC_BC_GROUPS_STRETCH), ms_Stretching ? 0 : 1);
00826 
00827     SetUnitGadgetValue(_R(IDC_BC_SPACING), PIXELS, ms_Spacing);
00828 
00829     String_256 Title;
00830     if (m_IsEditing)
00831         Title.Load(_R(IDS_BAR_EDIT_TITLE));
00832     else
00833         Title.Load(_R(IDS_BAR_CREATION_TITLE));
00834 
00835     if (m_ValidBar)
00836         Title += m_BarName;
00837     else
00838     {
00839         String_256 temp(_R(IDS_NO_VALID_BAR));
00840         Title += temp;
00841     }
00842 
00843     SetTitlebarName(&Title);
00844 
00845     m_AlreadyInThisFunction = FALSE;
00846 
00847     return TRUE;
00848 }

BOOL BarCreationDlg::SetUpDynamicControls  )  [protected]
 

Sets up all the controls in the dlg that are dynamic and reviewed upon a timer. So this function is called on a poll, to read the states and set the controls.

Author:
Simon_Knight (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/9/99
Returns:
TRUE always at present!

Definition at line 864 of file barcreationdlg.cpp.

00865 {
00866     // show the current layer in the dlg
00867     String_256 LayerName = "";
00868     Spread* pSpread = Document::GetSelectedSpread();
00869     if (pSpread == NULL)
00870         return FALSE;
00871 
00872     SelRange * pSelection = GetApplication()->FindSelection();
00873 
00874     // scan the selection has the bar name changed?
00875 
00876     String_256 TempBarName = "";
00877 
00878     Node * pCurrent = pSelection->FindFirst();
00879     TemplateAttribute * pTemplAttrib = NULL;
00880     Node * pTempNode = NULL;
00881 
00882     BOOL HasASelection = pCurrent != NULL;
00883 
00884     while (pCurrent && TempBarName.IsEmpty())
00885     {
00886         // look at the bar name on the attrib
00887         pTemplAttrib = (TemplateAttribute *) SliceHelper::FindNextOfClass(pCurrent, pCurrent, CC_RUNTIME_CLASS(TemplateAttribute));
00888         while (pTemplAttrib && TempBarName.IsEmpty())
00889         {
00890             TempBarName = SliceHelper::GetBarName(pTemplAttrib);
00891             pTemplAttrib = (TemplateAttribute *) SliceHelper::FindNextOfClass(pTemplAttrib, pCurrent, CC_RUNTIME_CLASS(TemplateAttribute));
00892         }
00893 
00894         pCurrent = pSelection->FindNext(pCurrent);
00895     }
00896 
00897     // something is selected but that doesn't have a bar name
00898     if (HasASelection && TempBarName.IsEmpty() && m_IsEditing)
00899     {
00900         // does the selection intersect with any known bars?
00901         SliceHelper::BarNameInRect(pSelection->GetBoundingRect(), &TempBarName);
00902     }
00903 
00904     if (m_IsEditing && HasASelection && TempBarName.IsEmpty() && m_ValidBar)
00905     {
00906         m_ValidBar = FALSE;
00907         EnableAllMyControls(FALSE);
00908         SetUpControls(FALSE);
00909     }
00910     else
00911         if (!m_ValidBar && !TempBarName.IsEmpty() )
00912         {
00913             m_ValidBar = TRUE;
00914             EnableAllMyControls(TRUE);
00915             m_BarName = "";
00916         }
00917 
00918     if (TempBarName.CompareTo(m_BarName) != 0 && !TempBarName.IsEmpty())
00919     {
00920         m_BarName = TempBarName;
00921         m_IsEditing = TRUE;
00922         ReadBarProperties();
00923         SetUpControls();
00924     }
00925 
00926     // enable disable the create button if there is no selection
00927     EnableGadget(_R(IDC_BC_CREATE), m_ValidBar && (HasASelection || m_IsEditing));
00928     // enable disable the create backbar button if there is no selection
00929     EnableGadget(_R(IDC_BC_REDEF_BACKBAR), m_ValidBar && HasASelection);
00930     
00931     return TRUE;
00932 }

void BarCreationDlg::WriteBarProperties  )  [protected]
 

Definition at line 1069 of file barcreationdlg.cpp.

01070 {
01071     NodeBarProperty* pNodeBarProperty = (NodeBarProperty*) Document::GetCurrent()->GetSetSentinel()->FindBarProperty();
01072     INT32 BarNumber = SliceHelper::GetBarNumberFromBarName(m_BarName);
01073 
01074     if (pNodeBarProperty )
01075     {
01076         BarDataType NewBarData;
01077 
01078         NewBarData.IsHorizontal = !ms_IsVertical;
01079         NewBarData.RequiresShuffle = ms_Continuous;
01080         NewBarData.SameSize = ms_SizeJustification;
01081         NewBarData.Spacing = ms_Spacing;
01082         NewBarData.ButtonsExtend = (ms_Stretching == 0 ? 1 : 0);
01083         NewBarData.ButtonsScale = (ms_Stretching == 1 ? 1 : 0);
01084         NewBarData.GroupsStretch = ms_GroupsStretch;
01085 
01086         pNodeBarProperty->MakeChange(BarNumber, NewBarData);
01087         // tell everyone that the selection may have changed
01088         // actually it wont have but the position of the blobs may well have
01089         // and sending this message means that everyone like the tool will
01090         // re-evaluate the postitions of the selection (sjk 11/7/00)
01091         BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
01092     }
01093 }


Member Data Documentation

const UINT32 BarCreationDlg::IDD = _R(IDD_BARCREATIONDLG) [static]
 

Definition at line 164 of file barcreationdlg.h.

BOOL BarCreationDlg::m_AlreadyInThisFunction [protected]
 

Definition at line 159 of file barcreationdlg.h.

String_256 BarCreationDlg::m_BarName [protected]
 

Definition at line 157 of file barcreationdlg.h.

String_256 BarCreationDlg::m_FirstBarName [protected]
 

Definition at line 158 of file barcreationdlg.h.

BOOL BarCreationDlg::m_FirstIsEditing [protected]
 

Definition at line 156 of file barcreationdlg.h.

BOOL BarCreationDlg::m_HasBackBar [protected]
 

Definition at line 160 of file barcreationdlg.h.

BOOL BarCreationDlg::m_IsEditing [protected]
 

Definition at line 155 of file barcreationdlg.h.

BOOL BarCreationDlg::m_ValidBar [protected]
 

Definition at line 161 of file barcreationdlg.h.

const CDlgMode BarCreationDlg::Mode = MODELESS [static]
 

Definition at line 165 of file barcreationdlg.h.

BOOL BarCreationDlg::ms_Continuous = TRUE [static]
 

Definition at line 178 of file barcreationdlg.h.

BOOL BarCreationDlg::ms_FromSelection = TRUE [static]
 

Definition at line 181 of file barcreationdlg.h.

BOOL BarCreationDlg::ms_GroupsStretch = TRUE [static]
 

Definition at line 183 of file barcreationdlg.h.

BOOL BarCreationDlg::ms_IsVertical = TRUE [static]
 

Definition at line 172 of file barcreationdlg.h.

INT32 BarCreationDlg::ms_Mode = 0 [static]
 

Definition at line 175 of file barcreationdlg.h.

INT32 BarCreationDlg::ms_NoOfButtons = 4 [static]
 

Definition at line 174 of file barcreationdlg.h.

INT32 BarCreationDlg::ms_SizeJustification = 0 [static]
 

Definition at line 177 of file barcreationdlg.h.

INT32 BarCreationDlg::ms_Spacing = 0 [static]
 

Definition at line 179 of file barcreationdlg.h.

INT32 BarCreationDlg::ms_StateToCreate = 0 [static]
 

Definition at line 182 of file barcreationdlg.h.

INT32 BarCreationDlg::ms_Stretching = 0 [static]
 

Definition at line 180 of file barcreationdlg.h.

BOOL BarCreationDlg::ms_SuggestDesign = TRUE [static]
 

Definition at line 173 of file barcreationdlg.h.

BOOL BarCreationDlg::ms_WantClicked = FALSE [static]
 

Definition at line 169 of file barcreationdlg.h.

BOOL BarCreationDlg::ms_WantDefault = TRUE [static]
 

Definition at line 171 of file barcreationdlg.h.

BOOL BarCreationDlg::ms_WantMouse = FALSE [static]
 

Definition at line 168 of file barcreationdlg.h.

BOOL BarCreationDlg::ms_WantSelected = FALSE [static]
 

Definition at line 170 of file barcreationdlg.h.

BarCreationDlg * BarCreationDlg::TheDialog = NULL [static, protected]
 

Definition at line 153 of file barcreationdlg.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:50:47 2007 for Camelot by  doxygen 1.4.4