2003-08-03 14:29:53 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: No names yet.
|
|
|
|
// Purpose: Contrib. demo
|
|
|
|
// Author: Aleksandras Gluchovas
|
|
|
|
// Modified by: Sebastian Haase (June 21, 2001)
|
|
|
|
// Created: 04/11/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Aleksandras Gluchovas
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation "fl_demo2.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
2004-05-25 07:20:37 -04:00
|
|
|
// wxWidgets headers.
|
2003-08-03 14:29:53 -04:00
|
|
|
#include "wx/treectrl.h"
|
|
|
|
#include "wx/imaglist.h"
|
2004-05-25 08:44:56 -04:00
|
|
|
#include "wx/notebook.h"
|
2003-08-03 14:29:53 -04:00
|
|
|
|
|
|
|
// fl headers.
|
|
|
|
#include "wx/fl/controlbar.h"
|
|
|
|
#include "wx/fl/rowlayoutpl.h"
|
|
|
|
#include "wx/fl/antiflickpl.h"
|
|
|
|
#include "wx/fl/bardragpl.h"
|
|
|
|
#include "wx/fl/cbcustom.h"
|
|
|
|
#include "wx/fl/rowdragpl.h"
|
|
|
|
|
|
|
|
// some extra fl plugins.
|
|
|
|
#include "wx/fl/barhintspl.h"
|
|
|
|
#include "wx/fl/hintanimpl.h"
|
|
|
|
|
|
|
|
#include "wx/fl/dyntbar.h"
|
|
|
|
#include "wx/fl/dyntbarhnd.h" // fl-dimension-handler for dynamic toolbar
|
|
|
|
|
|
|
|
#include "fl_demo2.h"
|
|
|
|
|
|
|
|
/***** Implementation for class MyApp *****/
|
|
|
|
|
|
|
|
// Create a new application object
|
|
|
|
IMPLEMENT_APP (MyApp)
|
|
|
|
|
|
|
|
// `Main program' equivalent, creating windows and returning main app frame
|
|
|
|
bool MyApp::OnInit(void)
|
|
|
|
{
|
|
|
|
// Create the main frame window
|
2004-05-25 07:20:37 -04:00
|
|
|
MyFrame *frame = new MyFrame(NULL, _("wxWidgets 2.0 wxFrameLayout demo"), 50, 50, 650, 540);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// Give it an icon
|
|
|
|
#ifdef __WINDOWS__
|
2003-08-25 15:40:30 -04:00
|
|
|
frame->SetIcon(wxIcon(wxT("mondrian")));
|
2003-08-03 14:29:53 -04:00
|
|
|
#endif
|
|
|
|
#ifdef __X__
|
2003-08-25 15:40:30 -04:00
|
|
|
frame->SetIcon(wxIcon(wxT("aiai.xbm")));
|
2003-08-03 14:29:53 -04:00
|
|
|
#endif
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// Make a menubar
|
|
|
|
wxMenu *file_menu = new wxMenu;
|
|
|
|
wxMenu *active_menu = new wxMenu;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
file_menu->Append( ID_LOAD, _("&Load layouts") );
|
|
|
|
file_menu->Append( ID_STORE, _("&Store layouts") );
|
2003-08-03 14:29:53 -04:00
|
|
|
file_menu->AppendSeparator();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
file_menu->Append( ID_AUTOSAVE, _("&Auto Save Layouts"), _("save layouts on exit"), wxITEM_CHECK );
|
2003-08-03 14:29:53 -04:00
|
|
|
file_menu->AppendSeparator();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
file_menu->Append(MINIMAL_ABOUT, _("A&bout !"));
|
|
|
|
file_menu->Append(MINIMAL_QUIT, _("E&xit\tTab"));
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
//active_menu->Append( ID_SETTINGS, _("&Settings...\tCtrl") );
|
2003-08-03 14:29:53 -04:00
|
|
|
//active_menu->AppendSeparator();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
active_menu->Append( ID_REMOVE, _("&Remove Active") );
|
|
|
|
active_menu->Append( ID_REMOVEALL, _("Remove &All") );
|
|
|
|
active_menu->Append( ID_RECREATE, _("Re&create") );
|
2003-08-03 14:29:53 -04:00
|
|
|
active_menu->AppendSeparator();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
active_menu->Append( ID_FIRST, _("Activate f&irst layout \tF1"), _("activate it"), wxITEM_CHECK );
|
|
|
|
active_menu->Append( ID_SECOND, _("Activate &second layout\tF2"), _("activate it"), wxITEM_CHECK );
|
|
|
|
active_menu->Append( ID_THIRD, _("Activate &third layout\tF3"), _("activate it"), wxITEM_CHECK );
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxMenuBar *menu_bar = new wxMenuBar;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
menu_bar->Append(file_menu, _("&File"));
|
|
|
|
menu_bar->Append(active_menu, _("Active &Layout"));
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
frame->CreateStatusBar(3);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
frame->SetMenuBar(menu_bar);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
frame->SyncMenuBarItems();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// Show the frame
|
2004-05-25 08:44:56 -04:00
|
|
|
frame->Show(true);
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
SetTopWindow(frame);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
return true;
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MyFrame::~MyFrame()
|
|
|
|
{
|
|
|
|
// frame-layouts is not a windows (objects), thus should
|
|
|
|
// be cleaned up manually
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
for( int i = 0; i != MAX_LAYOUTS; ++i )
|
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
if ( mLayouts[i] )
|
2003-08-03 14:29:53 -04:00
|
|
|
delete mLayouts[i];
|
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
if ( mpNestedLayout )
|
2003-08-03 14:29:53 -04:00
|
|
|
delete mpNestedLayout;
|
2004-05-25 08:44:56 -04:00
|
|
|
if ( mpAboutBoxLayout )
|
2003-08-03 14:29:53 -04:00
|
|
|
delete mpAboutBoxLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** Implementation for class MyFrame *****/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|
|
|
EVT_MENU( MINIMAL_QUIT, MyFrame::OnQuit )
|
|
|
|
EVT_MENU( MINIMAL_ABOUT, MyFrame::OnAbout )
|
|
|
|
|
|
|
|
EVT_MENU( ID_LOAD, MyFrame::OnLoad )
|
|
|
|
EVT_MENU( ID_STORE, MyFrame::OnStore )
|
|
|
|
EVT_MENU( ID_AUTOSAVE, MyFrame::OnAutoSave )
|
|
|
|
//EVT_MENU( ID_SETTINGS, MyFrame::OnSettings )
|
|
|
|
EVT_MENU( ID_REMOVE, MyFrame::OnRemove )
|
|
|
|
EVT_MENU( ID_REMOVEALL, MyFrame::OnRemoveAll )
|
|
|
|
EVT_MENU( ID_RECREATE, MyFrame::OnRecreate )
|
|
|
|
EVT_MENU( ID_FIRST, MyFrame::OnFirst )
|
|
|
|
EVT_MENU( ID_SECOND, MyFrame::OnSecond )
|
|
|
|
EVT_MENU( ID_THIRD, MyFrame::OnThird )
|
|
|
|
|
|
|
|
EVT_BUTTON( ID_SAY_ITSOK, MyFrame::OnSayItsOk )
|
|
|
|
EVT_BUTTON( ID_BTN_YES, MyFrame::OnBtnYes )
|
|
|
|
EVT_BUTTON( ID_BTN_NO, MyFrame::OnBtnNo )
|
|
|
|
EVT_BUTTON( ID_BTN_ESC, MyFrame::OnBtnEsc )
|
|
|
|
|
|
|
|
EVT_CHAR_HOOK( MyFrame::OnChar )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
// My frame constructor
|
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
MyFrame::MyFrame(wxFrame *frame, const wxChar *title, int x, int y, int w, int h)
|
2004-05-25 08:44:56 -04:00
|
|
|
: wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)),
|
2003-08-03 14:29:53 -04:00
|
|
|
mpNestedLayout( NULL ),
|
|
|
|
mpAboutBoxLayout( NULL ),
|
|
|
|
|
|
|
|
mActiveLayoutNo( FIRST_LAYOUT ),
|
2004-05-25 08:44:56 -04:00
|
|
|
mAutoSave( true ),
|
|
|
|
mSavedAlready( false ),
|
2003-08-03 14:29:53 -04:00
|
|
|
mpClntWindow( NULL ),
|
|
|
|
|
2004-05-25 08:44:56 -04:00
|
|
|
mImageList( 16,16, false, 2 )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2003-11-09 16:40:34 -05:00
|
|
|
int i;
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
mpInternalFrm = (wxPanel*)this;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
mAboutBox.Create( this, wxID_ANY, _T("About box in wxWidgets style..."),
|
2003-08-03 14:29:53 -04:00
|
|
|
wxDefaultPosition,
|
|
|
|
wxSize( 385,220),
|
2004-05-25 08:44:56 -04:00
|
|
|
wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL );
|
|
|
|
|
|
|
|
for( i = 0; i != MAX_LAYOUTS; ++i )
|
2003-08-03 14:29:53 -04:00
|
|
|
mLayouts[i] = NULL;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// image-list is one of the few objects which
|
2004-05-25 08:44:56 -04:00
|
|
|
// currently cannot be serialized, create it first
|
2003-08-03 14:29:53 -04:00
|
|
|
// and use it as initial reference (IR)
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxBitmap bmp1,bmp2;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
if ( wxFileExists( wxString(wxT(BMP_DIR)) + wxT("folder_icon.bmp") ) )
|
|
|
|
bmp1.LoadFile( wxString(wxT(BMP_DIR)) + wxT("folder_icon.bmp"), wxBITMAP_TYPE_BMP );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
if ( wxFileExists( wxString(wxT(BMP_DIR)) + wxT("class_icon1.bmp") ) )
|
|
|
|
bmp2.LoadFile( wxString(wxT(BMP_DIR)) + wxT("class_icon1.bmp"), wxBITMAP_TYPE_BMP );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
mImageList.Add( bmp1 );
|
|
|
|
mImageList.Add( bmp2 );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
InitAboutBox();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// create multiple layouts
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
mpNestedLayout = 0;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
mpClntWindow = CreateTxtCtrl(wxT("client window"));
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// Create all layouts
|
|
|
|
for( i = 0; i != MAX_LAYOUTS; ++i )
|
2004-05-25 08:44:56 -04:00
|
|
|
{
|
2003-08-03 14:29:53 -04:00
|
|
|
CreateLayout( i );
|
|
|
|
}
|
|
|
|
// hide others
|
|
|
|
for( i = SECOND_LAYOUT; i != MAX_LAYOUTS; ++i )
|
|
|
|
{
|
|
|
|
mLayouts[i]->HideBarWindows();
|
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
// activate first one
|
2003-08-03 14:29:53 -04:00
|
|
|
mLayouts[FIRST_LAYOUT]->Activate();
|
|
|
|
mActiveLayoutNo = FIRST_LAYOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** event handlers ***/
|
|
|
|
|
|
|
|
bool MyFrame::OnClose(void)
|
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
// USEFUL TRICK:: avoids flickering of application's frame
|
2003-08-03 14:29:53 -04:00
|
|
|
// when closing NN windows on exit:
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
Show(false);
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
if ( (mAutoSave && mSavedAlready) || !mAutoSave )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCommandEvent evt;
|
2004-05-25 08:44:56 -04:00
|
|
|
OnStore(evt);
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
mAboutBox.Destroy();
|
2004-05-25 08:44:56 -04:00
|
|
|
Destroy();
|
|
|
|
|
|
|
|
return true;
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
|
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::OnAutoSave( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
mAutoSave = !mAutoSave;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxCommandEvent evt;
|
2004-05-25 08:44:56 -04:00
|
|
|
OnStore(evt);
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
SyncMenuBarItems();
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnRemove( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
RemoveLayout( mActiveLayoutNo );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnRemoveAll( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
for( int i = 0; i != MAX_LAYOUTS; ++i )
|
2004-05-25 08:44:56 -04:00
|
|
|
{
|
2003-08-03 14:29:53 -04:00
|
|
|
RemoveLayout( i );
|
|
|
|
}
|
|
|
|
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MyFrame::OnRecreate( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
OnRemove( event ); // first destroy active layout
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
CreateLayout( mActiveLayoutNo );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
mLayouts[mActiveLayoutNo]->Activate();
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnFirst( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
ActivateLayout( FIRST_LAYOUT );
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnSecond( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
ActivateLayout( SECOND_LAYOUT );
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnThird( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
ActivateLayout( THIRD_LAYOUT );
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
// USEFUL TRICK:: avoids flickering of application's frame
|
2003-08-03 14:29:53 -04:00
|
|
|
// when closing NN windows on exit:
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
Show(false);
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
if ( (mAutoSave && mSavedAlready) || !mAutoSave )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCommandEvent evt;
|
2004-05-25 08:44:56 -04:00
|
|
|
OnStore(evt);
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
wxFont font;
|
|
|
|
#ifdef __WXMSW__
|
2003-08-25 15:40:30 -04:00
|
|
|
font.SetFaceName(wxT("MS Sans Serif"));
|
2003-08-03 14:29:53 -04:00
|
|
|
#else
|
|
|
|
font.SetFamily( wxSWISS );
|
|
|
|
#endif
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
font.SetStyle( wxSLANT );
|
|
|
|
font.SetWeight( wxNORMAL );
|
|
|
|
font.SetPointSize( 8 );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
font.RealizeResource();
|
|
|
|
#endif
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
mAboutBox.Center( wxBOTH );
|
2004-05-25 08:44:56 -04:00
|
|
|
mAboutBox.Show(true);
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnChar( wxKeyEvent& event )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
if ( event.m_keyCode == WXK_F1 )
|
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
OnFirst( evt );
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( event.m_keyCode == WXK_F2 )
|
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
OnSecond( evt );
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( event.m_keyCode == WXK_F3 )
|
2004-05-25 08:44:56 -04:00
|
|
|
{
|
|
|
|
OnThird( evt );
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
if ( event.m_keyCode == WXK_F4 && !event.AltDown() )
|
2004-05-25 08:44:56 -04:00
|
|
|
{
|
2003-08-03 14:29:53 -04:00
|
|
|
// "AI" :-)
|
2003-08-25 15:40:30 -04:00
|
|
|
wxMessageBox(_("There are only 3 layouts in this demo :-("));
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( event.m_keyCode == WXK_TAB )
|
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
// USEFUL TRICK:: avoids flickering of application's frame
|
2003-08-03 14:29:53 -04:00
|
|
|
// when closing NN windows on exit:
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
Show(false);
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
if ( (mAutoSave && mSavedAlready) || !mAutoSave )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCommandEvent evt;
|
2004-05-25 08:44:56 -04:00
|
|
|
OnStore(evt);
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnSayItsOk( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
wxMessageBox(_("It's OK :-)\n\n now click on the border around the button\n and try dragging it!") );
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnBtnYes( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
mAboutBox.Show(false);
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnBtnNo( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
mAboutBox.Show(false);
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::OnBtnEsc( wxCommandEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
mAboutBox.Show(false);
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** helper methods ***/
|
|
|
|
|
|
|
|
void MyFrame::InitAboutBox()
|
|
|
|
{
|
|
|
|
wxPanel* pArea = new wxPanel();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
pArea->Create( &mAboutBox, wxID_ANY );
|
|
|
|
|
|
|
|
new wxStaticText(pArea, wxID_ANY, _("This is wxFrameLayout contribution demo."),
|
2003-08-03 14:29:53 -04:00
|
|
|
wxPoint(10, 10) );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
new wxStaticText(pArea, wxID_ANY, _("Aleksandras Gluchovas (c) 1998"),
|
2003-08-03 14:29:53 -04:00
|
|
|
wxPoint(10, 30) );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
new wxStaticText(pArea, wxID_ANY, _("<mailto:alex@soften.ktu.lt>"),
|
2003-08-03 14:29:53 -04:00
|
|
|
wxPoint(10, 50) );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
mpAboutBoxLayout = new wxFrameLayout( &mAboutBox, pArea, true );
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxFrameLayout& layout = *mpAboutBoxLayout;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbDimInfo sizes( 90,40, // when docked horizontally
|
|
|
|
45,55, // when docked vertically
|
|
|
|
90,40, // when floated
|
2004-05-25 08:44:56 -04:00
|
|
|
true, 4, 4 // true - bar is fixed-size
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
wxButton* pYes = CreateButton(_("&Yes"), &mAboutBox, ID_SAY_ITSOK );
|
|
|
|
wxButton* pNo = CreateButton(_("&No"), &mAboutBox, ID_BTN_NO );
|
|
|
|
wxButton* pEsc = CreateButton(_("Cancel"), &mAboutBox, ID_BTN_ESC );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
layout.AddBar( pEsc, sizes, FL_ALIGN_BOTTOM, 0, 20, _("cancel button"));
|
|
|
|
layout.AddBar( pNo, sizes, FL_ALIGN_BOTTOM, 0, 20, _("no button"));
|
|
|
|
layout.AddBar( pYes, sizes, FL_ALIGN_BOTTOM, 0, 20, _("yes button"));
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
layout.mBorderPen.SetColour( 192, 192, 192 );
|
|
|
|
layout.SetMargins( 15, 15, 15, 15, wxALL_PANES );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbCommonPaneProperties props;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
layout.GetPaneProperties( props, FL_ALIGN_TOP );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
props.mShow3DPaneBorderOn = false;
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
layout.SetPaneProperties( props, wxALL_PANES );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
layout.Activate();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
pYes->SetDefault();
|
|
|
|
pYes->SetFocus();
|
|
|
|
}
|
|
|
|
|
2004-05-25 08:44:56 -04:00
|
|
|
wxTextCtrl* MyFrame::CreateTxtCtrl( const wxString& txt, wxWindow* parent )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
return new wxTextCtrl( (parent != NULL ) ? parent : mpInternalFrm,
|
2004-05-25 08:44:56 -04:00
|
|
|
wxID_ANY, txt, wxDefaultPosition, wxDefaultSize,
|
2003-08-03 14:29:53 -04:00
|
|
|
wxTE_MULTILINE );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxButton* MyFrame::CreateButton( const wxString& label,
|
|
|
|
wxWindow* pParent, long id )
|
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
return new wxButton( (pParent)?pParent : mpInternalFrm, id,
|
2003-08-03 14:29:53 -04:00
|
|
|
label, wxPoint( 0,0 ), wxSize( 0,0 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxTreeCtrl* MyFrame::CreateTreeCtrl( const wxString& label )
|
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
wxTreeCtrl* pTree = new wxTreeCtrl( mpInternalFrm, wxID_ANY );
|
|
|
|
|
2004-05-15 13:38:29 -04:00
|
|
|
const wxTreeItemId rootid = pTree->AppendItem( (long)0, label, 0);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
if ( label[0] != 'X' )
|
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
pTree->AppendItem(rootid, _("Leaf1"), 0);
|
|
|
|
pTree->AppendItem(rootid, _("Leaf2"), 0);
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
pTree->AppendItem(rootid, _("Scully"), 0);
|
|
|
|
pTree->AppendItem(rootid, _("Mulder"), 0);
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
return pTree;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxChoice* MyFrame::CreateChoice( const wxString& txt )
|
|
|
|
{
|
|
|
|
wxString choice_strings[5];
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
choice_strings[0] = txt;
|
2003-08-25 15:40:30 -04:00
|
|
|
choice_strings[1] = _("Julian");
|
|
|
|
choice_strings[2] = _("Hattie");
|
|
|
|
choice_strings[3] = _("Ken");
|
|
|
|
choice_strings[4] = _("Dick");
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
wxChoice *choice = new wxChoice( mpInternalFrm, 301, wxDefaultPosition,
|
2003-08-03 14:29:53 -04:00
|
|
|
wxDefaultSize, 5, choice_strings);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
choice->SetSelection(0);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
return choice;
|
|
|
|
}
|
|
|
|
|
|
|
|
// helper
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void MyFrame::AddSearchToolbars( wxFrameLayout& layout, wxWindow* WXUNUSED(pParent) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
cbDimInfo sizes2( 275,38, // when docked horizontally
|
|
|
|
45,275, // when docked vertically
|
|
|
|
80,30, // when floated
|
|
|
|
true, // the bar is fixed-size
|
2003-08-03 14:29:53 -04:00
|
|
|
4, // vertical gap (bar border)
|
|
|
|
4, // horizontal gap (bar border)
|
|
|
|
new cbDynToolBarDimHandler()
|
2004-05-25 08:44:56 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
cbDimInfo sizes3( 275,55, // when docked horizontally
|
|
|
|
275,60, // when docked vertically
|
|
|
|
45,130, // when floated
|
|
|
|
true, // the bar is fixed-size
|
2003-08-03 14:29:53 -04:00
|
|
|
4, // vertical gap (bar border)
|
|
|
|
4, // horizontal gap (bar border)
|
|
|
|
new cbDynToolBarDimHandler()
|
2004-05-25 08:44:56 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
cbDimInfo sizes4( 430,35, // when docked horizontally
|
|
|
|
44,375, // when docked vertically
|
|
|
|
80,100, // when floated
|
|
|
|
true, // the bar is fixed-size
|
2003-08-03 14:29:53 -04:00
|
|
|
4, // vertical gap (bar border)
|
|
|
|
4, // horizontal gap (bar border)
|
|
|
|
new cbDynToolBarDimHandler()
|
2004-05-25 08:44:56 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
wxDynamicToolBar* pTBar2 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY );
|
|
|
|
|
|
|
|
wxChoice* pChoice = new wxChoice( pTBar2, wxID_ANY, wxDefaultPosition, wxSize( 140,25 ) );
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
pTBar2->AddTool( 1, pChoice );
|
2003-08-25 15:40:30 -04:00
|
|
|
pTBar2->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("search.bmp") );
|
2003-08-03 14:29:53 -04:00
|
|
|
//pTBar2->AddSeparator();
|
2003-08-25 15:40:30 -04:00
|
|
|
pTBar2->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("bookmarks.bmp") );
|
|
|
|
pTBar2->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("nextmark.bmp") );
|
|
|
|
pTBar2->AddTool( 5, wxString(wxT(BMP_DIR)) + wxT("prevmark.bmp") );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
wxDynamicToolBar* pTBar3 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY );
|
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
pTBar3->AddTool( 1, wxString(wxT(BMP_DIR)) + wxT("open.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Open ")) );
|
|
|
|
pTBar3->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("save.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Save ")) );
|
|
|
|
pTBar3->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("saveall.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Save All ")) );
|
2003-08-03 14:29:53 -04:00
|
|
|
//pTBar3->AddSeparator();
|
2003-08-25 15:40:30 -04:00
|
|
|
pTBar3->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("cut.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Open ")) );
|
|
|
|
pTBar3->AddTool( 5, wxString(wxT(BMP_DIR)) + wxT("copy.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Copy ")) );
|
|
|
|
pTBar3->AddTool( 6, wxString(wxT(BMP_DIR)) + wxT("paste.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Paste ")) );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
#ifdef __WXMSW__
|
2004-05-25 08:44:56 -04:00
|
|
|
pTBar3->EnableTool( 2, false );
|
2003-08-03 14:29:53 -04:00
|
|
|
#endif
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
wxDynamicToolBar* pTBar4 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY );
|
|
|
|
|
|
|
|
pTBar4->AddTool( 1, wxString(wxT(BMP_DIR)) + wxT("bookmarks.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Bookmarks ")), true );
|
|
|
|
pTBar4->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("nextmark.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Next bookmark ")), true );
|
|
|
|
pTBar4->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("prevmark.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Prev bookmark ")), true );
|
2003-08-03 14:29:53 -04:00
|
|
|
//pTBar4->AddSeparator();
|
2004-05-25 08:44:56 -04:00
|
|
|
pTBar4->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("search.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Search ")), true );
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
#ifdef __WXMSW__
|
2004-05-25 08:44:56 -04:00
|
|
|
pTBar4->EnableTool( 4, false );
|
2003-08-03 14:29:53 -04:00
|
|
|
#endif
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
layout.AddBar( pTBar2,
|
|
|
|
sizes2, FL_ALIGN_TOP,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
wxT("Search"),
|
|
|
|
true
|
2003-08-03 14:29:53 -04:00
|
|
|
);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
layout.AddBar( pTBar3,
|
|
|
|
sizes3, FL_ALIGN_BOTTOM,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
wxT("Titled"),
|
|
|
|
true
|
2003-08-03 14:29:53 -04:00
|
|
|
);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
layout.AddBar( pTBar4,
|
|
|
|
sizes4, FL_ALIGN_BOTTOM,
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
wxT("Bookmarks"),
|
|
|
|
true
|
2003-08-03 14:29:53 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxWindow* MyFrame::CreateDevLayout( wxFrameLayout& layout, wxWindow* pParent )
|
|
|
|
{
|
|
|
|
bool isNested = (pParent != mpInternalFrm);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// check if we're craeting nested layout
|
|
|
|
if ( isNested )
|
|
|
|
{
|
|
|
|
layout.mBorderPen.SetColour( 128,255,128 );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// if so, than make border smaller
|
|
|
|
for( int i = 0; i != MAX_PANES; ++i )
|
|
|
|
{
|
|
|
|
cbDockPane& pane = *layout.GetPane( i );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
pane.mTopMargin = 5;
|
|
|
|
pane.mBottomMargin = 5;
|
|
|
|
pane.mLeftMargin = 5;
|
|
|
|
pane.mRightMargin = 5;
|
|
|
|
}
|
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
int cbWidth = 200;
|
|
|
|
int cbHeight = ( isNested ) ? 50 : 150;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbDimInfo sizes4( cbWidth,cbHeight,
|
|
|
|
cbWidth,cbHeight,
|
2004-05-25 08:44:56 -04:00
|
|
|
cbWidth,cbHeight, false );
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbWidth = 75;
|
|
|
|
cbHeight = 31;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbDimInfo sizes5( cbWidth,cbHeight,
|
|
|
|
42,65,
|
2004-05-25 08:44:56 -04:00
|
|
|
cbWidth,cbHeight, true,
|
2003-08-03 14:29:53 -04:00
|
|
|
3, // vertical gap (bar border)
|
|
|
|
3 // horizontal gap (bar border)
|
2004-05-25 08:44:56 -04:00
|
|
|
);
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// create "workplace" window in the third layout
|
|
|
|
// SEB: originally here was a wxpp (wxWorkshop) class demotrated
|
|
|
|
// wxTabbedWindow* pMiniTabArea = new wxTabbedWindow();
|
2004-05-25 08:44:56 -04:00
|
|
|
// pMiniTabArea->Create( pParent, wxID_ANY );
|
|
|
|
|
|
|
|
|
|
|
|
wxTreeCtrl* pClassView = new wxTreeCtrl( pParent, wxID_ANY,
|
2003-08-03 14:29:53 -04:00
|
|
|
wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
pClassView->SetImageList( &mImageList );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2004-05-25 07:20:37 -04:00
|
|
|
wxTreeItemId rootId = pClassView->AddRoot( wxT("wxWidgets 2.0 classes"), 0 );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
pClassView->AppendItem( rootId, _("wxWin Dynamic classes (grabbed at run-time)"), 0 );
|
|
|
|
pClassView->AppendItem( rootId, _("serializer-classes (grabbed at run-time)"), 0 );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// now create "output" window
|
2004-05-25 08:44:56 -04:00
|
|
|
wxNotebook* pTabbedArea = new wxNotebook(pParent, wxID_ANY);
|
2003-08-03 14:29:53 -04:00
|
|
|
// SEB: originally here was a wxpp (wxWorkshop) class used
|
|
|
|
// wxPaggedWindow* pTabbedArea = new wxPaggedWindow();
|
2004-05-25 08:44:56 -04:00
|
|
|
// pTabbedArea->Create( pParent, wxID_ANY );
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxPanel* pSheet3 = new wxPanel();
|
2004-05-25 08:44:56 -04:00
|
|
|
pSheet3->Create( pTabbedArea, wxID_ANY );
|
|
|
|
pSheet3->Show(false);
|
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
pTabbedArea->AddPage( CreateTxtCtrl(wxT("build"), pTabbedArea), wxT("Build"));
|
|
|
|
pTabbedArea->AddPage( CreateTxtCtrl(wxT("debug"), pTabbedArea), wxT("Debug"));
|
|
|
|
pTabbedArea->AddPage( pSheet3, wxT("is THIS recursive - or what !?"));
|
|
|
|
pTabbedArea->AddPage( CreateTxtCtrl(wxT("profile"), pTabbedArea), wxT("Profile"));
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
layout.AddBar( new StartButton95(pParent), sizes5, FL_ALIGN_TOP, 0, 0, wxT("Start...") );
|
|
|
|
layout.AddBar( pClassView, sizes4, FL_ALIGN_LEFT, 0, 0, wxT("Project Workplace") );
|
|
|
|
layout.AddBar( pTabbedArea, sizes4, FL_ALIGN_BOTTOM, 0, 50, wxT("Output") );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
return pSheet3;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::DropInSomeBars( int layoutNo )
|
|
|
|
{
|
|
|
|
/* create once... and forget! */
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// setup dimension infos for various bar shapes
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
int cbWidth = 90;
|
|
|
|
int cbHeight = 30;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
if ( layoutNo == SECOND_LAYOUT )
|
2003-08-03 14:29:53 -04:00
|
|
|
cbHeight = 60;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxFrameLayout& layout = *mLayouts[layoutNo];
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbDimInfo sizes( cbWidth,cbHeight, // when docked horizontally
|
|
|
|
cbWidth,cbHeight, // when docked vertically
|
|
|
|
cbWidth,cbHeight, // when floated
|
2004-05-25 08:44:56 -04:00
|
|
|
true // true - bar is fixed-size
|
|
|
|
);
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbWidth = 120;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbDimInfo sizes1( cbWidth,cbHeight,
|
|
|
|
cbWidth,cbHeight,
|
2004-05-25 08:44:56 -04:00
|
|
|
cbWidth,cbHeight, false ); // false - bar is "flexible"
|
2003-08-03 14:29:53 -04:00
|
|
|
|
|
|
|
cbWidth = 120;
|
|
|
|
cbHeight = 40;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbDimInfo sizes3( cbWidth,cbHeight,
|
|
|
|
cbWidth,cbHeight,
|
2004-05-25 08:44:56 -04:00
|
|
|
cbWidth,cbHeight, true ); // -/-
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbWidth = 200;
|
|
|
|
cbHeight = 150;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbDimInfo sizes4( cbWidth,cbHeight,
|
|
|
|
cbWidth,cbHeight,
|
2004-05-25 08:44:56 -04:00
|
|
|
cbWidth,cbHeight, false ); // -/-
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbWidth = 63;
|
|
|
|
cbHeight = 31;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
cbDimInfo sizes5( cbWidth,cbHeight,
|
|
|
|
cbHeight,cbWidth,
|
2004-05-25 08:44:56 -04:00
|
|
|
cbWidth,cbHeight, true,
|
2003-08-03 14:29:53 -04:00
|
|
|
3, // vertical gap (bar border)
|
|
|
|
3 // horizontal gap (bar border)
|
|
|
|
); // -/-
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
if ( layoutNo == FIRST_LAYOUT )
|
|
|
|
{
|
|
|
|
// add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info)
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxWindow* pGreenOne = new MyTestPanel(mpInternalFrm);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
pGreenOne->SetBackgroundColour( wxColour(128,255,128) );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
layout.AddBar( pGreenOne, sizes, FL_ALIGN_TOP, 0, 50, wxT("Bar1"), true );
|
|
|
|
layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_TOP, 2, 50, wxT("Bar2"), true );
|
|
|
|
layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_BOTTOM, 2, 50, wxT("Bar3"), true );
|
|
|
|
layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_LEFT, 2, 50, wxT("Bar4"), true );
|
|
|
|
layout.AddBar( new MyTestPanel(mpInternalFrm), sizes1, wxCBAR_HIDDEN, 2, 50, wxT("Super-Bar"), true );
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( layoutNo == SECOND_LAYOUT )
|
|
|
|
{
|
|
|
|
// show off various wx-controls in the second layout
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
layout.AddBar( CreateTxtCtrl(), sizes, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area&0") );
|
|
|
|
layout.AddBar( CreateButton(wxT("OK")), sizes, FL_ALIGN_TOP, 0, 100, wxT("First Button") );
|
|
|
|
layout.AddBar( CreateTxtCtrl(), sizes1, FL_ALIGN_BOTTOM, 0, 50, wxT("First Tree") );
|
|
|
|
layout.AddBar( CreateTreeCtrl(wxT("Root")), sizes1, FL_ALIGN_LEFT, 0, 0, wxT("TreeCtrl Window") );
|
2004-05-25 08:44:56 -04:00
|
|
|
layout.AddBar( CreateChoice(wxT("Choice 1")), sizes3, FL_ALIGN_TOP, 0, 0, wxT("Choice 1 (buggy)"), false, wxCBAR_HIDDEN );
|
|
|
|
layout.AddBar( CreateChoice(wxT("Choice 2")), sizes3, FL_ALIGN_TOP, 0, 0, wxT("Choice 2 (buggy)"), false, wxCBAR_HIDDEN );
|
2003-08-25 15:40:30 -04:00
|
|
|
layout.AddBar( CreateTreeCtrl(wxT("X-Files")), sizes1, FL_ALIGN_RIGHT, 0, 100, wxT("X-Files") );
|
|
|
|
layout.AddBar( CreateTxtCtrl(wxT("smaller1")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("smaller Area1") );
|
|
|
|
layout.AddBar( CreateTxtCtrl(wxT("smaller2")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("sm&ller Area2") );
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( layoutNo == THIRD_LAYOUT )
|
|
|
|
{
|
|
|
|
#if defined(__WXGTK__) || defined(__WXX11__)
|
|
|
|
cbCommonPaneProperties props;
|
|
|
|
layout.GetPaneProperties( props );
|
2004-05-25 08:44:56 -04:00
|
|
|
props.mRealTimeUpdatesOn = false; // real-time OFF for gtk!!!
|
2003-08-03 14:29:53 -04:00
|
|
|
layout.SetPaneProperties( props, wxALL_PANES );
|
|
|
|
#endif
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
layout.AddBar( CreateTxtCtrl(wxT("Tool1")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area1") );
|
|
|
|
layout.AddBar( CreateTxtCtrl(wxT("Tool2")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area2") );
|
|
|
|
layout.AddBar( CreateTxtCtrl(wxT("Tool3")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area3") );
|
|
|
|
layout.AddBar( CreateTxtCtrl(wxT("Tool4")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area4") );
|
|
|
|
layout.AddBar( CreateTxtCtrl(wxT("Tool5")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area5") );
|
|
|
|
layout.AddBar( CreateTxtCtrl(wxT("Tool6")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area6") );
|
|
|
|
layout.AddBar( CreateTxtCtrl(wxT("Tool7")), sizes3, FL_ALIGN_TOP, 2,250, wxT("Fixed text Area7") );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
cbDimInfo sizes10( 175,35, // when docked horizontally
|
|
|
|
175,38, // when docked vertically
|
|
|
|
170,35, // when floated
|
|
|
|
true, // the bar is not fixed-size
|
2003-08-03 14:29:53 -04:00
|
|
|
4, // vertical gap (bar border)
|
|
|
|
4, // horizontal gap (bar border)
|
|
|
|
new cbDynToolBarDimHandler()
|
2004-05-25 08:44:56 -04:00
|
|
|
);
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxDynamicToolBar* pToolBar = new wxDynamicToolBar();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
pToolBar->Create( mpInternalFrm, wxID_ANY );
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// 1001-1006 ids of command events fired by added tool-buttons
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
pToolBar->AddTool( 1001, wxString(wxT(BMP_DIR)) + wxT("new.bmp") );
|
|
|
|
pToolBar->AddTool( 1002, wxString(wxT(BMP_DIR)) + wxT("open.bmp") );
|
|
|
|
pToolBar->AddTool( 1003, wxString(wxT(BMP_DIR)) + wxT("save.bmp") );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
pToolBar->AddTool( 1004, wxString(wxT(BMP_DIR)) + wxT("cut.bmp") );
|
|
|
|
pToolBar->AddTool( 1005, wxString(wxT(BMP_DIR)) + wxT("copy.bmp") );
|
|
|
|
pToolBar->AddTool( 1006, wxString(wxT(BMP_DIR)) + wxT("paste.bmp") );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
layout.AddBar( pToolBar, // bar window (can be NULL)
|
|
|
|
sizes10, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc)
|
|
|
|
0, // insert into 0th row (vert. position)
|
|
|
|
0, // offset from the start of row (in pixels)
|
2003-08-25 15:40:30 -04:00
|
|
|
wxT("Real-Toolbar"), // name to refere in customization pop-ups
|
2004-05-25 08:44:56 -04:00
|
|
|
false
|
2003-08-03 14:29:53 -04:00
|
|
|
);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// create first "developement" layout
|
|
|
|
AddSearchToolbars( layout, mpInternalFrm);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
wxWindow* pSheet3 = CreateDevLayout( layout, mpInternalFrm);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// create another ***secreat developement*** layout inside
|
|
|
|
// the third sheet of the outter one's output bar
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
mpNestedLayout = new wxFrameLayout( pSheet3,
|
|
|
|
CreateTxtCtrl(wxT("\"Mobils in Mobile\" --C.Nemo"),pSheet3), false );
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
CreateDevLayout( *mpNestedLayout, pSheet3 );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
mpNestedLayout->Activate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
}
|
2003-08-03 14:29:53 -04:00
|
|
|
|
|
|
|
void MyFrame::CreateLayout( int layoutNo )
|
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
wxFrameLayout* pLayout = new wxFrameLayout( mpInternalFrm, mpClntWindow, false );
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
if ( layoutNo == THIRD_LAYOUT )
|
|
|
|
{
|
|
|
|
pLayout->PushDefaultPlugins();
|
|
|
|
pLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for bars
|
2004-05-25 08:44:56 -04:00
|
|
|
#if defined(__WXGTK__) || defined(__WXX11__)
|
2003-08-03 14:29:53 -04:00
|
|
|
pLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
|
|
|
|
#endif
|
2004-05-25 08:44:56 -04:00
|
|
|
pLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) );
|
2003-08-03 14:29:53 -04:00
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
mLayouts[layoutNo] = pLayout;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
DropInSomeBars( layoutNo );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::RemoveLayout( int layoutNo )
|
|
|
|
{
|
|
|
|
wxFrameLayout* pLayout = mLayouts[layoutNo];
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
if ( !pLayout )
|
2003-08-03 14:29:53 -04:00
|
|
|
return;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
pLayout->HideBarWindows();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
// destroy nested layout first
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
if ( layoutNo == THIRD_LAYOUT )
|
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
if ( mpNestedLayout )
|
2003-08-03 14:29:53 -04:00
|
|
|
delete mpNestedLayout;
|
|
|
|
mpNestedLayout = NULL;
|
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
// NOTE:: bar windows are NOT destroyed automatically by frame-layout
|
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
pLayout->DestroyBarWindows();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
delete pLayout;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
mLayouts[layoutNo] = NULL;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::SyncMenuBarItems()
|
|
|
|
{
|
|
|
|
for( int i = 0; i != MAX_LAYOUTS; ++i )
|
|
|
|
{
|
|
|
|
GetMenuBar()->Check( ID_FIRST+i, mActiveLayoutNo == FIRST_LAYOUT+i );
|
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
GetMenuBar()->Check( ID_AUTOSAVE, mAutoSave );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::ActivateLayout( int layoutNo )
|
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
if ( layoutNo == mActiveLayoutNo )
|
2003-08-03 14:29:53 -04:00
|
|
|
return;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
if ( mLayouts[mActiveLayoutNo] )
|
|
|
|
mLayouts[mActiveLayoutNo]->Deactivate();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
mActiveLayoutNo = layoutNo;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
if ( mLayouts[mActiveLayoutNo] )
|
2003-08-03 14:29:53 -04:00
|
|
|
mLayouts[mActiveLayoutNo]->Activate();
|
|
|
|
else
|
|
|
|
Refresh();
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
SyncMenuBarItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** Implementation for class StartButton95 (just for fun) *****/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( StartButton95, wxPanel )
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( StartButton95, wxPanel )
|
|
|
|
EVT_LEFT_DOWN( StartButton95::OnMouseDown )
|
|
|
|
EVT_LEFT_UP ( StartButton95::OnMouseUp )
|
|
|
|
EVT_PAINT ( StartButton95::OnPaint )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void StartButton95::OnMouseDown( wxMouseEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2004-05-25 08:44:56 -04:00
|
|
|
m_bPressed = true;
|
2003-08-03 14:29:53 -04:00
|
|
|
Refresh();
|
|
|
|
CaptureMouse();
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void StartButton95::OnMouseUp( wxMouseEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
|
|
|
// "this is not a bug"
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
SetCursor( wxCURSOR_WAIT );
|
|
|
|
GetParent()->SetCursor( wxCURSOR_WAIT );
|
2004-05-25 08:44:56 -04:00
|
|
|
::wxSetCursor( wxCURSOR_WAIT );
|
2003-08-03 14:29:53 -04:00
|
|
|
wxSleep(1);
|
2004-05-25 08:44:56 -04:00
|
|
|
|
|
|
|
for( int i = 1; i != 6; ++i )
|
|
|
|
{
|
2003-08-03 14:29:53 -04:00
|
|
|
m_bPressed = (i % 2) != 0;
|
|
|
|
Refresh();
|
|
|
|
wxSleep(1);
|
|
|
|
}
|
|
|
|
GetParent()->Close();
|
|
|
|
//*((char*)(i)-3) = 'X'; // Aleks what's the meaning of this???
|
|
|
|
}
|
|
|
|
|
2003-11-09 16:40:34 -05:00
|
|
|
void StartButton95::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
2003-08-03 14:29:53 -04:00
|
|
|
{
|
2003-11-09 16:40:34 -05:00
|
|
|
wxBitmap* pBmp;
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
if ( m_bPressed )
|
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
if ( !m_PBmp.Ok() && wxFileExists( wxString(wxT(BMP_DIR)) + wxT("start95_pr.bmp") ) )
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
m_PBmp.LoadFile( wxString(wxT(BMP_DIR)) + wxT("start95_pr.bmp"), wxBITMAP_TYPE_BMP );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
pBmp = &m_PBmp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-08-25 15:40:30 -04:00
|
|
|
if ( !m_DBmp.Ok() && wxFileExists( wxString(wxT(BMP_DIR)) + wxT("start95_dp.bmp") ) )
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-25 15:40:30 -04:00
|
|
|
m_DBmp.LoadFile( wxString(wxT(BMP_DIR)) + wxT("start95_dp.bmp"), wxBITMAP_TYPE_BMP );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
pBmp = &m_DBmp;
|
|
|
|
}
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
if (!pBmp) return;
|
|
|
|
wxMemoryDC mdc;
|
|
|
|
wxPaintDC dc(this);
|
|
|
|
mdc.SelectObject( *pBmp );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
dc.Blit( 0,0, pBmp->GetWidth(), pBmp->GetHeight(), &mdc, 0,0, wxCOPY );
|
2004-05-25 08:44:56 -04:00
|
|
|
|
2003-08-03 14:29:53 -04:00
|
|
|
mdc.SelectObject( wxNullBitmap );
|
|
|
|
}
|