00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 #include "camtypes.h"
00099
00100 #include "barcreationdlg.h"
00101 #include "menuops.h"
00102 #include "ccdc.h"
00103
00104
00105
00106
00107 #include "nodetxts.h"
00108 #include "sprdmsg.h"
00109 #include "slice.h"
00110 #include "opbarcreation.h"
00111 #include "slicetool.h"
00112
00113
00114
00115
00116 #include "userattr.h"
00117 #include "tmpltatr.h"
00118
00119 #include "layermsg.h"
00120
00121
00122 #include "ngcore.h"
00123 #include "ngitem.h"
00124 #include "ngsentry.h"
00125 #include "ngsetop.h"
00126
00127
00128
00129 #include "xshelpid.h"
00130
00131
00132 CC_IMPLEMENT_DYNCREATE(BarCreationDlg, DialogOp);
00133 CC_IMPLEMENT_DYNCREATE(BarStatesDlg, DialogOp);
00134 CC_IMPLEMENT_DYNCREATE(BarRedefineStateDlg, DialogOp);
00135
00136 #define new CAM_DEBUG_NEW
00137
00138 #define DLG_TIMER 2020
00139
00140
00141 const CDlgMode BarCreationDlg::Mode = MODELESS;
00142 const UINT32 BarCreationDlg::IDD = _R(IDD_BARCREATIONDLG);
00143
00144 BarCreationDlg *BarCreationDlg::TheDialog = NULL;
00145
00146
00147
00148
00149
00150 BOOL BarCreationDlg::ms_WantDefault = TRUE;
00151 BOOL BarCreationDlg::ms_WantMouse = FALSE;
00152 BOOL BarCreationDlg::ms_WantClicked = FALSE;
00153 BOOL BarCreationDlg::ms_WantSelected = FALSE;
00154 BOOL BarCreationDlg::ms_IsVertical = TRUE;
00155 BOOL BarCreationDlg::ms_SuggestDesign = TRUE;
00156 BOOL BarCreationDlg::ms_Continuous = TRUE;
00157 BOOL BarCreationDlg::ms_FromSelection = TRUE;
00158 INT32 BarCreationDlg::ms_StateToCreate = 0;
00159 INT32 BarCreationDlg::ms_SizeJustification = 0;
00160
00161 INT32 BarCreationDlg::ms_NoOfButtons = 4;
00162 INT32 BarCreationDlg::ms_Spacing = 0;
00163 INT32 BarCreationDlg::ms_Mode = NEW_BAR;
00164 INT32 BarCreationDlg::ms_Stretching = 0;
00165 BOOL BarCreationDlg::ms_GroupsStretch = TRUE;
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 BarCreationDlg::BarCreationDlg() : DialogOp(BarCreationDlg::IDD, BarCreationDlg::Mode)
00178 {
00179
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 }
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 BarCreationDlg::~BarCreationDlg()
00203 {
00204
00205 if (TheDialog == this)
00206 TheDialog = NULL;
00207 }
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223 MsgResult BarCreationDlg::Message( Msg* Message)
00224 {
00225 BOOL fEndDialog=FALSE;
00226
00227
00228 if (IS_OUR_DIALOG_MSG(Message))
00229 {
00230
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
00252
00253 break;
00254
00255
00256 case DIM_TITLEFOCUSWARN:
00257
00258 break;
00259
00260
00261 case DIM_LFT_BN_UP:
00262
00263 break;
00264
00265 case DIM_CANCEL:
00266 fEndDialog = TRUE;
00267 break;
00268
00269
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
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
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
00317 break;
00318
00319 case _R(IDC_BC_NO_OF_BUTTONS):
00320 {
00321
00322 INT32 NewNoOfButtons = GetLongGadgetValue(_R(IDC_BC_NO_OF_BUTTONS), 1, MAX_BUTTONS_IN_A_BAR);
00323
00324
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
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
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
00369 break;
00370
00371 }
00372
00373 break;
00374
00375
00376 case DIM_LFT_BN_CLICKED:
00377 switch(pDialogMsg->GadgetID)
00378 {
00379 case _R(IDC_BC_CREATE):
00380 if (m_IsEditing)
00381 {
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())
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
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
00420 break;
00421
00422
00423
00424
00425 case DIM_SELECTION_CHANGED:
00426 switch(pDialogMsg->GadgetID)
00427 {
00428
00429 case _R(IDC_BC_DIRECTION):
00430 switch (GetSelectedValueIndex(_R(IDC_BC_DIRECTION)))
00431 {
00432 case 0:
00433 ms_IsVertical = FALSE;
00434 ms_Continuous = TRUE;
00435 break;
00436
00437 case 1:
00438 ms_IsVertical = TRUE;
00439 ms_Continuous = TRUE;
00440 break;
00441
00442 case 2:
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)
00451 WriteBarProperties();
00452
00453
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
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;
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
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();
00508 SetUpControls(TRUE);
00509 }
00510 }
00511
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
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
00533
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
00539 Close();
00540 End();
00541 }
00542
00543
00544 return DialogOp::Message(Message);
00545 }
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557 OpState BarCreationDlg::GetState(String_256*, OpDescriptor*)
00558 {
00559 OpState OpSt;
00560
00561
00562 OpSt.Greyed = TRUE;
00563 Spread* pSpread = Document::GetSelectedSpread();
00564 if (pSpread && !pSpread->FindActiveLayer()->IsFrame())
00565 OpSt.Greyed = FALSE;
00566
00567
00568 if (TheDialog != NULL)
00569 OpSt.Ticked = TRUE;
00570
00571 return(OpSt);
00572 }
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587 BOOL BarCreationDlg::Init()
00588 {
00589 return (RegisterOpDescriptor(0,
00590 _R(IDS_BARCREATION),
00591 CC_RUNTIME_CLASS(BarCreationDlg),
00592 OPTOKEN_BARCREATIONDLG,
00593 BarCreationDlg::GetState,
00594 _R(IDH_NavBar_Create_Dialog_Box),
00595 _R(IDBBL_BARCREATION),
00596 _R(IDD_BARCONTROLSTORE),
00597 _R(IDC_BARCREATION),
00598 SYSTEMBAR_UTILITIES,
00599 TRUE,
00600 FALSE,
00601 TRUE,
00602 0,
00603 NULL,
00604 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC),
00605 TRUE
00606 ));
00607
00608 }
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625 void BarCreationDlg::Do(OpDescriptor*)
00626 {
00627 m_IsEditing = FALSE;
00628 m_BarName = "Bar1";
00629 m_FirstBarName = m_BarName;
00630 ms_Spacing = 0;
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();
00645 }
00646 }
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664 BOOL BarCreationDlg::Create()
00665 {
00666
00667 ReadBarProperties();
00668
00669
00670 if (!m_IsEditing)
00671
00672 {
00673 ms_StateToCreate = 0;
00674 ms_FromSelection = TRUE;
00675
00676 ms_WantDefault = TRUE;
00677 ms_WantMouse = FALSE;
00678 ms_WantClicked = FALSE;
00679 ms_WantSelected = FALSE;
00680
00681 ms_Spacing = 0;
00682 ms_GroupsStretch = TRUE;
00683 }
00684
00685
00686 if (TheDialog != this)
00687 return(FALSE);
00688
00689 if (DialogOp::Create())
00690 {
00691 return(TRUE);
00692 }
00693
00694 return(FALSE);
00695 }
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712 void BarCreationDlg::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
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;
00743 TheDialog->ms_GroupsStretch = TRUE;
00744
00745 TheDialog->EnableAllMyControls(TRUE);
00746
00747 TheDialog->SetUpControls(TRUE);
00748
00749 End();
00750 }
00751 }
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765 BOOL BarCreationDlg::SetUpControls( BOOL DoScan )
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
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));
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));
00794 SetStringGadgetValue(_R(IDC_BACKBAR_TEXT), _R(IDS_CREATE_BACKBAR_TEXT));
00795 }
00796 }
00797 else
00798 {
00799
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));
00811 HideGadget(_R(IDC_BC_CREATE), m_IsEditing);
00812
00813 SetStringGadgetValue(IDCANCEL, m_IsEditing ? _R(IDS_DLG_DONE) : _R(IDS_CANCEL_DIALOG));
00814
00815
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 }
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864 BOOL BarCreationDlg::SetUpDynamicControls()
00865 {
00866
00867 String_256 LayerName = "";
00868 Spread* pSpread = Document::GetSelectedSpread();
00869 if (pSpread == NULL)
00870 return FALSE;
00871
00872 SelRange * pSelection = GetApplication()->FindSelection();
00873
00874
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
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
00898 if (HasASelection && TempBarName.IsEmpty() && m_IsEditing)
00899 {
00900
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
00927 EnableGadget(_R(IDC_BC_CREATE), m_ValidBar && (HasASelection || m_IsEditing));
00928
00929 EnableGadget(_R(IDC_BC_REDEF_BACKBAR), m_ValidBar && HasASelection);
00930
00931 return TRUE;
00932 }
00933
00934 void BarCreationDlg::EnableAllMyControls(BOOL enable)
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 }
00944
00945
00946 BOOL BarCreationDlg::CreateBar()
00947 {
00948 BOOL Valid = TRUE;
00949 ms_NoOfButtons = GetLongGadgetValue(_R(IDC_BC_NO_OF_BUTTONS), 1, 20, 0 , &Valid);
00950 if (!Valid)
00951 {
00952 InformWarning(_R(IDS_TOO_MANY_BUTTONS));
00953 return FALSE;
00954 }
00955
00956
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
00988
00989 if (m_IsEditing)
00990 ms_Mode = REPLACE_SOME_STATES;
00991 else
00992 {
00993 ms_Mode = NEW_BAR;
00994
00995
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
01009 WriteBarProperties();
01010
01011 BYTE ExtendFlags = 0;
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,
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 }
01043
01044
01045
01046
01047
01048 void BarCreationDlg::ReadBarProperties()
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;
01061 if (NewBarData.ButtonsExtend)
01062 ms_Stretching = 0;
01063 else if (NewBarData.ButtonsScale)
01064 ms_Stretching = 1;
01065 ms_GroupsStretch = NewBarData.GroupsStretch;
01066 }
01067 }
01068
01069 void BarCreationDlg::WriteBarProperties()
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
01088
01089
01090
01091 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
01092 }
01093 }
01094
01095
01096
01097
01098
01099 const CDlgMode BarStatesDlg::Mode = MODELESS;
01100 const UINT32 BarStatesDlg::IDD = _R(IDD_BARSTATESDLG);
01101
01102 BarStatesDlg *BarStatesDlg::TheDialog = NULL;
01103 INT32 BarStatesDlg::m_State = 1;
01104 BOOL BarStatesDlg::ms_SuggestDesign = TRUE;
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117 BarStatesDlg::BarStatesDlg() : DialogOp(BarStatesDlg::IDD, BarStatesDlg::Mode)
01118 {
01119
01120 if (TheDialog == NULL)
01121 TheDialog = this;
01122
01123 m_ValidBar = TRUE;
01124 }
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138 BarStatesDlg::~BarStatesDlg()
01139 {
01140
01141 if (TheDialog == this)
01142 TheDialog = NULL;
01143 }
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159 MsgResult BarStatesDlg::Message( Msg* Message)
01160 {
01161 BOOL fEndDialog=FALSE;
01162
01163
01164 if (IS_OUR_DIALOG_MSG(Message))
01165 {
01166
01167 DialogMsg* pDialogMsg = ((DialogMsg*) Message);
01168
01169 switch (pDialogMsg->DlgMsg)
01170 {
01171 case DIM_CREATE:
01172 SetStringGadgetValue(_R(IDC_MUTATE_COLOURS), _R(IDS_STATE_COPY), FALSE, 0);
01173 SetStringGadgetValue(_R(IDC_MUTATE_COLOURS), _R(IDS_STATE_DISTINCT), TRUE, 1);
01174 ScanForBarDetails();
01175 SetUpControls();
01176
01177
01178 break;
01179
01180
01181 case DIM_TITLEFOCUSWARN:
01182
01183 break;
01184
01185
01186 case DIM_LFT_BN_UP:
01187
01188 break;
01189
01190 case DIM_CANCEL:
01191 fEndDialog = TRUE;
01192 break;
01193
01194
01195 case DIM_LFT_BN_CLICKED:
01196 switch(pDialogMsg->GadgetID)
01197 {
01198 case _R(IDC_MOUSE_OFF):
01199 m_State = 0;
01200 SetUpControls();
01201
01202 break;
01203 case _R(IDC_MOUSE_OVER):
01204 m_State = 1;
01205 SetUpControls();
01206
01207 break;
01208 case _R(IDC_CLICKED):
01209 m_State = 2;
01210 SetUpControls();
01211
01212 break;
01213 case _R(IDC_SELECTED):
01214 m_State = 3;
01215 SetUpControls();
01216
01217 break;
01218
01219
01220
01221
01222
01223 case _R(IDC_CREATE_STATE):
01224
01225 CreateBarStates(m_StateExists[m_State]);
01226 ScanForBarDetails();
01227 SetUpControls();
01228
01229 break;
01230
01231 case _R(IDC_DELETE_STATE):
01232 {
01233 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_DELBAROP);
01234
01235 if (pOpDesc && m_State > 0)
01236 {
01237 OpParamDelBar ParamDelBar(m_BarName, m_State);
01238 pOpDesc->Invoke(&ParamDelBar);
01239
01240 ScanForBarDetails();
01241 SetUpControls();
01242 }
01243 else if (pOpDesc)
01244 {
01245 if (AskQuestion(_R(IDS_DEL_WHOLE_BAR), _R(IDS_YES), _R(IDS_NO)) == 1)
01246 {
01247 OpParamDelBar ParamDelBar(m_BarName, 5 );
01248 pOpDesc->Invoke(&ParamDelBar);
01249
01250
01251 fEndDialog = TRUE;
01252 }
01253 }
01254 }
01255
01256 break;
01257 }
01258 break;
01259
01260
01261
01262 case DIM_SELECTION_CHANGED:
01263 switch(pDialogMsg->GadgetID)
01264 {
01265
01266 case _R(IDC_MUTATE_COLOURS):
01267 ms_SuggestDesign = GetSelectedValueIndex(_R(IDC_MUTATE_COLOURS));;
01268 break;
01269 }
01270 break;
01271
01272 }
01273 }
01274
01275 else if (MESSAGE_IS_A(Message, SelChangingMsg))
01276 {
01277 SelChangingMsg* pSelChange = (SelChangingMsg*)Message;
01278
01279 if (pSelChange->State == SelChangingMsg::SelectionState::SELECTIONCHANGED ||
01280 pSelChange->State == SelChangingMsg::SelectionState::NONCOLOURATTCHANGED)
01281 OnSelectionChanged();
01282 }
01283
01284 else if (MESSAGE_IS_A(Message, DocChangingMsg))
01285 {
01286 DocChangingMsg* TheMsg = (DocChangingMsg*) Message;
01287 if (TheMsg->State == DocChangingMsg::BORN || TheMsg->State == DocChangingMsg::SELCHANGED)
01288 Close();
01289 }
01290 else if (MESSAGE_IS_A(Message, OpMsg))
01291 {
01292 if (((OpMsg *)Message)->MsgType == OpMsg::AFTER_UNDO ||
01293 ((OpMsg *)Message)->MsgType == OpMsg::AFTER_REDO ||
01294 IS_A( ((OpMsg *)Message)->pOp, OpDelete) )
01295 {
01296 ScanForBarDetails();
01297 SetUpControls();
01298 OnSelectionChanged();
01299 }
01300 }
01301
01302 if (fEndDialog)
01303 {
01304
01305 Close();
01306 End();
01307 }
01308
01309
01310 return DialogOp::Message(Message);
01311 }
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323 OpState BarStatesDlg::GetState(String_256*, OpDescriptor*)
01324 {
01325 OpState OpSt;
01326
01327
01328 OpSt.Greyed = TRUE;
01329 Spread* pSpread = Document::GetSelectedSpread();
01330 if (pSpread && !pSpread->FindActiveLayer()->IsFrame())
01331 OpSt.Greyed = FALSE;
01332
01333
01334 if (TheDialog != NULL)
01335 OpSt.Ticked = TRUE;
01336
01337 return(OpSt);
01338 }
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353 BOOL BarStatesDlg::Init()
01354 {
01355 return (RegisterOpDescriptor(0,
01356 _R(IDS_CREATE_STATES),
01357 CC_RUNTIME_CLASS(BarStatesDlg),
01358 OPTOKEN_BARSTATESDLG,
01359 BarStatesDlg::GetState,
01360 _R(IDH_NavBar_Edit_States_Dialog_Box),
01361 _R(IDBBL_STATES),
01362 _R(IDD_BARCONTROLSTORE),
01363 _R(IDC_STATES),
01364 SYSTEMBAR_UTILITIES,
01365 TRUE,
01366 FALSE,
01367 TRUE,
01368 0,
01369 NULL,
01370 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC),
01371 TRUE
01372 ));
01373
01374 }
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391 void BarStatesDlg::Do(OpDescriptor*)
01392 {
01393 m_BarName = "Bar1";
01394
01395 if (TheDialog==NULL || TheDialog==this)
01396 {
01397 if (Create())
01398 Open();
01399 else
01400 End();
01401 }
01402 else
01403 {
01404 TheDialog->Open();
01405 TheDialog->BringToTop();
01406
01407 End();
01408 }
01409 }
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426 BOOL BarStatesDlg::Create()
01427 {
01428 if (TheDialog != this)
01429 return(FALSE);
01430
01431 for (INT32 i = 0; i < 5; i++)
01432 m_StateExists[i] = FALSE;
01433
01434 ScanForBarDetails();
01435
01436 if (DialogOp::Create())
01437 {
01438 return(TRUE);
01439 }
01440
01441 return(FALSE);
01442 }
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459 void BarStatesDlg::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
01460 {
01461 m_BarName = ((OpParamBarStatesDlg *)pParam)->m_BarName;
01462
01463 if (TheDialog==NULL || TheDialog==this)
01464 {
01465 if (Create())
01466 Open();
01467 else
01468 End();
01469 }
01470 else
01471 {
01472 TheDialog->Open();
01473 TheDialog->BringToTop();
01474
01475 TheDialog->m_BarName = ((OpParamBarStatesDlg *)pParam)->m_BarName;
01476
01477 TheDialog->ScanForBarDetails();
01478 TheDialog->SetUpControls();
01479
01480 End();
01481 }
01482 }
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496 BOOL BarStatesDlg::ScanForBarDetails()
01497 {
01498
01499 String_256 templayer;
01500
01501
01502
01503
01504
01505
01506 Layer * pLayer = NULL;
01507
01508 List BarList;
01509
01510 templayer.Load(_R(IDS_ROLLOVER_DEFAULT));
01511 pLayer = SliceHelper::FindLayerCalled(templayer);
01512 if (pLayer)
01513 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, m_BarName);
01514 DWORD BarElements = BarList.GetCount();
01515 DWORD NextElements = BarElements;
01516 if (BarElements > 0)
01517 m_StateExists[0] = TRUE;
01518 else
01519 m_StateExists[0] = FALSE;
01520
01521 templayer.Load(_R(IDS_ROLLOVER_MOUSE));
01522 pLayer = SliceHelper::FindLayerCalled(templayer);
01523 if (pLayer)
01524 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, m_BarName);
01525 NextElements = BarList.GetCount();
01526 if (NextElements > BarElements)
01527 {
01528 BarElements = NextElements;
01529 m_StateExists[1] = TRUE;
01530 }
01531 else
01532 m_StateExists[1] = FALSE;
01533
01534 templayer.Load(_R(IDS_ROLLOVER_CLICKED));
01535 pLayer = SliceHelper::FindLayerCalled(templayer);
01536 if (pLayer)
01537 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, m_BarName);
01538 NextElements = BarList.GetCount();
01539 if (NextElements > BarElements)
01540 {
01541 BarElements = NextElements;
01542 m_StateExists[2] = TRUE;
01543 }
01544 else
01545 m_StateExists[2] = FALSE;
01546
01547 templayer.Load(_R(IDS_ROLLOVER_SELECTED));
01548 pLayer = SliceHelper::FindLayerCalled(templayer);
01549 if (pLayer)
01550 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, m_BarName);
01551 NextElements = BarList.GetCount();
01552 if (NextElements > BarElements)
01553 {
01554 BarElements = NextElements;
01555 m_StateExists[3] = TRUE;
01556 }
01557 else
01558 m_StateExists[3] = FALSE;
01559
01560
01561
01562 templayer.Load(_R(IDS_BACK_BAR));
01563 pLayer = SliceHelper::FindLayerCalled(templayer);
01564 m_StateExists[4] = FALSE;
01565 if (pLayer)
01566 {
01567 Node * pTemplAttrib = SliceHelper::FindNextOfClass(pLayer, pLayer, CC_RUNTIME_CLASS(TemplateAttribute));
01568 while (pTemplAttrib)
01569 {
01570 if (m_BarName == SliceHelper::GetBarName((TemplateAttribute *)pTemplAttrib))
01571 {
01572 m_StateExists[4] = TRUE;
01573 break;
01574 }
01575 pTemplAttrib = SliceHelper::FindNextOfClass(pTemplAttrib, pLayer, CC_RUNTIME_CLASS(TemplateAttribute));
01576 }
01577 }
01578
01579 NodeListItem *pNodeListItem = NULL;
01580 NodeListItem *pDelThisToo = NULL;
01581
01582
01583 pNodeListItem = (NodeListItem *)BarList.GetHead();
01584
01585 while(pNodeListItem)
01586 {
01587 pDelThisToo = pNodeListItem;
01588
01589 pNodeListItem = (NodeListItem *)BarList.GetNext(pNodeListItem);
01590
01591
01592 BarList.RemoveItem((NodeListItem *)pDelThisToo);
01593 delete pDelThisToo;
01594 }
01595
01596
01597
01598 String_256 Title;
01599 Title.Load(_R(IDS_BAR_STATES_TITLE));
01600 if (m_ValidBar)
01601 Title += m_BarName;
01602 else
01603 {
01604 String_256 temp(_R(IDS_NO_VALID_BAR));
01605 Title += temp;
01606 }
01607
01608 SetTitlebarName(&Title);
01609
01610 return TRUE;
01611 }
01612
01613
01614
01615 void BarStatesDlg::SetUpControls()
01616 {
01617 SetLongGadgetValue(_R(IDC_MOUSE_OFF), m_State == 0);
01618 SetLongGadgetValue(_R(IDC_MOUSE_OVER), m_State == 1);
01619 SetLongGadgetValue(_R(IDC_CLICKED), m_State == 2);
01620 SetLongGadgetValue(_R(IDC_SELECTED), m_State == 3);
01621
01622
01623 HideGadget(_R(IDC_MOUSE_OFF_EXISTS), !m_StateExists[0]);
01624 HideGadget(_R(IDC_MOUSE_OVER_EXISTS), !m_StateExists[1]);
01625 HideGadget(_R(IDC_CLICKED_EXISTS), !m_StateExists[2]);
01626 HideGadget(_R(IDC_SELECTED_EXISTS), !m_StateExists[3]);
01627
01628
01629 EnableGadget(_R(IDC_DELETE_STATE), m_StateExists[m_State]);
01630
01631 if (m_StateExists[m_State])
01632 SetStringGadgetValue(_R(IDC_CREATE_STATE), _R(IDS_RECREATE));
01633 else
01634 SetStringGadgetValue(_R(IDC_CREATE_STATE), _R(IDS_CREATE_BUTTON_TEXT));
01635
01636 SetSelectedValueIndex(_R(IDC_MUTATE_COLOURS), ms_SuggestDesign);
01637 HideGadget(_R(IDC_MUTATE_COLOURS), m_State == 4);
01638
01639 if (m_State == 4)
01640 SetStringGadgetValue(_R(IDC_SOURCE_TEXT), _R(IDS_FROM_SELECTION));
01641 else
01642 SetStringGadgetValue(_R(IDC_SOURCE_TEXT), _R(IDS_FROM_MOUSE_OFF));
01643 }
01644
01645 BOOL BarStatesDlg::CreateBarStates(BOOL ReCreate)
01646 {
01647 NodeBarProperty* pNodeBarProperty = (NodeBarProperty*) Document::GetCurrent()->GetSetSentinel()->FindBarProperty();
01648 INT32 BarNumber = SliceHelper::GetBarNumberFromBarName(m_BarName);
01649
01650 if (!pNodeBarProperty || BarNumber >= pNodeBarProperty->HowMany())
01651 return FALSE;
01652
01653 BarDataType NewBarData = pNodeBarProperty->Bar(BarNumber);
01654 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BARCREATIONOP);
01655
01656 if (!pOpDesc)
01657 return FALSE;
01658
01659 BYTE ExtendFlags = 0;
01660
01661 if (NewBarData.ButtonsExtend)
01662 ExtendFlags = X_EXTEND | Y_EXTEND;
01663 else
01664 if (NewBarData.ButtonsScale)
01665 ExtendFlags = X_STRETCH | Y_STRETCH;
01666
01667 OpParamBarCreation BarParam(m_State == 1,
01668 m_State == 2,
01669 m_State == 3,
01670 m_State == 4,
01671 NewBarData.IsHorizontal ? FALSE : TRUE,
01672 ms_SuggestDesign,
01673 0,
01674 m_State == 0,
01675 REPLACE_SOME_STATES,
01676 NewBarData.Spacing,
01677 NewBarData.RequiresShuffle,
01678 NewBarData.SameSize,
01679 m_BarName,
01680 (m_State == DEFAULT || m_State == BACKBAR) ? TRUE : FALSE,
01681 ExtendFlags,
01682 ReCreate);
01683 pOpDesc->Invoke(&BarParam);
01684
01685 return TRUE;
01686 }
01687
01688
01689
01690 BOOL BarStatesDlg::OnSelectionChanged()
01691 {
01692
01693 String_256 LayerName = "";
01694 Spread* pSpread = Document::GetSelectedSpread();
01695 if (pSpread == NULL)
01696 return FALSE;
01697
01698 SelRange * pSelection = GetApplication()->FindSelection();
01699
01700
01701
01702 String_256 TempBarName = "";
01703
01704 Node * pCurrent = pSelection->FindFirst();
01705 TemplateAttribute * pTemplAttrib = NULL;
01706 Node * pTempNode = NULL;
01707
01708 BOOL HasASelection = pCurrent != NULL;
01709
01710 while (pCurrent && TempBarName.IsEmpty())
01711 {
01712
01713 pTemplAttrib = (TemplateAttribute *) SliceHelper::FindNextOfClass(pCurrent, pCurrent, CC_RUNTIME_CLASS(TemplateAttribute));
01714 while (pTemplAttrib && TempBarName.IsEmpty())
01715 {
01716 TempBarName = SliceHelper::GetBarName(pTemplAttrib);
01717 pTemplAttrib = (TemplateAttribute *) SliceHelper::FindNextOfClass(pTemplAttrib, pCurrent, CC_RUNTIME_CLASS(TemplateAttribute));
01718 }
01719
01720 pCurrent = pSelection->FindNext(pCurrent);
01721 }
01722
01723
01724 if (HasASelection && TempBarName.IsEmpty())
01725 {
01726
01727 SliceHelper::BarNameInRect(pSelection->GetBoundingRect(), &TempBarName);
01728 }
01729
01730 if (HasASelection && TempBarName.IsEmpty() && m_ValidBar)
01731 {
01732 m_ValidBar = FALSE;
01733
01734 EnableGadget(_R(IDC_CREATE_STATE), FALSE);
01735 EnableGadget(_R(IDC_MUTATE_COLOURS), FALSE);
01736 EnableGadget(_R(IDC_DELETE_STATE), FALSE);
01737
01738 ScanForBarDetails();
01739 }
01740 else
01741 if (!m_ValidBar && !TempBarName.IsEmpty())
01742 {
01743 m_ValidBar = TRUE;
01744
01745 EnableGadget(_R(IDC_CREATE_STATE), TRUE);
01746 EnableGadget(_R(IDC_MUTATE_COLOURS), TRUE);
01747 EnableGadget(_R(IDC_DELETE_STATE), TRUE);
01748
01749 m_BarName = "";
01750 }
01751
01752 if (TempBarName.CompareTo(m_BarName) != 0 && !TempBarName.IsEmpty())
01753 {
01754
01755 m_BarName = TempBarName;
01756 ScanForBarDetails();
01757 SetUpControls();
01758 }
01759
01760 return TRUE;
01761 }
01762
01763
01764
01765
01766
01767
01768
01769
01770 const CDlgMode BarRedefineStateDlg::Mode = MODELESS;
01771 const UINT32 BarRedefineStateDlg::IDD = _R(IDD_REDEFINE_STATE);
01772
01773 BarRedefineStateDlg *BarRedefineStateDlg::TheDialog = NULL;
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786 BarRedefineStateDlg::BarRedefineStateDlg() : DialogOp(BarRedefineStateDlg::IDD, BarRedefineStateDlg::Mode)
01787 {
01788
01789 if (TheDialog == NULL)
01790 TheDialog = this;
01791
01792 }
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806 BarRedefineStateDlg::~BarRedefineStateDlg()
01807 {
01808
01809 if (TheDialog == this)
01810 TheDialog = NULL;
01811 }
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827 MsgResult BarRedefineStateDlg::Message( Msg* Message)
01828 {
01829 BOOL fEndDialog=FALSE;
01830
01831
01832 if (IS_OUR_DIALOG_MSG(Message))
01833 {
01834
01835 DialogMsg* pDialogMsg = ((DialogMsg*) Message);
01836
01837 switch (pDialogMsg->DlgMsg)
01838 {
01839 case DIM_CREATE:
01840 SetUpControls();
01841
01842 break;
01843
01844
01845 case DIM_TITLEFOCUSWARN:
01846
01847 break;
01848
01849
01850 case DIM_LFT_BN_UP:
01851
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
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
01875 Close();
01876 End();
01877 }
01878
01879
01880 return DialogOp::Message(Message);
01881 }
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893 OpState BarRedefineStateDlg::GetState(String_256*, OpDescriptor*)
01894 {
01895 OpState OpSt;
01896
01897
01898 OpSt.Greyed = TRUE;
01899 Spread* pSpread = Document::GetSelectedSpread();
01900 if (pSpread && !pSpread->FindActiveLayer()->IsFrame())
01901 OpSt.Greyed = FALSE;
01902
01903
01904 if (TheDialog != NULL)
01905 OpSt.Ticked = TRUE;
01906
01907 return(OpSt);
01908 }
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923 BOOL BarRedefineStateDlg::Init()
01924 {
01925 return (RegisterOpDescriptor(0,
01926 _R(IDS_RECREATE_STATES),
01927 CC_RUNTIME_CLASS(BarRedefineStateDlg),
01928 OPTOKEN_BARREDEFINESTATEDLG,
01929 BarRedefineStateDlg::GetState,
01930 _R(IDH_NavBar_Edit_Design_Dialog_Box),
01931 _R(IDBBL_REDEFINE_STATE),
01932 _R(IDD_BARCONTROLSTORE),
01933 _R(IDC_REDEFINE_STATE),
01934 SYSTEMBAR_UTILITIES,
01935 TRUE,
01936 FALSE,
01937 TRUE,
01938 0,
01939 NULL,
01940 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC),
01941 TRUE
01942 ));
01943
01944 }
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961 void BarRedefineStateDlg::Do(OpDescriptor*)
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();
01979 }
01980 }
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997 BOOL BarRedefineStateDlg::Create()
01998 {
01999 if (TheDialog != this)
02000 return(FALSE);
02001
02002 if (DialogOp::Create())
02003 {
02004 return(TRUE);
02005 }
02006
02007 return(FALSE);
02008 }
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025 void BarRedefineStateDlg::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
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();
02043 }
02044 }
02045
02046 BOOL BarRedefineStateDlg::SetUpControls()
02047 {
02048
02049
02050
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
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
02075 if (pNameGallery)
02076 pNameGallery->FastUpdateNamedSetSizes();
02077
02078 String_256 BarName = "";
02079
02080
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
02101 SetSelectedValueIndex(_R(IDC_BAR_NO_COMBO), selthis);
02102
02103
02104 return TRUE;
02105 }
02106
02107
02108
02109 BOOL BarRedefineStateDlg::IsAttribInSelected(Node * pNode)
02110 {
02111 Node *pParent = pNode->FindParent();
02112
02113
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
02127 while (pParent && !pParent->IsLayer())
02128 {
02129 if (pParent->IsSelected())
02130 return TRUE;
02131
02132 pParent = pParent->FindParent();
02133 }
02134
02135 return FALSE;
02136 }
02137
02138
02139 BOOL BarRedefineStateDlg::RedefineState()
02140 {
02141
02142 m_BarName = GetStringGadgetValue(_R(IDC_BAR_NO_COMBO));
02143
02144
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
02156
02157
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
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
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
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
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;
02226 else
02227 break;
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;
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,
02249 m_State == 2,
02250 m_State == 3,
02251 m_State == 4,
02252 NewBarData.IsHorizontal ? FALSE : TRUE,
02253 FALSE,
02254 NoOfButtons,
02255 m_State == 0,
02256 REPLACE_SOME_STATES,
02257 NewBarData.Spacing,
02258 NewBarData.RequiresShuffle,
02259 NewBarData.SameSize,
02260 m_BarName,
02261 TRUE,
02262 ExtendFlags);
02263 pOpDesc->Invoke(&BarParam);
02264
02265 return TRUE;
02266 }