dtinfo: remove register keyword
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / Other / WindowSystemMotif.hh
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /*
24  * $XConsortium: WindowSystemMotif.hh /main/15 1996/11/27 12:29:47 rcs $
25  * 
26  * Copyright (c) 1991 HaL Computer Systems, Inc.  All rights reserved.
27  * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28  * States.  Use of a copyright notice is precautionary only and does not
29  * imply publication or disclosure.
30  * 
31  * This software contains confidential information and trade secrets of HaL
32  * Computer Systems, Inc.  Use, disclosure, or reproduction is prohibited
33  * without the prior express written permission of HaL Computer Systems, Inc.
34  * 
35  *                         RESTRICTED RIGHTS LEGEND
36  * Use, duplication, or disclosure by the Government is subject to
37  * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38  * Technical Data and Computer Software clause at DFARS 252.227-7013.
39  *                        HaL Computer Systems, Inc.
40  *                  1315 Dell Avenue, Campbell, CA  95008
41  * 
42  */
43
44 #include <WWL/WApplicationShell.h>
45 #include "Other/AppPrintData.hh"
46
47 enum WaitState {
48     WS_ON,
49     WS_OFF
50 };
51
52 //  VideoShell structure definition
53  
54 typedef struct _VideoShell
55 {
56     Widget widget;
57     Boolean print_only;
58     String file_name;
59     Boolean hierarchy;
60     String printer;
61     int copies;
62     String paper_size;
63     Boolean silent;
64 } VideoShell;
65
66 typedef void _DtHelpDeSelectAll_t(_WidgetRec*,_XEvent*,char**,unsigned*);
67 typedef _DtHelpDeSelectAll_t * DeSelectAll_ptr;
68 typedef void _DtHelpSelectAll_t(_WidgetRec*,_XEvent*,char**,unsigned*);
69 typedef _DtHelpSelectAll_t * SelectAll_ptr;
70 typedef void _DtHelpActivateLink_t(_WidgetRec*,_XEvent*,char**,unsigned*);
71 typedef _DtHelpActivateLink_t * ActivateLink_ptr;
72 typedef void _DtHelpCopyAction_t(_WidgetRec*,_XEvent*,char**,unsigned*);
73 typedef _DtHelpCopyAction_t * CopyAction_ptr;
74 typedef void _DtHelpPageUpOrDown_t(_WidgetRec*,_XEvent*,char**,unsigned*);
75 typedef _DtHelpPageUpOrDown_t * PageUpOrDown_ptr;
76 typedef void _DtHelpPageLeftOrRight_t(_WidgetRec*,_XEvent*,char**,unsigned*);
77 typedef _DtHelpPageLeftOrRight_t * PageLeftOrRight_ptr;
78 typedef void _DtHelpNextLink_t(_WidgetRec*,_XEvent*,char**,unsigned*);
79 typedef _DtHelpNextLink_t * NextLink_ptr;
80 typedef void XmuCvtStringToGravity_t(XrmValue*,unsigned*,XrmValue*,XrmValue*);
81 typedef XmuCvtStringToGravity_t * XmuCvtStringToGravity_ptr;
82
83 extern "C"
84 {
85   typedef void core_dump_handler_t(int signal_number);
86   typedef core_dump_handler_t * core_dump_handler_ptr;
87   typedef void interrupt_handler_t(int signal_number);
88   typedef interrupt_handler_t * interrupt_handler_ptr;
89   typedef int xevent_error_aborter_t(Display *display,XErrorEvent* error_event);
90   typedef xevent_error_aborter_t * xevent_error_aborter_ptr;
91 }
92
93 class WindowGeometry;
94
95 class WindowSystem : public WWL, public FolioObject
96 {
97   struct CursorStackElement
98     {
99       Cursor cursor;            // Cursor set at this stack level. 
100       Widget exception;         // Any exception to this cursor. 
101     };
102 public:  // functions
103   
104   // Constructing
105   WindowSystem (int &argc, char *argv[]);
106   
107   // Destructing 
108   ~WindowSystem();              
109
110   // Initialization
111   void init();
112   
113   // Accessing
114   XtAppContext          app_context(){ return f_application_context ; } 
115   XtAppContext          applicationContext() { return app_context(); }
116   AppPrintData *        GetAppPrintData() { return f_AppPrintData; };
117
118   WApplicationShell &toplevel();
119   WApplicationShell &printToplevel();
120   WApplicationShell &onlineToplevel();
121   Display              *display();
122   Screen               *screen();
123
124   Boolean  printing();
125   Display              *printDisplay();
126   Display              *onlineDisplay();
127   void                 setPrintDisplay(Widget widget);
128   void                 setPrinting(Boolean state);
129   VideoShell           *videoShell();
130   Atom WM_DELETE_WINDOW()
131     { return f_wm_delete_window; }
132   
133   Pixmap locked_pixmap(Widget w);
134   Pixmap unlocked_pixmap(Widget w);
135   Pixmap semilocked_pixmap(Widget w);
136   
137   Pixmap  default_pixmap (Dimension *width, Dimension *height);
138   // NOTE: until we get a real detached pixmap, use default
139   Pixmap  detached_pixmap(Dimension *width, Dimension *height);
140   
141   static WindowSystem &window_system()
142     { return (*f_window_system); }
143   
144   // utility 
145   XmString make_space(int num_pixels, Widget w);
146   
147   void beep()
148     { XBell (f_display, 0); }
149
150   void show_all_windows();
151
152   // use this only after a fork!!
153   void close_display_connection();
154   
155   // Color and Preferences
156   
157   // get_color returns 0 for failure 
158   unsigned long get_color(const char *colorval, unsigned long &pixel) const ;
159   
160   // Execution
161   void          run();
162   
163   Cursor create_cursor (const char *filename);
164   
165   void register_shell (WShell *);
166   void register_full_modal_shell (WShell *);
167   void register_primary_modal_shell (WShell *);
168   void set_cursor (Cursor cursor, Widget exception = NULL);
169   void reset_cursor (WCallback *wcb = NULL);
170   void full_modal_cursor (WCallback *wcb = NULL);
171   void primary_modal_cursor (WCallback *wcb = NULL);
172   void wait_cursor()
173     { set_cursor (f_wait_cursor); }
174   
175   // NOTE: replace calls to set_wait_state with other calls 
176   void      set_wait_state (WaitState state)
177     { if (state == WS_ON) wait_cursor(); else reset_cursor(); }
178   
179   // Get bool value from resource file
180   bool get_boolean_app_resource (const char *name)
181     { return (get_boolean_default (name)); }
182   
183   bool get_boolean_default (const char *name);
184   int get_int_default (const char *name);
185   const char *get_string_default (const char *name);
186   const WindowGeometry &get_geometry_default (const char *name);
187 #if 1
188   Pixel get_color_default(const char *name);
189 #endif  
190   // Get message from resource file
191   char *get_message(const char *message_name);
192   
193   void update_display();
194
195   bool nofonts()
196     { return f_nofonts; }
197
198   XmFontListEntry dtinfo_font();
199   XmFontListEntry dtinfo_space_font();
200
201 private: // functions
202   void unregister_shell (WCallback *);
203   static void core_dump_handler (int signal_number);
204   static void interrupt_handler (int signal_number); 
205  
206   Pixmap        read_pixmap(const char *name,
207                             Dimension *width,
208                             Dimension *height);
209   
210 protected: // variables
211   int                  *f_argc;
212   char                **f_argv;
213   WApplicationShell     f_toplevel;
214   Display              *f_display;
215   Display              *f_print_display;
216   Boolean               f_printing;
217   Screen               *f_screen;
218   Cursor                f_wait_cursor;
219   Cursor                f_modal_cursor;
220   Cursor                f_bomb_cursor;
221   Atom                  f_wm_delete_window;
222   Pixmap                f_locked_pixmap;
223   Pixmap                f_unlocked_pixmap;
224   Pixmap                f_semilocked_pixmap;
225   Pixmap                f_default_pixmap;
226   Pixmap                f_default_print_pixmap;
227   // Node Pixmaps - default and detached 
228   Dimension             f_defpix_width;
229   Dimension             f_defpix_height;
230   Dimension             f_print_defpix_width;
231   Dimension             f_print_defpix_height;
232   Pixmap                f_detached_pixmap ;
233   Dimension             f_detached_width ;
234   Dimension             f_detached_height ;
235   List                  f_shell_list;
236   CursorStackElement    f_cursor_stack[16];
237   short                 f_cursor_stack_pos;
238   bool                  f_nofonts;
239   static WindowSystem  *f_window_system;
240   AppPrintData *        f_AppPrintData;   
241   VideoShell * f_video_shell;        
242   WApplicationShell     f_print_toplevel;
243   Screen               *f_print_screen;
244   XmFontListEntry       f_dtinfo_font;
245   XmFontListEntry       f_dtinfo_space_font;
246 public:
247   XtAppContext          f_application_context;
248
249 };
250
251
252 inline WindowSystem &
253 window_system()
254 {
255   return (WindowSystem::window_system());
256 }
257
258
259 class Wait_Cursor : public Destructable
260 {
261 public:
262   Wait_Cursor()
263     { window_system().set_wait_state (WS_ON); }
264   ~Wait_Cursor()
265     { window_system().set_wait_state (WS_OFF); }
266 };
267
268 enum { DTINFO_FONT, DTINFO_SPACE_FONT };
269
270 extern XmFontListEntry dtinfo_font(int);
271