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