1 // $Id: xxWindow.hh 2641 2007-09-02 21:31:02Z flaterco $
2 
3 /*  xxWindow  An XTide window.
4 
5     Copyright (C) 1998  David Flater.
6 
7     This program is free software: you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation, either version 3 of the License, or
10     (at your option) any later version.
11 
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 class xxWindow: public xxRedrawable {
22 public:
23 
24   // Normal constructor for a window needing a popup and maybe a
25   // container.
26   enum ContainerType {noContainer, boxContainer, formContainer};
27   xxWindow (const xxWidget &parent,
28             ContainerType containerType,
29             XtGrabKind grabKind = XtGrabNone);
30 
31   // One-time-only constructor to produce a top-level application
32   // shell, which is weird and different in lots of ways.  Command
33   // line switches recognized by X11 are removed from argc and argv.
34   xxWindow (int &argc, char **argv);
35 
36   ~xxWindow();
37 
38 
39   virtual void realize();             // Show the window.
40   void move (const Dstr &geometry);   // Move the window.
41   virtual void unrealize();           // Hide the window.
42   void globalRedraw();                // See xxRedrawable.
43 
44   // Get rid of the window (almost).
45   // The returned pointer must be deleted by the caller.
46   // It is considered harmful for objects to delete themselves.
47   // See xxRoot and xxLocationList for why this can't be simpler.
48   virtual xxWindow * const dismiss() warnUnusedResult;
49 
50   // Set to true to prevent user from closing window at inopportune times.
51   bool noClose;
52 
53 protected:
54   const ContainerType _containerType;
55   const XtGrabKind _grabKind;
56   std::auto_ptr<xxWidget> popup, container;
57   Window _iconWindow;
58   bool _isRealized;
59 
60   // Radius (in pixels) affected by right mouse click in location
61   // choosers.
62   static const unsigned rightClickRadius = 15U;
63 
64   // How far (in pixels) outside the location chooser window do we
65   // draw to avoid chopping off lines.
66   static const int antiChopMargin = 50;
67 
68 
69   // Install default icon.  Only works on old fashioned window managers.
70   void setIcon();
71   void setTitle (const Dstr &title);  // Set window title and icon name.
72 
73   // Restrict resizing of the window.  Doable only while the window is
74   // realized; is forgotten when the window is unrealized.
75   void fixSize();
76   void widthNoSmaller();
77   void setMinSize (Dimension width, Dimension height);
78 
79   // If possible, use the NET_WM protocol to set the window title
80   // correctly on systems expecting a UTF-8 encoding.  Indirection
81   // through _title necessary because the NET_WM property can only be
82   // changed while the window is realized.
83   Dstr _title;
84   void setTitle_NET_WM();
85 };
86 
87 // Cleanup2006 Done
88