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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
|
/////////////////////////////////////////////////////////////////////////////
// Name: sizer.h
// Purpose: provide wxSizer class for layouting
// Author: Robert Roebling and Robin Dunn
// Modified by:
// Created:
// RCS-ID: $Id: sizer.h,v 1.14.2.6 2000/12/23 23:04:36 roebling Exp $
// Copyright: (c) Robin Dunn, Dirk Holtwick and Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WXSIZER_H__
#define __WXSIZER_H__
#ifdef __GNUG__
#pragma interface "sizer.h"
#endif
#include "wx/defs.h"
#include "wx/window.h"
#include "wx/frame.h"
#include "wx/dialog.h"
//---------------------------------------------------------------------------
// classes
//---------------------------------------------------------------------------
class wxStaticBox;
class wxNotebook;
class wxSizerItem;
class wxSizer;
class wxBoxSizer;
class wxStaticBoxSizer;
//---------------------------------------------------------------------------
// wxSizerItem
//---------------------------------------------------------------------------
class WXDLLEXPORT wxSizerItem: public wxObject
{
DECLARE_CLASS(wxSizerItem);
public:
// spacer
wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData);
// window
wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData );
// subsizer
wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData );
~wxSizerItem();
virtual wxSize GetSize();
virtual wxSize CalcMin();
virtual void SetDimension( wxPoint pos, wxSize size );
wxSize GetMinSize()
{ return m_minSize; }
void SetRatio( int width, int height )
// if either of dimensions is zero, ratio is assumed to be 1
// to avoid "divide by zero" errors
{ m_ratio = (width && height) ? ((float) width / (float) height) : 1; }
void SetRatio( wxSize size )
{ m_ratio = (size.x && size.y) ? ((float) size.x / (float) size.y) : 1; }
void SetRatio( float ratio )
{ m_ratio = ratio; }
float GetRatio() const
{ return m_ratio; }
bool IsWindow();
bool IsSizer();
bool IsSpacer();
void SetInitSize( int x, int y )
{ m_minSize.x = x; m_minSize.y = y; }
void SetOption( int option )
{ m_option = option; }
void SetFlag( int flag )
{ m_flag = flag; }
void SetBorder( int border )
{ m_border = border; }
wxWindow *GetWindow() const
{ return m_window; }
void SetWindow( wxWindow *window )
{ m_window = window; }
wxSizer *GetSizer() const
{ return m_sizer; }
void SetSizer( wxSizer *sizer )
{ m_sizer = sizer; }
int GetOption() const
{ return m_option; }
int GetFlag() const
{ return m_flag; }
int GetBorder() const
{ return m_border; }
wxObject* GetUserData()
{ return m_userData; }
wxPoint GetPosition()
{ return m_pos; }
protected:
wxWindow *m_window;
wxSizer *m_sizer;
wxSize m_size;
wxPoint m_pos;
wxSize m_minSize;
int m_option;
int m_border;
int m_flag;
// als: aspect ratio can always be calculated from m_size,
// but this would cause precision loss when the window
// is shrinked. it is safer to preserve initial value.
float m_ratio;
// user data for shadow objects
wxObject *m_userData;
};
//---------------------------------------------------------------------------
// wxSizer
//---------------------------------------------------------------------------
class WXDLLEXPORT wxSizer: public wxObject
{
public:
wxSizer();
~wxSizer();
/* These should be called Append() really. */
virtual void Add( wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
virtual void Add( wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
virtual void Add( int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
virtual void Insert( int before, wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
virtual void Insert( int before, wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
virtual void Insert( int before, int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
virtual void Prepend( wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
virtual void Prepend( wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
virtual void Prepend( int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
virtual bool Remove( wxWindow *window );
virtual bool Remove( wxSizer *sizer );
virtual bool Remove( int pos );
void SetMinSize( int width, int height )
{ DoSetMinSize( width, height ); }
void SetMinSize( wxSize size )
{ DoSetMinSize( size.x, size.y ); }
/* Searches recursively */
bool SetItemMinSize( wxWindow *window, int width, int height )
{ return DoSetItemMinSize( window, width, height ); }
bool SetItemMinSize( wxWindow *window, wxSize size )
{ return DoSetItemMinSize( window, size.x, size.y ); }
/* Searches recursively */
bool SetItemMinSize( wxSizer *sizer, int width, int height )
{ return DoSetItemMinSize( sizer, width, height ); }
bool SetItemMinSize( wxSizer *sizer, wxSize size )
{ return DoSetItemMinSize( sizer, size.x, size.y ); }
bool SetItemMinSize( int pos, int width, int height )
{ return DoSetItemMinSize( pos, width, height ); }
bool SetItemMinSize( int pos, wxSize size )
{ return DoSetItemMinSize( pos, size.x, size.y ); }
wxSize GetSize()
{ return m_size; }
wxPoint GetPosition()
{ return m_position; }
/* Calculate the minimal size or return m_minSize if bigger. */
wxSize GetMinSize();
virtual void RecalcSizes() = 0;
virtual wxSize CalcMin() = 0;
virtual void Layout();
void Fit( wxWindow *window );
void SetSizeHints( wxWindow *window );
wxList& GetChildren()
{ return m_children; }
void SetDimension( int x, int y, int width, int height );
protected:
wxSize m_size;
wxSize m_minSize;
wxPoint m_position;
wxList m_children;
wxSize GetMinWindowSize( wxWindow *window );
virtual void DoSetMinSize( int width, int height );
virtual bool DoSetItemMinSize( wxWindow *window, int width, int height );
virtual bool DoSetItemMinSize( wxSizer *sizer, int width, int height );
virtual bool DoSetItemMinSize( int pos, int width, int height );
private:
DECLARE_CLASS(wxSizer);
};
//---------------------------------------------------------------------------
// wxGridSizer
//---------------------------------------------------------------------------
class WXDLLEXPORT wxGridSizer: public wxSizer
{
public:
wxGridSizer( int rows, int cols, int vgap, int hgap );
wxGridSizer( int cols, int vgap = 0, int hgap = 0 );
void RecalcSizes();
wxSize CalcMin();
void SetCols( int cols ) { m_cols = cols; }
void SetRows( int rows ) { m_rows = rows; }
void SetVGap( int gap ) { m_vgap = gap; }
void SetHGap( int gap ) { m_hgap = gap; }
int GetCols() { return m_cols; }
int GetRows() { return m_rows; }
int GetVGap() { return m_vgap; }
int GetHGap() { return m_hgap; }
protected:
int m_rows;
int m_cols;
int m_vgap;
int m_hgap;
void SetItemBounds( wxSizerItem *item, int x, int y, int w, int h );
private:
DECLARE_CLASS(wxGridSizer);
};
//---------------------------------------------------------------------------
// wxFlexGridSizer
//---------------------------------------------------------------------------
class WXDLLEXPORT wxFlexGridSizer: public wxGridSizer
{
public:
wxFlexGridSizer( int rows, int cols, int vgap, int hgap );
wxFlexGridSizer( int cols, int vgap = 0, int hgap = 0 );
~wxFlexGridSizer();
void RecalcSizes();
wxSize CalcMin();
void AddGrowableRow( size_t idx );
void RemoveGrowableRow( size_t idx );
void AddGrowableCol( size_t idx );
void RemoveGrowableCol( size_t idx );
protected:
int *m_rowHeights;
int *m_colWidths;
wxArrayInt m_growableRows;
wxArrayInt m_growableCols;
void CreateArrays();
private:
DECLARE_CLASS(wxFlexGridSizer);
};
//---------------------------------------------------------------------------
// wxBoxSizer
//---------------------------------------------------------------------------
class WXDLLEXPORT wxBoxSizer: public wxSizer
{
public:
wxBoxSizer( int orient );
void RecalcSizes();
wxSize CalcMin();
int GetOrientation()
{ return m_orient; }
protected:
int m_orient;
int m_stretchable;
int m_minWidth;
int m_minHeight;
int m_fixedWidth;
int m_fixedHeight;
private:
DECLARE_CLASS(wxBoxSizer);
};
//---------------------------------------------------------------------------
// wxStaticBoxSizer
//---------------------------------------------------------------------------
class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer
{
public:
wxStaticBoxSizer( wxStaticBox *box, int orient );
void RecalcSizes();
wxSize CalcMin();
wxStaticBox *GetStaticBox()
{ return m_staticBox; }
protected:
wxStaticBox *m_staticBox;
private:
DECLARE_CLASS(wxStaticBoxSizer);
};
//---------------------------------------------------------------------------
// wxNotebookSizer
//---------------------------------------------------------------------------
#if wxUSE_NOTEBOOK
class WXDLLEXPORT wxNotebookSizer: public wxSizer
{
public:
wxNotebookSizer( wxNotebook *nb );
void RecalcSizes();
wxSize CalcMin();
wxNotebook *GetNotebook()
{ return m_notebook; }
protected:
wxNotebook *m_notebook;
private:
DECLARE_CLASS(wxNotebookSizer);
};
#endif
#endif
// __WXSIZER_H__
|