2000-08-17 07:53:48 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: multicell.h
|
|
|
|
// Purpose: provide two new classes for layout, wxMultiCellSizer and wxMultiCellCanvas
|
|
|
|
// Author: Jonathan Bayer
|
|
|
|
// Modified by:
|
|
|
|
// Created:
|
2002-12-14 16:16:27 -05:00
|
|
|
// RCS-ID: $Id$
|
2000-08-17 07:53:48 -04:00
|
|
|
// Copyright: (c) Jonathan Bayer
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// This was inspired by the gbsizer class written by Alex Andruschak
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __WX_MULTICELL_H__
|
|
|
|
#define __WX_MULTICELL_H__
|
|
|
|
|
2003-07-19 08:03:47 -04:00
|
|
|
#include "wx/gizmos/gizmos.h"
|
2001-11-26 14:58:06 -05:00
|
|
|
|
2000-08-17 07:53:48 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// The classes are derived from wxSizer
|
|
|
|
#include "wx/sizer.h"
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
enum wxResizable
|
|
|
|
{
|
2004-06-08 15:27:42 -04:00
|
|
|
wxNOT_RESIZABLE = 0x00,
|
|
|
|
wxHORIZONTAL_RESIZABLE = 0x01,
|
|
|
|
wxVERTICAL_RESIZABLE = 0x10,
|
|
|
|
wxRESIZABLE = 0x11
|
2000-08-17 07:53:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// wxMultiCellItemHandle
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2003-07-19 08:03:47 -04:00
|
|
|
class WXDLLIMPEXP_GIZMOS wxMultiCellItemHandle: public wxObject
|
2000-08-17 07:53:48 -04:00
|
|
|
{
|
2005-02-09 09:14:21 -05:00
|
|
|
DECLARE_CLASS(wxMultiCellItemHandle)
|
2000-08-17 07:53:48 -04:00
|
|
|
protected:
|
2004-06-08 15:27:42 -04:00
|
|
|
int m_column;
|
|
|
|
int m_row;
|
|
|
|
int m_width;
|
|
|
|
int m_height;
|
|
|
|
wxResizable m_style;
|
|
|
|
wxSize m_fixedSize;
|
|
|
|
int m_alignment;
|
|
|
|
wxSize m_weight;
|
2000-08-17 07:53:48 -04:00
|
|
|
|
|
|
|
public:
|
2004-06-08 15:27:42 -04:00
|
|
|
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);
|
|
|
|
wxMultiCellItemHandle( int row, int column, wxSize size, wxResizable style = wxNOT_RESIZABLE, wxSize weight = wxSize(1,1), int align = wxALIGN_NOT);
|
|
|
|
wxMultiCellItemHandle( int row, int column, wxResizable style, wxSize weight = wxSize(1,1), int align = wxALIGN_NOT);
|
|
|
|
int GetColumn();
|
|
|
|
int GetRow();
|
|
|
|
int GetWidth();
|
|
|
|
int GetHeight();
|
|
|
|
wxResizable GetStyle();
|
|
|
|
wxSize GetLocalSize();
|
|
|
|
int GetAlignment();
|
|
|
|
wxSize GetWeight();
|
2000-08-17 07:53:48 -04:00
|
|
|
|
|
|
|
private:
|
2004-06-08 15:27:42 -04:00
|
|
|
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);
|
2000-08-17 07:53:48 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// wxMultiCellSizer
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2003-07-19 08:03:47 -04:00
|
|
|
class WXDLLIMPEXP_GIZMOS wxMultiCellSizer : virtual public wxSizer
|
2000-08-17 07:53:48 -04:00
|
|
|
{
|
2005-02-09 09:14:21 -05:00
|
|
|
DECLARE_CLASS(wxMultiCellSizer)
|
2000-08-17 07:53:48 -04:00
|
|
|
|
|
|
|
protected:
|
2004-06-08 15:27:42 -04:00
|
|
|
wxSize m_cell_count;
|
2000-08-17 07:53:48 -04:00
|
|
|
|
|
|
|
public:
|
2004-06-08 15:27:42 -04:00
|
|
|
wxMultiCellSizer(wxSize & size);
|
|
|
|
wxMultiCellSizer(int rows, int cols);
|
|
|
|
~wxMultiCellSizer();
|
|
|
|
|
|
|
|
virtual void RecalcSizes();
|
|
|
|
virtual wxSize CalcMin();
|
|
|
|
bool SetDefaultCellSize(wxSize size);
|
|
|
|
bool SetColumnWidth(int column, int colSize = 5, bool expandable = false);
|
|
|
|
bool SetRowHeight(int row, int rowSize = 5, bool expandable = false);
|
|
|
|
bool EnableGridLines(wxWindow *win);
|
2006-04-26 12:27:20 -04:00
|
|
|
bool SetGridPen(const wxPen *pen);
|
2004-06-08 15:27:42 -04:00
|
|
|
void OnPaint(wxDC& dc);
|
2000-08-17 07:53:48 -04:00
|
|
|
|
|
|
|
private:
|
2004-06-08 15:27:42 -04:00
|
|
|
void GetMinimums();
|
|
|
|
int Sum(int *array, int x);
|
2000-08-17 07:53:48 -04:00
|
|
|
|
|
|
|
private:
|
2004-06-08 15:27:42 -04:00
|
|
|
int *m_maxHeight;
|
|
|
|
int *m_maxWidth;
|
|
|
|
int *m_rowStretch;
|
|
|
|
int *m_colStretch;
|
|
|
|
wxSize **m_weights;
|
|
|
|
wxSize **m_minSizes;
|
|
|
|
int m_maxWeights;
|
|
|
|
wxSize m_defaultCellSize;
|
|
|
|
wxWindow *m_win; // usually used for debugging
|
2006-04-18 04:29:15 -04:00
|
|
|
const wxPen *m_pen;
|
2004-06-08 15:27:42 -04:00
|
|
|
|
|
|
|
void DrawGridLines(wxDC& dc);
|
|
|
|
void Initialize(wxSize size);
|
2000-08-17 07:53:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// wxCell is used internally, so we don't need to declare it here
|
|
|
|
|
|
|
|
class wxCell;
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// wxMultiCellCanvas
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2003-07-19 08:03:47 -04:00
|
|
|
class WXDLLIMPEXP_GIZMOS wxMultiCellCanvas : public wxFlexGridSizer
|
2000-08-17 07:53:48 -04:00
|
|
|
{
|
|
|
|
public:
|
2004-06-08 15:27:42 -04:00
|
|
|
wxMultiCellCanvas(wxWindow *parent, int numRows = 2, int numCols = 2);
|
|
|
|
void Add(wxWindow *win, unsigned int row, unsigned int col);
|
|
|
|
|
|
|
|
void Resize(int numRows, int numCols);
|
|
|
|
int MaxRows()
|
|
|
|
{
|
|
|
|
return m_maxRows;
|
|
|
|
};
|
|
|
|
int MaxCols()
|
|
|
|
{
|
|
|
|
return m_maxCols;
|
|
|
|
};
|
|
|
|
void CalculateConstraints();
|
|
|
|
void SetMinCellSize(const wxSize size)
|
|
|
|
{
|
|
|
|
m_minCellSize = size;
|
|
|
|
};
|
2000-08-17 07:53:48 -04:00
|
|
|
|
2004-01-08 03:35:31 -05:00
|
|
|
/* These are to hide Add() method of parents and to avoid Borland warning about hiding virtual functions */
|
|
|
|
void Add( wxWindow *window, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL )
|
|
|
|
{ wxFlexGridSizer::Add( window, proportion, flag, border, userData); }
|
|
|
|
void Add( wxSizer *sizer, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL )
|
|
|
|
{ wxFlexGridSizer::Add( sizer, proportion, flag, border, userData); }
|
|
|
|
void Add( int width, int height, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL )
|
|
|
|
{ wxFlexGridSizer::Add( width, height, proportion, flag, border, userData); }
|
|
|
|
void Add( wxSizerItem *item )
|
|
|
|
{ wxFlexGridSizer::Add( item); }
|
|
|
|
|
2000-08-17 07:53:48 -04:00
|
|
|
private:
|
2004-06-08 15:27:42 -04:00
|
|
|
wxWindow *m_parent;
|
|
|
|
unsigned int m_maxRows, m_maxCols;
|
2000-08-17 07:53:48 -04:00
|
|
|
|
2004-06-08 15:27:42 -04:00
|
|
|
wxSize m_minCellSize;
|
|
|
|
wxCell **m_cells;
|
2000-08-17 07:53:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** End of File ***/
|