]> git.saurik.com Git - wxWidgets.git/blob - src/motif/mdi/lib/XsMotifWindow.h
minor clean up
[wxWidgets.git] / src / motif / mdi / lib / XsMotifWindow.h
1 /*
2 Copyright (C) 1996 Scott W. Sadler
3 All rights reserved.
4 */
5
6 /*
7 XsMotifWindow.h
8
9 History
10 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
11 Created
12 */
13
14 #ifndef XSMOTIFWINDOW_H
15 #define XSMOTIFWINDOW_H
16
17 // Includes
18
19 #include <Xm/Xm.h>
20 #include "XsMDIWindow.h"
21
22 // Forward declarations
23
24 class XsMotifWindow;
25
26 /*
27 ----------------------------------------------------------------------------
28 _XsMotifBase class
29 */
30
31 class _XsMotifBase : public XsComponent {
32
33 public:
34
35 // Destructor
36
37 virtual ~_XsMotifBase ( );
38
39 // Window actions
40
41 virtual void show ( );
42
43 // Class name
44
45 virtual const char *className ( ) const;
46
47 protected:
48
49 // Protected constructor
50
51 _XsMotifBase (const char *name, XsMotifWindow *win);
52
53 // Component life-cycle
54
55 virtual void _componentDestroyed ( );
56
57 // Utilities
58
59 void _drawShadows (Position x, Position y, Dimension width,
60 Dimension height, Dimension thick, Boolean reverse = False);
61
62 void _drawLine (Position x1, Position y1, Position x2, Position y2, GC &gc);
63
64 // Implementation
65
66 XsMotifWindow *_win;
67
68 GC _topShadowGC;
69 GC _bottomShadowGC;
70
71 // Event handlers
72
73 virtual void _map ( );
74
75 // Internal Event handlers
76
77 static void _mapEventHandler (Widget, XtPointer, XEvent*, Boolean*);
78 };
79
80 /*
81 ----------------------------------------------------------------------------
82 _XsMotifComponent class
83 */
84
85 class _XsMotifComponent : public _XsMotifBase {
86
87 public:
88
89 // Destructor
90
91 virtual ~_XsMotifComponent ( );
92
93 // Enumerations
94
95 enum Cursors {
96 TopCursor = 0, BottomCursor, LeftCursor, RightCursor,
97 TopLeftCursor, TopRightCursor, BottomLeftCursor,
98 BottomRightCursor, NumCursors };
99
100 // Class name
101
102 virtual const char *className ( ) const;
103
104 protected:
105
106 // Protected constructor
107
108 _XsMotifComponent (const char *name, XsMotifWindow *win, Widget parent = 0);
109
110 // Cursors
111
112 static Cursor _cursors[NumCursors];
113
114 // Component parameters
115
116 Dimension _borderSize;
117 Dimension _buttonSize;
118 Dimension _cornerSize;
119
120 // Event handlers
121
122 virtual void _expose (XEvent*) = 0;
123 virtual void _input (XEvent*);
124
125 private:
126
127 // Internal Event handlers
128
129 static void _exposeEventHandler (Widget, XtPointer, XEvent*, Boolean*);
130 static void _inputEventHandler (Widget, XtPointer, XEvent*, Boolean*);
131
132 // Resources
133
134 static XtResource _resourceList[];
135
136 static int _mutex;
137 };
138
139 /*
140 ----------------------------------------------------------------------------
141 _XsMotifCorner class
142 */
143
144 class _XsMotifCorner : public _XsMotifComponent {
145
146 public:
147
148 // Enumerations
149
150 enum Corner { TopLeft = 0, TopRight, BottomLeft, BottomRight, Max };
151
152 // Constructor/Destructor
153
154 _XsMotifCorner (const char *name, XsMotifWindow *win, Corner corner);
155 virtual ~_XsMotifCorner ( );
156
157 // Class name
158
159 virtual const char *className ( ) const;
160
161 protected:
162
163 // Implementation
164
165 Corner _corner;
166
167 // Event handlers
168
169 virtual void _expose (XEvent*);
170 virtual void _input (XEvent*);
171 virtual void _map ( );
172 };
173
174 /*
175 ----------------------------------------------------------------------------
176 _XsMotifSide class
177 */
178
179 class _XsMotifSide : public _XsMotifComponent {
180
181 public:
182
183 // Enumerations
184
185 enum Side { Top = 0, Bottom, Left, Right, Max };
186
187 // Constructor/Destructor
188
189 _XsMotifSide (const char *name, XsMotifWindow *win, Side side);
190 virtual ~_XsMotifSide ( );
191
192 // Class name
193
194 virtual const char *className ( ) const;
195
196 protected:
197
198 // Implementation
199
200 Side _side;
201
202 int _lastW;
203 int _lastH;
204
205 // Event handlers
206
207 virtual void _expose (XEvent*);
208 virtual void _input (XEvent*);
209 virtual void _map ( );
210 virtual void _configure (XEvent *);
211
212 private:
213
214 // Callbacks
215
216 static void _configureEventHandler (Widget, XtPointer, XEvent*, Boolean*);
217 };
218
219 /*
220 ----------------------------------------------------------------------------
221 _XsMotifButton class
222 */
223
224 class _XsMotifButton : public _XsMotifComponent {
225
226 public:
227
228 // Enumerations
229
230 enum Button { Menu = 0, Minimize, Maximize, Max };
231
232 // Constructor/Destructor
233
234 _XsMotifButton (const char *name, XsMotifWindow *win, Button button);
235 virtual ~_XsMotifButton ( );
236
237 // Utilities
238
239 virtual void redraw ( );
240
241 // Class name
242
243 virtual const char *className ( ) const;
244
245 protected:
246
247 // Implementation
248
249 Boolean _pressed;
250 Button _button;
251
252 // Event handlers
253
254 virtual void _expose (XEvent*);
255 virtual void _input (XEvent*);
256 virtual void _map ( );
257 };
258
259 /*
260 ----------------------------------------------------------------------------
261 _XsMotifTitle class
262 */
263
264 class _XsMotifTitle : public _XsMotifComponent {
265
266 public:
267
268 // Constructor/Destructor
269
270 _XsMotifTitle (const char *name, XsMotifWindow *win);
271 virtual ~_XsMotifTitle ( );
272
273 // Title string
274
275 void setTitle (const char *name);
276 const char *title ( ) const;
277
278 // Class name
279
280 virtual const char *className ( ) const;
281
282 protected:
283
284 // Implementation
285
286 Boolean _pressed;
287 String _titleString;
288 GC _fontGC;
289
290 XFontStruct *_titleFont;
291
292 int _lastW;
293 int _lastH;
294
295 // Component life-cycle
296
297 virtual void _componentDestroyed ( );
298
299 // Utilities
300
301 virtual void _redraw ( );
302
303 // Event handlers
304
305 virtual void _expose (XEvent*);
306 virtual void _input (XEvent*);
307 virtual void _map ( );
308 virtual void _configure (XEvent*);
309
310 private:
311
312 // Callbacks
313
314 static void _configureEventHandler (Widget, XtPointer, XEvent*, Boolean*);
315
316 // Resources
317
318 static XtResource _resourceList[];
319 };
320
321 // Inline member functions
322
323 inline const char *_XsMotifTitle::title ( ) const
324 {
325 return (_titleString);
326 }
327
328 /*
329 ----------------------------------------------------------------------------
330 _XsMotifIcon class
331 */
332
333 class _XsMotifIcon : public _XsMotifComponent {
334
335 public:
336
337 // Constructor/Destructor
338
339 _XsMotifIcon (const char *name, XsMotifWindow *win, Widget parent);
340 virtual ~_XsMotifIcon ( );
341
342 // Window operations
343
344 virtual void show ( );
345
346 // Icon name/pixmap
347
348 void setIconName (const char *name);
349 const char *iconName ( ) const;
350
351 void setPixmap (Pixmap pm);
352 Pixmap pixmap ( ) const;
353
354 // Class name
355
356 virtual const char *className ( ) const;
357
358 protected:
359
360 // Implementation
361
362 GC _fontGC;
363 GC _pixmapGC;
364
365 Dimension _iconSize;
366 String _iconName;
367 XFontStruct *_iconFont;
368 Pixmap _pixmap;
369 Boolean _freePixmap;
370
371 Dimension _width, _height;
372 Position _iconX, _iconY;
373 Boolean _placed;
374
375 // Component life-cycle
376
377 virtual void _componentDestroyed ( );
378
379 // Event handlers
380
381 virtual void _expose (XEvent*);
382 virtual void _input (XEvent*);
383 virtual void _map ( );
384
385 private:
386
387 // Resources
388
389 static XtResource _resourceList[];
390 };
391
392 // Inline member-functions
393
394 inline const char *_XsMotifIcon::iconName ( ) const
395 {
396 return (_iconName);
397 }
398
399 inline Pixmap _XsMotifIcon::pixmap ( ) const
400 {
401 return (_pixmap);
402 }
403
404 /*
405 ----------------------------------------------------------------------------
406 _XsMotifMenu class
407 */
408
409 class _XsMotifMenu : public _XsMotifBase {
410
411 public:
412
413 // Constructor/Destructor
414
415 _XsMotifMenu (const char *name, XsMotifWindow *win);
416 virtual ~_XsMotifMenu ( );
417
418 // Utilities
419
420 virtual void popup (Boolean atPointer = True);
421
422 // Enumerations
423
424 enum Item {
425 NoItem = -1, Restore, Move, Size, Minimize,
426 Maximize, Raise, Lower, Close, Num
427 };
428
429 // Class name
430
431 virtual const char *className ( ) const;
432
433 protected:
434
435 // Dimensions
436
437 enum { ShadowThickness = 1 };
438 enum { VertTextOffset = 3 };
439 enum { HorizTextOffset = 10 };
440
441 // Implementation
442
443 static Cursor _cursor;
444 static Pixmap _stipple;
445 static Display *_dpy;
446
447 Boolean _saveUnder;
448
449 String _strings[Num];
450 XFontStruct *_menuFont;
451
452 GC _fontGC;
453 GC _grayGC;
454 GC _backgroundGC;
455
456 Item _curItem;
457
458 // Component life-cycle
459
460 virtual void _componentDestroyed ( );
461
462 // Menu event processing
463
464 virtual void _processEvents ( );
465
466 // Utilities
467
468 virtual void _processItem (Item item);
469 virtual void _redrawMenu ( );
470
471 void _redrawItem (Item);
472 void _toggleItem (Item, Boolean active = False);
473 Item _trackPointer (XMotionEvent *event);
474
475 // Pointer grabs
476
477 Boolean _grabPointer ( );
478 void _ungrabPointer ( );
479
480 // Event handlers
481
482 virtual void _map ( );
483
484 private:
485
486 // Work procedure
487
488 static Boolean _workProc (XtPointer);
489
490 // Resources
491
492 static XtResource _resourceList[];
493 static int _count;
494 };
495
496
497 /*
498 ----------------------------------------------------------------------------
499 XsMotifWindow class
500 */
501
502 class XsMotifWindow : public XsMDIWindow {
503
504 public:
505
506 // Constructor/Destructor
507
508 XsMotifWindow (const char *name);
509 virtual ~XsMotifWindow ( );
510
511 // Window manipulation
512
513 virtual void raise ( );
514 virtual void lower ( );
515
516 virtual void minimize ( );
517 virtual void maximize ( );
518 virtual void restore ( );
519
520 virtual void close ( );
521
522 // Window and icon strings
523
524 void setTitle (const char *name);
525 const char *title ( ) const;
526
527 void setIconName (const char *name);
528 const char *iconName ( ) const;
529
530 void setPixmap (Pixmap pm);
531 Pixmap pixmap ( ) const;
532
533 // Window icon handle
534
535 Widget icon ( ) const;
536
537 // Menu settings
538
539 void popupMenu (Boolean atPointer = True);
540
541 // Utilities
542
543 Boolean maximized ( ) const;
544 Boolean minimized ( ) const;
545
546 // Position and size
547
548 virtual void setPosition (Position, Position);
549 virtual void setSize (Dimension, Dimension);
550
551 Dimension minWidth ( ) const;
552 Dimension minHeight ( ) const;
553
554 // Class name
555
556 virtual const char *className ( ) const;
557
558 protected:
559
560 // Window creation functions
561
562 virtual void _buildClientArea (Widget parent) = 0;
563 virtual void _createWindow (Widget parent);
564
565 // Window components
566
567 _XsMotifCorner *_corners[_XsMotifCorner::Max];
568 _XsMotifSide *_sides[_XsMotifSide::Max];
569 _XsMotifButton *_buttons[_XsMotifButton::Max];
570 _XsMotifTitle *_title;
571 _XsMotifIcon *_icon;
572 _XsMotifMenu *_menu;
573
574 // Window dimensions
575
576 Dimension _savedWidth, _savedHeight;
577 Position _savedX, _savedY;
578 Dimension _minW, _maxW;
579 Dimension _minH, _maxH;
580
581 // Window parameters
582
583 Boolean _showBorder;
584 Boolean _showResize;
585 Boolean _showTitle;
586 Boolean _showMenu;
587 Boolean _showMinimize;
588 Boolean _showMaximize;
589 Boolean _lowerOnIconify;
590
591 // Window state
592
593 Boolean _maximized;
594 Boolean _minimized;
595
596 // Callbacks
597
598 virtual void _mapEvent ( );
599
600 private:
601
602 // Internal event handlers
603
604 static void _mapEventHandler (Widget, XtPointer, XEvent*, Boolean*);
605
606 // Resources
607
608 static XtResource _resourceList[];
609 };
610
611 // Inline member functions
612
613 inline Boolean XsMotifWindow::maximized ( ) const
614 {
615 return (_maximized);
616 }
617
618 inline Boolean XsMotifWindow::minimized ( ) const
619 {
620 return (_minimized);
621 }
622
623 inline const char *XsMotifWindow::title ( ) const
624 {
625 if (_title != 0)
626 return (_title->title ( ));
627 else
628 return (0);
629 }
630
631 inline const char *XsMotifWindow::iconName ( ) const
632 {
633 if (_icon != 0)
634 return (_icon->iconName ( ));
635 else
636 return (0);
637 }
638
639 inline Pixmap XsMotifWindow::pixmap ( ) const
640 {
641 if (_icon != 0)
642 return (_icon->pixmap ( ));
643 else
644 return (None);
645 }
646
647 inline Widget XsMotifWindow::icon ( ) const
648 {
649 if (_icon != 0)
650 return (_icon->base ( ));
651 else
652 return (0);
653 }
654
655 inline Dimension XsMotifWindow::minWidth ( ) const
656 {
657 return (_minW);
658 }
659
660 inline Dimension XsMotifWindow::minHeight ( ) const
661 {
662 return (_minH);
663 }
664
665 #endif