BarRedefineStateDlg Class Reference

#include <barcreationdlg.h>

Inheritance diagram for BarRedefineStateDlg:

DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 BarRedefineStateDlg ()
 Constructor.
 ~BarRedefineStateDlg ()
 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.
BOOL IsAttribInSelected (Node *pNode)
virtual MsgResult Message (Msg *Message)
 This is the message handler for the BarStatesDlg. 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
static const CDlgMode Mode

Protected Member Functions

BOOL Create ()
 Creates a dlg.
BOOL SetUpControls ()
BOOL RedefineState ()

Protected Attributes

String_256 m_BarName
INT32 m_State

Static Protected Attributes

static BarRedefineStateDlgTheDialog

Private Member Functions

 CC_DECLARE_DYNCREATE (BarRedefineStateDlg)

Detailed Description

Definition at line 289 of file barcreationdlg.h.


Constructor & Destructor Documentation

BarRedefineStateDlg::BarRedefineStateDlg  ) 
 

Constructor.

/

Set up our static variables const CDlgMode BarRedefineStateDlg::Mode = MODELESS; const UINT32 BarRedefineStateDlg::IDD = _R(IDD_REDEFINE_STATE);

BarRedefineStateDlg *BarRedefineStateDlgTheDialog = NULL;

/*!

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

Definition at line 1786 of file barcreationdlg.cpp.

01786                                          : DialogOp(BarRedefineStateDlg::IDD, BarRedefineStateDlg::Mode) 
01787 {
01788     //Set our member variable pointer so it points at ourself
01789     if (TheDialog == NULL)
01790         TheDialog = this;
01791 
01792 }       

BarRedefineStateDlg::~BarRedefineStateDlg  ) 
 

Destructor.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/5/00

Definition at line 1806 of file barcreationdlg.cpp.

01807 {
01808     //Set our member variable pointer to NULL
01809     if (TheDialog == this)
01810         TheDialog = NULL;
01811 } 


Member Function Documentation

BarRedefineStateDlg::CC_DECLARE_DYNCREATE BarRedefineStateDlg   )  [private]
 

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

Creates a dlg.

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

Errors: -

See also:
-

Reimplemented from DialogOp.

Definition at line 1997 of file barcreationdlg.cpp.

01998 {
01999     if (TheDialog != this)      // Allow only one instance of this dialogue open at once
02000         return(FALSE);
02001 
02002     if (DialogOp::Create())
02003     { 
02004         return(TRUE);
02005     }
02006 
02007     return(FALSE);
02008 }

void BarRedefineStateDlg::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>
Date:
8/5/00

Reimplemented from Operation.

Definition at line 1961 of file barcreationdlg.cpp.

01962 {
01963     m_BarName = "Bar1";
01964     m_State = 0;
01965 
01966     if (TheDialog==NULL || TheDialog==this)
01967     {
01968         if (Create())
01969             Open();
01970         else
01971             End();
01972     }
01973     else
01974     {
01975         TheDialog->Open();
01976         TheDialog->BringToTop();
01977 
01978         End();              // Kill ourself
01979     }
01980 }

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

Performs the BarCreationDlg operation.

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

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 2025 of file barcreationdlg.cpp.

02026 {
02027     m_BarName = ((OpParamBarRedefineStateDlg *)pParam)->m_BarName;
02028     m_State = ((OpParamBarRedefineStateDlg *)pParam)->m_State;
02029 
02030     if (TheDialog==NULL || TheDialog==this)
02031     {
02032         if (Create())
02033             Open();
02034         else
02035             End();
02036     }
02037     else
02038     {
02039         TheDialog->Open();
02040         TheDialog->BringToTop();
02041 
02042         End();              // Kill ourself
02043     }
02044 }

OpState BarRedefineStateDlg::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 1893 of file barcreationdlg.cpp.

01894 {
01895     OpState OpSt;
01896 
01897     // if we don't allow it
01898     OpSt.Greyed = TRUE;
01899     Spread* pSpread = Document::GetSelectedSpread();
01900     if (pSpread && !pSpread->FindActiveLayer()->IsFrame())
01901         OpSt.Greyed = FALSE;
01902 
01903     // Tick the menu while the editor is open
01904     if (TheDialog != NULL)
01905         OpSt.Ticked = TRUE;
01906 
01907     return(OpSt);
01908 }

BOOL BarRedefineStateDlg::Init void   )  [static]
 

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

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/5/00
Returns:
FALSE if it fails (due to lack of memory)

Reimplemented from SimpleCCObject.

Definition at line 1923 of file barcreationdlg.cpp.

01924 {
01925     return (RegisterOpDescriptor(0,                             // Tool ID
01926                                 _R(IDS_RECREATE_STATES),                    // String resource ID
01927                                 CC_RUNTIME_CLASS(BarRedefineStateDlg),      // Runtime class
01928                                 OPTOKEN_BARREDEFINESTATEDLG,                // Token string
01929                                 BarRedefineStateDlg::GetState,              // GetState function
01930                                 _R(IDH_NavBar_Edit_Design_Dialog_Box),          // Help ID
01931                                 _R(IDBBL_REDEFINE_STATE),               // Bubble ID
01932                                 _R(IDD_BARCONTROLSTORE),            // Resource ID
01933                                 _R(IDC_REDEFINE_STATE),             // Control ID
01934                                 SYSTEMBAR_UTILITIES,            // Bar ID
01935                                 TRUE,                           // Recieve system messages
01936                                 FALSE,                          // Smart duplicate operation
01937                                 TRUE,                           // Clean operation
01938                                 0,                              // No vertical counterpart
01939                                 NULL,
01940                                 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC),
01941                                 TRUE
01942                                 )); 
01943                         
01944 }   

BOOL BarRedefineStateDlg::IsAttribInSelected Node pNode  ) 
 

Definition at line 2109 of file barcreationdlg.cpp.

02110 {
02111     Node *pParent = pNode->FindParent();
02112 
02113     // if it is a bevel controller check the bev components for selection
02114     if (pParent->IsCompound())
02115     {
02116         pNode = pParent->FindFirstChild();
02117         while (pNode)
02118         {
02119             if (pNode->IsSelected())
02120                 return TRUE;
02121 
02122             pNode = pNode->FindNext();
02123         }
02124     }
02125 
02126     // look for selected parents
02127     while (pParent && !pParent->IsLayer())
02128     {
02129         if (pParent->IsSelected())
02130             return TRUE;
02131 
02132         pParent = pParent->FindParent();
02133     }
02134 
02135     return FALSE;
02136 }

MsgResult BarRedefineStateDlg::Message Msg Message  )  [virtual]
 

This is the message handler for the BarStatesDlg. 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:
9/5/00
Parameters:
Message,: The incoming message [INPUTS]
Returns:
DialogOp::Message (Message)

Reimplemented from DialogOp.

Definition at line 1827 of file barcreationdlg.cpp.

01828 {
01829     BOOL fEndDialog=FALSE;
01830 
01831     //If the message is a dialog message
01832     if (IS_OUR_DIALOG_MSG(Message))
01833     {
01834         //Then work out what it says
01835         DialogMsg* pDialogMsg = ((DialogMsg*) Message); 
01836     
01837         switch (pDialogMsg->DlgMsg)
01838         {
01839             case DIM_CREATE:
01840                 SetUpControls();
01841                 //DialogManager::DefaultKeyboardFocus(); // throws focus
01842                 break;
01843     
01844             // these two messages are used to throw the focus back to the main window
01845             case DIM_TITLEFOCUSWARN:
01846                 //DialogManager::DefaultKeyboardFocus();
01847                 break;
01848 
01849             // focus throw
01850             case DIM_LFT_BN_UP:
01851                 //DialogManager::DefaultKeyboardFocus();
01852                 break;
01853     
01854             case DIM_CANCEL:    
01855                 fEndDialog = TRUE;
01856                 break;
01857 
01858             case DIM_COMMIT:
01859                 RedefineState();
01860                 fEndDialog = TRUE;
01861                 break;
01862         }
01863     }
01864     // If we've changed to a different document then get rid of the dlg.
01865     else if (MESSAGE_IS_A(Message, DocChangingMsg))
01866     {
01867         DocChangingMsg* TheMsg = (DocChangingMsg*) Message;
01868         if (TheMsg->State == DocChangingMsg::BORN || TheMsg->State == DocChangingMsg::SELCHANGED)
01869             Close();
01870     }
01871         
01872     if (fEndDialog) 
01873     {
01874         // close the dlg
01875         Close();           
01876         End();
01877     }
01878 
01879 
01880     return DialogOp::Message(Message);
01881 } 

BOOL BarRedefineStateDlg::RedefineState  )  [protected]
 

Definition at line 2139 of file barcreationdlg.cpp.

02140 {
02141     // get the barname from the drop down
02142     m_BarName = GetStringGadgetValue(_R(IDC_BAR_NO_COMBO));
02143 
02144     // get the no of buttons in the bar
02145     INT32 NoOfButtons = SliceHelper::CountButtonsInBar(m_BarName);
02146 
02147     NodeBarProperty* pNodeBarProperty = (NodeBarProperty*) Document::GetCurrent()->GetSetSentinel()->FindBarProperty();
02148     INT32 BarNumber = SliceHelper::GetBarNumberFromBarName(m_BarName);
02149 
02150     if (!pNodeBarProperty || BarNumber >= pNodeBarProperty->HowMany())
02151         return FALSE;
02152 
02153     BarDataType NewBarData = pNodeBarProperty->Bar(BarNumber);
02154 
02155     // we need to check if the user doesn't have selected all the elements of a button from this bar
02156     // if not warn the user that elements not selected will be deleted
02157     // first which button is it that we think we have selected - if none then use a different warning
02158     String_256 ButtonName = "";
02159 
02160     Node * pNode = NULL;
02161     Layer * pLayer = NULL;
02162     String_256 templayer = "";
02163 
02164     switch (m_State)
02165     {
02166     case 0:
02167         templayer.Load(_R(IDS_ROLLOVER_DEFAULT));
02168         break;
02169 
02170     case 1:
02171         templayer.Load(_R(IDS_ROLLOVER_MOUSE));
02172         break;
02173 
02174     case 2:
02175         templayer.Load(_R(IDS_ROLLOVER_CLICKED));
02176         break;
02177 
02178     case 3:
02179         templayer.Load(_R(IDS_ROLLOVER_SELECTED));
02180         break;
02181 
02182     case 4:
02183         templayer.Load(_R(IDS_BACK_BAR));
02184         break;
02185     }
02186 
02187     if (!templayer.IsEmpty())
02188         pLayer = SliceHelper::FindLayerCalled(templayer);
02189 
02190     if (!pLayer)
02191         return FALSE;
02192 
02193     BOOL FoundSelected = FALSE;
02194 
02195     // scan this layer for which button is selected
02196     pNode = SliceHelper::FindNextOfClass(pLayer, pLayer, CC_RUNTIME_CLASS(TemplateAttribute));
02197     while (pNode && !FoundSelected)
02198     {
02199         if (m_BarName.CompareTo(SliceHelper::GetBarName((TemplateAttribute *)pNode)) == 0)
02200         {
02201             // set the button name we are looking for
02202             if (IsAttribInSelected(pNode)) 
02203             {
02204                 ButtonName = ((TemplateAttribute *)pNode)->GetParam();
02205                 FoundSelected = TRUE;
02206             }
02207         }
02208 
02209         pNode = SliceHelper::FindNextOfClass(pNode, pLayer, CC_RUNTIME_CLASS(TemplateAttribute));
02210     }
02211 
02212     // scan this layer for none selected elements of the button
02213     pNode = SliceHelper::FindNextOfClass(pLayer, pLayer, CC_RUNTIME_CLASS(TemplateAttribute));
02214     while (FoundSelected && pNode)
02215     {
02216         if (m_BarName.CompareTo(SliceHelper::GetBarName((TemplateAttribute *)pNode)) == 0)
02217         {
02218             // if we have found a selected button name are other
02219             if (ButtonName.CompareTo(((TemplateAttribute *)pNode)->GetParam()) == 0)
02220             {
02221                 if (!IsAttribInSelected(pNode))
02222                 {
02223                     INT32 msg = InformWarning(_R(IDS_BUTTON_NOT_ALL_SELECTED), _R(IDS_CANCEL), _R(IDS_CARRY_ON));
02224                     if (msg == 1)
02225                         return FALSE; // give up & go back
02226                     else
02227                         break; // stop the test and go ahead
02228                 }
02229             }
02230         }
02231 
02232         pNode = SliceHelper::FindNextOfClass(pNode, pLayer, CC_RUNTIME_CLASS(TemplateAttribute));
02233     }
02234 
02235     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BARCREATIONOP); 
02236 
02237     if (!pOpDesc)
02238         return FALSE;
02239 
02240     BYTE ExtendFlags = 0; // dont extend
02241 
02242     if (NewBarData.ButtonsExtend)
02243         ExtendFlags = X_EXTEND | Y_EXTEND;
02244     else
02245         if (NewBarData.ButtonsScale)
02246             ExtendFlags = X_STRETCH | Y_STRETCH;
02247 
02248     OpParamBarCreation BarParam(m_State == 1,   //ms_WantMouse,
02249                                 m_State == 2,   //ms_WantClicked,
02250                                 m_State == 3,   //ms_WantSelected,
02251                                 m_State == 4,   //(ms_StateToCreate == BACKBAR),
02252                                 NewBarData.IsHorizontal ? FALSE : TRUE,
02253                                 FALSE,
02254                                 NoOfButtons,
02255                                 m_State == 0, // ms_WantDefault - dont use this to make the default from this dlg
02256                                 REPLACE_SOME_STATES,
02257                                 NewBarData.Spacing,
02258                                 NewBarData.RequiresShuffle,
02259                                 NewBarData.SameSize,
02260                                 m_BarName,
02261                                 TRUE, // alsways from selection
02262                                 ExtendFlags);
02263     pOpDesc->Invoke(&BarParam);
02264 
02265     return TRUE;
02266 }

BOOL BarRedefineStateDlg::SetUpControls  )  [protected]
 

Definition at line 2046 of file barcreationdlg.cpp.

02047 {
02048     // fill in the bar state we are creating
02049 
02050     // set the text in the redefine state button
02051     String_256 Temp(_R(IDS_ROLLOVER_DEFAULT));
02052     if (m_State == 1)
02053         Temp.Load(_R(IDS_ROLLOVER_MOUSE));
02054     else if (m_State == 2)
02055         Temp.Load(_R(IDS_ROLLOVER_CLICKED));
02056     else if (m_State == 3)
02057         Temp.Load(_R(IDS_ROLLOVER_SELECTED));
02058     else if (m_State == 4)
02059         Temp.Load(_R(IDS_BACK_BAR));
02060     String_256 StateText = Temp;
02061     Temp.Load(_R(IDS_STATE_TEXT));
02062     StateText += Temp;
02063     SetStringGadgetValue(_R(IDC_STATE_TEXT), &StateText);
02064 
02065 
02066     // first find all the bar names available
02067     String_256 DefLayerName;
02068     DefLayerName.Load(_R(IDS_ROLLOVER_DEFAULT));
02069     Layer * pDef = SliceHelper::FindLayerCalled(DefLayerName);
02070 
02071     if (!pDef) return FALSE;
02072 
02073     NameGallery* pNameGallery = NameGallery::Instance();
02074         // make sure we are dealing with the most uptodate information
02075     if (pNameGallery)
02076         pNameGallery->FastUpdateNamedSetSizes();
02077 
02078     String_256 BarName = "";
02079 
02080     // find a new bar name
02081     INT32 BarNo = 0;
02082     INT32 misses = 0;
02083     INT32 selthis = 0;
02084     do
02085     {
02086         BarNo++;
02087         BarName.MakeMsg(_R(IDS_BARNAME), BarNo);
02088         BOOL BarExists = SliceHelper::BarNameExists(pDef, BarName);
02089         if (BarExists)
02090         {
02091             SetStringGadgetValue(_R(IDC_BAR_NO_COMBO), &BarName, FALSE, BarNo-1-misses);
02092             if (BarName == m_BarName)
02093                 selthis = BarNo-1-misses;
02094         }
02095         else
02096             misses++;
02097     }
02098     while (misses < 3);
02099 
02100     // then select the bar name we have been passed
02101     SetSelectedValueIndex(_R(IDC_BAR_NO_COMBO), selthis);
02102 
02103 
02104     return TRUE;
02105 }


Member Data Documentation

const UINT32 BarRedefineStateDlg::IDD [static]
 

Definition at line 323 of file barcreationdlg.h.

String_256 BarRedefineStateDlg::m_BarName [protected]
 

Definition at line 319 of file barcreationdlg.h.

INT32 BarRedefineStateDlg::m_State [protected]
 

Definition at line 320 of file barcreationdlg.h.

const CDlgMode BarRedefineStateDlg::Mode [static]
 

Definition at line 324 of file barcreationdlg.h.

BarRedefineStateDlg* BarRedefineStateDlg::TheDialog [static, protected]
 

Definition at line 318 of file barcreationdlg.h.


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