1 /* $TOG: DtMainW.C /main/5 1998/07/24 16:12:56 mgreess $ */
3 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
4 * (c) Copyright 1993, 1994 International Business Machines Corp. *
5 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
6 * (c) Copyright 1993, 1994 Novell, Inc. *
10 #include "Application.h"
17 #include "DtWorkArea.h"
18 #include "DtActions.h"
19 #include "DtSetModList.h"
21 #include "HelpSystem.h"
25 #include "dtprintinfomsg.h"
30 static char *GetIcon(AnyUI *obj, PrinterApplicationMode app_mode)
32 if (app_mode == SINGLE_PRINTER)
42 return "FpPrtmg.l.bm";
44 return "FpPrtmg.l.pm";
48 DtMainW::DtMainW(char *category,
51 ContainerType container_type,
52 SelectionType select_type,
54 void *openCallbackData,
55 PreferenceCallback prefCB,
56 void *prefCallbackData,
58 char *fileMenuMnemonic,
59 PrinterApplicationMode _app_mode)
60 : MainWindow(category, p, name, name, GetIcon(p, _app_mode))
69 _openCallbackData = openCallbackData;
71 _openCallbackData = this;
73 _prefCallbackData = prefCallbackData;
75 _prefCallbackData = this;
76 _fileMenuName = fileMenuName;
77 _fileMenuMnemonic = fileMenuMnemonic;
78 _container_type = container_type;
79 _select_type = select_type;
85 action_data = (ActionData **) malloc(sizeof(ActionData *));
92 for (i = 0; i < n_action_data; i++)
94 delete action_data[i]->actionReferenceName;
95 delete action_data[i];
100 void DtMainW::DisplayHelp(char *location_id, char *volume)
104 strcpy(old_msg, status_line->Name());
105 status_line->Name(MESSAGE(GettingHelpL));
109 char *title = new char[120];
110 sprintf(title, "%s - %s", Name(), MESSAGE(HelpL));
112 helpSystem = new HelpSystem(this, title, volume, location_id);
113 helpSystem->Visible(true);
118 helpSystem->Visible(true);
119 helpSystem->Refresh();
120 helpSystem->HelpVolume(volume, location_id);
122 status_line->Name(old_msg);
123 WorkingCursor(false);
124 helpSystem->ToFront();
127 void DtMainW::Initialize()
129 mbar = new MenuBar(this);
130 Container *form = new DtWorkArea((char *) Category(), this, (char *)Name(),
132 container = new DtWorkArea((char *) Category(), form, (char *)Name(),
133 _container_type, _select_type);
135 status_line = new LabelObj(form, " ", LEFT_JUSTIFIED, true);
136 status_line->AttachBottom();
137 status_line->AttachLeft();
138 status_line->AttachRight();
139 container->AttachTop();
140 container->AttachLeft();
141 container->AttachRight();
142 container->AttachBottom(status_line);
143 if (app_mode == SINGLE_PRINTER)
144 container->WidthHeight(600, 150);
146 container->WidthHeight(600, 400);
149 char *title = new char[100];
150 sprintf(title, MESSAGE(SetOptionsTitleL), Name());
151 setPrefD = new DtSetPref(this, title, container, _prefCB,
155 fileMenu = new DtMenu(mbar, _fileMenuName, _fileMenuMnemonic,
157 exitB = new Button(fileMenu, MESSAGE(ExitChoiceL), PUSH_BUTTON, ExitCB, this,
158 MESSAGE(ExitMnemonicL), MESSAGE(ExitAcceleratorL));
160 actionsMenu = new DtActions(mbar, MESSAGE(SelectedMenuL),
161 MESSAGE(SelectedAcceleratorL));
162 actionsMenu->Active(false);
164 if (app_mode != CONFIG_PRINTERS)
166 viewMenu = new DtMenu(mbar, MESSAGE(ViewMenuL),
167 MESSAGE(ViewAcceleratorL), "ViewMenuDE");
169 setPref = new Button(viewMenu, MESSAGE(SetOptionsChoiceL), PUSH_BUTTON,
170 SetPrefCB, setPrefD, MESSAGE(SetOptionsMnemonicL));
174 helpMenu = new DtMenu(mbar, MESSAGE(HelpChoiceL), MESSAGE(HelpMnemonicL),
176 introduction = new Button(helpMenu, MESSAGE(OverviewChoiceL), PUSH_BUTTON,
177 HelpCB, this, MESSAGE(OverviewMnemonicL));
179 tasks = new Button(helpMenu, MESSAGE(TaskChoiceL), PUSH_BUTTON, TasksCB,
180 this, MESSAGE(TaskMnemonicL));
181 reference = new Button(helpMenu, MESSAGE(ReferenceChoiceL), PUSH_BUTTON,
182 ReferenceCB, this, MESSAGE(ReferenceMnemonicL));
183 onWindow = new Button(helpMenu, MESSAGE(OnItemChoiceL), PUSH_BUTTON,
184 OnItemCB, this, MESSAGE(OnItemMnemonicL));
186 usingHelp = new Button(helpMenu, MESSAGE(UsingHelpChoiceL), PUSH_BUTTON,
187 UsingHelpCB, this, MESSAGE(UsingHelpMnemonicL));
190 if (app_mode == PRINT_MANAGER)
191 tmp = MESSAGE(AboutChoice1L);
192 else if (app_mode == SINGLE_PRINTER)
193 tmp = MESSAGE(AboutChoice2L);
195 tmp = MESSAGE(AboutChoice3L);
196 version = new Button(helpMenu, tmp, PUSH_BUTTON, AboutCB,
197 this, MESSAGE(AboutMnemonicL));
199 mbar->SetHelpMenu(helpMenu);
202 void DtMainW::SetPrefCB(void *data)
204 DtSetPref *obj = (DtSetPref *) data;
209 void DtMainW::ExitCB(void *data)
211 Application *app = (Application *)((BaseUI *)data)->Parent();
213 delete (BaseObj *)((BaseUI *)data)->ApplicationData;
214 delete ((BaseUI *)data)->Parent();
218 void DtMainW::OpenClose(BaseUI *obj)
221 (*_openClose)(_openCallbackData, obj);
224 void DtMainW::DtAddAction(char *name, char *category, char *actionName,
225 ActionCallback callback, void *callback_data,
226 char *mnemonic, char *acceleratorText,
230 if (action1 = actionsMenu->FindByName(name))
231 action1->Category(NULL);
233 actionsMenu->AddAction(name, category, actionName, callback,
234 callback_data, mnemonic, acceleratorText,
237 int size = sizeof(ActionData *) * (n_action_data + 1);
238 action_data = (ActionData **) realloc(action_data, size);
239 action_data[n_action_data] = (ActionData *)malloc(sizeof(ActionData));
240 action_data[n_action_data]->actionReferenceName = strdup(actionName);
241 action_data[n_action_data]->callback_data = callback_data;
242 action_data[n_action_data]->actionCallback = callback;
243 Button *action = AddAction(name, category, &DtMainW::ActionCB, NULL,
244 mnemonic, acceleratorText, accelerator);
245 action->ApplicationData = action_data[n_action_data];
249 void DtMainW::DtAddSep(char *category)
251 actionsMenu->AddSep(category);
255 void DtMainW::ActionCB(void *callback_data)
257 Button *action = (Button *) callback_data;
258 DtMainW *window = (DtMainW *)action->Parent()->Parent()->Parent();
259 ActionData *cb = (ActionData *) action->ApplicationData;
260 if (cb->actionCallback)
262 if (window->container->ObjectExists(window->PopupObjectUniqueID))
264 (*cb->actionCallback)(cb->callback_data, window->PopupObject,
265 cb->actionReferenceName);
269 Dialog *dialog = new Dialog(window, (char *)window->Name(),
270 MESSAGE(NotFoundMessageL), INFORMATION,
272 dialog->Visible(true);
277 void DtMainW::HelpCB(void *data)
279 DtMainW * obj = (DtMainW *) data;
280 obj->DisplayHelp("_hometopic");
283 void DtMainW::ReferenceCB(void *data)
285 DtMainW * obj = (DtMainW *) data;
286 obj->DisplayHelp("Reference");
289 void DtMainW::TasksCB(void *data)
291 DtMainW * obj = (DtMainW *) data;
292 obj->DisplayHelp("Tasks");
295 void DtMainW::UsingHelpCB(void *data)
297 DtMainW * obj = (DtMainW *) data;
298 obj->DisplayHelp("_hometopic", "Help4Help");
301 void DtMainW::AboutCB(void *data)
303 DtMainW * obj = (DtMainW *) data;
304 obj->DisplayHelp("_copyright");
307 void DtMainW::OnItemCB(void *data)
309 DtMainW * obj = (DtMainW *) data;
311 obj->ContextualHelp();
314 boolean DtMainW::HandleHelpRequest()
316 if (app_mode == PRINT_MANAGER)
317 DisplayHelp("MainWindowDE");
319 DisplayHelp("PJMainWindowDE");
323 void DtMainW::WorkingCursor(boolean flag)
326 BaseUI **children = Children();
329 if (working_curs == 0)
330 for (i = 0; i < NumChildren(); i++, children++)
331 (*children)->PointerShape(HOUR_GLASS_CURSOR);
337 if (working_curs == 0)
338 for (i = 0; i < NumChildren(); i++, children++)
339 (*children)->PointerShape(LEFT_SLANTED_ARROW_CURSOR);
344 boolean DtMenu::HandleHelpRequest()
346 ((DtMainW *)Parent()->Parent())->DisplayHelp(location_id);