2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: DtMainW.C /main/5 1998/07/24 16:12:56 mgreess $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
26 * (c) Copyright 1993, 1994 International Business Machines Corp. *
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
28 * (c) Copyright 1993, 1994 Novell, Inc. *
32 #include "Application.h"
39 #include "DtWorkArea.h"
40 #include "DtActions.h"
41 #include "DtSetModList.h"
43 #include "HelpSystem.h"
47 #include "dtprintinfomsg.h"
52 static char *GetIcon(AnyUI *obj, PrinterApplicationMode app_mode)
54 if (app_mode == SINGLE_PRINTER)
64 return "FpPrtmg.l.bm";
66 return "FpPrtmg.l.pm";
70 DtMainW::DtMainW(char *category,
73 ContainerType container_type,
74 SelectionType select_type,
76 void *openCallbackData,
77 PreferenceCallback prefCB,
78 void *prefCallbackData,
80 char *fileMenuMnemonic,
81 PrinterApplicationMode _app_mode)
82 : MainWindow(category, p, name, name, GetIcon(p, _app_mode))
91 _openCallbackData = openCallbackData;
93 _openCallbackData = this;
95 _prefCallbackData = prefCallbackData;
97 _prefCallbackData = this;
98 _fileMenuName = fileMenuName;
99 _fileMenuMnemonic = fileMenuMnemonic;
100 _container_type = container_type;
101 _select_type = select_type;
107 action_data = (ActionData **) malloc(sizeof(ActionData *));
114 for (i = 0; i < n_action_data; i++)
116 delete action_data[i]->actionReferenceName;
117 delete action_data[i];
122 void DtMainW::DisplayHelp(char *location_id, char *volume)
126 snprintf(old_msg, sizeof(old_msg), "%s", status_line->Name());
127 status_line->Name(MESSAGE(GettingHelpL));
131 char *title = new char[120];
132 sprintf(title, "%s - %s", Name(), MESSAGE(HelpL));
134 helpSystem = new HelpSystem(this, title, volume, location_id);
135 helpSystem->Visible(true);
140 helpSystem->Visible(true);
141 helpSystem->Refresh();
142 helpSystem->HelpVolume(volume, location_id);
144 status_line->Name(old_msg);
145 WorkingCursor(false);
146 helpSystem->ToFront();
149 void DtMainW::Initialize()
151 mbar = new MenuBar(this);
152 Container *form = new DtWorkArea((char *) Category(), this, (char *)Name(),
154 container = new DtWorkArea((char *) Category(), form, (char *)Name(),
155 _container_type, _select_type);
157 status_line = new LabelObj(form, " ", LEFT_JUSTIFIED, true);
158 status_line->AttachBottom();
159 status_line->AttachLeft();
160 status_line->AttachRight();
161 container->AttachTop();
162 container->AttachLeft();
163 container->AttachRight();
164 container->AttachBottom(status_line);
165 if (app_mode == SINGLE_PRINTER)
166 container->WidthHeight(600, 150);
168 container->WidthHeight(600, 400);
171 char *title = new char[100];
172 sprintf(title, MESSAGE(SetOptionsTitleL), Name());
173 setPrefD = new DtSetPref(this, title, container, _prefCB,
177 fileMenu = new DtMenu(mbar, _fileMenuName, _fileMenuMnemonic,
179 exitB = new Button(fileMenu, MESSAGE(ExitChoiceL), PUSH_BUTTON, ExitCB, this,
180 MESSAGE(ExitMnemonicL), MESSAGE(ExitAcceleratorL));
182 actionsMenu = new DtActions(mbar, MESSAGE(SelectedMenuL),
183 MESSAGE(SelectedAcceleratorL));
184 actionsMenu->Active(false);
186 if (app_mode != CONFIG_PRINTERS)
188 viewMenu = new DtMenu(mbar, MESSAGE(ViewMenuL),
189 MESSAGE(ViewAcceleratorL), "ViewMenuDE");
191 setPref = new Button(viewMenu, MESSAGE(SetOptionsChoiceL), PUSH_BUTTON,
192 SetPrefCB, setPrefD, MESSAGE(SetOptionsMnemonicL));
196 helpMenu = new DtMenu(mbar, MESSAGE(HelpChoiceL), MESSAGE(HelpMnemonicL),
198 introduction = new Button(helpMenu, MESSAGE(OverviewChoiceL), PUSH_BUTTON,
199 HelpCB, this, MESSAGE(OverviewMnemonicL));
201 tasks = new Button(helpMenu, MESSAGE(TaskChoiceL), PUSH_BUTTON, TasksCB,
202 this, MESSAGE(TaskMnemonicL));
203 reference = new Button(helpMenu, MESSAGE(ReferenceChoiceL), PUSH_BUTTON,
204 ReferenceCB, this, MESSAGE(ReferenceMnemonicL));
205 onWindow = new Button(helpMenu, MESSAGE(OnItemChoiceL), PUSH_BUTTON,
206 OnItemCB, this, MESSAGE(OnItemMnemonicL));
208 usingHelp = new Button(helpMenu, MESSAGE(UsingHelpChoiceL), PUSH_BUTTON,
209 UsingHelpCB, this, MESSAGE(UsingHelpMnemonicL));
212 if (app_mode == PRINT_MANAGER)
213 tmp = MESSAGE(AboutChoice1L);
214 else if (app_mode == SINGLE_PRINTER)
215 tmp = MESSAGE(AboutChoice2L);
217 tmp = MESSAGE(AboutChoice3L);
218 version = new Button(helpMenu, tmp, PUSH_BUTTON, AboutCB,
219 this, MESSAGE(AboutMnemonicL));
221 mbar->SetHelpMenu(helpMenu);
224 void DtMainW::SetPrefCB(void *data)
226 DtSetPref *obj = (DtSetPref *) data;
231 void DtMainW::ExitCB(void *data)
233 Application *app = (Application *)((BaseUI *)data)->Parent();
235 delete (BaseObj *)((BaseUI *)data)->ApplicationData;
236 delete ((BaseUI *)data)->Parent();
240 void DtMainW::OpenClose(BaseUI *obj)
243 (*_openClose)(_openCallbackData, obj);
246 void DtMainW::DtAddAction(char *name, char *category, char *actionName,
247 ActionCallback callback, void *callback_data,
248 char *mnemonic, char *acceleratorText,
252 if (action1 = actionsMenu->FindByName(name))
253 action1->Category(NULL);
255 actionsMenu->AddAction(name, category, actionName, callback,
256 callback_data, mnemonic, acceleratorText,
259 int size = sizeof(ActionData *) * (n_action_data + 1);
260 action_data = (ActionData **) realloc(action_data, size);
261 action_data[n_action_data] = (ActionData *)malloc(sizeof(ActionData));
262 action_data[n_action_data]->actionReferenceName = strdup(actionName);
263 action_data[n_action_data]->callback_data = callback_data;
264 action_data[n_action_data]->actionCallback = callback;
265 Button *action = AddAction(name, category, &DtMainW::ActionCB, NULL,
266 mnemonic, acceleratorText, accelerator);
267 action->ApplicationData = action_data[n_action_data];
271 void DtMainW::DtAddSep(char *category)
273 actionsMenu->AddSep(category);
277 void DtMainW::ActionCB(void *callback_data)
279 Button *action = (Button *) callback_data;
280 DtMainW *window = (DtMainW *)action->Parent()->Parent()->Parent();
281 ActionData *cb = (ActionData *) action->ApplicationData;
282 if (cb->actionCallback)
284 if (window->container->ObjectExists(window->PopupObjectUniqueID))
286 (*cb->actionCallback)(cb->callback_data, window->PopupObject,
287 cb->actionReferenceName);
291 Dialog *dialog = new Dialog(window, (char *)window->Name(),
292 MESSAGE(NotFoundMessageL), INFORMATION,
294 dialog->Visible(true);
299 void DtMainW::HelpCB(void *data)
301 DtMainW * obj = (DtMainW *) data;
302 obj->DisplayHelp("_hometopic");
305 void DtMainW::ReferenceCB(void *data)
307 DtMainW * obj = (DtMainW *) data;
308 obj->DisplayHelp("Reference");
311 void DtMainW::TasksCB(void *data)
313 DtMainW * obj = (DtMainW *) data;
314 obj->DisplayHelp("Tasks");
317 void DtMainW::UsingHelpCB(void *data)
319 DtMainW * obj = (DtMainW *) data;
320 obj->DisplayHelp("_hometopic", "Help4Help");
323 void DtMainW::AboutCB(void *data)
325 DtMainW * obj = (DtMainW *) data;
326 obj->DisplayHelp("_copyright");
329 void DtMainW::OnItemCB(void *data)
331 DtMainW * obj = (DtMainW *) data;
333 obj->ContextualHelp();
336 boolean DtMainW::HandleHelpRequest()
338 if (app_mode == PRINT_MANAGER)
339 DisplayHelp("MainWindowDE");
341 DisplayHelp("PJMainWindowDE");
345 void DtMainW::WorkingCursor(boolean flag)
348 BaseUI **children = Children();
351 if (working_curs == 0)
352 for (i = 0; i < NumChildren(); i++, children++)
353 (*children)->PointerShape(HOUR_GLASS_CURSOR);
359 if (working_curs == 0)
360 for (i = 0; i < NumChildren(); i++, children++)
361 (*children)->PointerShape(LEFT_SLANTED_ARROW_CURSOR);
366 boolean DtMenu::HandleHelpRequest()
368 ((DtMainW *)Parent()->Parent())->DisplayHelp(location_id);