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