home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wxos2233.zip / wxOS2-2_3_3.zip / wxWindows-2.3.3 / contrib / include / wx / gizmos / multicell.h < prev    next >
C/C++ Source or Header  |  2002-09-08  |  5KB  |  176 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name:        multicell.h
  3. // Purpose:     provide two new classes for layout, wxMultiCellSizer and wxMultiCellCanvas
  4. // Author:      Jonathan Bayer
  5. // Modified by:
  6. // Created:
  7. // RCS-ID:      $Id:
  8. // Copyright:   (c) Jonathan Bayer
  9. // Licence:     wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11.  
  12. // This was inspired by the gbsizer class written by Alex Andruschak
  13.  
  14.  
  15. #ifndef __WX_MULTICELL_H__
  16. #define __WX_MULTICELL_H__
  17.  
  18. #if defined(__GNUG__) && !defined(__APPLE__)
  19.     #pragma interface "multicell.h"
  20. #endif
  21.  
  22.  
  23. #ifdef GIZMOISDLL
  24. #define GIZMODLLEXPORT WXDLLEXPORT
  25. #else
  26. #define GIZMODLLEXPORT
  27. #endif
  28.  
  29.  
  30. // ----------------------------------------------------------------------------
  31. // headers
  32. // ----------------------------------------------------------------------------
  33. // The classes are derived from wxSizer
  34. #include "wx/sizer.h"
  35.  
  36.  
  37. // ----------------------------------------------------------------------------
  38. // constants
  39. // ----------------------------------------------------------------------------
  40. enum wxResizable
  41. {
  42.     wxNOT_RESIZABLE =           0x00,
  43.     wxHORIZENTAL_RESIZABLE =    0x01,
  44.     wxVERTICAL_RESIZABLE =      0x10,
  45.     wxRESIZABLE =               0x11
  46. };
  47.  
  48. //---------------------------------------------------------------------------
  49. // classes
  50. //---------------------------------------------------------------------------
  51.  
  52. //---------------------------------------------------------------------------
  53. // wxMultiCellItemHandle
  54. //---------------------------------------------------------------------------
  55.  
  56. class GIZMODLLEXPORT wxMultiCellItemHandle: public wxObject
  57. {
  58.     DECLARE_CLASS(wxMultiCellItemHandle);
  59. protected:
  60.     int             m_column;
  61.     int             m_row;
  62.     int             m_width;
  63.     int             m_height;
  64.     wxResizable     m_style;
  65.     wxSize          m_fixedSize;
  66.     int             m_alignment;
  67.     wxSize          m_weight;
  68.  
  69. public:
  70.     wxMultiCellItemHandle( int row, int column, int height = 1, int width = 1, wxSize size = wxDefaultSize, wxResizable style = wxNOT_RESIZABLE, wxSize weight = wxSize(1,1), int align = wxALIGN_NOT);
  71.     wxMultiCellItemHandle( int row, int column, wxSize size, wxResizable style = wxNOT_RESIZABLE, wxSize weight = wxSize(1,1), int align = wxALIGN_NOT);
  72.     wxMultiCellItemHandle( int row, int column, wxResizable style, wxSize weight = wxSize(1,1), int align = wxALIGN_NOT);
  73.     wxMultiCellItemHandle( int row, int column, int align);
  74.     int             GetColumn();
  75.     int             GetRow();
  76.     int             GetWidth();
  77.     int             GetHeight();
  78.     wxResizable     GetStyle();
  79.     wxSize          GetLocalSize();
  80.     int             GetAlignment();
  81.     wxSize          GetWeight();
  82.  
  83. private:
  84.     void Initialize( int row, int column, int height = 1, int width = 1, wxSize size = wxDefaultSize, wxResizable style = wxNOT_RESIZABLE, wxSize weight = wxSize(1,1), int align = wxALIGN_NOT);
  85.  
  86. };
  87.  
  88. //---------------------------------------------------------------------------
  89. // wxMultiCellSizer
  90. //---------------------------------------------------------------------------
  91.  
  92. class GIZMODLLEXPORT wxMultiCellSizer : virtual public wxSizer
  93. {
  94.     DECLARE_CLASS(wxMultiCellSizer);
  95.  
  96. protected:
  97.     wxSize m_cell_count;
  98.  
  99. public:
  100.     wxMultiCellSizer(wxSize & size);
  101.     wxMultiCellSizer(int rows, int cols);
  102.     ~wxMultiCellSizer();
  103.  
  104.     virtual void     RecalcSizes();
  105.     virtual wxSize     CalcMin();
  106.     bool             SetDefaultCellSize(wxSize size);
  107.     bool             SetColumnWidth(int column, int colSize = 5, bool expandable = FALSE);
  108.     bool             SetRowHeight(int row, int rowSize = 5, bool expandable = FALSE);
  109.     bool            EnableGridLines(wxWindow *win);
  110.     bool            SetGridPen(wxPen *pen);
  111.     void             OnPaint(wxDC& dc);
  112.  
  113. private:
  114.     void             GetMinimums();
  115.     int             Sum(int *array, int x);
  116.  
  117. private:
  118.     int             *m_maxHeight;
  119.     int             *m_maxWidth;
  120.     int             *m_rowStretch;
  121.     int             *m_colStretch;
  122.     wxSize             **m_weights;
  123.     wxSize            **m_minSizes;
  124.     int                m_maxWeights;
  125.     wxSize            m_defaultCellSize;
  126.     wxWindow        *m_win; // usually used for debugging
  127.     wxPen            *m_pen;
  128.  
  129.     void            DrawGridLines(wxDC& dc);
  130.     void            Initialize(wxSize size);
  131. };
  132.  
  133.  
  134. // wxCell is used internally, so we don't need to declare it here
  135.  
  136. class wxCell;
  137.  
  138. //---------------------------------------------------------------------------
  139. // wxMultiCellCanvas
  140. //---------------------------------------------------------------------------
  141.  
  142. class GIZMODLLEXPORT wxMultiCellCanvas : public wxFlexGridSizer
  143. {
  144. public:
  145.     wxMultiCellCanvas(wxWindow *parent, int numRows = 2, int numCols = 2);
  146.     void Add(wxWindow *win, unsigned int row, unsigned int col);
  147.  
  148.     void Resize(int numRows, int numCols);
  149.     int MaxRows()
  150.     {
  151.         return m_maxRows;
  152.     };
  153.     int MaxCols()
  154.     {
  155.         return m_maxCols;
  156.     };
  157.     void CalculateConstraints();
  158.     void SetMinCellSize(const wxSize size)
  159.     {
  160.         m_minCellSize = size;
  161.     };
  162.  
  163. private:
  164.     wxWindow            *m_parent;
  165.     unsigned int         m_maxRows, m_maxCols;
  166.  
  167.     wxSize              m_minCellSize;
  168.     wxCell              **m_cells;
  169. };
  170.  
  171. #endif
  172.  
  173.  
  174.  
  175. /*** End of File ***/
  176.