File: xxRoot.hh

package info (click to toggle)
xtide 2.9.5-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,996 kB
  • ctags: 2,141
  • sloc: cpp: 20,379; sh: 1,044; makefile: 224; yacc: 114; lex: 58
file content (110 lines) | stat: -rw-r--r-- 4,220 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// $Id: xxRoot.hh 2641 2007-09-02 21:31:02Z flaterco $

/*  xxRoot  XTide "root" window (control panel, top-level logic)

    Copyright (C) 1998  David Flater.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

class xxHelpBox;
class xxGraphMode;
class xxTextMode;
class xxClock;

class xxRoot: public xxWindow, public xxMouseWheelViewport {
public:

  // There can be only one instance of xxRoot.
  xxRoot (int argc, char **argv);

  // No destructor because the single instance lasts until exit().

  void run(); // Does not return.

  // Methods to create independent new windows (those using
  // XtGrabNone).  The preferred way for any other class to create
  // such a window is by invoking one of these methods on
  // Global::root.  The resulting window will be a child of root.

  // Those methods that get mutable Station *station assume ownership
  // of the station.

  xxHelpBox * const newHelpBox     (const Dstr &help);
  xxHelpBox * const newAbout       (const Station *station);
  xxGraphMode * const newGraph     (Station *station, Timestamp t);
  xxGraphMode * const newGraph     (const StationRef &stationRef);   // t = now
  xxTextMode * const newPlain      (Station *station, Timestamp t);
  xxTextMode * const newRaw        (Station *station, Timestamp t);
  xxTextMode * const newMediumRare (Station *station, Timestamp t);
  xxClock * const newClock         (Station *station,
				    xxClock::ButtonsStyle buttonsStyle);
  xxClock * const newClock         (Station *station);  // style per settings
  void newMap();
  void newGlobe();
  void newChooser();        // Map or Globe according to settings.

  // Other methods.

  void realize();              // Show control panel.
  void unrealize();            // Hide control panel.
  xxWindow * const dismiss();  // Hide control panel, return NULL (no delete).
  void globalRedraw();         // Redraw all windows.

  // Apply and maybe save settings.  These operations are combined to
  // ensure that settings will not be saved unless they can be
  // successfully applied.
  enum ApplyProtocol {justApply, applyAndSave};
  void apply (ApplyProtocol protocol);

  void dup (xxWindow *child);     // Add a child window and call dup().
  void release (xxWindow *child); // Remove a child window and call release().

  // This is needed for the error callback from barf.  Other classes
  // are not expected to invoke it directly.  Does not return if
  // fatality is Fatal.
  void newErrorBox (const Dstr &errmsg, Error::ErrType fatality);

protected:

  // xxRoot keeps track of all windows and propagates globalRedraw to
  // them all when its own globalRedraw is invoked.
  std::set<xxWindow*> children;

  // The number of popups is one more than children.size() when the
  // control panel is visible; otherwise they are equal.
  unsigned popupCount;

  // No need for auto_ptr here because xxRoot remains in scope until exit().
  xxWidget *viewport, *viewBox, *dismissButton, *helpButton, *label,
           *applyButton, *saveButton;

  // Map from switchName to a pointer to an xxMultiChoice, xxHorizDialog,
  // or xxUnsignedChooser, as appropriate.
  BetterMap<const Dstr, xxRedrawable*> dialogs;


  // Start windows as requested on command line.
  void commandLineWindows();

  // This replaces XtAppMainLoop.  Does not return if protocol is
  // loopForever.
  enum HandleXEventsReturnProtocol {returnWhenIdle, loopForever};
  void handleXEvents (HandleXEventsReturnProtocol protocol);

  void dup();     // Increment count of popups.
  void release(); // Decrement count of popups, exit if now zero.
};

// Cleanup2006 Done