2003-08-03 14:29:53 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: fl_sample3.cpp
|
|
|
|
// Purpose: Contrib. demo
|
|
|
|
// Author: Aleksandras Gluchovas
|
|
|
|
// Modified by: Sebastian Haase (June 21, 2001)
|
2005-07-22 12:43:04 -04:00
|
|
|
// Created: 24/11/98
|
2003-08-03 14:29:53 -04:00
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Aleksandras Gluchovas
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/textctrl.h"
|
|
|
|
|
|
|
|
// fl headers
|
|
|
|
#include "wx/fl/controlbar.h"
|
|
|
|
|
|
|
|
// plugins used
|
|
|
|
#include "wx/fl/barhintspl.h"
|
|
|
|
#include "wx/fl/hintanimpl.h"
|
|
|
|
|
|
|
|
#define ID_LOAD 102
|
|
|
|
#define ID_STORE 103
|
|
|
|
#define ID_QUIT 104
|
|
|
|
|
|
|
|
#define ID_BUTT 145
|
|
|
|
#define ID_BUTT2 146
|
|
|
|
|
|
|
|
class MyApp: public wxApp
|
2005-07-22 12:43:04 -04:00
|
|
|
{
|
2003-08-03 14:29:53 -04:00
|
|
|
public:
|
|
|
|
bool OnInit(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
class MyFrame: public wxFrame
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
wxFrameLayout* mpLayout;
|
|
|
|
wxWindow* mpClientWnd;
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxButton * my_butt;
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxTextCtrl* CreateTextCtrl( const wxString& value );
|
|
|
|
public:
|
2003-08-25 15:40:30 -04:00
|
|
|
MyFrame( wxWindow* parent, const wxChar *title );
|
2003-08-03 14:29:53 -04:00
|
|
|
~MyFrame();
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
void OnLoad( wxCommandEvent& event );
|
|
|
|
void OnStore( wxCommandEvent& event );
|
|
|
|
void OnQuit( wxCommandEvent& event );
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
void OnButt( wxCommandEvent& event );
|
|
|
|
void OnButt2( wxCommandEvent& event );
|
2004-06-07 12:02:23 -04:00
|
|
|
bool OnClose(void) { return true; }
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
/***** Implementation for class MyApp *****/
|
|
|
|
|
|
|
|
IMPLEMENT_APP (MyApp)
|
|
|
|
|
|
|
|
bool MyApp::OnInit(void)
|
|
|
|
{
|
2004-05-25 07:20:37 -04:00
|
|
|
// wxWidgets boiler-plate:
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
MyFrame *frame = new MyFrame(NULL, _("wxFrameLayout sample"));
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxMenu *file_menu = new wxMenu;
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
file_menu->Append( ID_LOAD, _("&Load layout") );
|
|
|
|
file_menu->Append( ID_STORE, _("&Store layout") );
|
2003-08-03 14:29:53 -04:00
|
|
|
file_menu->AppendSeparator();
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
file_menu->Append( ID_QUIT, _("E&xit") );
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxMenuBar *menu_bar = new wxMenuBar;
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
menu_bar->Append(file_menu, _("&File"));
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2004-07-19 11:14:07 -04:00
|
|
|
#if wxUSE_STATUSBAR
|
2003-08-03 14:29:53 -04:00
|
|
|
frame->CreateStatusBar(3);
|
2004-07-19 11:14:07 -04:00
|
|
|
#endif // wxUSE_STATUSBAR
|
2003-08-03 14:29:53 -04:00
|
|
|
frame->SetMenuBar(menu_bar);
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2004-06-07 12:02:23 -04:00
|
|
|
frame->Show(true);
|
2003-08-03 14:29:53 -04:00
|
|
|
SetTopWindow(frame);
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2004-06-07 12:02:23 -04:00
|
|
|
return true;
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/***** Immlementation for class MyFrame *****/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|
|
|
EVT_MENU( ID_LOAD, MyFrame::OnLoad )
|
|
|
|
EVT_MENU( ID_STORE, MyFrame::OnStore )
|
|
|
|
EVT_MENU( ID_QUIT, MyFrame::OnQuit )
|
|
|
|
EVT_BUTTON( ID_BUTT, MyFrame::OnButt )
|
|
|
|
EVT_BUTTON( ID_BUTT2, MyFrame::OnButt2 )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
MyFrame::MyFrame( wxWindow* parent, const wxChar *title )
|
2004-06-07 12:02:23 -04:00
|
|
|
: wxFrame( parent, wxID_ANY, title, wxDefaultPosition,
|
2003-08-03 14:29:53 -04:00
|
|
|
wxSize( 700, 500 ),
|
|
|
|
wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX |
|
2006-03-31 13:07:22 -05:00
|
|
|
wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX,
|
2003-08-25 15:40:30 -04:00
|
|
|
wxT("freimas") )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2005-07-22 12:43:04 -04:00
|
|
|
|
|
|
|
mpClientWnd = new wxWindow(this, wxID_ANY);
|
2003-08-03 14:29:53 -04:00
|
|
|
mpLayout = new wxFrameLayout( this, mpClientWnd );
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
/// mpLayout->PushDefaultPlugins();
|
|
|
|
/// mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for barso
|
|
|
|
/// //mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
|
2005-07-22 12:43:04 -04:00
|
|
|
|
|
|
|
cbDimInfo sizes( 80,65, // when docked horizontally
|
|
|
|
80,165, // when docked vertically
|
|
|
|
180,30, // when floated
|
2004-06-07 12:02:23 -04:00
|
|
|
true, // the bar is fixed-size
|
2003-08-03 14:29:53 -04:00
|
|
|
5, // vertical gap (bar border)
|
|
|
|
5 // horizontal gap (bar border)
|
2005-07-22 12:43:04 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// drop-in some bars
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
for( int i = 1; i <= 11; ++i )
|
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
wxChar buf[4];
|
|
|
|
wxSprintf( buf, wxT("%d"), i );
|
|
|
|
wxString name = wxString(wxT("Bar-"));
|
2003-08-03 14:29:53 -04:00
|
|
|
name += buf;
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
sizes.mIsFixed = (i !=3); // every fifth bar is not fixed-size
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
if ( !sizes.mIsFixed ) name += wxT(" (flexible)");
|
2005-07-22 12:43:04 -04:00
|
|
|
// mpLayout->AddBar( CreateTextCtrl(name), // bar window
|
2003-08-03 14:29:53 -04:00
|
|
|
if(i != 4 && i!= 5 && i!=11) {
|
2005-07-22 12:43:04 -04:00
|
|
|
mpLayout->AddBar( new wxTextCtrl(this, wxID_ANY, name), // bar window
|
|
|
|
sizes,
|
|
|
|
i % MAX_PANES, // alignment ( 0-top,1-bottom, etc)
|
|
|
|
0, // insert into 0th row (vert. position)
|
|
|
|
0, // offset from the start of row (in pixels)
|
|
|
|
name // name to refere in customization pop-ups
|
2003-08-03 14:29:53 -04:00
|
|
|
);
|
|
|
|
} else if(i==4){
|
2005-07-22 12:43:04 -04:00
|
|
|
mpLayout->AddBar( new wxTextCtrl(this, wxID_ANY, name), // bar window
|
|
|
|
cbDimInfo( 100,100, 100,100, 100,100, true, 5, 5),
|
|
|
|
i % MAX_PANES, // alignment ( 0-top,1-bottom, etc)
|
|
|
|
0, // insert into 0th row (vert. position)
|
|
|
|
0, // offset from the start of row (in pixels)
|
|
|
|
name // name to refere in customization pop-ups
|
2003-08-03 14:29:53 -04:00
|
|
|
);
|
|
|
|
} else if(i==5) {
|
|
|
|
my_butt = new wxButton(this, ID_BUTT, name);
|
2005-07-22 12:43:04 -04:00
|
|
|
mpLayout->AddBar( my_butt, // bar window
|
|
|
|
cbDimInfo( 100,100, 200,200, 400,400, true, 5, 5),
|
|
|
|
i % MAX_PANES, // alignment ( 0-top,1-bottom, etc)
|
|
|
|
0, // insert into 0th row (vert. position)
|
|
|
|
0, // offset from the start of row (in pixels)
|
|
|
|
name // name to refere in customization pop-ups
|
2003-08-03 14:29:53 -04:00
|
|
|
);
|
|
|
|
} else if(i==11) {
|
2003-08-25 15:40:30 -04:00
|
|
|
mpLayout->AddBar( new wxButton(this, ID_BUTT2, name+wxT("_2")),
|
2005-07-22 12:43:04 -04:00
|
|
|
cbDimInfo( 100,100, 200,200, 400,400, true, 5, 5),
|
|
|
|
i % MAX_PANES, // alignment ( 0-top,1-bottom, etc)
|
|
|
|
0, // insert into 0th row (vert. position)
|
|
|
|
0, // offset from the start of row (in pixels)
|
|
|
|
name // name to refere in customization pop-ups
|
2003-08-03 14:29:53 -04:00
|
|
|
);
|
|
|
|
}
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// mpLayout->RecalcLayout(true);
|
|
|
|
// Layout();
|
|
|
|
// Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MyFrame::~MyFrame()
|
|
|
|
{
|
|
|
|
// layout is not a window, should be released manually
|
2005-07-22 12:43:04 -04:00
|
|
|
if ( mpLayout )
|
2003-08-03 14:29:53 -04:00
|
|
|
delete mpLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value )
|
|
|
|
{
|
2005-07-22 12:43:04 -04:00
|
|
|
wxTextCtrl* pCtrl = new wxTextCtrl( this, wxID_ANY, value,
|
2003-08-03 14:29:53 -04:00
|
|
|
wxPoint(0,0), wxSize(1,1), wxTE_MULTILINE );
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) );
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
return pCtrl;
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnLoad( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
wxMessageBox(_("Hey - you found a BIG question-mark !!"));
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnStore( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
wxMessageBox(_("Hey - you found another BIG question-mark !!"));
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2004-06-07 12:02:23 -04:00
|
|
|
Show( false ); // TRICK:: hide it, to avoid flickered destruction
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2004-06-07 12:02:23 -04:00
|
|
|
Close(true);
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnButt( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
static int i =0;
|
2005-07-22 12:43:04 -04:00
|
|
|
|
|
|
|
// cbBarInfo* FindBarByName( const wxString& name );
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
switch(i % 2) {
|
2005-07-22 12:43:04 -04:00
|
|
|
case 0:
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
cbBarInfo* x = mpLayout->FindBarByName(wxString(wxT("Bar-1")));
|
2005-07-22 12:43:04 -04:00
|
|
|
if(x)
|
|
|
|
mpLayout->InverseVisibility(x);
|
|
|
|
else
|
2003-08-03 14:29:53 -04:00
|
|
|
wxBell();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
cbBarInfo* x = mpLayout->FindBarByName(wxString(wxT("Bar-6")));
|
2005-07-22 12:43:04 -04:00
|
|
|
if(x)
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2005-07-22 12:43:04 -04:00
|
|
|
if(i % 4 == 1)
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2004-06-07 12:02:23 -04:00
|
|
|
mpLayout->SetBarState(x, wxCBAR_FLOATING, true);
|
2003-08-03 14:29:53 -04:00
|
|
|
//mpLayout->RecalcLayout(true);
|
|
|
|
mpLayout->RepositionFloatedBar(x);
|
2005-07-22 12:43:04 -04:00
|
|
|
}
|
|
|
|
else
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2004-06-07 12:02:23 -04:00
|
|
|
mpLayout->SetBarState(x, 0, true);
|
2003-08-03 14:29:53 -04:00
|
|
|
//mpLayout->RecalcLayout(true);
|
|
|
|
//mpLayout->RepositionFloatedBar(x);
|
|
|
|
}
|
2004-06-07 12:02:23 -04:00
|
|
|
// // // x->mState = wxCBAR_FLOATING;
|
|
|
|
// // // mpLayout->ApplyBarProperties(x);
|
2005-07-22 12:43:04 -04:00
|
|
|
}
|
|
|
|
else
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
}
|
2005-07-22 12:43:04 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnButt2( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
static int i =0;
|
2005-07-22 12:43:04 -04:00
|
|
|
|
|
|
|
// cbBarInfo* FindBarByName( const wxString& name );
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
switch(i % 2) {
|
2005-07-22 12:43:04 -04:00
|
|
|
case 0:
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
cbBarInfo* x = mpLayout->FindBarByName(wxString(wxT("Bar-1")));
|
2005-07-22 12:43:04 -04:00
|
|
|
if(x)
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
for(int a=0;a<MAX_BAR_STATES;a++)
|
|
|
|
{
|
|
|
|
x->mDimInfo.mSizes[a].x = 200;
|
|
|
|
x->mDimInfo.mSizes[a].y = 200;
|
|
|
|
}
|
|
|
|
x->mpBarWnd->SetSize(200,200);
|
2004-06-07 12:02:23 -04:00
|
|
|
mpLayout->SetBarState(x, wxCBAR_FLOATING, true); // HACK !!!
|
|
|
|
mpLayout->SetBarState(x, 0, true); // HACK !!!
|
2005-07-22 12:43:04 -04:00
|
|
|
wxYield(); // HACK !!! needed to resize BEFORE redraw
|
2004-06-07 12:02:23 -04:00
|
|
|
mpLayout->RefreshNow( true ); // HACK !!! needed to trigger redraw
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
2005-07-22 12:43:04 -04:00
|
|
|
else
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
cbBarInfo* x = mpLayout->FindBarByName(wxString(wxT("Bar-1")));
|
2005-07-22 12:43:04 -04:00
|
|
|
if(x)
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2005-07-22 12:43:04 -04:00
|
|
|
//mpLayout->InverseVisibility(x);
|
2003-08-03 14:29:53 -04:00
|
|
|
for(int a=0;a<MAX_BAR_STATES;a++)
|
|
|
|
{
|
2005-07-22 12:43:04 -04:00
|
|
|
// see cbPaneDrawPlugin::OnSizeBarWindow( cbSizeBarWndEvent& event )
|
2003-08-03 14:29:53 -04:00
|
|
|
x->mDimInfo.mSizes[a].x = 10 + 2 + 2*x->mDimInfo.mHorizGap;
|
|
|
|
x->mDimInfo.mSizes[a].y = 10 + 2 + 2*x->mDimInfo.mVertGap;
|
|
|
|
}
|
|
|
|
x->mpBarWnd->SetSize(10,10);
|
2004-06-07 12:02:23 -04:00
|
|
|
mpLayout->SetBarState(x, wxCBAR_FLOATING, true); // HACK !!!
|
|
|
|
mpLayout->SetBarState(x, 0, true); // HACK !!!
|
2005-07-22 12:43:04 -04:00
|
|
|
wxYield(); // HACK !!! needed to resize BEFORE redraw
|
2004-06-07 12:02:23 -04:00
|
|
|
mpLayout->RefreshNow( true ); // HACK !!! needed to trigger redraw
|
2005-07-22 12:43:04 -04:00
|
|
|
|
|
|
|
// mpLayout->SetBarState(x, wxCBAR_FLOATING, true);
|
|
|
|
// mpLayout->RecalcLayout(true);
|
|
|
|
// mpLayout->RepositionFloatedBar(x);
|
|
|
|
// mpLayout->RecalcLayout(true);
|
|
|
|
// mpLayout->RepositionFloatedBar(x);
|
|
|
|
// mpLayout->SetBarState(x, 0, true);
|
|
|
|
// wxYield();
|
|
|
|
// mpLayout->RefreshNow( true );
|
|
|
|
// mpLayout->RecalcLayout(true);
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
2005-07-22 12:43:04 -04:00
|
|
|
else
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|