2000-08-17 07:53:48 -04:00
|
|
|
/*
|
2004-06-08 15:27:42 -04:00
|
|
|
* File: mtest.cpp
|
|
|
|
* Purpose: wxMultiCellSizer and wxMultiCellCanvas test
|
|
|
|
* Author: Alex Andruschak
|
|
|
|
* Created: 2000
|
|
|
|
* Updated:
|
2000-08-17 07:53:48 -04:00
|
|
|
* Copyright:
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const char sccsid[] = "%W% %G%";
|
|
|
|
|
2002-09-07 08:28:46 -04:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
2004-06-08 15:27:42 -04:00
|
|
|
#pragma implementation
|
|
|
|
#pragma interface
|
2000-08-17 07:53:48 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
2004-06-08 15:27:42 -04:00
|
|
|
#pragma hdrstop
|
2000-08-17 07:53:48 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
2004-06-08 15:27:42 -04:00
|
|
|
#include "wx/wx.h"
|
2000-08-17 07:53:48 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/gizmos/multicell.h"
|
|
|
|
|
|
|
|
class MyApp: public wxApp
|
|
|
|
{public:
|
2004-06-08 15:27:42 -04:00
|
|
|
bool OnInit(void);
|
2000-08-17 07:53:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class MyFrame: public wxFrame
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2004-06-08 15:27:42 -04:00
|
|
|
MyFrame(int type, wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size);
|
2000-08-17 07:53:48 -04:00
|
|
|
|
2004-06-08 15:27:42 -04:00
|
|
|
void OnCloseWindow(wxCloseEvent& event);
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
wxMultiCellSizer *sizer;
|
2000-08-17 07:53:48 -04:00
|
|
|
|
2004-06-08 15:27:42 -04:00
|
|
|
DECLARE_EVENT_TABLE()
|
2000-08-17 07:53:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_APP(MyApp)
|
|
|
|
|
|
|
|
bool MyApp::OnInit(void)
|
|
|
|
{
|
2004-06-08 15:27:42 -04:00
|
|
|
MyFrame *frame = new MyFrame(1, (wxFrame *) NULL, wxT("wxMultiCellSizer Sample"), wxPoint(50, 50), wxDefaultSize); //, wxSize(600, 500));
|
2000-08-17 07:53:48 -04:00
|
|
|
|
2004-06-08 15:27:42 -04:00
|
|
|
frame->Show(true);
|
2000-08-17 07:53:48 -04:00
|
|
|
|
2004-06-08 15:27:42 -04:00
|
|
|
SetTopWindow(frame);
|
|
|
|
frame = new MyFrame(2, (wxFrame *) NULL, wxT("wxMultiCellCanvas Sample"), wxPoint(100, 100), wxSize(600, 500));
|
2000-08-17 07:53:48 -04:00
|
|
|
|
2004-06-08 15:27:42 -04:00
|
|
|
frame->Show(true);
|
2000-08-17 07:53:48 -04:00
|
|
|
|
2004-06-08 15:27:42 -04:00
|
|
|
SetTopWindow(frame);
|
|
|
|
return true;
|
2000-08-17 07:53:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MyFrame::MyFrame(int type, wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size):
|
2004-06-08 15:27:42 -04:00
|
|
|
wxFrame(frame, wxID_ANY, title, pos, size, wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL)
|
2000-08-17 07:53:48 -04:00
|
|
|
{
|
2004-06-08 15:27:42 -04:00
|
|
|
CreateStatusBar(1);
|
|
|
|
sizer = NULL;
|
|
|
|
if (type == 1)
|
|
|
|
{
|
|
|
|
// create sizer 4 columns 5 rows
|
|
|
|
wxSize aa(4,9);
|
|
|
|
sizer = new wxMultiCellSizer(aa);
|
|
|
|
sizer->SetDefaultCellSize(wxSize(15,15));
|
|
|
|
sizer->SetRowHeight(7,5,true);
|
|
|
|
sizer->SetRowHeight(8,5,false);
|
|
|
|
// add first row
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT( "B1 - 0,0, horizontal resizable")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(0,0,1,1, wxDefaultSize, wxHORIZONTAL_RESIZABLE, wxSize(2,2)));
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("B2 - 0,1, vertical resizable")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(0,1,1,1, wxDefaultSize, wxVERTICAL_RESIZABLE, wxSize(2, 2)));
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("B3 - 0,2")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(0,2,1,1, wxDefaultSize, wxNOT_RESIZABLE, wxSize(1,1), wxALIGN_CENTER_HORIZONTAL)); //, wxALIGN_CENTER));
|
|
|
|
sizer->Add(
|
|
|
|
new wxStaticText(this, wxID_ANY, wxT("jbb 0,3, lower-right")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(0,3,1,1, wxDefaultSize, wxNOT_RESIZABLE, wxSize(1,1), wxALIGN_BOTTOM | wxALIGN_RIGHT));
|
|
|
|
|
|
|
|
// add button for secord row
|
|
|
|
sizer->Add(
|
|
|
|
new wxTextCtrl(this, wxID_ANY, wxT("Text control - 1,0, 4 cols wide")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(1,0,1,4));
|
|
|
|
|
|
|
|
// add buttons for next row
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("B6 - 2,0, 2 cols wide")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(2,0,1,2));
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("B7 - 2,3")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(2,3,1,1));
|
|
|
|
|
|
|
|
// and last additions
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("B8 - 3,0, 4 rows high, vert resizable")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(3,0,4,1,wxDefaultSize, wxVERTICAL_RESIZABLE));
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("B9 - 3,2, 2 cols wide, vert resizable")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(3,2,1,2,wxDefaultSize, wxVERTICAL_RESIZABLE));
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("B10 - 4,1, 3 cols wide, vert resizable")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(4,1,1,3,wxDefaultSize, wxVERTICAL_RESIZABLE));
|
|
|
|
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("B11 - 5,1, 3 cols wide")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(5,1,1,3));
|
|
|
|
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("B12 - 6,1, 3 cols wide")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(6,1,1,3));
|
|
|
|
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("B13 - 7,1, 2 cols wide")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(7,1,1,2));
|
|
|
|
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("B14 - 8,1, 3 cols wide")),
|
|
|
|
0, 0, 0, new wxMultiCellItemHandle(8,1,1,3));
|
|
|
|
|
|
|
|
SetAutoLayout( true );
|
|
|
|
// sizer->SetMinSize(sizer->CalcMin());
|
|
|
|
SetSizer( sizer );
|
|
|
|
wxSize s = sizer->CalcMin();
|
|
|
|
wxSize c = GetSize() - GetClientSize();
|
|
|
|
SetSizeHints(s.GetWidth() + c.GetWidth() , s.GetHeight() + c.GetHeight());
|
|
|
|
sizer->EnableGridLines(this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// create sizer 4 columns 5 rows
|
|
|
|
wxMultiCellCanvas *sizer = new wxMultiCellCanvas(this, 5,5);
|
|
|
|
|
|
|
|
// add first row
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("Button 1")),
|
|
|
|
0, 0);
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("Button 2")),
|
|
|
|
0, 1);
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("Button 3")),
|
|
|
|
0, 2);
|
|
|
|
sizer->Add(
|
|
|
|
new wxStaticText(this, wxID_ANY, wxT("jbb test")),
|
|
|
|
0, 3);
|
|
|
|
|
|
|
|
sizer->Add(
|
|
|
|
new wxStaticText(this, wxID_ANY, wxT("jbb test 2")),
|
|
|
|
0, 4);
|
|
|
|
|
|
|
|
// add button for secord row
|
|
|
|
sizer->Add(
|
|
|
|
new wxTextCtrl(this, wxID_ANY, wxT("Text control")),
|
|
|
|
1, 0);
|
|
|
|
|
|
|
|
// add buttons for next row
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("Button 6")),
|
|
|
|
2, 0);
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("Button 7")),
|
|
|
|
2, 3);
|
|
|
|
|
|
|
|
// and last additions
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("Button 8")),
|
|
|
|
3, 0);
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("Button 9")),
|
|
|
|
3, 1);
|
|
|
|
sizer->Add(
|
|
|
|
new wxButton( this, wxID_ANY, wxT("Button 10")),
|
|
|
|
4, 1);
|
|
|
|
|
|
|
|
sizer->CalculateConstraints();
|
|
|
|
SetSizer( sizer );
|
|
|
|
SetAutoLayout( true );
|
|
|
|
}
|
2000-08-17 07:53:48 -04:00
|
|
|
}
|
|
|
|
// Define the repainting behaviour
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|
|
|
EVT_PAINT(MyFrame::OnPaint)
|
|
|
|
EVT_CLOSE(MyFrame::OnCloseWindow)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
void MyFrame::OnPaint(wxPaintEvent& WXUNUSED(event) )
|
|
|
|
{
|
2004-06-08 15:27:42 -04:00
|
|
|
wxPaintDC dc(this);
|
2000-08-17 07:53:48 -04:00
|
|
|
|
2004-06-08 15:27:42 -04:00
|
|
|
if (sizer)
|
|
|
|
{
|
|
|
|
sizer->OnPaint(dc);
|
|
|
|
}
|
2000-08-17 07:53:48 -04:00
|
|
|
}
|
|
|
|
|
2004-01-08 03:35:31 -05:00
|
|
|
void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
2000-08-17 07:53:48 -04:00
|
|
|
{
|
2004-06-08 15:27:42 -04:00
|
|
|
Destroy();
|
2000-08-17 07:53:48 -04:00
|
|
|
}
|
|
|
|
|