00001 #ifndef NUB_CLASS 00002 #define NUB_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : nub * 00007 * Author : Chris Koeritz * 00008 * * 00009 * Purpose: * 00010 * * 00011 * This class is the root of all objects that must interact with the * 00012 * windowing system. * 00013 * * 00014 ******************************************************************************* 00015 * Copyright (c) 1991-$now By Author. This program is free software; you can * 00016 * redistribute it and/or modify it under the terms of the GNU General Public * 00017 * License as published by the Free Software Foundation; either version 2 of * 00018 * the License or (at your option) any later version. This is online at: * 00019 * http://www.fsf.org/copyleft/gpl.html * 00020 * Please send any updates to: fred@gruntose.com * 00021 \*****************************************************************************/ 00022 00023 #include "argument_list.h" 00024 #include "definitions_passive.h" 00025 00026 #include <geometric/cartesian_objects.h> 00027 00028 // forward. 00029 class color; 00030 00031 class WP_PASSIVE_CLASS_STYLE nub 00032 { 00033 public: 00034 nub(window_handle parent, window_handle self); 00035 // Creates a nodule for interacting with the windowing system. "parent" 00036 // must be a valid, non-NIL window handle. "self" may be NIL, but must 00037 // be filled in before any function in nub is called. If parent and 00038 // self are identical, then the nub is assumed to be either: 1) one for 00039 // which only one window_handle is known or 2) the root window_handle. 00040 // If the two handles are identical, then the self's corresponding 00041 // windowing system object is NOT destroyed when the nub is destructed. 00042 00043 ~nub(); 00044 00045 window_handle self() const; 00046 // Returns the underlying window_handle encapsulated by "this". This is 00047 // the only function involving the "self" window_handle that does not 00048 // abort if self is NIL. This means that it must be checked first for 00049 // being NIL unless one is definite that self is already non-NIL. 00050 00051 window_handle parent() const; 00052 // Returns the parent of this nub. 00053 00054 c_rectangle device_dimensions() const; 00055 // Returns a rectangle bounding the nub by querying the windowing system 00056 // regarding the object's size. This will only work if the object has 00057 // already been created (self is non-NIL) and mapped to the screen. 00058 // The returned rectangle is currently relative to the outermost containing 00059 // window's origin. The fact that it is relative unfortunately means that 00060 // if that outermost window's dimensions are asked for, then its origin 00061 // will be reported as zero. 00062 00063 void device_dimensions(const c_rectangle &new_size); 00064 // Sets the size of the nub's associated object in device coordinates. 00065 // This assumes that the first vertex of the rectangle (taken as the 00066 // origin of the rectangle) is ordered in accordance with the device 00067 // coordinate system. If the two vertices are identical, then only 00068 // the origin of the nub is set. 00069 00070 // The following functions retrieve underlying windowing system information 00071 // concerning the window handle encapsulated by this nub. 00072 00073 #ifdef __XWINDOWS__ 00074 Display *display(); 00075 Visual *visual(); 00076 Window window(); 00077 int screen(); 00078 00079 bool realized() const; 00080 // reports whether the nub is actually on the screen yet or not. 00081 void realize(); 00082 // tells the nub to set itself up. all pertinent preconditions should 00083 // be satisfied (e.g., the self exists and has been configured). 00084 00085 void disengage(); 00086 void engage(); 00087 // Needed within __XWINDOWS__ to disconnect a widget from its parent so that 00088 // the callbacks on the widget will not be invoked (the parent performs 00089 // no management on the child when it is disengaged). 00090 00091 void map(); 00092 void unmap(); 00093 // Places a previously existing window back on the screen or removes the 00094 // window from the screen, respectively. 00095 00096 void add_dimensions(argument_list &to_add_to, const c_rectangle &size); 00097 // Used to update an argument list with the necessary commands to cause 00098 // a window to be at a particular origin and to possess a particular size. 00099 // The "size" is a rectangle measured in device coordinates which should 00100 // be aligned appropriately with the device coordinate system. 00101 00102 void add_origin(argument_list &wargs, const c_point &origin); 00103 // adds only the origin to an argument list. 00104 00105 void set_foreground(const color &new_foreground); 00106 void set_background(const color &new_background); 00107 00108 private: 00109 bool i_am_realized; 00110 00111 #elif defined(OS_2) 00112 #elif defined(MS_WINDOWS) 00113 #endif 00114 00115 protected: 00116 void self(window_handle to_set); 00117 // resets the handle encapsulated in "this". 00118 00119 void parent(window_handle w); 00120 // resets the parent window_handle. 00121 00122 private: 00123 window_handle _parent; 00124 window_handle _self; 00125 }; 00126 00127 #endif
1.5.1