#include <slicetool.h>
Inheritance diagram for SliceInfoBarOp:
Public Member Functions | |
SliceInfoBarOp () | |
INT32 | FindCurrentState () |
Scans the layers looking at which named states are visible. | |
MsgResult | Message (Msg *Msg) |
Slice info bar dialog message handler. | |
void | OnSelectionChanged () |
Should be called everytime something changes the selection, so that the correct buttons are highlit and the correct text is placed in the barname edit field. | |
void | SetSliceTool (SliceTool *pTool) |
void | UpdateCurrentStateGadget () |
Quickly scans the tree to find the layers shown then sets the drop down control which displays the current button state. Includes the define code for including the "clicked" state or not. | |
Static Public Member Functions | |
static BOOL | ScanFromNodeForBarMembers (Node *pNode, String_256 &BarName, String_256 *pButtonName=NULL) |
Checks from a given node down looking for the first template attrib (set name) Once found it returns TRUE and fills in the bar name string from the question of the template attrib and if a ptr to a string was passed for the button name it fills this in too. NB. This function is RECURSIVE. | |
Public Attributes | |
BOOL | m_InfoBarCreated |
Protected Member Functions | |
String_256 | GetNextUnusedBarName (Range *pSel, BOOL *pFromSel) |
It checks the selection to see if it is part of a bar. If it was it returns that name. If not it returns the next good name to use for a bar, that isn't currently in use. | |
Protected Attributes | |
BOOL | m_EditingBar |
INT32 | m_TopVisibleState |
SliceTool * | pSliceTool |
Definition at line 367 of file slicetool.h.
|
Definition at line 371 of file slicetool.h. 00371 { m_InfoBarCreated = FALSE; m_TopVisibleState = -1; m_EditingBar = FALSE; pSliceTool = NULL; };
|
|
Scans the layers looking at which named states are visible.
NB. matches the order of the combo box options Definition at line 2974 of file slicetool.cpp. 02975 { 02976 // find a spread? 02977 Spread* pSelSpread = Document::GetSelectedSpread(); 02978 if (pSelSpread == NULL) 02979 return 6; 02980 02981 // init the layer pointers 02982 Layer * pLayer = pSelSpread->FindFirstLayer(); 02983 02984 BOOL ActiveState[4]; 02985 String_32 StateName[4]; 02986 02987 StateName[DEFAULT].Load(_R(IDS_ROLLOVER_DEFAULT)); // = "Default"; 02988 StateName[MOUSE].Load(_R(IDS_ROLLOVER_MOUSE)); // = "Mouse"; 02989 StateName[CLICKED].Load(_R(IDS_ROLLOVER_CLICKED)); // = "Clicked"; 02990 StateName[SELECTED].Load(_R(IDS_ROLLOVER_SELECTED)); // = "Selected"; 02991 02992 INT32 i = 0; 02993 02994 // init the bools 02995 for (i = 0; i < 4 ; i++) 02996 ActiveState[i] = FALSE; 02997 02998 m_TopVisibleState = -1; 02999 03000 while (pLayer) 03001 { 03002 for (i = 0; i < 4 ; i++) 03003 { 03004 if (pLayer->GetLayerID().CompareTo(StateName[i]) == 0) 03005 { 03006 ActiveState[i] = pLayer->IsVisible(); 03007 if (ActiveState[i]) 03008 { 03009 if (m_TopVisibleState == -1 || m_TopVisibleState > i) 03010 m_TopVisibleState = i; 03011 } 03012 } 03013 } 03014 03015 pLayer = pLayer->FindNextLayer(); 03016 } 03017 03018 03019 if (ActiveState[0] && ActiveState[1] && (ActiveState[2] || !INCLUDE_CLICKED_STATE ) && ActiveState[3]) 03020 return 4; // all states 03021 03022 if (ActiveState[0] && !ActiveState[1] && !ActiveState[2] && !ActiveState[3]) 03023 return 0; // default state 03024 03025 if (!ActiveState[0] && ActiveState[1] && !ActiveState[2] && !ActiveState[3]) 03026 return 1; // mouse state 03027 03028 if (!ActiveState[0] && !ActiveState[1] && ActiveState[2] && !ActiveState[3]) 03029 return 2; // clicked state 03030 03031 if (!ActiveState[0] && !ActiveState[1] && !ActiveState[2] && ActiveState[3]) 03032 return 3; // selected state 03033 03034 if (!ActiveState[0] && !ActiveState[1] && !ActiveState[2] && !ActiveState[3]) 03035 return 5; // no states 03036 03037 return 6; // another state 03038 }
|
|
It checks the selection to see if it is part of a bar. If it was it returns that name. If not it returns the next good name to use for a bar, that isn't currently in use.
Definition at line 3124 of file slicetool.cpp. 03125 { 03126 String_256 NewBarName = ""; 03127 03128 *pFromSel = FALSE; 03129 03130 Spread* pSpread = Document::GetSelectedSpread(); 03131 if (pSpread == NULL) 03132 return g_BarName; 03133 03134 if (pSel) 03135 { 03136 Node * pCurrent = pSel->FindFirst(); 03137 // for each node in the selection 03138 while (pCurrent) 03139 { 03140 // does the selection contain a named bar ? 03141 // if it does we will edit this and return it here 03142 if (ScanFromNodeForBarMembers(pCurrent, NewBarName)) 03143 { 03144 *pFromSel = TRUE; 03145 return NewBarName; 03146 } 03147 03148 pCurrent = pSel->FindNext(pCurrent); 03149 } 03150 03151 // no actual bar in selection so does the selection cross a bar? 03152 SliceHelper::BarNameInRect(pSel->GetBoundingRect(), &g_BarName); 03153 } 03154 03155 return g_BarName; // keep what we had before 03156 }
|
|
Slice info bar dialog message handler.
Reimplemented from InformationBarOp. Definition at line 2647 of file slicetool.cpp. 02648 { 02649 if (IS_OUR_DIALOG_MSG(Message)) 02650 { 02651 DialogMsg* Msg = (DialogMsg*)Message; 02652 02653 switch(Msg->DlgMsg) 02654 { 02655 case DIM_CANCEL: 02656 m_InfoBarCreated = FALSE; 02657 Close(); // close the dlg 02658 break; 02659 02660 case DIM_CREATE: 02661 m_InfoBarCreated = TRUE; 02662 // Initialise the infobar controls here 02663 // This is sent when you create the infobar in your tool startup code 02664 SetStringGadgetValue(_R(IDC_ST_STATE), _R(IDS_ROLLOVER_DEFAULT), FALSE, 0); 02665 SetStringGadgetValue(_R(IDC_ST_STATE), _R(IDS_ROLLOVER_MOUSE), FALSE, 1); 02666 SetStringGadgetValue(_R(IDC_ST_STATE), _R(IDS_ROLLOVER_CLICKED), FALSE, 2); 02667 SetStringGadgetValue(_R(IDC_ST_STATE), _R(IDS_ROLLOVER_SELECTED), FALSE, 3); 02668 SetStringGadgetValue(_R(IDC_ST_STATE), _R(IDS_ROLLOVER_ALL), FALSE, 4); 02669 SetStringGadgetValue(_R(IDC_ST_STATE), _R(IDS_ROLLOVER_NONE), TRUE, 5); 02670 UpdateCurrentStateGadget(); 02671 02672 // set up the bar name bit and grey the buttons that are selection dependant 02673 // check again for the new bar name 02674 m_TopVisibleState = -1; 02675 02676 // set the bar name 02677 //g_BarName.MakeMsg(_R(IDS_BARNAME), 1); 02678 OnSelectionChanged(); 02679 break; 02680 02681 //NB: This means someone has altered the combo box. It doesn't mean 02682 //the selection has changed! 02683 case DIM_SELECTION_CHANGED: 02684 if(Msg->GadgetID == _R(IDC_ST_STATE)) 02685 { 02686 OpParam Param(GetSelectedValueIndex(_R(IDC_ST_STATE)), 0); 02687 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SHOWSTATE); 02688 if (pOpDesc != NULL) 02689 pOpDesc->Invoke((OpParam*)&Param); 02690 else 02691 { 02692 ERROR3("Couldn't find OPTOKEN_SHOWSTATE op descriptor"); 02693 } 02694 UpdateCurrentStateGadget(); 02695 } 02696 break; 02697 02698 case DIM_LFT_BN_CLICKED: 02699 switch(Msg->GadgetID) 02700 { 02701 case _R(IDC_ST_EXPORT): 02702 // run the Op that does the image slicing / rollover creation 02703 // from the back end 02704 { 02705 // matt-24/08/2000 02706 // Should check first that buttons exist in this document - same code as 02707 // used in Edit section below... 02708 02709 BOOL ok = TRUE; 02710 // nothing selected then test that the bar we think we are editing exists 02711 // warn if it doesn't 02712 if (!m_EditingBar) 02713 { 02714 String_256 defaultLayerName; 02715 defaultLayerName.Load(_R(IDS_ROLLOVER_DEFAULT)); 02716 Layer * pDef = SliceHelper::FindLayerCalled(defaultLayerName); 02717 02718 if (pDef == NULL || !SliceHelper::BarNameExists(pDef, g_BarName)) 02719 { 02720 ok = FALSE; 02721 InformWarning(_R(IDS_BAR_DOESNT_EXIST)); 02722 } 02723 } 02724 02725 if (ok) 02726 { 02727 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_IMAGESLICE); 02728 if (pOpDesc != NULL) 02729 pOpDesc->Invoke();//(OpParam*)&Param); 02730 else 02731 { 02732 ERROR3("Couldn't find OPTOKEN_IMAGESLICE op descriptor"); 02733 } 02734 } 02735 } 02736 break; 02737 02738 case _R(IDC_NEW_BAR): 02739 // Brings up the edit/create bar dlg 02740 { 02741 // find a new bar name and put it in g_BarName 02742 String_256 DefLayerName; 02743 DefLayerName.Load(_R(IDS_ROLLOVER_DEFAULT)); 02744 Layer * pDef = SliceHelper::FindLayerCalled(DefLayerName); 02745 INT32 UnusedBarID = 0; 02746 String_256 NewBarName = ""; 02747 02748 do 02749 { 02750 UnusedBarID++; 02751 NewBarName.MakeMsg(_R(IDS_BARNAME), UnusedBarID); 02752 } 02753 while (pDef && SliceHelper::BarNameExists(pDef, NewBarName)); 02754 02755 // run the op to create a new bar 02756 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BARCREATIONDLG); 02757 if (pOpDesc != NULL) 02758 { 02759 OpParamBarCreationDlg Param(FALSE /*Creating*/, NewBarName, SliceHelper::CountButtonsInBar(NewBarName)); 02760 pOpDesc->Invoke((OpParam*)&Param); 02761 } 02762 else 02763 { 02764 ERROR3("Couldn't find OPTOKEN_BARCREATIONDLG op descriptor"); 02765 } 02766 } 02767 break; 02768 02769 case _R(IDC_EDIT_BAR): 02770 // Brings up the edit/create bar dlg 02771 { 02772 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BARCREATIONDLG); 02773 if (pOpDesc != NULL) 02774 { 02775 BOOL ok = TRUE; 02776 // nothing selected then test that the bar we think we are editing exists 02777 // warn if it doesn't 02778 if (!m_EditingBar) 02779 { 02780 String_256 DefLayerName; 02781 DefLayerName.Load(_R(IDS_ROLLOVER_DEFAULT)); 02782 Layer * pDef = SliceHelper::FindLayerCalled(DefLayerName); 02783 02784 if (pDef == NULL || !SliceHelper::BarNameExists(pDef, g_BarName)) 02785 { 02786 ok = FALSE; 02787 InformWarning(_R(IDS_BAR_DOESNT_EXIST)); 02788 } 02789 } 02790 02791 if (ok) 02792 { 02793 OpParamBarCreationDlg Param(TRUE /*editing*/, g_BarName, SliceHelper::CountButtonsInBar(g_BarName)); 02794 pOpDesc->Invoke((OpParam*)&Param); 02795 } 02796 } 02797 else 02798 { 02799 ERROR3("Couldn't find OPTOKEN_BARCREATIONDLG op descriptor"); 02800 } 02801 } 02802 break; 02803 02804 case _R(IDC_STATES): 02805 // Brings up the edit/create bar dlg 02806 { 02807 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BARSTATESDLG); 02808 if (pOpDesc != NULL) 02809 { 02810 BOOL ok = TRUE; 02811 // nothing selected then test that the bar we think we are editing exists 02812 // warn if it doesn't 02813 if (!m_EditingBar) 02814 { 02815 String_256 DefLayerName; 02816 DefLayerName.Load(_R(IDS_ROLLOVER_DEFAULT)); 02817 Layer * pDef = SliceHelper::FindLayerCalled(DefLayerName); 02818 02819 if (pDef == NULL || !SliceHelper::BarNameExists(pDef, g_BarName)) 02820 { 02821 ok = FALSE; 02822 InformWarning(_R(IDS_BAR_DOESNT_EXIST)); 02823 } 02824 } 02825 02826 if (ok) 02827 { 02828 OpParamBarStatesDlg ParamBarStatesDlg(g_BarName); 02829 pOpDesc->Invoke(&ParamBarStatesDlg); 02830 } 02831 } 02832 } 02833 break; 02834 02835 case _R(IDC_REDEFINE_STATE): 02836 // Brings up the edit/create bar dlg 02837 { 02838 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BARREDEFINESTATEDLG); 02839 if (pOpDesc != NULL) 02840 { 02841 FindCurrentState(); 02842 BOOL ok = TRUE; 02843 // nothing selected then test that the bar we think we are editing exists 02844 // warn if it doesn't 02845 if (!m_EditingBar) 02846 { 02847 String_256 DefLayerName; 02848 DefLayerName.Load(_R(IDS_ROLLOVER_DEFAULT)); 02849 Layer * pDef = SliceHelper::FindLayerCalled(DefLayerName); 02850 02851 if (pDef == NULL || !SliceHelper::BarNameExists(pDef, g_BarName)) 02852 { 02853 ok = FALSE; 02854 InformWarning(_R(IDS_BAR_DOESNT_EXIST)); 02855 } 02856 } 02857 02858 if (ok) 02859 { 02860 OpParamBarRedefineStateDlg ParamBarRedefineStateDlg(g_BarName, m_TopVisibleState); 02861 pOpDesc->Invoke(&ParamBarRedefineStateDlg); 02862 } 02863 } 02864 } 02865 break; 02866 02867 case _R(IDC_LIVE): // is the stretching live or not??? 02868 { 02869 NodeBarProperty* pNodeBarProperty = (NodeBarProperty*) Document::GetCurrent()->GetSetSentinel()->FindBarProperty(); 02870 INT32 BarNumber = SliceHelper::GetBarNumberFromBarName(g_BarName); 02871 02872 if (pNodeBarProperty && BarNumber < pNodeBarProperty->HowMany()) 02873 { 02874 BarDataType NewBarData = pNodeBarProperty->Bar(BarNumber); 02875 NewBarData.IsLive = !NewBarData.IsLive; 02876 02877 NameGallery * pNameGallery = NameGallery::Instance(); 02878 if (pNameGallery) 02879 pNameGallery->FastUpdateNamedSetSizes(); 02880 02881 pNodeBarProperty->MakeChange(BarNumber, NewBarData); 02882 } 02883 } 02884 02885 break; 02886 02887 } 02888 break; 02889 } 02890 02891 } 02892 else if (m_InfoBarCreated && MESSAGE_IS_A(Message, SpreadMsg)) 02893 { 02894 SpreadMsg* pSpreadMsg = (SpreadMsg*) Message; 02895 02896 switch (pSpreadMsg->Reason) 02897 { 02898 case SpreadMsg::LAYERCHANGES: 02899 UpdateCurrentStateGadget(); 02900 break; 02901 } 02902 } 02903 else if (m_InfoBarCreated && MESSAGE_IS_A(Message, LayerMsg)) 02904 { 02905 LayerMsg *TheMsg = (LayerMsg *) Message; 02906 02907 if (TheMsg->Reason == LayerMsg::LAYER_VISIBILITY_CHANGED) 02908 { 02909 UpdateCurrentStateGadget(); 02910 } 02911 } 02912 02913 // Karim MacDonald - 20/10/1999 02914 // for whenever someone announces that they have changed the selection. 02915 // FYI, this SelChangingMsg is also sent when you do (SelRange*)->Update(TRUE). 02916 else if (m_InfoBarCreated && MESSAGE_IS_A(Message, SelChangingMsg)) 02917 { 02918 SelChangingMsg* pSelChange = (SelChangingMsg*)Message; 02919 02920 if (pSelChange->State == SelChangingMsg::SelectionState::SELECTIONCHANGED || 02921 pSelChange->State == SelChangingMsg::SelectionState::NONCOLOURATTCHANGED) 02922 { 02923 OnSelectionChanged(); 02924 } 02925 } 02926 02927 // Karim 06/07/2000 - the slice tool needs to know if the view changes. 02928 else if (MESSAGE_IS_A(Message, DocViewMsg)) 02929 { 02930 if (pSliceTool != NULL) 02931 pSliceTool->ViewChanged( *((DocViewMsg*)Message) ); 02932 } 02933 02934 // If we've changed to a different document then get rid of the dlg. 02935 else if (MESSAGE_IS_A(Message, DocChangingMsg)) 02936 { 02937 DocChangingMsg* TheMsg = (DocChangingMsg*) Message; 02938 if (TheMsg->State == DocChangingMsg::BORN || TheMsg->State == DocChangingMsg::SELCHANGED) 02939 { 02940 // this will be a new set of named sets! 02941 NameGallery * pNameGallery = NameGallery::Instance(); 02942 if (pNameGallery) 02943 pNameGallery->FastUpdateNamedSetSizes(); 02944 } 02945 } 02946 02947 // Pass the message on to the immediate Slice class 02948 return (InformationBarOp::Message(Message)); 02949 }
|
|
Should be called everytime something changes the selection, so that the correct buttons are highlit and the correct text is placed in the barname edit field.
Definition at line 3051 of file slicetool.cpp. 03052 { 03053 // find out what the bar id should be - the next one to be used or the selected one 03054 Spread* pSpread = Document::GetSelectedSpread(); 03055 03056 // is it part of a animation? 03057 // test the current frame if it is a frame or a layer 03058 if (pSpread != NULL) 03059 { 03060 Layer * ActiveLayer = pSpread->FindActiveLayer(); 03061 if (ActiveLayer && ActiveLayer->IsFrame()) 03062 { 03063 // can't do lots of these things if we are in an animation 03064 EnableGadget(_R(IDC_NEW_BAR), FALSE); 03065 EnableGadget(_R(IDC_EDIT_BAR), FALSE); 03066 EnableGadget(_R(IDC_STATES), FALSE); 03067 EnableGadget(_R(IDC_LIVE), FALSE); 03068 EnableGadget(_R(IDC_ST_EXPORT), FALSE); 03069 EnableGadget(_R(IDC_ST_STATE), FALSE); 03070 } 03071 else 03072 { 03073 // get the selection 03074 Range Sel(*(GetApplication()->FindSelection())); 03075 03076 // set the range flags so it includes shadow and bevel manager nodes 03077 RangeControl rg = Sel.GetRangeControlFlags(); 03078 rg.PromoteToParent = TRUE; 03079 rg.IgnoreInvisibleLayers = TRUE; 03080 Sel.Range::SetRangeControl(rg); 03081 03082 m_EditingBar = FALSE; 03083 g_BarName = GetNextUnusedBarName(&Sel, &m_EditingBar); 03084 INT32 BarNo = SliceHelper::GetBarNumberFromBarName(g_BarName); 03085 NodeBarProperty* pNodeBarProperty = (NodeBarProperty*) Document::GetCurrent()->GetSetSentinel()->FindBarProperty(); 03086 BOOL IsBar = pNodeBarProperty && BarNo < pNodeBarProperty->HowMany(); 03087 03088 SetStringGadgetValue(_R(IDC_ST_BARNAME), &g_BarName); 03089 03090 EnableGadget(_R(IDC_NEW_BAR), !m_EditingBar && Sel.Count() >= 1); 03091 EnableGadget(_R(IDC_EDIT_BAR), TRUE /*m_EditingBar || BarNo > 0*/); 03092 EnableGadget(_R(IDC_STATES), TRUE /*m_EditingBar || BarNo > 0*/); 03093 EnableGadget(_R(IDC_LIVE), IsBar); 03094 EnableGadget(_R(IDC_ST_EXPORT), TRUE); 03095 EnableGadget(_R(IDC_ST_STATE), TRUE); 03096 03097 // set the live tick 03098 SetLongGadgetValue(_R(IDC_LIVE), IsBar && pNodeBarProperty->Bar(BarNo).IsLive); 03099 } 03100 } 03101 03102 // Karim - 19/10/1999 03103 // inform the SliceTool that the selection has changed. 03104 if (pSliceTool != NULL) 03105 pSliceTool->SelectionHasChanged(); 03106 }
|
|
Checks from a given node down looking for the first template attrib (set name) Once found it returns TRUE and fills in the bar name string from the question of the template attrib and if a ptr to a string was passed for the button name it fills this in too. NB. This function is RECURSIVE.
Definition at line 3175 of file slicetool.cpp. 03176 { 03177 if (!BarName.IsEmpty()) 03178 return TRUE; 03179 03180 if (pNode->IsAnAttribute()) 03181 { 03182 if (pNode->IsKindOf(CC_RUNTIME_CLASS(TemplateAttribute))) 03183 { 03184 BarName = SliceHelper::GetBarName((TemplateAttribute *)pNode); 03185 03186 // found a bar name? then set the button name too 03187 if (!BarName.IsEmpty() && pButtonName) 03188 *pButtonName = ((TemplateAttribute *)pNode)->GetParam(); 03189 } 03190 } 03191 else // find anything else interesting? 03192 { 03193 Node * pChildNode = pNode->FindFirstChild(); 03194 03195 while (pChildNode) 03196 { 03197 // ***recursive call*** 03198 if (ScanFromNodeForBarMembers(pChildNode, BarName, pButtonName)) 03199 return TRUE; 03200 pChildNode = pChildNode->FindNext(); 03201 } 03202 } 03203 03204 return FALSE; 03205 }
|
|
Definition at line 382 of file slicetool.h. 00382 { pSliceTool = pTool; };
|
|
Quickly scans the tree to find the layers shown then sets the drop down control which displays the current button state. Includes the define code for including the "clicked" state or not.
Definition at line 4034 of file slicetool.cpp. 04035 { 04036 INT32 state = FindCurrentState(); 04037 04038 /* // set the text in the redefine state button 04039 String_256 RedefineText = ""; 04040 String_256 Temp(_R(IDS_ROLLOVER_DEFAULT)); 04041 RedefineText += " \""; 04042 if (m_TopVisibleState == 1) 04043 Temp.Load(_R(IDS_ROLLOVER_MOUSE)); 04044 else if (m_TopVisibleState == 2) 04045 Temp.Load(_R(IDS_ROLLOVER_CLICKED)); 04046 else if (m_TopVisibleState == 3) 04047 Temp.Load(_R(IDS_ROLLOVER_SELECTED)); 04048 else if (m_TopVisibleState == 4) 04049 Temp.Load(_R(IDS_BACK_BAR)); 04050 04051 RedefineText.MakeMsg(_R(IDS_DESIGN_TEXT), (LPCSTR) Temp); 04052 SetStringGadgetValue(_R(IDC_REDEFINE_STATE), &RedefineText); 04053 */ 04054 EnableGadget(_R(IDC_REDEFINE_STATE), m_TopVisibleState != -1); 04055 04056 // set the text in the dropdown 04057 if (state >=0 && state <= 4 + INCLUDE_CLICKED_STATE) 04058 SetSelectedValueIndex(_R(IDC_ST_STATE), state); 04059 else 04060 SetStringGadgetValue(_R(IDC_ST_STATE), _R(IDS_MANY), FALSE, -1); 04061 }
|
|
Definition at line 388 of file slicetool.h. |
|
Definition at line 374 of file slicetool.h. |
|
Definition at line 389 of file slicetool.h. |
|
Definition at line 392 of file slicetool.h. |