00001 // Class QWindow 00002 // Filename QWindow.h 00003 // FaPra 2003-2004, A5, Alexander Kramer 00004 00005 #ifndef QWindow_h 00006 #define QWindow_h 00007 00008 00009 //! Pre-declaration of QWindow 00010 class QWindow; 00011 00012 00013 #include "QButton.h" 00014 #include "QColor.h" 00015 #include "QFont.h" 00016 #include "QWidget.h" 00017 00018 //! Widget which is a GUI-Window. 00019 class QWindow : public QWidget 00020 { 00021 private: 00022 //! indicates whether the window is currently resizing 00023 bool Resizing; 00024 00025 //! old position for restore from maximize 00026 int OldLeft; 00027 00028 //! old position for restore from maximize 00029 int OldTop; 00030 00031 //! old position for restore from maximize 00032 int OldWidth; 00033 00034 //! old position for restore from maximize 00035 int OldHeight; 00036 00037 //! position x at the beginning of the resizing 00038 int ResizeStartX; 00039 00040 //! position y at the beginning of the resizing 00041 int ResizeStartY; 00042 00043 protected: 00044 //! titlebar height 00045 int TitleBarHeight; 00046 00047 //! titlebar border 00048 int TitleBarBorder; 00049 00050 //! caption of the window 00051 string Caption; 00052 00053 //! minimum allowed width if resizing with mouse 00054 int MinResizeWidth; 00055 00056 //! minimum allowed height if resizing with mouse 00057 int MinResizeHeight; 00058 00059 //! indicates whether the window is currently maximized 00060 bool Maximized; 00061 00062 //! defines whether the window can be resized by mouse 00063 bool Resizable; 00064 00065 //! Button for close 00066 QButton* CloseButton; 00067 00068 //! Button for maximize 00069 QButton* MaximizeButton; 00070 00071 //! widget for caption text 00072 QFont* Font; 00073 00074 //! color of Title bar 00075 QColor* TitleBarColor; 00076 00077 //! color of title bar if window is not active 00078 QColor* TitleBarColorInactive; 00079 00080 public: 00081 //! draws frame 00082 virtual void drawFrame(); 00083 00084 //! draws info about size/position. Semi transparent rectangle with window font 00085 void drawCoordInfos( int x , int y , const char* Text ); 00086 00087 //! draws close button 00088 void drawCloseButton(); 00089 00090 //! draws maximize button 00091 void drawMaximizeButton(); 00092 00093 //! maximize / restore window. If window is maximized, restore its size/position, else maximize its size 00094 void maximize(); 00095 00096 //! draws itself with OpenGL. Here is the OpenGL drawing code 00097 virtual void draw( QEvent* e ); 00098 00099 //! layout the children widgets. This method is called every time the size is changed. Have to be overwritten for respond on size changes 00100 virtual void layout(); 00101 00102 //! have to return true if widget should be dragged with mouse. This method is overwritten in sub classes. If returns true, widget will be dragged 00103 virtual bool canDrag( QEvent* e ); 00104 00105 //! processing mouse/keyboard events which are in widgets region. Mouse coordinates are relative to Owner 00106 virtual bool processEvent( QEvent* e ); 00107 00108 //! processing mouse events which are in Owner widget region. Mouse coordinates are relative to Owner 00109 virtual bool processMouseOwner( QEvent* e ); 00110 00111 //! called if a child is added/removed 00112 virtual void childrenChanged(); 00113 00114 //! defines whether control can have keyboard focus. Should return true if Widget wants to get keyboard focus 00115 virtual bool canFocus( QEvent* e ); 00116 00117 //! initialization code 00118 virtual void Init(); 00119 00120 //! clean up code 00121 virtual void CleanUp(); 00122 00123 //! getter method for TitleBarHeight 00124 virtual int getTitleBarHeight(); 00125 00126 //! setter method for TitleBarHeight 00127 virtual void setTitleBarHeight( int newValue ); 00128 00129 //! getter method for TitleBarBorder 00130 virtual int getTitleBarBorder(); 00131 00132 //! setter method for TitleBarBorder 00133 virtual void setTitleBarBorder( int newValue ); 00134 00135 //! getter method for Caption 00136 virtual string getCaption(); 00137 00138 //! setter method for Caption 00139 virtual void setCaption( string newValue ); 00140 00141 //! getter method for MinResizeWidth 00142 virtual int getMinResizeWidth(); 00143 00144 //! setter method for MinResizeWidth 00145 virtual void setMinResizeWidth( int newValue ); 00146 00147 //! getter method for MinResizeHeight 00148 virtual int getMinResizeHeight(); 00149 00150 //! setter method for MinResizeHeight 00151 virtual void setMinResizeHeight( int newValue ); 00152 00153 //! getter method for Maximized 00154 virtual bool getMaximized(); 00155 00156 //! setter method for Maximized 00157 virtual void setMaximized( bool newValue ); 00158 00159 //! getter method for Resizable 00160 virtual bool getResizable(); 00161 00162 //! setter method for Resizable 00163 virtual void setResizable( bool newValue ); 00164 00165 //! getter method for CloseButton 00166 virtual QButton* getCloseButton(); 00167 00168 //! getter method for MaximizeButton 00169 virtual QButton* getMaximizeButton(); 00170 00171 //! getter method for Font 00172 QFont* getFont(); 00173 00174 //! getter method for TitleBarColor 00175 QColor* getTitleBarColor(); 00176 00177 //! getter method for TitleBarColorInactive 00178 QColor* getTitleBarColorInactive(); 00179 00180 //! prints itself to the cout 00181 void print(); 00182 00183 //! Constructor 00184 QWindow( QWidget* aOwner ); 00185 00186 //! Destructor 00187 virtual ~QWindow(); 00188 00189 00190 }; 00191 #endif 00192
1.2.18