InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CSelectableDialogSwitcher.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Tom Taylor
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __CSelectableDialogSwitcher__
25 #define __CSelectableDialogSwitcher__
26 
27 #include "ISelectableDialogSwitcher.h"
28 #include "HelperInterface.h"
29 #include "K2Vector.h"
30 #include "IStringListControlData.h"
31 
32 //========================================================================================
33 // Class DialogPanelEntry
34 //========================================================================================
35 
37 {
38 public:
39  typedef base_type data_type;
41  DialogPanelEntry(const WidgetID dialogPanelWidgetID, int32 index, bool16 shown, bool16 autoVisible);
42  DialogPanelEntry(const DialogPanelEntry& other);
43 
44  DialogPanelEntry& operator=(const DialogPanelEntry& other);
45  bool16 operator==(const DialogPanelEntry& other) const;
46 
47  void SetWidgetID(WidgetID widgetID) { fWidgetID = widgetID; }
48  WidgetID GetWidgetID() const { return fWidgetID; }
49 
50  void SetIndex(int32 index) { fIndex = index; }
51  int32 GetIndex() const { return fIndex; }
52 
53  void SetShown(bool16 shown) { fShown = shown; }
54  bool16 GetShown() const { return fShown; }
55 
56  void SetAutoVisible(bool16 autoVisible) { fAutoVisible = autoVisible; }
57  bool16 GetAutoVisible() const { return fAutoVisible; }
58 
59 private:
60  WidgetID fWidgetID;
61  int32 fIndex;
62  bool16 fShown;
63  bool16 fAutoVisible;
64 };
65 
66 
67 inline DialogPanelEntry::DialogPanelEntry() :
68  fWidgetID(kInvalidWidgetID),
69  fIndex(-1),
70  fShown(kFalse),
71  fAutoVisible(kFalse)
72 {
73 }
74 
75 inline DialogPanelEntry::DialogPanelEntry(const WidgetID dialogPanelWidgetID, int32 index, bool16 shown, bool16 autoVisible) :
76  fWidgetID(dialogPanelWidgetID),
77  fIndex(index),
78  fShown(shown),
79  fAutoVisible(autoVisible)
80 {
81 }
82 
83 inline DialogPanelEntry::DialogPanelEntry(const DialogPanelEntry& other) :
84  fWidgetID(other.fWidgetID),
85  fIndex(other.fIndex),
86  fShown(other.fShown),
87  fAutoVisible(other.fAutoVisible)
88 {
89 }
90 
91 inline DialogPanelEntry& DialogPanelEntry::operator=(const DialogPanelEntry& other)
92 {
93  if (&other != this)
94  {
95  fWidgetID = other.fWidgetID;
96  fIndex = other.fIndex;
97  fShown = other.fShown;
98  fAutoVisible = other.fAutoVisible;
99  }
100 
101  return *this;
102 }
103 
104 inline bool16 DialogPanelEntry::operator==(const DialogPanelEntry& other) const
105 {
106  return fWidgetID == other.fWidgetID && fIndex == other.fIndex && fAutoVisible == other.fAutoVisible;
107 }
108 
109 //========================================================================================
110 // Class CSelectableDialogSwitcher
111 //========================================================================================
112 
114 {
115 public:
116  // ----- Initialization -----
117 
119  virtual ~CSelectableDialogSwitcher();
120 
121  virtual void ReadWrite(IPMStream* s, ImplementationID prop);
122 
123  // ----- Selectable dialog methods -----
124 
125  virtual void SwitchDialogPanel(int32 dialogNumber, bool16 validate = kTrue);
126  // Changes the displayed dialog panel to that of dialogNumber.
127 
128  virtual void SwitchDialogPanelByID(WidgetID panelsWidgetID);
129  // Changes the displayed dialog panel to the panel with the specified widget id.
130 
131  virtual void AddDialogPanel(IControlView* dialogPanel, const PMString& panelName, int32 at = -1, bool16 autoVisible = kTrue);
132  // Adds the dialog panel to the selectable dialog. "at" specifies the position
133  // of the panel relative to the others. If "at" is -1, the panel is appended
134  // to the end of the list of panels. If visible is true, the panel is added to
135  // the dialog's selection list.
136 
137  virtual IControlView* GetDialogPanel(WidgetID panelsWidgetID);
138  // Finds the dialog panel in the selectable dialog.
139 
140  virtual void SetDialogServiceID(const ServiceID& dialogServiceID,
141  const WidgetID dialogGroupPanelWidgetID = kDialogGroupPanelWidgetID,
142  const WidgetID dialogSelectionWidgetID = kSelectDialogSelectionWidgetID,
143  const WidgetID dialogTitleTextWidgetID = kSelectDialogTitleTextWidgetID);
144  // Set the service ID for this dialog. Used to find the sub dialog panels
145 
146  virtual ServiceID GetDialogServiceID() const;
147  // Gets the service ID for this dialog.
148 
149  virtual WidgetID GetGroupPanelWidgetID() const;
150  // Gets the widget ID of the group panel that holds the dialog panels.
151 
152  virtual WidgetID GetSelectionListWidgetID() const;
153  // Gets the widget ID of the list box used to select the dialog panels.
154 
155  virtual WidgetID GetTitleTextWidgetID() const;
156  // Gets the widget ID of the TextWidget that is to display the name of
157  // the currently active dialog panel.
158 
160  // Returns the panel control data associated with the group panel widget
161  // The group panel widget is the widget that holds all of the dialog sub panels.
162 
163  virtual void LoadDialogPanels();
164  // Forces a dynamic load of all the dialog panels associated with this selectable dialog
165 
166  virtual void ShowDialogPanel(const WidgetID panelWidgetID, const bool16 show = kTrue);
167  // Call ShowDialogPanel to show a dialog panel and add its name to the selectable dialog's selection list.
168 
169  virtual int32 GetCurrentPanelIndex() const;
170  // Returns the index of the currently displayed panel.
171 
172  virtual void HideNonAutoShownPanels();
173  // Call this function when the selectable dialog is closed to hide any non auto shown panels that
174  // were made visible after the dialog was opened.
175 
176  virtual WidgetID GetPanelWidgetID(int32 index) const;
177  // Given an index to a panel, this function returns the widget id of the panel.
178 
179  virtual bool16 GetAutoResizable() const;
180  // Does the parent panel auto-resize in height as you switch to each panel.
181 
182  virtual void SetAutoResizable(const bool16 bAutoSize);
183  // Sets auto-resize for parent panel.
184 
185  virtual void RemoveDialogPanel(IControlView* dialogPanel);
186  // Remove a dialog panel.
187 
188  virtual int32 GetDialogPanelIndex (WidgetID panelWidgetID) const;
189  // Given the dialog panel's WidgetID, return its current position in the
190  // panel list.
191  virtual int32 GetNumDialogPanels() const;
192 
193  virtual void UnloadDialogPanels();
194  virtual bool16 SetKeyFocusToSelectionList();
195 
196 protected:
197  // ----- Implementation -----
198 
199  virtual void ShowHideDialogPanel(int32 dialogNumber, bool16 showPanel);
200 
201  virtual void SelectionWidgetAddString(const PMString& newString, int32 at = IStringListControlData::kEnd, bool16 invalidate = kTrue, bool16 notifyOfChange = kTrue);
202  virtual void SelectionWidgetClear(bool16 invalidate = kTrue, bool16 notifyOfChange = kTrue);
203  virtual PMString SelectionWidgetGetString(int32 index) const;
204  virtual int32 SelectionWidgetLength() const;
205  virtual void SelectionWidgetRemoveString(int32 index, bool16 invalidate = kTrue, bool16 notifyOfChange = kTrue);
206  virtual void SelectionWidgetSelect(int32 index, bool16 invalidate = kTrue, bool16 notifyOfChange = kTrue);
207 private:
208  virtual void InitializePanel();
209 protected:
210  virtual void RebuildIfNecessary();
211 
212  virtual void UpdateTitleTextString(int32 dialogNumber);
213 
214  virtual int32 GetPanelIndexInDialog(const int32& panelIndex) const;
215  virtual bool16 GetPanelAutoVisible(const int32& index) const;
216  virtual void GetAdjustedPanelPosition(IControlView* panel, const K2Vector<ClassID>& panelIDs, int32& panelPosition);
217  virtual void ReadWriteDialogPanel(IPMStream* s, K2Vector<DialogPanelEntry>& dialogPanelList);
218  void CustomLoadDialogPanel(bool skipAddRomanPanel = kFalse);
219 
220  int32 fCurrentDialogPanelIndex;
221  bool16 fSwitchingPanels;
222  ServiceID fDialogServiceID;
223  bool16 fPanelsLoaded;
224  WidgetID fGroupPanelWidgetID;
225  WidgetID fSelectionWidgetID;
226  WidgetID fTitleTextWidgetID;
227  K2Vector<DialogPanelEntry> fDialogPanelList;
228  bool16 fPanelsInitialized;
229  bool16 fAutoResizable;
230 
231 #ifdef DEBUG
232  void DumpPanelEntries();
233 #endif
234 
235 
236 };
237 
238 #endif