Added Aleksandras' framelayout code, with more or less working Linux Makefiles

General makefiles to be added later.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1876 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Harco de Hilster
1999-03-07 23:34:37 +00:00
parent 8c0d01c876
commit bd9396d52d
84 changed files with 32941 additions and 0 deletions

View File

@@ -0,0 +1 @@
include ../../setup/general/makedirs

View File

@@ -0,0 +1 @@
include ../../../setup/general/makedirs

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1 @@
include ../../../../setup/general/makedirs

View File

@@ -0,0 +1,27 @@
# WXXT base directory
WXBASEDIR=@WXBASEDIR@
# set the OS type for compilation
OS=@OS@
# compile a binary only
RULE=bin
# define executable name
BIN_TARGET=fl_demo
# define library sources
BIN_CPP_SRC=\
fl_demo.cpp\
#define library objects
BIN_OBJ=\
$(BIN_CPP_SRC:.cpp=.o)
# additional things needed to link
BIN_LINK=-lwx_fl_gtk
# additional things needed to compile
ADD_COMPILE=-I../../../src
# include the definitions now
include ../../../../../template.mak

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,142 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 04/11/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __FLDEMO_G__
#define __FLDEMO_G__
// ID for the menu commands
#define MINIMAL_QUIT 1
#define MINIMAL_ABOUT 102
#define ID_LOAD 103
#define ID_STORE 104
#define ID_AUTOSAVE 105
#define ID_SETTINGS 106
#define ID_REMOVE 107
#define ID_REMOVEALL 108
#define ID_RECREATE 109
#define ID_ACTIVATE 110
#define ID_FIRST 111
#define ID_SECOND 112
#define ID_THIRD 113
#define ID_SAY_ITSOK 114
#define ID_BTN_YES 115
#define ID_BTN_NO 116
#define ID_BTN_ESC 117
#define MAX_LAYOUTS 3
#define FIRST_LAYOUT 0
#define SECOND_LAYOUT 1
#define THIRD_LAYOUT 2
class wxFrameLayout;
class wxObjectStorage;
// FOR NOW::
typedef wxPanel MyTestPanel;
// Define a new application type
class MyApp: public wxApp
{
public:
bool OnInit(void);
};
// Define a new frame type
class MyFrame: public wxFrame
{
protected:
wxFrameLayout* mLayouts[MAX_LAYOUTS];
wxFrameLayout* mpNestedLayout;
wxFrameLayout* mpAboutBoxLayout;
int mActiveLayoutNo;
bool mAutoSave;
bool mSavedAlready;
// container windows:
wxTextCtrl* mpClntWindow;
wxPanel* mpInternalFrm;
wxImageList mImageList;
wxFrame mAboutBox;
// helpers for control-creation
wxTextCtrl* CreateTxtCtrl ( const wxString& txt = "wxTextCtrl", wxWindow* parent = NULL );
wxTreeCtrl* CreateTreeCtrl( const wxString& label = "TreeCtrl" );
wxChoice* CreateChoice ( const wxString& txt = "Choice1" );
wxButton* CreateButton ( const wxString& label = "wxButton",
wxWindow* pParent = NULL, long id = ID_SAY_ITSOK );
// helpers for layout-creation
void AddSearchToolbars( wxFrameLayout& layout, wxWindow* pParent );
wxWindow* CreateDevLayout( wxFrameLayout& layout, wxWindow* pParent );
void DropInSomeBars( int layoutNo );
void CreateLayout( int layoutNo );
void RemoveLayout( int layoutNo );
void DestroyEverything();
void InitAboutBox();
void ActivateLayout( int layoutNo );
void SerializeMe( wxObjectStorage& store );
public: /* public */
MyFrame(wxFrame *frame, char *title,
int x, int y, int w, int h);
~MyFrame();
void SyncMenuBarItems();
// event handlers
bool OnClose(void);
void OnLoad( wxCommandEvent& event );
void OnStore( wxCommandEvent& event );
void OnAutoSave( wxCommandEvent& event );
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnSettings( wxCommandEvent& event );
void OnRemove( wxCommandEvent& event );
void OnRemoveAll( wxCommandEvent& event );
void OnRecreate( wxCommandEvent& event );
void OnFirst( wxCommandEvent& event );
void OnSecond( wxCommandEvent& event );
void OnThird( wxCommandEvent& event );
void OnSayItsOk( wxCommandEvent& event );
void OnBtnYes( wxCommandEvent& event );
void OnBtnNo( wxCommandEvent& event );
void OnBtnEsc( wxCommandEvent& event );
void OnChar( wxKeyEvent& event );
DECLARE_EVENT_TABLE()
};
#endif

View File

@@ -0,0 +1,29 @@
#!/bin/sh
cat <<EOF
This script will create Linux build dirs in each of the sample subdirs and
create the makefile.
Make sure you execute the samples in the bitmaps dir, otherwise they
won't find their bitmaps! This will probably result in a crash.
Until I find a more elegant method for this...
EOF
for DIR in demo sample test ; do
cd $DIR
echo Entering $DIR ...
if [ ! -d Linux ] ; then
echo "Making Linux dir"
mkdir Linux
fi
echo "Creating Makefile"
sed -f ../../../../setup/Linux/substit Makefile.in > Linux/Makefile
cd ..
done

View File

@@ -0,0 +1 @@
include ../../../../setup/general/makedirs

View File

@@ -0,0 +1,27 @@
# WXXT base directory
WXBASEDIR=@WXBASEDIR@
# set the OS type for compilation
OS=@OS@
# compile a binary only
RULE=bin
# define executable name
BIN_TARGET=fl_sample
# define library sources
BIN_CPP_SRC=\
fl_sample.cpp\
#define library objects
BIN_OBJ=\
$(BIN_CPP_SRC:.cpp=.o)
# additional things needed to link
BIN_LINK=-lwx_fl_gtk
# additional things needed to compile
ADD_COMPILE=-I../../../src
# include the definitions now
include ../../../../../template.mak

View File

@@ -0,0 +1,294 @@
/////////////////////////////////////////////////////////////////////////////
// Name: main.cpp
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 24/11/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "fl_sample.cpp"
#pragma interface "fl_sample.cpp"
#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
#include "controlbar.h"
#include "objstore.h"
// plugins used
#include "barhintspl.h"
#include "hintanimpl.h"
#include "wx/textctrl.h"
// ADDED by alex (linker complaints...):
char wxDummyChar=0;
#define ID_LOAD 102
#define ID_STORE 103
#define ID_QUIT 104
#define LAYOUT_FILE "layouts.dat"
class MyApp: public wxApp
{
public:
bool OnInit(void);
};
class MyFrame: public wxFrame
{
protected:
wxFrameLayout* mpLayout;
wxWindow* mpClientWnd;
wxPanel* mpInternalFrm;
void SerializeMe( wxObjectStorage& store );
wxTextCtrl* CreateTextCtrl( const wxString& value );
public:
MyFrame( wxWindow* parent, char *title );
~MyFrame();
void OnLoad( wxCommandEvent& event );
void OnStore( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event );
bool OnClose(void) { return TRUE; }
DECLARE_EVENT_TABLE()
};
/***** Implementation for class MyApp *****/
IMPLEMENT_APP (MyApp)
bool MyApp::OnInit(void)
{
// wxWindows boiler-plate:
MyFrame *frame = new MyFrame(NULL, "wxFrameLayout sample");
wxMenu *file_menu = new wxMenu;
file_menu->Append( ID_LOAD, "&Load layout" );
file_menu->Append( ID_STORE, "&Store layout" );
file_menu->AppendSeparator();
file_menu->Append( ID_QUIT, "E&xit" );
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, "&File");
frame->CreateStatusBar(3);
frame->SetMenuBar(menu_bar);
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
/***** 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 )
END_EVENT_TABLE()
MyFrame::MyFrame( wxWindow* parent, char *title )
: wxFrame( parent, -1, "NewTest-II", wxDefaultPosition,
wxSize( 700, 500 ),
wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX |
wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION,
"freimas" )
{
#ifdef __WXMSW__
mpInternalFrm = (wxPanel*)this;
#else
mpInternalFrm = new wxPanel( this, -1 );
#endif
mpClientWnd = CreateTextCtrl( "Client window" );
// btw, creation of internal frame is needed for wxGtk version
// to act correctly (since menu-bar is a separate window there..)
mpLayout = new wxFrameLayout( mpInternalFrm, mpClientWnd );
#ifdef __WXGTK__
// real-time dosn't work well under wxGtk yet
cbCommonPaneProperties props;
mpLayout->GetPaneProperties( props );
props.mRealTimeUpdatesOn = FALSE; // off
mpLayout->SetPaneProperties( props, wxALL_PANES );
#endif
mpLayout->PushDefaultPlugins();
mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for barso
//mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
cbDimInfo sizes( 80,65, // when docked horizontally
80,65, // when docked vertically
80,30, // when floated
TRUE, // the bar is fixed-size
5, // vertical gap (bar border)
5 // horizontal gap (bar border)
);
// drop-in 20 bars
for( int i = 1; i <= 10; ++i )
{
char buf[4];
sprintf( buf, "%d", i );
wxString name = wxString("Bar-");
name += buf;
sizes.mIsFixed = i % 5 > 0; // every fifth bar is not fixed-size
if ( !sizes.mIsFixed ) name += " (flexible)";
mpLayout->AddBar( CreateTextCtrl(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
);
}
}
MyFrame::~MyFrame()
{
// layout is not a window, should be released manually
if ( mpLayout ) delete mpLayout;
}
wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value )
{
wxTextCtrl* pCtrl =
new wxTextCtrl( mpInternalFrm, -1, value,
wxPoint(0,0), wxSize(1,1), wxTE_MULTILINE );
pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) );
return pCtrl;
}
void MyFrame::OnLoad( wxCommandEvent& event )
{
if ( !wxFileExists( LAYOUT_FILE ) )
{
wxMessageBox( "layout data file `layout.dat' not found\n\n store layout first" );
return;
}
mpLayout->HideBarWindows(); // hide first, to avoid flickered destruction
mpLayout->DestroyBarWindows();
if ( mpClientWnd )
{
mpClientWnd->Destroy();
delete mpLayout;
mpClientWnd = NULL;
}
wxIOStreamWrapper stm;
stm.CreateForInput( LAYOUT_FILE ); // TRUE - create stream for input
wxObjectStorage store( stm );
SerializeMe( store );
mpLayout->Activate();
}
void MyFrame::OnStore( wxCommandEvent& event )
{
wxIOStreamWrapper stm;
stm.CreateForOutput( LAYOUT_FILE ); // FALSE - create stream for output
wxObjectStorage store( stm );
SerializeMe( store );
}
void MyFrame::OnQuit( wxCommandEvent& event )
{
Show( FALSE ); // TRICK:: hide it, to avoid flickered destruction
Close(TRUE);
}
void MyFrame::SerializeMe( wxObjectStorage& store )
{
// mark contaienr-frames as not serializable
store.AddInitialRef( mpInternalFrm );
store.AddInitialRef( this );
// does all the rest for as
store.XchgObjPtr( (wxObject**) &(mpLayout) );
store.XchgObjPtr( (wxObject**) &(mpClientWnd) );
store.Finalize(); // finish serialization
}
#ifdef __HACK_MY_MSDEV40__
////////////// new 2.0-magic (linker errors...) ////////////////
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{
wxCHECK_MSG( m_frameToolBar == NULL, FALSE,
"recreating toolbar in wxFrame" );
wxToolBar* toolBar = OnCreateToolBar(style, id, name);
if (toolBar)
{
SetToolBar(toolBar);
PositionToolBar();
return toolBar;
}
else
{
return NULL;
}
}
wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name)
{
return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name);
}
#endif

View File

@@ -0,0 +1 @@
include ../../../../setup/general/makedirs

View File

@@ -0,0 +1,27 @@
# WXXT base directory
WXBASEDIR=@WXBASEDIR@
# set the OS type for compilation
OS=@OS@
# compile a binary only
RULE=bin
# define executable name
BIN_TARGET=fl_test
# define library sources
BIN_CPP_SRC=\
fl_test.cpp\
#define library objects
BIN_OBJ=\
$(BIN_CPP_SRC:.cpp=.o)
# additional things needed to link
BIN_LINK=-lwx_fl_gtk
# additional things needed to compile
ADD_COMPILE=-I../../../src
# include the definitions now
include ../../../../../template.mak

View File

@@ -0,0 +1,324 @@
/////////////////////////////////////////////////////////////////////////////
// Name: minimal.cpp
// Purpose: Minimal wxWindows sample
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "minimal.cpp"
#pragma interface "minimal.cpp"
#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
#include "wx/textctrl.h"
#include "controlbar.h" // core API
#include "fl_test.h"
// extra plugins
#include "barhintspl.h" // beveal for bars with "X"s and grooves
#include "rowdragpl.h" // NC-look with dragable rows
#include "cbcustom.h" // customization plugin
#include "hintanimpl.h"
// beuty-care
#include "gcupdatesmgr.h" // smooth d&d
#include "antiflickpl.h" // double-buffered repaint of decorations
#include "dyntbar.h" // auto-layouting toolbar
#include "dyntbarhnd.h" // control-bar dimension handler for it
// comment it out if it breaks, (this is my workaround for MSDev 4.0 linker)
char wxDummyChar;
IMPLEMENT_APP (MyApp)
bool MyApp::OnInit(void)
{
MyFrame *frame = new MyFrame(NULL);
frame->SetBackgroundColour( wxColour(192,192,192) );
wxMenu *file_menu = new wxMenu;
file_menu->Append( NEW_TEST_LOAD, "&Load layouts" );
file_menu->Append( NEW_TEST_SAVE, "&Store layouts" );
file_menu->Append( NEW_TEST_EXIT, "E&xit" );
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, "&File");
frame->SetMenuBar(menu_bar);
frame->CreateStatusBar(3);
frame->Show(TRUE);
frame->mpClientWnd->Refresh();
SetTopWindow(frame);
return TRUE;
/*
wxMessageBox("Hello, this demo has a bunch of yet-not-fixed-bugs and misssing functionality\n\
The ONLY purpose is to demostrate self-layouting toolbars,\n flat-bitmapped-buttons and 2-new FL-plugins\
(cbRowDragPlugin & cbBarHintsPlugin)\n\n\
BTW, disabled images and label-text are rendered at run-time" );
*/
return TRUE;
}
/***** Implementation for class MyFrame *****/
BEGIN_EVENT_TABLE( MyFrame, wxFrame )
// EVT_CHAR_HOOK(MyFrame::OnKeyDown)
// EVT_PAINT( MyFrame::OnPaint )
EVT_MENU( NEW_TEST_SAVE, MyFrame::OnSave )
EVT_MENU( NEW_TEST_LOAD, MyFrame::OnLoad )
EVT_MENU( NEW_TEST_EXIT, MyFrame::OnExit )
END_EVENT_TABLE()
void MyFrame::OnLoad( wxCommandEvent& event )
{
mpLayout->HideBarWindows();
mpLayout->DestroyBarWindows();
delete mpLayout;
if ( mpClientWnd )
{
mpClientWnd->Destroy();
mpClientWnd = NULL;
}
mpLayout = NULL;
wxIOStreamWrapper& stm = *(new wxIOStreamWrapper());
stm.CreateForInput( "layouts1.dat" );
mStore.SetDataStream( stm );
mStore.XchgObjPtr( (wxObject**) &mpLayout );
mStore.Finalize(); // finish serialization
mpLayout->Activate();
}
void MyFrame::OnSave( wxCommandEvent& event )
{
wxIOStreamWrapper& stm = *(new wxIOStreamWrapper());
stm.CreateForOutput( "layouts1.dat" );
mStore.SetDataStream( stm );
mStore.XchgObjPtr( (wxObject**) &mpLayout );
mStore.Finalize(); // finish serialization
}
void MyFrame::OnExit( wxCommandEvent& event )
{
Destroy();
}
wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value )
{
wxTextCtrl* pCtrl =
new wxTextCtrl( mpInternalFrm, -1, value,
wxDefaultPosition, wxSize(0,0), wxTE_MULTILINE );
pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) );
return pCtrl;
}
MyFrame::MyFrame(wxFrame *frame)
: wxFrame( frame, -1, "wxWindows 2.0 wxFrameLayout Test Application", wxDefaultPosition,
wxSize( 700, 500 ),
wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX |
wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION,
"freimas" )
{
#ifdef __WXMSW__
mpInternalFrm = (wxPanel*)this;
#else
mpInternalFrm = new wxPanel( this, -1 );
#endif
mpClientWnd = CreateTextCtrl( "Client window" );
mStore.AddInitialRef( this );
mStore.AddInitialRef( mpInternalFrm );
//mStore.AddInitialRef( mpClientWnd );
mpLayout = new wxFrameLayout( mpInternalFrm, mpClientWnd );
#ifdef __WXGTK__
cbCommonPaneProperties props;
mpLayout->GetPaneProperties( props );
props.mRealTimeUpdatesOn = FALSE; // real-time OFF!!!
mpLayout->SetPaneProperties( props, wxALL_PANES );
#endif
mpLayout->SetUpdatesManager( new cbGCUpdatesMgr() );
// this is now default...
//mpLayout->SetMargins( 1,1,1,1 ); // gaps for vertical/horizontal/right/left panes
// setup plugins for testing
mpLayout->PushDefaultPlugins();
mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for bars
mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
mpLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) );
mpLayout->AddPlugin( CLASSINFO( cbAntiflickerPlugin ) );
mpLayout->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin ) );
// drop in some bars
cbDimInfo sizes0(200,45, // when docked horizontally
200,85, // when docked vertically
175,35, // when floated
FALSE, // the bar is not fixed-size
4, // vertical gap (bar border)
4 // horizontal gap (bar border)
);
cbDimInfo sizes1(150,35, // when docked horizontally
150,85, // when docked vertically
175,35, // when floated
TRUE, // the bar is not fixed-size
4, // vertical gap (bar border)
4 // horizontal gap (bar border)
);
cbDimInfo sizes2(175,45, // when docked horizontally
175,37, // when docked vertically
170,35, // when floated
TRUE, // the bar is not fixed-size
4, // vertical gap (bar border)
4, // horizontal gap (bar border)
new cbDynToolBarDimHandler()
);
mpLayout->AddBar( CreateTextCtrl("Hello"), // bar window
sizes0, wxTOP, // alignment ( 0-top,1-bottom, etc)
0, // insert into 0th row (vert. position)
0, // offset from the start of row (in pixels)
"InfoViewer1", // name to refere in customization pop-ups
TRUE
);
mpLayout->AddBar( CreateTextCtrl("Bye"), // bar window
sizes0, wxTOP, // alignment ( 0-top,1-bottom, etc)
1, // insert into 0th row (vert. position)
0, // offset from the start of row (in pixels)
"InfoViewer2", // name to refere in customization pop-ups
TRUE
);
mpLayout->AddBar( CreateTextCtrl("Fixed0"), // bar window
sizes1, wxTOP, // alignment ( 0-top,1-bottom, etc)
0, // insert into 0th row (vert. position)
0, // offset from the start of row (in pixels)
"ToolBar1", // name to refere in customization pop-ups
TRUE
);
wxDynamicToolBar* pToolBar = new wxDynamicToolBar();
pToolBar->Create( mpInternalFrm, -1 );
// 1001-1006 ids of command events fired by added tool-buttons
pToolBar->AddTool( 1001, "new.bmp" );
pToolBar->AddTool( 1002, "open.bmp" );
pToolBar->AddTool( 1003, "save.bmp" );
pToolBar->AddTool( 1004, "cut.bmp" );
pToolBar->AddTool( 1005, "copy.bmp" );
pToolBar->AddTool( 1006, "paste.bmp" );
mpLayout->AddBar( pToolBar, // bar window (can be NULL)
sizes2, wxTOP, // alignment ( 0-top,1-bottom, etc)
0, // insert into 0th row (vert. position)
0, // offset from the start of row (in pixels)
"ToolBar2", // name to refere in customization pop-ups
FALSE
);
mpLayout->EnableFloating( TRUE ); // off, thinking bout wxGtk...
}
MyFrame::~MyFrame()
{
if ( mpLayout) delete mpLayout; // should be destroyed manually
}
#ifdef __HACK_MY_MSDEV40__
////////////// new 2.0-magic (linker errors...) ////////////////
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{
wxCHECK_MSG( m_frameToolBar == NULL, FALSE,
"recreating toolbar in wxFrame" );
wxToolBar* toolBar = OnCreateToolBar(style, id, name);
if (toolBar)
{
SetToolBar(toolBar);
PositionToolBar();
return toolBar;
}
else
{
return NULL;
}
}
wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name)
{
return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name);
}
#endif

View File

@@ -0,0 +1,41 @@
#ifndef __NEW_TEST_G__
#define __NEW_TEST_G__
#include "objstore.h"
#include "wx/panel.h"
// Define a new application type
class MyApp: public wxApp
{ public:
bool OnInit(void);
};
class MyFrame: public wxFrame
{
public:
wxObjectStorage mStore;
wxFrameLayout* mpLayout;
wxTextCtrl* mpClientWnd;
wxPanel* mpInternalFrm;
wxTextCtrl* CreateTextCtrl( const wxString& value );
public:
MyFrame(wxFrame *frame);
virtual ~MyFrame();
bool OnClose(void) { Show(FALSE); return TRUE; }
void OnLoad( wxCommandEvent& event );
void OnSave( wxCommandEvent& event );
void OnExit( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
};
#define NEW_TEST_SAVE 1101
#define NEW_TEST_LOAD 1102
#define NEW_TEST_EXIT 1103
#endif

View File

@@ -0,0 +1 @@
include ../../../setup/general/makedirs

View File

@@ -0,0 +1,88 @@
#
# wxFrameLayout source makefile for Unix
#
# Copyright 1999, Harm van der Heijden
#
# wxWindows base directory
WXBASEDIR=@WXBASEDIR@
# set the OS type for compilation
OS=@OS@
# compile a library only
RULE=gslib
# needed for unactivated
NONE=
# define library name
LIB_TARGET=wx_fl_gtk
LIB_MAJOR=0
LIB_MINOR=1
# define library sources
LIB_CPP_SRC= \
antiflickpl.cpp \
bardragpl.cpp \
barhintspl.cpp \
cbcustom.cpp \
cbstore.cpp \
controlarea.cpp \
controlbar.cpp \
dyntbar.cpp \
dyntbarhnd.cpp \
frmview.cpp \
garbagec.cpp \
gcupdatesmgr.cpp \
hintanimpl.cpp \
newbmpbtn.cpp \
objstore.cpp \
panedrawpl.cpp \
pf_sample.cpp \
rowdragpl.cpp \
rowlayoutpl.cpp \
settingsdlg.cpp \
toolwnd.cpp \
updatesmgr.cpp \
wxinfo.cpp
#define library objects
LIB_OBJ= \
\
$(LIB_CPP_SRC:.cpp=.o)
all::
clean::
#additional things needed for compile
ADD_COMPILE=
# include the definitions now
include ../../../../template.mak
install::
@echo "Installing library files and headers for libwx_gl_gtk.."
@echo " Creating directory.."
@$(WXBASEDIR)/mkinstalldirs /usr/local/include/wx_fl
@echo " Copying headers from framelayout/src"
@cd $(WXBASEDIR)/utils/framelayout/src ; \
for f in *.h ; do \
rm -f /usr/local/include/wx_fl/$$f ; \
$(INSTALL_DATA) $$f /usr/local/include/wx_fl/$$f ; \
done
@echo " Copying static library files to /usr/local/lib"
@cd $(WXBASEDIR)/lib/$(OS) ; \
for f in libwx_fl_gtk.a ; do \
rm -f /usr/local/lib/$$f ; \
$(INSTALL_DATA) $$f /usr/local/lib/$$f ; \
done
@echo " Copying shared libraries to /usr/local/lib"
@cd $(WXBASEDIR)/lib/$(OS) ; \
for f in libwx_fl_gtk.so* ; do \
rm -f /usr/local/lib/$$f ; \
$(INSTALL_PROGRAM) $$f /usr/local/lib/$$f ; \
done

View File

@@ -0,0 +1,238 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas (@Lithuania)
// Modified by:
// Created: 23/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "antiflickpl.h"
// #pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "antiflickpl.h"
/***** Implementation for class cbAntiflickerPlugin *****/
IMPLEMENT_DYNAMIC_CLASS( cbAntiflickerPlugin, cbPluginBase )
BEGIN_EVENT_TABLE( cbAntiflickerPlugin, cbPluginBase )
EVT_PL_START_DRAW_IN_AREA ( cbAntiflickerPlugin::OnStartDrawInArea )
EVT_PL_FINISH_DRAW_IN_AREA ( cbAntiflickerPlugin::OnFinishDrawInArea )
END_EVENT_TABLE()
// initialization of static members
int cbAntiflickerPlugin::mRefCount = 0;
wxBitmap* cbAntiflickerPlugin::mpVertBuf = 0;
wxBitmap* cbAntiflickerPlugin::mpHorizBuf = 0;
wxMemoryDC* cbAntiflickerPlugin::mpVertBufDc = 0;
wxMemoryDC* cbAntiflickerPlugin::mpHorizBufDc = 0;
// constructors
cbAntiflickerPlugin::cbAntiflickerPlugin(void)
: mpLRUBufDc ( NULL ),
mLRUArea ( -1,-1, -1,-1 )
{
++mRefCount;
}
cbAntiflickerPlugin::cbAntiflickerPlugin( wxFrameLayout* pPanel, int paneMask )
: cbPluginBase( pPanel, paneMask ),
mpLRUBufDc ( NULL ),
mLRUArea ( -1,-1, -1,-1 )
{
++mRefCount;
}
cbAntiflickerPlugin::~cbAntiflickerPlugin()
{
if ( --mRefCount == 0 )
{
if ( mpHorizBuf )
{
mpHorizBufDc->SelectObject( wxNullBitmap );
delete mpHorizBuf;
delete mpHorizBufDc;
mpHorizBuf = 0;
mpHorizBufDc = 0;
}
if ( mpVertBuf )
{
mpVertBufDc->SelectObject( wxNullBitmap );
delete mpVertBuf;
delete mpVertBufDc;
mpVertBuf = 0;
mpVertBufDc = 0;
}
}
}
wxDC* cbAntiflickerPlugin::FindSuitableBuffer( const wxRect& forArea )
{
if ( mpVertBuf )
{
if ( mpVertBuf->GetHeight() >= forArea.height &&
mpVertBuf->GetWidth() >= forArea.width )
return mpVertBufDc;
}
else
if ( mpHorizBuf )
{
if ( mpHorizBuf->GetHeight() >= forArea.height &&
mpHorizBuf->GetWidth() >= forArea.width )
return mpHorizBufDc;
}
return 0;
}
wxDC* cbAntiflickerPlugin::AllocNewBuffer( const wxRect& forArea )
{
// TBD:: preallocate bit larger bitmap at once, to avoid
// excessive realocations later
// check whether the given area is oriented horizontally
// or verticallya and choose correspoinding bitmap to create or
// recreate
wxBitmap* pBuf = 0;
if ( forArea.height > forArea.width )
{
wxSize prevDim( 0,0 );
if ( mpVertBuf )
{
prevDim.x = mpVertBuf->GetWidth();
prevDim.y = mpVertBuf->GetHeight();
mpVertBufDc->SelectObject( wxNullBitmap );
delete mpVertBuf;
}
else
mpVertBufDc = new wxMemoryDC();
mpVertBuf = new wxBitmap( int( wxMax(forArea.width, prevDim.x ) ),
int( wxMax(forArea.height, prevDim.y ) )
);
mpVertBufDc->SelectObject( *mpVertBuf );
return mpVertBufDc;
}
else
{
wxSize prevDim( 0,0 );
if ( mpHorizBuf )
{
prevDim.x = mpHorizBuf->GetWidth();
prevDim.y = mpHorizBuf->GetHeight();
mpHorizBufDc->SelectObject( wxNullBitmap );
delete mpHorizBuf;
}
else
mpHorizBufDc = new wxMemoryDC();
mpHorizBuf = new wxBitmap( int( wxMax(forArea.width, prevDim.x ) ),
int( wxMax(forArea.height, prevDim.y ) )
);
mpHorizBufDc->SelectObject( *mpHorizBuf );
return mpHorizBufDc;
}
}
void cbAntiflickerPlugin::OnStartDrawInArea( cbStartDrawInAreaEvent& event )
{
wxASSERT( mpLRUBufDc == NULL ); // DBG:: see comments in OnFinishDrawInArea(..) method
// short-cut
wxRect& area = event.mArea;
if ( event.mArea.width < 0 ||
event.mArea.height < 0 ) return;
// memorize given area
mLRUArea.x = area.x;
mLRUArea.y = area.y;
mLRUArea.width = area.width;
mLRUArea.height = area.height;
wxDC* pBufDc = FindSuitableBuffer( area );
if ( !pBufDc )
pBufDc = AllocNewBuffer( area );
pBufDc->SetDeviceOrigin( -area.x, -area.y );
pBufDc->SetClippingRegion( area.x, area.y,
area.width, area.height );
wxClientDC clntDc( &mpLayout->GetParentFrame() );
(*event.mppDc) = pBufDc;
mpLRUBufDc = pBufDc; // memorize buffer, which will be flushed to screen
// upon "commiting" the drawing
/*
// OLD STUFF::
mpLRUBufDc->Blit( pos.x, pos.y, size.x, size.y,
&clntDc, pos.x, pos.y, wxCOPY );
*/
}
void cbAntiflickerPlugin::OnFinishDrawInArea( cbFinishDrawInAreaEvent& event )
{
wxRect& area = event.mArea;
if ( event.mArea.width < 0 ||
event.mArea.height < 0 ) return;
wxASSERT( mpLRUBufDc ); // DBG:: OnStartDrawInArea should be called first
// FOR NOW:: OnStartDrawInArea(..) should be immediatelly followed
// by OnFinishDrawInArea(..) for the same area
wxASSERT( mLRUArea.x == area.x );
wxASSERT( mLRUArea.y == area.y );
wxASSERT( mLRUArea.width == area.width );
wxASSERT( mLRUArea.height == area.height );
wxClientDC clntDc( &mpLayout->GetParentFrame() );
// "commit" drawings in one-shot
clntDc.Blit( area.x, area.y, area.width, area.height,
mpLRUBufDc, area.x, area.y, wxCOPY );
mpLRUBufDc->DestroyClippingRegion();
mpLRUBufDc = 0;
}

View File

@@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas (@Lithuania)
// Modified by:
// Created: 23/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __ANTIFLICKPL_G__
#define __ANTIFLICKPL_G__
#include "controlbar.h"
class cbAntiflickerPlugin : public cbPluginBase
{
DECLARE_DYNAMIC_CLASS( cbAntiflickerPlugin )
protected:
// double-buffers are shared "resource" among all instances of
// antiflicker plugin within the application
//
// TODO:: locking should be implemented, for multithreaded GUIs
static wxBitmap* mpVertBuf;
static wxBitmap* mpHorizBuf;
static wxMemoryDC* mpVertBufDc;
static wxMemoryDC* mpHorizBufDc;
static int mRefCount;
wxDC* mpLRUBufDc; // last-reacently-used buffer
wxRect mLRUArea; // last-reacently-used area
protected:
// returns NULL, if sutable buffer is not present
wxDC* FindSuitableBuffer( const wxRect& forArea );
wxDC* AllocNewBuffer( const wxRect& forArea );
wxDC& GetWindowDC();
wxDC& GetClientDC();
public:
cbAntiflickerPlugin(void);
cbAntiflickerPlugin( wxFrameLayout* pPanel, int paneMask = wxALL_PANES );
virtual ~cbAntiflickerPlugin();
// handlers for plugin events
void OnStartDrawInArea ( cbStartDrawInAreaEvent& event );
void OnFinishDrawInArea( cbFinishDrawInAreaEvent& event );
DECLARE_EVENT_TABLE()
};
#endif

View File

@@ -0,0 +1,929 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 23/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "bardragpl.h"
// #pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "bardragpl.h"
#define POS_UNDEFINED -32768
// helpers, FOR NOW:: static
static inline bool rect_hits_rect( const wxRect& r1, const wxRect& r2 )
{
if ( ( r2.x >= r1.x && r2.x <= r1.x + r1.width ) ||
( r1.x >= r2.x && r1.x <= r2.x + r2.width ) )
if ( ( r2.y >= r1.y && r2.y <= r1.y + r1.height ) ||
( r1.y >= r2.y && r1.y <= r2.y + r2.height ) )
return TRUE;
return FALSE;
}
static inline bool rect_contains_point( const wxRect& rect, int x, int y )
{
return ( x >= rect.x &&
y >= rect.y &&
x < rect.x + rect.width &&
y < rect.y + rect.height );
}
/***** Implementation for class cbBarDragPlugin *****/
IMPLEMENT_DYNAMIC_CLASS( cbBarDragPlugin, cbPluginBase )
BEGIN_EVENT_TABLE( cbBarDragPlugin, cbPluginBase )
//EVT_PL_LEFT_DOWN ( cbBarDragPlugin::OnLButtonDown )
EVT_PL_LEFT_UP ( cbBarDragPlugin::OnLButtonUp )
EVT_PL_MOTION ( cbBarDragPlugin::OnMouseMove )
EVT_PL_DRAW_HINT_RECT ( cbBarDragPlugin::OnDrawHintRect )
EVT_PL_START_BAR_DRAGGING ( cbBarDragPlugin::OnStartBarDragging )
EVT_PL_LEFT_DCLICK ( cbBarDragPlugin::OnLDblClick )
END_EVENT_TABLE()
cbBarDragPlugin::cbBarDragPlugin(void)
: mBarDragStarted ( FALSE ),
mCanStick ( TRUE ),
mpDraggedBar ( NULL ),
mInClientHintBorder( 4 ),
mpScrDc ( NULL ),
mpCurCursor ( NULL )
{}
cbBarDragPlugin::cbBarDragPlugin( wxFrameLayout* pPanel, int paneMask )
: cbPluginBase( pPanel, paneMask ),
mBarDragStarted ( FALSE ),
mCanStick ( TRUE ),
mpDraggedBar ( NULL ),
mInClientHintBorder( 4 ),
mpScrDc ( NULL ),
mpCurCursor ( NULL )
{}
cbBarDragPlugin::~cbBarDragPlugin()
{
// nothing
}
// helper methods (protected)
// clips (top/bottom) or (right/left) edges against the frame's bounding rect.
void do_clip_edges( int len, long& rectPos, long& rectLen )
{
if ( rectPos < 0 )
{
rectLen += rectPos;
rectPos = 0;
if ( rectLen < 0 ) rectLen = 1;
}
else
if ( rectPos > len-1 )
{
rectPos = len-1;
rectLen = 1;
}
else
if ( rectPos + rectLen - 1 > len )
rectLen -= (rectPos + rectLen) - len + 1;
}
void cbBarDragPlugin::ClipRectInFrame( wxRect& rect )
{
int w, h;
mpLayout->GetParentFrame().GetClientSize( &w, &h );
do_clip_edges( w, rect.x, rect.width );
do_clip_edges( h, rect.y, rect.height );
}
void cbBarDragPlugin::ClipPosInFrame( wxPoint& pos )
{
int w, h;
mpLayout->GetParentFrame().GetClientSize( &w, &h );
if ( pos.x < 0 ) pos.x = 0;
if ( pos.y < 0 ) pos.y = 0;
if ( pos.x > w ) pos.x = w-1;
if ( pos.y > h ) pos.y = h-1;
}
void cbBarDragPlugin::AdjustHintRect( wxPoint& mousePos )
{
mHintRect.x = mousePos.x - mMouseInRectX;
mHintRect.y = mousePos.y - mMouseInRectY;
}
cbDockPane* cbBarDragPlugin::HitTestPanes( wxRect& rect )
{
//wxRect clipped = rect;
//ClipRectInFrame( clipped );
cbDockPane** pPanes = mpLayout->GetPanesArray();
for( int i = 0; i != MAX_PANES; ++i )
if ( rect_hits_rect( pPanes[i]->mBoundsInParent, rect ) )
return pPanes[i];
return NULL;
}
cbDockPane* cbBarDragPlugin::HitTestPanes( wxPoint& pos )
{
wxPoint clipped = pos;
//ClipPosInFrame( pos );
cbDockPane** pPanes = mpLayout->GetPanesArray();
for( int i = 0; i != MAX_PANES; ++i )
if ( rect_contains_point( pPanes[i]->mBoundsInParent, clipped.x, clipped.y ) )
return pPanes[i];
return NULL;
}
bool cbBarDragPlugin::HitsPane( cbDockPane* pPane, wxRect& rect )
{
return rect_hits_rect( pPane->mBoundsInParent, rect );
}
int cbBarDragPlugin::GetDistanceToPane( cbDockPane* pPane, wxPoint& mousePos )
{
wxRect& bounds = pPane->mBoundsInParent;
switch( pPane->mAlignment )
{
case wxTOP : return mousePos.y - ( bounds.y + bounds.height );
case wxBOTTOM : return bounds.y - mousePos.y;
case wxLEFT : return mousePos.x - ( bounds.x + bounds.width );
case wxRIGHT : return bounds.x - mousePos.x;
default : return 0; // never reached
}
return 0;
}
bool cbBarDragPlugin::IsInOtherPane( wxPoint& mousePos )
{
cbDockPane* pPane = HitTestPanes( mousePos );
if ( pPane && pPane != mpCurPane ) return TRUE;
else return FALSE;
}
bool cbBarDragPlugin::IsInClientArea( wxPoint& mousePos )
{
return ( HitTestPanes( mousePos ) == NULL );
}
bool cbBarDragPlugin::IsInClientArea( wxRect& rect )
{
return ( HitTestPanes( rect ) == NULL );
}
void cbBarDragPlugin::CalcOnScreenDims( wxRect& rect )
{
if ( !mpCurPane || mpDraggedBar->IsFixed() ) return;
wxRect inPane = rect;
mpCurPane->FrameToPane( &inPane );
int rowNo = mpCurPane->GetRowAt( inPane.y, inPane.y + inPane.height );
bool isMaximized = ( rowNo >= (int)mpCurPane->GetRowList().Count() || rowNo < 0 );
if ( isMaximized )
{
inPane.x = 0;
inPane.width = mpCurPane->mPaneWidth;
mpCurPane->PaneToFrame( &inPane );
rect = inPane;
}
}
// helpers
static inline void check_upper_overrun( long& pos, int width, int mousePos )
{
if ( mousePos >= pos + width )
pos = mousePos - width/2;
}
static inline void check_lower_overrun( long& pos, int width, int mousePos )
{
if ( mousePos <= pos )
pos = mousePos - width/2;
}
void cbBarDragPlugin::StickToPane( cbDockPane* pPane, wxPoint& mousePos )
{
int wInPane = GetBarWidthInPane ( pPane );
int hInPane = GetBarHeightInPane( pPane );
// adjsut hint-rect horizontally (in pane's orientation)
if ( pPane->IsHorizontal() )
{
mHintRect.width = wInPane;
mHintRect.height = hInPane;
}
else
{
mHintRect.height = wInPane;
mHintRect.width = hInPane;
}
// adjsut hint-rect vertically (in pane's orientation)
wxRect& bounds = pPane->mBoundsInParent;
// TRUE, if hint enters the pane through it's lower edge
bool fromLowerEdge = ( pPane->IsHorizontal() )
? mousePos.y > bounds.y
: mousePos.x > bounds.x;
// NOTE:: about all the below min/max things: they are ment to ensure
// that mouse pointer doesn't overrun (leave) the hint-rectangle
// when dimensions it's are recalculated upon sticking it to the pane
if ( pPane->IsHorizontal() && fromLowerEdge )
{
int paneBottomEdgeY = bounds.y + bounds.height;
mHintRect.y = wxMin( paneBottomEdgeY, mousePos.y );
check_lower_overrun( mHintRect.y, hInPane, mousePos.y );
}
else
if ( pPane->IsHorizontal() && !fromLowerEdge )
{
int paneTopEdgeY = bounds.y;
mHintRect.y = wxMax( paneTopEdgeY - hInPane, mousePos.y - hInPane );
check_upper_overrun( mHintRect.y, hInPane, mousePos.y );
}
else
if ( !pPane->IsHorizontal() && fromLowerEdge )
{
int paneRightEdgeX = bounds.x + bounds.width;
mHintRect.x = wxMin( paneRightEdgeX, mousePos.x );
check_lower_overrun( mHintRect.x, hInPane, mousePos.x );
}
else
if ( !pPane->IsHorizontal() && !fromLowerEdge )
{
int paneLeftEdgeX = bounds.x;
mHintRect.x = wxMax( paneLeftEdgeX - hInPane, mousePos.x - hInPane );
check_upper_overrun( mHintRect.x, hInPane, mousePos.x );
}
mMouseInRectX = mousePos.x - mHintRect.x;
mMouseInRectY = mousePos.y - mHintRect.y;
mpCurPane = pPane; // memorize pane to which the hint is currently sticked
}
void cbBarDragPlugin::UnstickFromPane( cbDockPane* pPane, wxPoint& mousePos )
{
// unsticking causes rectangle to get the shape, in which
// dragged control-bar would be when floated
int newWidth = mpDraggedBar->mDimInfo.mSizes[wxCBAR_FLOATING].x;
int newHeight = mpDraggedBar->mDimInfo.mSizes[wxCBAR_FLOATING].y;
wxRect& flBounds = mpDraggedBar->mDimInfo.mBounds[wxCBAR_FLOATING];
if ( flBounds.width != -1 )
{
newWidth = flBounds.width;
newHeight = flBounds.height;
}
mHintRect.width = newWidth;
mHintRect.height = newHeight;
wxRect& bounds = pPane->mBoundsInParent;
// TRUE, if hint leaves the pane through it's lower edge
bool fromLowerEdge = ( pPane->IsHorizontal() )
? mousePos.y > bounds.y
: mousePos.x > bounds.x;
// NOTE:: ...all the below min/max things - see comments about it in StickToPane(..)
if ( pPane->IsHorizontal() && fromLowerEdge )
{
bool fromLowerEdge = mousePos.y > bounds.y;
mHintRect.y = wxMax( bounds.y + bounds.height + 1, mousePos.y - newHeight );
check_upper_overrun( mHintRect.y, newHeight, mousePos.y );
// this is how MFC's hint behaves:
if ( mMouseInRectX > newWidth )
mHintRect.x = mousePos.x - ( newWidth / 2 );
}
else
if ( pPane->IsHorizontal() && !fromLowerEdge )
{
mHintRect.y = wxMin( bounds.y - newHeight - 1, mousePos.y );
// -/-
if ( mMouseInRectX > newWidth )
mHintRect.x = mousePos.x - ( newWidth / 2 );
check_lower_overrun( mHintRect.y, newHeight, mousePos.y );
}
else
if ( !pPane->IsHorizontal() && fromLowerEdge )
{
mHintRect.x = wxMax( bounds.x + bounds.width, mousePos.x - newWidth );
// -/-
if ( mMouseInRectY > newHeight )
mHintRect.y = mousePos.y - ( newHeight / 2 );
check_upper_overrun( mHintRect.x, newWidth, mousePos.x );
}
else
if ( !pPane->IsHorizontal() && !fromLowerEdge )
{
mHintRect.x = wxMin( bounds.x - newWidth - 1, mousePos.x );
// -/-
if ( mMouseInRectY > newHeight )
mHintRect.y = mousePos.y - ( newHeight / 2 );
check_lower_overrun( mHintRect.x, newWidth, mousePos.x );
}
mMouseInRectX = mousePos.x - mHintRect.x;
mMouseInRectY = mousePos.y - mHintRect.y;
mpCurPane = NULL;
}
int cbBarDragPlugin::GetBarWidthInPane( cbDockPane* pPane )
{
if ( pPane == mpSrcPane )
return mBarWidthInSrcPane;
// this is how MFC's bars behave:
if ( pPane->IsHorizontal() )
return mpDraggedBar->mDimInfo.mSizes[wxCBAR_DOCKED_HORIZONTALLY].x;
else
return mpDraggedBar->mDimInfo.mSizes[wxCBAR_DOCKED_VERTICALLY ].x;
}
int cbBarDragPlugin::GetBarHeightInPane( cbDockPane* pPane )
{
if ( pPane->IsHorizontal() )
return mpDraggedBar->mDimInfo.mSizes[wxCBAR_DOCKED_HORIZONTALLY].y;
else
return mpDraggedBar->mDimInfo.mSizes[wxCBAR_DOCKED_VERTICALLY ].y;
}
void cbBarDragPlugin::ShowHint( bool prevWasInClient )
{
bool wasDocked = FALSE;
if ( mpDraggedBar->mState != wxCBAR_FLOATING && !mpCurPane )
{
mpLayout->SetBarState( mpDraggedBar, wxCBAR_FLOATING, TRUE );
}
else
if ( mpDraggedBar->mState == wxCBAR_FLOATING && mpCurPane )
{
mpLayout->SetBarState( mpDraggedBar, wxCBAR_DOCKED_HORIZONTALLY, FALSE );
wasDocked = TRUE;
}
if ( mpSrcPane->mProps.mRealTimeUpdatesOn == FALSE )
{
// do hevy calculations first
wxRect actualRect = mHintRect; // will be adjusted depending on drag-settings
if ( mpSrcPane->mProps.mExactDockPredictionOn && mpCurPane )
{
bool success = mpLayout->RedockBar( mpDraggedBar, mHintRect, mpCurPane, FALSE );
wxASSERT( success ); // DBG::
actualRect = mpDraggedBar->mBounds;
mpCurPane->PaneToFrame( &actualRect );
}
else
CalcOnScreenDims( actualRect );
// release previouse hint
if ( mPrevHintRect.x != POS_UNDEFINED )
{
// erase previouse rectangle
cbDrawHintRectEvent evt( mPrevHintRect, prevWasInClient, TRUE, FALSE );
mpLayout->FirePluginEvent( evt );
}
// draw new hint
cbDrawHintRectEvent evt( actualRect, mpCurPane == NULL, FALSE, FALSE );
mpLayout->FirePluginEvent( evt );
mPrevHintRect = actualRect;
}
else
{
// otherwise, if real-time updates option is ON
if ( mpCurPane )
{
mpLayout->GetUpdatesManager().OnStartChanges();
if ( wasDocked )
mpDraggedBar->mUMgrData.SetDirty( TRUE );
bool success = mpLayout->RedockBar( mpDraggedBar, mHintRect, mpCurPane, FALSE );
wxASSERT( success ); // DBG ::
mpLayout->GetUpdatesManager().OnFinishChanges();
mpLayout->GetUpdatesManager().UpdateNow();
}
else
{
if ( mpLayout->mFloatingOn )
{
// move the top-most floated bar around as user drags the hint
mpDraggedBar->mDimInfo.mBounds[ wxCBAR_FLOATING ] = mHintRect;
mpLayout->ApplyBarProperties( mpDraggedBar );
}
}
}
}
/*** event handlers ***/
void cbBarDragPlugin::OnMouseMove( cbMotionEvent& event )
{
// calculate postion in frame's coordiantes
if ( !mBarDragStarted )
{
event.Skip(); // pass event to the next plugin
return;
}
wxPoint mousePos = event.mPos;
event.mpPane->PaneToFrame( &mousePos.x, &mousePos.y );
wxRect prevRect = mHintRect;
bool prevIsInClient = ( mpCurPane == 0 );
AdjustHintRect( mousePos );
// if the hint-rect is not "tempted" to any pane yet
if ( mpCurPane == NULL )
{
cbDockPane* pPane = HitTestPanes( mHintRect );
if ( !pPane )
// enable sticking again, if we've left the pane completely
mCanStick = TRUE;
if ( mCanStick && pPane &&
GetDistanceToPane( pPane, mousePos ) < GetBarHeightInPane( pPane ) )
StickToPane( pPane, mousePos );
else
if ( pPane && HitTestPanes( mousePos ) == pPane && 0 ) // FOR NOW:: disabled
StickToPane( pPane, mousePos );
}
else
{
// otherwise, when rect is now sticked to some of the panes
// check if it should still remain in this pane
mCanStick = TRUE;
bool mouseInOther = IsInOtherPane( mousePos );
if ( mouseInOther )
{
cbDockPane* pPane = HitTestPanes( mousePos );
StickToPane( pPane, mousePos );
}
else
{
if ( IsInClientArea( mousePos ) )
{
cbDockPane* pPane = HitTestPanes( mHintRect );
if ( pPane &&
pPane != mpCurPane &&
GetDistanceToPane( pPane, mousePos ) < GetBarHeightInPane( pPane ) )
StickToPane( pPane, mousePos );
else
if ( !pPane )
{
UnstickFromPane( mpCurPane, mousePos );
// FOR NOW:: disabled, would cause some mess
//mCanStick = FALSE; // prevents from sticking to this
// pane again, flag is reset when hint-rect
// leaves the pane completely
}
else
if ( GetDistanceToPane( pPane, mousePos ) > GetBarHeightInPane( pPane ) )
{
if ( !HitsPane( mpCurPane, mHintRect ) )
{
UnstickFromPane( mpCurPane, mousePos );
// FOR NOW:: disabled, would cause some mess
//mCanStick = FALSE; // prevents from sticking to this
// pane again, flag is reset when hint-rect
// leaves the pane completely
}
}
}
else
{
}
}
}
ShowHint( prevIsInClient );
wxCursor* pPrevCurs = mpCurCursor;
if ( mpCurPane )
mpCurCursor = mpLayout->mpDragCursor;
else
{
if ( mpLayout->mFloatingOn && mpSrcPane->mProps.mRealTimeUpdatesOn )
mpCurCursor = mpLayout->mpDragCursor;
else
mpCurCursor = mpLayout->mpNECursor;
}
if ( pPrevCurs != mpCurCursor )
mpLayout->GetParentFrame().SetCursor( *mpCurCursor );
}
void cbBarDragPlugin::OnLButtonDown( cbLeftDownEvent& event )
{
if ( mBarDragStarted )
{
wxMessageBox("DblClick!");
}
event.Skip();
}
void cbBarDragPlugin::OnLButtonUp( cbLeftUpEvent& event )
{
if ( mBarDragStarted )
{
if ( mpSrcPane->mProps.mRealTimeUpdatesOn == FALSE )
{
// erase current rectangle, and finsih on-screen drawing session
cbDrawHintRectEvent evt( mPrevHintRect, mpCurPane == NULL, TRUE, TRUE );
mpLayout->FirePluginEvent( evt );
if ( mpCurPane != NULL )
{
if ( mpSrcPane->mProps.mExactDockPredictionOn )
{
mpLayout->RedockBar( mpDraggedBar, mHintRect, mpCurPane, FALSE );
mpLayout->GetUpdatesManager().OnFinishChanges();
mpLayout->GetUpdatesManager().UpdateNow();
}
else
mpLayout->RedockBar( mpDraggedBar, mHintRect, mpCurPane );
}
}
mHintRect.width = -1;
mpLayout->GetParentFrame().SetCursor( *mpLayout->mpNormalCursor );
mpLayout->ReleaseEventsFromPane( event.mpPane );
mpLayout->ReleaseEventsFromPlugin( this );
mBarDragStarted = FALSE;
if ( mBarWasFloating && mpDraggedBar->mState != wxCBAR_FLOATING )
{
// save bar's floating position before it was docked
mpDraggedBar->mDimInfo.mBounds[ wxCBAR_FLOATING ] = mFloatedBarBounds;
}
}
else
event.Skip(); // pass event to the next plugin
}
void cbBarDragPlugin::OnLDblClick( cbLeftDClickEvent& event )
{
if ( 1 )
{
cbBarInfo* pHittedBar;
cbRowInfo* pRow;
if ( event.mpPane->HitTestPaneItems( event.mPos, // in pane's coordiantes
&pRow,
&pHittedBar ) == CB_BAR_CONTENT_HITTED
)
{
mpLayout->SetBarState( pHittedBar, wxCBAR_FLOATING, TRUE );
mpLayout->RepositionFloatedBar( pHittedBar );
return; // event is "eaten" by this plugin
}
mBarDragStarted = FALSE;
event.Skip();
}
//wxMessageBox("Hi, dblclick arrived!");
}
void cbBarDragPlugin::OnStartBarDragging( cbStartBarDraggingEvent& event )
{
mpDraggedBar = event.mpBar;
mpSrcPane = event.mpPane;
mpLayout->CaptureEventsForPane( event.mpPane );
mpLayout->CaptureEventsForPlugin( this );
mpLayout->GetParentFrame().SetCursor( *mpLayout->mpDragCursor );
mBarDragStarted = TRUE;
wxRect inParent = mpDraggedBar->mBounds;
mBarWasFloating = mpDraggedBar->mState == wxCBAR_FLOATING;
if ( mBarWasFloating )
{
inParent = mpDraggedBar->mDimInfo.mBounds[ wxCBAR_FLOATING ];
mFloatedBarBounds = inParent;
}
else
event.mpPane->PaneToFrame( &inParent );
mHintRect.x = POS_UNDEFINED;
mHintRect.width = inParent.width;
mHintRect.height = inParent.height;
mMouseInRectX = event.mPos.x - inParent.x;
mMouseInRectY = event.mPos.y - inParent.y;
mpSrcPane = event.mpPane;
if ( mpDraggedBar->mState == wxCBAR_FLOATING )
mpCurPane = NULL;
else
mpCurPane = event.mpPane;
mPrevHintRect.x = POS_UNDEFINED;
mCanStick = FALSE; // we're not stuck into any pane now -
// there's nowhere to "stick-twice"
mBarWidthInSrcPane = mpDraggedBar->mDimInfo.mSizes[ mpDraggedBar->mState ].x;
if ( mpSrcPane->mProps.mRealTimeUpdatesOn == FALSE &&
mpSrcPane->mProps.mExactDockPredictionOn )
mpLayout->GetUpdatesManager().OnStartChanges(); // capture initial state of layout
// simulate the first mouse movement
long x = event.mPos.x, y = event.mPos.y;
mpSrcPane->FrameToPane( &x, &y );
cbMotionEvent motionEvt( wxPoint(x,y), event.mpPane );
this->OnMouseMove( motionEvt );
return; // event is "eaten" by this plugin
}
/*** on-screen hint-tracking related methods ***/
void cbBarDragPlugin::OnDrawHintRect( cbDrawHintRectEvent& event )
{
if ( !mpScrDc ) StartTracking();
DoDrawHintRect( event.mRect, event.mIsInClient );
if ( event.mLastTime )
FinishTracking();
}
#define _A 0xAA
#define _B 0x00
#define _C 0x55
#define _D 0x00
// FOR NOW:: static
static const unsigned char _gCheckerImg[16] = { _A,_B,_C,_D,
_A,_B,_C,_D,
_A,_B,_C,_D,
_A,_B,_C,_D
};
void cbBarDragPlugin::StartTracking()
{
mpScrDc = new wxScreenDC;
wxScreenDC::StartDrawingOnTop(&mpLayout->GetParentFrame());
}
void cbBarDragPlugin::DoDrawHintRect( wxRect& rect, bool isInClientRect)
{
wxRect scrRect;
RectToScr( rect, scrRect );
int prevLF = mpScrDc->GetLogicalFunction();
mpScrDc->SetLogicalFunction( wxXOR );
if ( isInClientRect )
{
// BUG BUG BUG (wx):: somehow stippled brush works only
// when the bitmap created on stack, not
// as a member of the class
wxBitmap checker( (const char*)_gCheckerImg, 8,8 );
wxBrush checkerBrush( checker );
mpScrDc->SetPen( mpLayout->mNullPen );
mpScrDc->SetBrush( checkerBrush );
int half = mInClientHintBorder / 2;
mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y - half,
scrRect.width + 2*half, mInClientHintBorder );
mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y + scrRect.height - half,
scrRect.width + 2*half, mInClientHintBorder );
mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y + half - 1,
mInClientHintBorder, scrRect.height - 2*half + 2);
mpScrDc->DrawRectangle( scrRect.x + scrRect.width - half,
scrRect.y + half - 1,
mInClientHintBorder, scrRect.height - 2*half + 2);
mpScrDc->SetBrush( wxNullBrush );
}
else
{
mpScrDc->SetPen( mpLayout->mBlackPen );
mpScrDc->DrawLine( scrRect.x, scrRect.y,
scrRect.x + scrRect.width, scrRect.y );
mpScrDc->DrawLine( scrRect.x, scrRect.y + 1,
scrRect.x, scrRect.y + scrRect.height );
mpScrDc->DrawLine( scrRect.x+1, scrRect.y + scrRect.height,
scrRect.x + scrRect.width, scrRect.y + scrRect.height );
mpScrDc->DrawLine( scrRect.x + scrRect.width , scrRect.y,
scrRect.x + scrRect.width, scrRect.y + scrRect.height + 1);
}
mpScrDc->SetLogicalFunction( prevLF );
}
void cbBarDragPlugin::DrawHintRect ( wxRect& rect, bool isInClientRect)
{
DoDrawHintRect( rect, isInClientRect );
}
void cbBarDragPlugin::EraseHintRect( wxRect& rect, bool isInClientRect)
{
DoDrawHintRect( rect, isInClientRect );
}
void cbBarDragPlugin::FinishTracking()
{
wxScreenDC::EndDrawingOnTop();
delete mpScrDc;
mpScrDc = NULL;
}
void cbBarDragPlugin::RectToScr( wxRect& frameRect, wxRect& scrRect )
{
scrRect = frameRect;
int x = frameRect.x, y = frameRect.y;
mpLayout->GetParentFrame().ClientToScreen( &x, &y );
scrRect.x = x;
scrRect.y = y;
}

View File

@@ -0,0 +1,117 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 23/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __BARDRAGPL_G__
#define __BARDRAGPL_G__
#include "controlbar.h"
#include "toolwnd.h"
class cbBarDragPlugin : public cbPluginBase
{
DECLARE_DYNAMIC_CLASS( cbBarDragPlugin )
protected:
// plugin is active only in bar-dragging state
bool mBarDragStarted;
bool mCanStick; // flag used to prevent "bouncing" of hint-rectangle
wxScreenDC* mpScrDc; // created while tracking hint-rect
wxCursor* mpCurCursor;
// rectnagle shows the position/dimensions of the bar,
// if it would be docked now
wxRect mPrevHintRect;
wxRect mHintRect;
int mMouseInRectX;
int mMouseInRectY;
cbDockPane* mpSrcPane; // pane, from which the bar was originally taken
int mBarWidthInSrcPane;
cbDockPane* mpCurPane;
cbBarInfo* mpDraggedBar; // bar, which is being dragged
bool mBarWasFloating;
wxRect mFloatedBarBounds;
public: /*** public properties ***/
int mInClientHintBorder; // when hint-rect moves within client window area,
// the thicker rectangle is drawn using hatched brush,
// the default border width for this rectangle is 8 pix.
protected:
void AdjustHintRect( wxPoint& mousePos );
void ClipRectInFrame( wxRect& rect );
void ClipPosInFrame( wxPoint& pos );
cbDockPane* HitTestPanes( wxRect& rect );
cbDockPane* HitTestPanes( wxPoint& pos );
bool HitsPane( cbDockPane* pPane, wxRect& rect );
void CalcOnScreenDims( wxRect& rect );
int GetDistanceToPane( cbDockPane* pPane, wxPoint& mousePos );
bool IsInOtherPane ( wxPoint& mousePos );
bool IsInClientArea( wxPoint& mousePos );
bool IsInClientArea( wxRect& rect );
void StickToPane( cbDockPane* pPane, wxPoint& mousePos );
void UnstickFromPane( cbDockPane* pPane, wxPoint& mousePos );
int GetBarWidthInPane( cbDockPane* pPane );
int GetBarHeightInPane( cbDockPane* pPane );
// on-screen hint-tracking related methods
void StartTracking();
void DrawHintRect ( wxRect& rect, bool isInClientRect);
void EraseHintRect( wxRect& rect, bool isInClientRect);
void FinishTracking();
void DoDrawHintRect( wxRect& rect, bool isInClientRect);
void RectToScr( wxRect& frameRect, wxRect& scrRect );
void ShowHint( bool prevWasInClient );
public:
cbBarDragPlugin(void);
cbBarDragPlugin( wxFrameLayout* pPanel, int paneMask = wxALL_PANES );
virtual ~cbBarDragPlugin();
// handlers for plugin events
void OnMouseMove( cbMotionEvent& event );
void OnLButtonUp( cbLeftUpEvent& event );
void OnLButtonDown( cbLeftDownEvent& event );
void OnLDblClick( cbLeftDClickEvent& event );
// handles event, which oriniates from itself
void OnDrawHintRect( cbDrawHintRectEvent& event );
void OnStartBarDragging( cbStartBarDraggingEvent& event );
DECLARE_EVENT_TABLE()
};
#endif

View File

@@ -0,0 +1,535 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 30/11/98 (my 22th birthday :-)
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "rowlayoutpl.h"
// #pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/utils.h"
#include "barhintspl.h"
// fixed settings
#define GROOVE_WIDTH 3 // left shade + middle line + right shade
#define GROOVE_TO_GROOVE_GAP 1
#define BOX_T_BOX_GAP 2
#define BOX_TO_GROOVE_GAP 3
#define BOXES_IN_HINT 2
#define CLOSE_BOX_IDX 0
#define COLLAPSE_BOX_IDX 1
// used interally
#define CLOSE_BOX_HITTED 1
#define COLLAPSE_BOX_HITTED 2
/***** Implementation fro class cbBarHintsPlugin *****/
IMPLEMENT_DYNAMIC_CLASS( cbBarHintsPlugin, cbPluginBase )
BEGIN_EVENT_TABLE( cbBarHintsPlugin, cbPluginBase )
EVT_PL_SIZE_BAR_WND ( cbBarHintsPlugin::OnSizeBarWindow )
EVT_PL_DRAW_BAR_DECOR( cbBarHintsPlugin::OnDrawBarDecorations )
EVT_PL_LEFT_DOWN( cbBarHintsPlugin::OnLeftDown )
EVT_PL_LEFT_UP ( cbBarHintsPlugin::OnLeftUp )
EVT_PL_MOTION ( cbBarHintsPlugin::OnMotion )
END_EVENT_TABLE()
cbBarHintsPlugin::cbBarHintsPlugin(void)
: mpPane( 0 ),
mCollapseBoxOn( TRUE ),
mCloseBoxOn ( TRUE ),
mBtnPressed ( FALSE ),
mGrooveCount ( 2 ),
mHintGap ( 4 ),
mXWeight ( 2 )
{}
cbBarHintsPlugin::cbBarHintsPlugin( wxFrameLayout* pLayout, int paneMask )
: cbPluginBase( pLayout, paneMask ),
mpPane( 0 ),
mCollapseBoxOn( TRUE ),
mCloseBoxOn ( TRUE ),
mBtnPressed ( FALSE ),
mGrooveCount ( 2 ),
mHintGap ( 5 ),
mXWeight ( 2 )
{}
void cbBarHintsPlugin::SetGrooveCount( int nGrooves )
{
mGrooveCount = nGrooves;
}
void cbBarHintsPlugin::CreateBoxes()
{
cbCloseBox* box1 = new cbCloseBox();
cbCollapseBox* box2 = new cbCollapseBox();
mBoxes[CLOSE_BOX_IDX] = box1;
mBoxes[COLLAPSE_BOX_IDX] = box2;
for( int i = 0; i != BOXES_IN_HINT; ++i )
{
mBoxes[i]->mpLayout = mpLayout;
mBoxes[i]->mpPlugin = this;
mBoxes[i]->mpWnd = NULL;
}
}
void cbBarHintsPlugin::Draw3DBox( wxDC& dc, const wxPoint& pos, bool pressed )
{
}
void cbBarHintsPlugin::DrawCloseBox( wxDC& dc, const wxPoint& pos, bool pressed )
{
}
void cbBarHintsPlugin::DrawCollapseBox( wxDC& dc, const wxPoint& pos,
bool atLeft, bool disabled, bool pressed )
{
}
void cbBarHintsPlugin::DrawGrooves( wxDC& dc, const wxPoint& pos, int length )
{
int ofs = 0;
for( int i = 0; i != mGrooveCount; ++i, ofs += ( GROOVE_WIDTH + GROOVE_TO_GROOVE_GAP ) )
if ( mpPane->IsHorizontal() )
{
dc.SetPen( mpLayout->mLightPen );
dc.DrawLine( pos.x + ofs, pos.y, pos.x + ofs, pos.y + length - 1 );
dc.DrawPoint( pos.x + ofs + 1, pos.y );
dc.SetPen( mpLayout->mDarkPen );
dc.DrawLine( pos.x + ofs + 2, pos.y, pos.x + ofs + 2, pos.y + length );
dc.DrawPoint( pos.x + ofs + 1, pos.y + length - 1 );
dc.DrawPoint( pos.x + ofs, pos.y + length - 1 );
}
else
{
dc.SetPen( mpLayout->mLightPen );
dc.DrawLine( pos.x, pos.y + ofs, pos.x + length - 1, pos.y + ofs );
dc.DrawPoint( pos.x, pos.y + ofs + 1 );
dc.SetPen( mpLayout->mDarkPen );
dc.DrawLine( pos.x, pos.y + ofs + 2, pos.x + length, pos.y + ofs + 2 );
dc.DrawPoint( pos.x + length - 1, pos.y + ofs + 1 );
dc.DrawPoint( pos.x + length - 1, pos.y + ofs );
}
}
void cbBarHintsPlugin::ExcludeHints( wxRect& rect, cbBarInfo& info )
{
int boxHeight = BTN_BOX_HEIGHT;
// collapse and close box are not placed on fixed bars
if ( info.IsFixed() || ( !mCloseBoxOn && !mCollapseBoxOn ) )
boxHeight = 0;
int height = wxMax( mGrooveCount*(GROOVE_WIDTH + GROOVE_TO_GROOVE_GAP)
- GROOVE_TO_GROOVE_GAP,
boxHeight
);
if ( mpPane->IsHorizontal() )
{
rect.x += ( mHintGap*2 + height );
rect.width -= (height + 2*mHintGap);
rect.x -= info.mDimInfo.mHorizGap + 2;
rect.width += info.mDimInfo.mHorizGap + 2;
}
else
{
rect.y += (mHintGap*2 + height);
rect.height -= (height + 2*mHintGap);
rect.y -= info.mDimInfo.mVertGap + 2;
rect.height += info.mDimInfo.mVertGap + 2;
}
}
void cbBarHintsPlugin::DoDrawHint( wxDC& dc, wxRect& rect,
int pos, int boxOfs, int grooveOfs,
bool isFixed )
{
if ( !isFixed )
{
if ( mpPane->IsHorizontal() )
{
if ( mCloseBoxOn )
mBoxes[CLOSE_BOX_IDX]->Draw( dc );
if ( mCollapseBoxOn )
mBoxes[COLLAPSE_BOX_IDX]->Draw( dc );
}
else
{
if ( mCloseBoxOn )
mBoxes[CLOSE_BOX_IDX]->Draw( dc );
if ( mCollapseBoxOn )
mBoxes[COLLAPSE_BOX_IDX]->Draw( dc );
}
}
if ( mpPane->IsHorizontal() )
DrawGrooves( dc, wxPoint( rect.x + mHintGap + grooveOfs, pos ),
rect.height - (pos - rect.y) - mHintGap );
else
DrawGrooves( dc, wxPoint( rect.x + mHintGap, rect.y + mHintGap + grooveOfs ),
(pos - rect.x) - mHintGap );
}
void cbBarHintsPlugin::GetHintsLayout( wxRect& rect, cbBarInfo& info,
int& boxOfs, int& grooveOfs, int& pos )
{
int boxHeight = BTN_BOX_HEIGHT;
int boxWidth = BTN_BOX_WIDTH + BOX_TO_GROOVE_GAP + BTN_BOX_WIDTH;
// collapse and close box are not placed on fixed bars
if ( info.IsFixed() || ( !mCloseBoxOn && !mCollapseBoxOn ) )
{
boxHeight = 0;
boxWidth = 0;
}
else
if ( !mCloseBoxOn || !mCollapseBoxOn )
boxWidth = BTN_BOX_WIDTH;
int grooveHeight = mGrooveCount*(GROOVE_WIDTH + GROOVE_TO_GROOVE_GAP)
- GROOVE_TO_GROOVE_GAP;
int height = wxMax( grooveHeight, boxHeight );
// center boxs and groves with respect to each other
boxOfs = ( height - boxHeight ) / 2;
grooveOfs = ( height - grooveHeight ) / 2;
pos = ( mpPane->IsHorizontal() ) ? rect.y + mHintGap
: rect.x + rect.width - mHintGap;
// setup positions for boxes
if ( !info.IsFixed() )
{
// what direction "collapse-triangle" should look at?
bool& isAtLeft = ((cbCollapseBox*)(mBoxes[COLLAPSE_BOX_IDX]))->mIsAtLeft;
isAtLeft= info.mBounds.x <= mpPane->mPaneWidth - ( info.mBounds.x + info.mBounds.width );
if ( info.IsExpanded() )
{
isAtLeft = FALSE;
cbBarInfo* pCur = info.mpPrev;
while( pCur )
{
if ( !pCur->IsFixed() )
{
isAtLeft = TRUE; break;
}
pCur = pCur->mpPrev;
}
}
// collapse/expand works only when more not-fixed bars are present in the same row
mBoxes[COLLAPSE_BOX_IDX]->Enable( info.mpRow->mNotFixedBarsCnt > 1 );
for( int i = 0; i != BOXES_IN_HINT; ++i )
mBoxes[i]->mpPane = mpPane;
if ( mpPane->IsHorizontal() )
{
if ( mCloseBoxOn )
{
mBoxes[CLOSE_BOX_IDX]->mPos = wxPoint( rect.x + mHintGap + boxOfs, pos );
pos += BTN_BOX_HEIGHT;
}
if ( mCollapseBoxOn )
{
if ( mCloseBoxOn ) pos += BOX_T_BOX_GAP;
mBoxes[COLLAPSE_BOX_IDX]->mPos = wxPoint( rect.x + mHintGap + boxOfs, pos );
pos += BTN_BOX_HEIGHT;
pos += BOX_TO_GROOVE_GAP;
}
}
else
{
if ( mCloseBoxOn )
{
pos -= BTN_BOX_WIDTH;
mBoxes[CLOSE_BOX_IDX]->mPos = wxPoint( pos , rect.y + mHintGap + boxOfs );
}
if ( mCollapseBoxOn )
{
if ( mCloseBoxOn ) pos -= BOX_T_BOX_GAP;
pos -= BTN_BOX_WIDTH;
mBoxes[COLLAPSE_BOX_IDX]->mPos = wxPoint( pos, rect.y + mHintGap + boxOfs );
pos -= BOX_TO_GROOVE_GAP;
}
}
}
}
static inline bool is_in_box( const wxPoint& rectPos, const wxPoint& mousePos )
{
return ( mousePos.x >= rectPos.x &&
mousePos.y >= rectPos.y &&
mousePos.x < rectPos.x + BTN_BOX_WIDTH &&
mousePos.y < rectPos.y + BTN_BOX_HEIGHT );
}
int cbBarHintsPlugin::HitTestHints( cbBarInfo& info, const wxPoint& pos )
{
wxPoint inPane = pos;
mpPane->PaneToFrame( &inPane.x, &inPane.y );
wxRect& rect = info.mBoundsInParent;
if ( info.IsFixed() ) return FALSE;
int boxOfs, grooveOfs, coord;
GetHintsLayout( rect, info, boxOfs, grooveOfs, coord );
if ( mpPane->IsHorizontal() )
{
if ( mCloseBoxOn )
{
if ( is_in_box( wxPoint( rect.x + mHintGap + boxOfs, coord ), inPane ) )
return CLOSE_BOX_HITTED;
coord += BTN_BOX_HEIGHT;
}
if ( mCollapseBoxOn )
{
if ( mCloseBoxOn ) coord += BOX_T_BOX_GAP;
if ( is_in_box( wxPoint( rect.x + mHintGap + boxOfs, coord ), inPane ) )
return COLLAPSE_BOX_HITTED;
coord += BTN_BOX_HEIGHT;
}
}
else
{
if ( mCloseBoxOn )
{
coord -= BTN_BOX_WIDTH;
if ( is_in_box( wxPoint( coord , rect.y + mHintGap + boxOfs ), inPane ) )
return CLOSE_BOX_HITTED;
}
if ( mCollapseBoxOn )
{
if ( mCloseBoxOn ) coord -= BOX_T_BOX_GAP;
coord -= BTN_BOX_WIDTH;
if ( is_in_box( wxPoint( coord, rect.y + mHintGap + boxOfs ), inPane ) )
return COLLAPSE_BOX_HITTED;
}
}
return FALSE;
}
// handlers for plugin-events
void cbBarHintsPlugin::OnSizeBarWindow( cbSizeBarWndEvent& event )
{
wxRect& rect = event.mBoundsInParent;
mpPane = event.mpPane;
ExcludeHints( rect, *event.mpBar );
event.Skip(); // pass event to the next plugin in the chain
}
void cbBarHintsPlugin::OnDrawBarDecorations( cbDrawBarDecorEvent& event )
{
wxRect& rect = event.mBoundsInParent;
mpPane = event.mpPane;
int boxOfs, grooveOfs, pos;
GetHintsLayout( rect, *event.mpBar, boxOfs, grooveOfs, pos );
DoDrawHint( *event.mpDc, rect, pos, boxOfs, grooveOfs, event.mpBar->IsFixed() );
// let other plugins add on their decorations
event.Skip();
}
void cbBarHintsPlugin::OnLeftDown( cbLeftDownEvent& event )
{
mpPane = event.mpPane;
wxPoint inFrame = event.mPos;
mpPane->PaneToFrame( &inFrame.x, &inFrame.y );
wxBarIterator iter( mpPane->GetRowList() );
mpClickedBar = NULL;
while ( iter.Next() )
{
cbBarInfo& bar = iter.BarInfo();
int boxOfs, grooveOfs, pos;
GetHintsLayout( bar.mBoundsInParent, bar, boxOfs, grooveOfs, pos );
if ( !bar.IsFixed() )
for( int i = 0; i != BOXES_IN_HINT; ++i )
{
mBoxes[i]->OnLeftDown( inFrame );
if ( mBoxes[i]->mPressed )
{
mBtnPressed = TRUE;
mpClickedBar = &bar;
return; // event handled
}
}
}
event.Skip();
}
void cbBarHintsPlugin::OnLeftUp( cbLeftUpEvent& event )
{
if ( mBtnPressed )
{
wxPoint inFrame = event.mPos;
mpPane->PaneToFrame( &inFrame.x, &inFrame.y );
int boxOfs, grooveOfs, pos;
GetHintsLayout( mpClickedBar->mBoundsInParent, *mpClickedBar, boxOfs, grooveOfs, pos );
int result = HitTestHints( *mpClickedBar, event.mPos );
for( int i = 0; i != BOXES_IN_HINT; ++i )
{
mBoxes[i]->OnLeftUp( inFrame );
if ( mBoxes[i]->WasClicked() )
{
if ( i == 0 )
mpLayout->SetBarState( mpClickedBar, wxCBAR_HIDDEN, TRUE );
else
{
if ( mpClickedBar->IsExpanded() )
mpPane->ContractBar( mpClickedBar );
else
mpPane->ExpandBar( mpClickedBar );
}
}
}
mBtnPressed = FALSE;
return;
}
else
event.Skip();
}
void cbBarHintsPlugin::OnMotion( cbMotionEvent& event )
{
if ( mBtnPressed )
{
wxPoint inFrame = event.mPos;
mpPane->PaneToFrame( &inFrame.x, &inFrame.y );
mpPane = event.mpPane;
for( int i = 0; i != BOXES_IN_HINT; ++i )
mBoxes[i]->OnMotion( inFrame );
}
else
event.Skip();
}
void cbBarHintsPlugin::OnInitPlugin()
{
cbPluginBase::OnInitPlugin();
cbDockPane** panes = mpLayout->GetPanesArray();
for( int i = 0; i != MAX_PANES; ++i )
if ( panes[i]->MatchesMask( mPaneMask ) )
{
panes[i]->mProps.mMinCBarDim.x = 25;
panes[i]->mProps.mMinCBarDim.y = 16;
}
CreateBoxes();
}

View File

@@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 30/11/98 (my 22th birthday :-)
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __DRAGHINTSPL_G__
#define __DRAGHINTSPL_G__
#include "controlbar.h"
#include "toolwnd.h"
/*
* Intercepts bar-decoration and sizing events, draws 3d-hints
* around fixed and flexible bars, similar to those in Microsoft DevStudio 6.x
*/
class cbBarHintsPlugin : public cbPluginBase
{
DECLARE_DYNAMIC_CLASS( cbBarHintsPlugin )
protected:
cbDockPane* mpPane; // is set up temorarely, while handling event
cbMiniButton* mBoxes[2];
bool mBtnPressed;
bool mClosePressed;
cbBarInfo* mpClickedBar;
bool mDepressed;
protected:
// drawing helpers
void Draw3DBox ( wxDC& dc, const wxPoint& pos, bool pressed );
void DrawCloseBox ( wxDC& dc, const wxPoint& pos, bool pressed );
void DrawCollapseBox( wxDC& dc, const wxPoint& pos,
bool atLeft, bool disabled, bool pressed );
void DrawGrooves ( wxDC& dc, const wxPoint& pos, int length );
void DoDrawHint( wxDC& dc, wxRect& rect, int pos, int boxOfs, int grooveOfs, bool isFixed );
void GetHintsLayout( wxRect& rect, cbBarInfo& info,
int& boxOfs, int& grooveOfs, int& pos );
int HitTestHints( cbBarInfo& info, const wxPoint& pos );
void ExcludeHints( wxRect& rect, cbBarInfo& info );
void CreateBoxes();
public:
/* public properties */
bool mCloseBoxOn; // default: ON
bool mCollapseBoxOn; // default: ON
int mGrooveCount; // default: 2 (two shaded bars)
int mHintGap; // default: 5 (pixels from above, below, right and left)
int mXWeight; // default: 2 (width in pixels of lines which used for drawing cross)
public:
cbBarHintsPlugin(void);
cbBarHintsPlugin( wxFrameLayout* pLayout, int paneMask = wxALL_PANES );
void SetGrooveCount( int nGrooves );
void OnInitPlugin();
// handlers of plugin-events
void OnSizeBarWindow( cbSizeBarWndEvent& event );
void OnDrawBarDecorations( cbDrawBarDecorEvent& event );
void OnLeftDown( cbLeftDownEvent& event );
void OnLeftUp ( cbLeftUpEvent& event );
void OnMotion ( cbMotionEvent& event );
DECLARE_EVENT_TABLE()
};
#endif

View File

@@ -0,0 +1,203 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 06/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "cbcustom.h"
// #pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "cbcustom.h"
// helper class to receive menu customization event
class cbContextMenuHandler : public wxEvtHandler
{
public:
cbSimpleCustomizationPlugin* mpBackRef;
public:
void OnMenuCommand( wxCommandEvent& evt );
void OnCommandEvents( wxCommandEvent& evt );
DECLARE_EVENT_TABLE();
};
// FIXME:: is this "safe" ?
#define CB_CUSTOMIZE_MENU_FIRST_ITEM_ID 17500
/***** Implementation for helper class cbContextMenuHandler *****/
BEGIN_EVENT_TABLE( cbContextMenuHandler, wxEvtHandler )
// FIXME:: what is the right range for these ids ? so that they
// would not collide with user commands?
EVT_COMMAND_RANGE( CB_CUSTOMIZE_MENU_FIRST_ITEM_ID,
CB_CUSTOMIZE_MENU_FIRST_ITEM_ID + 300,
wxEVT_COMMAND_MENU_SELECTED,
cbContextMenuHandler::OnCommandEvents )
END_EVENT_TABLE()
void cbContextMenuHandler::OnCommandEvents( wxCommandEvent& evt )
{
//wxMessageBox("Wowwwww, Yeah!");
mpBackRef->OnMenuItemSelected( evt );
}
/***** Implementation for class cbSimpleCustomizationPlugin *****/
IMPLEMENT_DYNAMIC_CLASS( cbSimpleCustomizationPlugin, cbPluginBase )
BEGIN_EVENT_TABLE( cbSimpleCustomizationPlugin, cbPluginBase )
EVT_PL_CUSTOMIZE_BAR ( cbSimpleCustomizationPlugin::OnCustomizeBar )
EVT_PL_CUSTOMIZE_LAYOUT( cbSimpleCustomizationPlugin::OnCustomizeLayout )
END_EVENT_TABLE()
cbSimpleCustomizationPlugin::cbSimpleCustomizationPlugin(void)
{}
cbSimpleCustomizationPlugin::cbSimpleCustomizationPlugin( wxFrameLayout* pPanel, int paneMask )
: cbPluginBase( pPanel, paneMask )
{}
void cbSimpleCustomizationPlugin::OnCustomizeBar( cbCustomizeBarEvent& event )
{
// ingnore bar customization, treat it
// as layout-customization...ugly, eh?
cbCustomizeLayoutEvent clEvt( event.mClickPos );
OnCustomizeLayout( clEvt );
}
void cbSimpleCustomizationPlugin::OnCustomizeLayout( cbCustomizeLayoutEvent& event )
{
wxString helpStr1 = "Select this item to show the corresponding control bar";
wxString helpStr2 = "Select this itme to hide the corresponding control bar";
int id = CB_CUSTOMIZE_MENU_FIRST_ITEM_ID;
wxMenu* pMenu = new wxMenu();
BarArrayT& bars = mpLayout->GetBars();
for( size_t i = 0; i != bars.GetCount(); ++i )
{
cbBarInfo& bar = *bars[i];
bool isHidden = ( bar.mState == wxCBAR_HIDDEN );
wxString* pHelpStr = ( isHidden ) ? &helpStr1 : &helpStr2;
pMenu->Append( id, bar.mName, *pHelpStr, TRUE );
pMenu->Check( id, (isHidden == FALSE) );
++id;
}
pMenu->AppendSeparator();
pMenu->Append( id, "Customize...", "Show layout customization dialog", FALSE );
mCustMenuItemId = id;
cbContextMenuHandler* pHandler = new cbContextMenuHandler();
pHandler->mpBackRef = this;
wxWindow* pFrm = &mpLayout->GetParentFrame();
// FOR NOW FOR NOW:: to work-around wxFrame's (MSW) nasty event-handling bugs!!!
wxWindow* pTmpWnd = new wxWindow( pFrm, -1, event.mClickPos, wxSize(0,0) );
pMenu->SetEventHandler( pHandler );
pTmpWnd->PopupMenu( pMenu, 0,0 );
pTmpWnd->Destroy();
delete pMenu;
delete pHandler;
// event is "eaten" by this plugin
}
void cbSimpleCustomizationPlugin::OnMenuItemSelected( wxCommandEvent& event )
{
if ( event.m_commandInt == mCustMenuItemId )
{
wxMessageBox("Customization dialog box is not supproted by this plugin yet");
return;
}
else
{
cbBarInfo* pBar = mpLayout->GetBars()[ event.m_commandInt -
CB_CUSTOMIZE_MENU_FIRST_ITEM_ID
];
wxASSERT( pBar ); // DBG::
// "inverse" bar-visibility of the selected bar
int newState = 0;
if ( pBar->mState == wxCBAR_HIDDEN )
{
if ( pBar->mAlignment == -1 )
{
pBar->mAlignment = 0; // just remove "-1" marking
newState = wxCBAR_FLOATING;
}
else
if ( pBar->mAlignment == wxTOP ||
pBar->mAlignment == wxBOTTOM )
newState = wxCBAR_DOCKED_HORIZONTALLY;
else
newState = wxCBAR_DOCKED_VERTICALLY;
}
else
{
newState = wxCBAR_HIDDEN;
if ( pBar->mState == wxCBAR_FLOATING )
pBar->mAlignment = -1;
}
mpLayout->SetBarState( pBar, newState, TRUE );
if ( newState == wxCBAR_FLOATING )
mpLayout->RepositionFloatedBar( pBar );
}
// menu-item-selected event is "eaten"
}

View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 28/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __CBCUSTOM_G__
#define __CBCUSTOM_G__
#ifdef __GNUG__
#pragma interface "cbcustom.h"
#endif
#include "controlbar.h"
class cbSimpleCustomizationPlugin : public cbPluginBase
{
public:
DECLARE_DYNAMIC_CLASS( cbSimpleCustomizationPlugin )
int mCustMenuItemId;
public:
cbSimpleCustomizationPlugin(void);
cbSimpleCustomizationPlugin( wxFrameLayout* pPanel, int paneMask = wxALL_PANES );
// plugin-event handlers
void OnCustomizeBar( cbCustomizeBarEvent& event );
void OnCustomizeLayout( cbCustomizeLayoutEvent& event );
// menu-event handler
void OnMenuItemSelected( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
};
#endif

View File

@@ -0,0 +1,611 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 27/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "cbstore.h"
// #pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "cbstore.h"
/***** Implementation for class wxFrameLayoutSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( wxFrameLayout,
wxFrameLayoutSerializer,
wxFrameLayoutSerializer::Serialize,
wxFrameLayoutSerializer::Initialize )
void wxFrameLayoutSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
// wxFrameLayout is a "kind of" wxEvtHandler - perform
// serialization of the base class first
info.SerializeInherited( pObj, store );
wxFrameLayout* pLayout = (wxFrameLayout*)pObj;
store.XchgObjPtr( (wxObject**) &pLayout->mpFrame );
store.XchgObjPtr( (wxObject**) &pLayout->mpFrameClient );
for( int i = 0; i != MAX_PANES; ++i )
store.XchgObjPtr( (wxObject**) &(pLayout->mPanes[i]) );
// plugins are serialized _after_ panes
store.XchgObjPtr( (wxObject**) &(pLayout->mpTopPlugin) );
// and the rest will follow...
store.XchgObjArray( pLayout->mAllBars );
store.XchgObjList( pLayout->mBarSpyList );
store.XchgObjList( pLayout->mFloatedFrames );
store.XchgObjPtr( (wxObject**) &(pLayout->mpUpdatesMgr) );
store.XchgBool( pLayout->mFloatingOn );
store.XchgWxPoint( pLayout->mNextFloatedWndPos );
store.XchgWxSize( pLayout->mFloatingPosStep );
store.XchgObj( (wxObject*) &pLayout->mDarkPen );
store.XchgObj( (wxObject*) &pLayout->mLightPen );
store.XchgObj( (wxObject*) &pLayout->mGrayPen );
store.XchgObj( (wxObject*) &pLayout->mBlackPen );
store.XchgObj( (wxObject*) &pLayout->mBorderPen );
}
void wxFrameLayoutSerializer::Initialize( wxObject* pObj )
{
wxFrameLayout* pLayout = (wxFrameLayout*)pObj;
// wxFrameLayout is a "kind of" wxEvtHandler - perform
// wxEvtHandler-specific initialization first
info.InitializeInherited( pObj );
//pLayout->RecalcLayout( TRUE );
}
/***** Implementation for class wxFrameLayoutSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( cbBarSpy,
cbBarSpySerializer,
cbBarSpySerializer::Serialize,
cbBarSpySerializer::Initialize )
void cbBarSpySerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
// cbBarSpy is a "kind of" wxEvtHandler - perform
// serialization of the base class first
info.SerializeInherited( pObj, store );
cbBarSpy* pSpy = (cbBarSpy*)pObj;
store.XchgObjPtr( (wxObject**) &(pSpy->mpLayout) );
store.XchgObjPtr( (wxObject**) &(pSpy->mpBarWnd) );
}
void cbBarSpySerializer::Initialize( wxObject* pObj )
{
// cbBarSpySerializer is a "kind of" wxEvtHandler - perform
// wxEvtHandler-specific initialization first
info.InitializeInherited( pObj );
cbBarSpy* pSpy = (cbBarSpy*)pObj;
// is done by wxEventHandler's serializer already!
//pSpy->mpBarWnd->PushEventHandler( pSpy );
}
/***** Implementation for class cbBarDimHandlerBaseSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( cbBarDimHandlerBase,
cbBarDimHandlerBaseSerializer,
cbBarDimHandlerBaseSerializer::Serialize,
NO_CLASS_INIT )
void cbBarDimHandlerBaseSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
cbBarDimHandlerBase* pHandler = (cbBarDimHandlerBase*)pObj;
store.XchgInt( pHandler->mRefCount );
}
/***** Implementation for class cbDimInfoSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( cbDimInfo,
cbDimInfoSerializer,
cbDimInfoSerializer::Serialize,
NO_CLASS_INIT )
void cbDimInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
cbDimInfo* pInfo = (cbDimInfo*)pObj;
int i = 0;
for( i = 0; i != MAX_BAR_STATES; ++i )
store.XchgWxSize( pInfo->mSizes[i] );
for( i = 0; i != MAX_BAR_STATES; ++i )
store.XchgWxRect( pInfo->mBounds[i] );
store.XchgInt ( pInfo->mLRUPane );
store.XchgInt ( pInfo->mHorizGap );
store.XchgInt ( pInfo->mVertGap );
store.XchgBool ( pInfo->mIsFixed );
store.XchgObjPtr( (wxObject**) &(pInfo->mpHandler) );
}
/***** Implementation for class cbRowInfoSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( cbRowInfo,
cbRowInfoSerializer,
cbRowInfoSerializer::Serialize,
NO_CLASS_INIT )
void cbRowInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
cbRowInfo* pInfo = (cbRowInfo*)pObj;
store.XchgObjArray( pInfo->mBars );
store.XchgLongArray( pInfo->mSavedRatios );
store.XchgObjPtr( (wxObject**) &pInfo->mpNext );
store.XchgObjPtr( (wxObject**) &pInfo->mpPrev );
store.XchgObjPtr( (wxObject**) &pInfo->mpExpandedBar );
store.XchgBool ( pInfo->mHasUpperHandle );
store.XchgBool ( pInfo->mHasLowerHandle );
store.XchgBool ( pInfo->mHasOnlyFixedBars );
store.XchgInt ( pInfo->mNotFixedBarsCnt );
// other properties of the row are transient, since
// they are reclaculated each time the frame is resized/activated
}
/***** Implementation for class cbBarInfoSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( cbBarInfo,
cbBarInfoSerializer,
cbBarInfoSerializer::Serialize,
NO_CLASS_INIT )
void cbBarInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
cbBarInfo* pInfo = (cbBarInfo*)pObj;
store.XchgWxStr ( pInfo->mName );
store.XchgWxRect( pInfo->mBounds );
store.XchgObjPtr( (wxObject**) &(pInfo->mpRow) );
store.XchgBool ( pInfo->mHasLeftHandle );
store.XchgBool ( pInfo->mHasRightHandle );
store.XchgObj ( (wxObject*) &(pInfo->mDimInfo ) );
store.XchgInt ( pInfo->mState );
store.XchgInt ( pInfo->mAlignment );
store.XchgInt ( pInfo->mRowNo );
store.XchgObjPtr( (wxObject**) &(pInfo->mpBarWnd) );
store.XchgDouble( pInfo->mLenRatio );
store.XchgWxPoint( pInfo->mPosIfFloated );
store.XchgObjPtr( (wxObject**) &(pInfo->mpNext) );
store.XchgObjPtr( (wxObject**) &(pInfo->mpPrev) );
// other properties of the bar are transient, since
// they are reclaculated each time the frame is resized/activated
}
/***** Implementation for class cbCommonPanePropertiesSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( cbCommonPaneProperties,
cbCommonPanePropertiesSerializer,
cbCommonPanePropertiesSerializer::Serialize,
NO_CLASS_INIT )
void cbCommonPanePropertiesSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
cbCommonPaneProperties* pProps = (cbCommonPaneProperties*)pObj;
store.XchgBool ( pProps->mRealTimeUpdatesOn );
store.XchgBool ( pProps->mOutOfPaneDragOn );
store.XchgBool ( pProps->mExactDockPredictionOn );
store.XchgBool ( pProps->mNonDestructFirctionOn );
store.XchgBool ( pProps->mShow3DPaneBorderOn );
store.XchgBool ( pProps->mBarFloatingOn );
store.XchgBool ( pProps->mRowProportionsOn );
store.XchgBool ( pProps->mColProportionsOn );
store.XchgBool ( pProps->mBarCollapseIconsOn );
store.XchgBool ( pProps->mBarDragHintsOn );
store.XchgWxSize( pProps->mMinCBarDim );
store.XchgInt( pProps->mResizeHandleSize );
}
/***** Implementation for class *****/
IMPLEMENT_SERIALIZER_CLASS( cbDockPane,
cbDockPaneSerializer,
cbDockPaneSerializer::Serialize,
NO_CLASS_INIT )
void cbDockPaneSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
cbDockPane* pPane = (cbDockPane*)pObj;
store.XchgObj( (wxObject*) &(pPane->mProps) );
store.XchgInt( pPane->mLeftMargin );
store.XchgInt( pPane->mRightMargin );
store.XchgInt( pPane->mTopMargin );
store.XchgInt( pPane->mBottomMargin );
store.XchgInt( pPane->mAlignment );
store.XchgObjArray( pPane->mRows );
store.XchgObjPtr ( (wxObject**) &(pPane->mpLayout) );
}
/***** Implementation for class cbUpdatesManagerBaseSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( cbUpdatesManagerBase,
cbUpdatesManagerBaseSerializer,
cbUpdatesManagerBaseSerializer::Serialize,
NO_CLASS_INIT )
void cbUpdatesManagerBaseSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
cbUpdatesManagerBase* pMgr = (cbUpdatesManagerBase*)pObj;
// only back-reference to layout "engine"
store.XchgObjPtr( (wxObject**) &(pMgr->mpLayout) );
}
/***** Implementation for class cbPluginBaseSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( cbPluginBase,
cbPluginBaseSerializer,
cbPluginBaseSerializer::Serialize,
cbPluginBaseSerializer::Initialize )
void cbPluginBaseSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
// plugin is "a kind" of wxEvtHandler - perform
// serialization of the base class first
info.SerializeInherited( pObj, store );
cbPluginBase* pPlugin = (cbPluginBase*)pObj;
store.XchgObjPtr( (wxObject**) &(pPlugin->mpLayout) );
store.XchgInt( pPlugin->mPaneMask );
}
void cbPluginBaseSerializer::Initialize( wxObject* pObj )
{
// plugins need extra-initialization, after they are
// attached to the frame-layout and pane mask is set
( (cbPluginBase*)pObj )->OnInitPlugin();
}
/***** Implementation for class cbRowDragPluginSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( cbRowDragPlugin,
cbRowDragPluginSerializer,
cbRowDragPluginSerializer::Serialize,
cbRowDragPluginSerializer::Initialize )
void cbRowDragPluginSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
// plugin is "a kind" of cbPluginBaseSerializer - perform
// serialization of the base class first
info.SerializeInherited( pObj, store );
cbRowDragPlugin* pPlugin = (cbRowDragPlugin*)pObj;
store.XchgInt( pPlugin->mSvTopMargin );
store.XchgInt( pPlugin->mSvBottomMargin );
store.XchgInt( pPlugin->mSvLeftMargin );
store.XchgInt( pPlugin->mSvRightMargin );
store.XchgObjList( pPlugin->mHiddenBars );
}
void cbRowDragPluginSerializer::Initialize( wxObject* pObj )
{
// plugins need extra-initialization, after they are
// attached to the frame-layout and pane mask is set
( (cbPluginBase*)pObj )->OnInitPlugin();
}
/***** Implementation for class cbHiddenBarInfoSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( cbHiddenBarInfo,
cbHiddenBarInfoSerializer,
cbHiddenBarInfoSerializer::Serialize,
NO_CLASS_INIT )
void cbHiddenBarInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
cbHiddenBarInfo* pInfo = (cbHiddenBarInfo*)pObj;
store.XchgObjPtr( (wxObject**) &(pInfo->mpBar) );
store.XchgInt( pInfo->mRowNo );
store.XchgInt( pInfo->mIconNo );
store.XchgInt( pInfo->mAlignment );
}
/***** Implementation for class cbFloatedBarWindowSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( cbFloatedBarWindow,
cbFloatedBarWindowSerializer,
cbFloatedBarWindowSerializer::Serialize,
cbFloatedBarWindowSerializer::Initialize )
static wxString __gTmpFrameTitle;
void cbFloatedBarWindowSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
cbFloatedBarWindow* pWnd = (cbFloatedBarWindow*)pObj;
if ( store.IsLoading() == FALSE )
__gTmpFrameTitle = pWnd->GetTitle();
store.XchgWxStr( __gTmpFrameTitle );
// cbFloatedBarWindow is "a kind" of wxWindow - perform
// serialization of the base class first
wxWindowSerializer::DoSerialize( pObj, store,
(wndCreationFn)cbFloatedBarWindowSerializer::CreateFloatedBarWindowFn );
store.XchgObjPtr( (wxObject**) &(pWnd->mpBar) );
store.XchgObjPtr( (wxObject**) &(pWnd->mpLayout) );
store.XchgObjPtr( (wxObject**) &(pWnd->mpClientWnd) );
}
void cbFloatedBarWindowSerializer::CreateFloatedBarWindowFn( cbFloatedBarWindow* fbar, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style ,
const wxString& name )
{
fbar->Create( parent, id, __gTmpFrameTitle, pos, size, style );
}
void cbFloatedBarWindowSerializer::Initialize( wxObject* pObj )
{
// FOR NOW:: nothing
}
/***** Implementation for class wxNewBitmapButtonSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( wxNewBitmapButton,
wxNewBitmapButtonSerializer,
wxNewBitmapButtonSerializer::Serialize,
wxNewBitmapButtonSerializer::Initialize )
void wxNewBitmapButtonSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
wxNewBitmapButton* pBtn = (wxNewBitmapButton*)pObj;
store.XchgInt ( pBtn->mTextToLabelGap );
store.XchgInt ( pBtn->mMarginX );
store.XchgInt ( pBtn->mMarginY );
store.XchgInt ( pBtn->mTextAlignment );
store.XchgBool( pBtn->mIsFlat );
store.XchgBool( pBtn->mIsSticky );
store.XchgWxStr( pBtn->mLabelText );
store.XchgWxStr( pBtn->mImageFileName );
store.XchgInt ( pBtn->mImageFileType );
store.XchgInt( pBtn->mFiredEventType );
// cbFloatedBarWindow is "a kind" of wxWindow - perform
// serialization of the base class
wxWindowSerializer::DoSerialize( pObj, store,
(wndCreationFn)wxNewBitmapButtonSerializer::CreateNewBmpBtnWindowFn );
}
void wxNewBitmapButtonSerializer::CreateNewBmpBtnWindowFn( wxNewBitmapButton* btn, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style ,
const wxString& name )
{
btn->Create( parent, id, pos, size, style, name );
//btn->Reshape();
btn->mIsCreated = FALSE;
btn->Reshape();
}
void wxNewBitmapButtonSerializer::Initialize( wxObject* pObj )
{
// FOR NOW:: nothing
wxNewBitmapButton* pBtn = (wxNewBitmapButton*)pObj;
//pBtn->Reshape();
}
/***** Implementation for class wxDynamicToolBarSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( wxDynamicToolBar,
wxDynamicToolBarSerializer,
wxDynamicToolBarSerializer::Serialize,
wxDynamicToolBarSerializer::Initialize )
void wxDynamicToolBarSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
// cbFloatedBarWindow is "a kind" of wxWindow - perform
// serialization of the base class first
wxWindowSerializer::DoSerialize( pObj, store,
(wndCreationFn)wxDynamicToolBarSerializer::CreateDynTBarWindowFn );
wxDynamicToolBar* pTBar = (wxDynamicToolBar*)pObj;
store.XchgObjArray( pTBar->mTools );
}
void wxDynamicToolBarSerializer::CreateDynTBarWindowFn( wxDynamicToolBar* tbar, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style ,
const wxString& name )
{
tbar->Create( parent, id, pos, size, style );
}
void wxDynamicToolBarSerializer::Initialize( wxObject* pObj )
{
// FOR NOW:: nothing
}
/***** Implementation for class wxDynToolInfoSerializer *****/
IMPLEMENT_SERIALIZER_CLASS( wxDynToolInfo,
wxDynToolInfoSerializer,
wxDynToolInfoSerializer::Serialize,
NO_CLASS_INIT )
void wxDynToolInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
// cbFloatedBarWindow is "a kind" of wxWindow - perform
// serialization of the base class first
wxDynToolInfo* pInfo = (wxDynToolInfo*)pObj;
store.XchgWxRect( pInfo->mRect );
store.XchgBool ( pInfo->mIsSeparator );
store.XchgObjPtr( (wxObject**) &pInfo->mpToolWnd );
store.XchgInt ( pInfo->mIndex );
store.XchgWxSize( pInfo->mRealSize );
}
#include "objstore.h" // tabbed window is serialiable
/***** Implementation for class wxTabbedWindowSerializer ****/
IMPLEMENT_SERIALIZER_CLASS( wxTabbedWindow,
wxTabbedWindowSerializer,
wxTabbedWindowSerializer::Serialize,
wxTabbedWindowSerializer::Initialize)
void wxTabbedWindowSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
wxTabbedWindow* pWnd = (wxTabbedWindow*)pObj;
// we're kind of window - serialize it first
if ( store.IsLoading() )
// FOR NOW::workaround for the mistery
pWnd->mpTabScroll = (wxScrollBar*)(-1);
wxWindowSerializer::DoSerialize( pObj, store,
(wndCreationFn)wxWindowSerializer::CreateWindowFn,
FALSE );
store.XchgObjList( pWnd->mTabs );
store.XchgInt( pWnd->mActiveTab );
store.XchgInt( pWnd->mTitleHeight );
store.XchgInt( pWnd->mLayoutType );
store.XchgInt( pWnd->mTitleHeight );
store.XchgObj( (wxObject*) &(pWnd->mWhitePen) );
store.XchgObj( (wxObject*) &(pWnd->mGrayPen) );
store.XchgObj( (wxObject*) &(pWnd->mDarkPen) );
store.XchgObj( (wxObject*) &(pWnd->mBlackPen) );
store.XchgObjPtr( (wxObject**) &(pWnd->mpTabScroll ) );
store.XchgObjPtr( (wxObject**) &(pWnd->mpHorizScroll) );
store.XchgObjPtr( (wxObject**) &(pWnd->mpVertScroll ) );
store.XchgInt( pWnd->mVertGap );
store.XchgInt( pWnd->mHorizGap );
store.XchgInt( pWnd->mTitleVertGap );
store.XchgInt( pWnd->mTitleHorizGap );
store.XchgInt( pWnd->mImageTextGap );
store.XchgInt( pWnd->mFirstTitleGap );
store.XchgInt( pWnd->mBorderOnlyWidth );
}
void wxTabbedWindowSerializer::Initialize( wxObject* pObj )
{
wxTabbedWindow* pWnd = (wxTabbedWindow*)pObj;
pWnd->RecalcLayout(TRUE);
}
/***** Implementation for class twTabInfoSerializer ****/
IMPLEMENT_SERIALIZER_CLASS( twTabInfo,
twTabInfoSerializer,
twTabInfoSerializer::Serialize,
NO_CLASS_INIT )
void twTabInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
twTabInfo* pInfo = (twTabInfo*)pObj;
store.XchgObjPtr( (wxObject**) &(pInfo->mpContent) );
// NOTE:: wxSize is NOT a dynamic class unfortunately ...
store.XchgWxSize( pInfo->mDims );
store.XchgWxStr ( pInfo->mText );
store.XchgWxStr( pInfo->mImageFile );
store.XchgLong( pInfo->mImageType );
if ( store.IsLoading() && wxFileExists( pInfo->mImageFile ) )
pInfo->mBitMap.LoadFile( pInfo->mImageFile, pInfo->mImageType );
}

View File

@@ -0,0 +1,181 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: ??/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __CBSTORE_G__
#define __CBSTORE_G__
#include "controlbar.h"
#include "objstore.h" // used for persistance of control-bars
// serializers for some additional classes placed here
#include "rowdragpl.h"
#include "toolwnd.h"
#include "newbmpbtn.h"
#include "dyntbar.h"
#include "controlarea.h"
// serialziers for common components of frame-layout engine
class wxFrameLayoutSerializer : public wxEvtHandlerSerializer
{
DECLARE_SERIALIZER_CLASS( wxFrameLayoutSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void Initialize( wxObject* pObj );
};
class cbBarSpySerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( cbBarSpySerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void Initialize( wxObject* pObj );
};
class cbBarDimHandlerBaseSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( cbBarDimHandlerBaseSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
class cbDimInfoSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( cbDimInfoSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
class cbRowInfoSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( cbRowInfoSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
class cbBarInfoSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( cbBarInfoSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
class cbCommonPanePropertiesSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( cbCommonPanePropertiesSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
class cbDockPaneSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( cbDockPaneSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
class cbUpdatesManagerBaseSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( cbUpdatesManagerBaseSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
class cbPluginBaseSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( cbPluginBaseSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void Initialize( wxObject* pObj );
};
class cbRowDragPluginSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( cbRowDragPluginSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void Initialize( wxObject* pObj );
};
class cbHiddenBarInfoSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( cbHiddenBarInfoSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
class cbFloatedBarWindowSerializer : public wxWindowSerializer
{
DECLARE_SERIALIZER_CLASS( cbFloatedBarWindowSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void Initialize( wxObject* pObj );
static void CreateFloatedBarWindowFn( cbFloatedBarWindow* fbar, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style,
const wxString& name );
};
/*** serializers for some additional classes (FOR NOW:: also placed here) ***/
class wxNewBitmapButtonSerializer : public wxWindowSerializer
{
DECLARE_SERIALIZER_CLASS( wxNewBitmapButtonSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void Initialize( wxObject* pObj );
static void CreateNewBmpBtnWindowFn( wxNewBitmapButton* btn, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style,
const wxString& name );
};
class wxDynamicToolBarSerializer : public wxWindowSerializer
{
DECLARE_SERIALIZER_CLASS( wxDynamicToolBarSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void Initialize( wxObject* pObj );
static void CreateDynTBarWindowFn( wxDynamicToolBar* btn, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style,
const wxString& name );
};
class wxDynToolInfoSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( wxDynToolInfoSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
class wxTabbedWindowSerializer : public wxWindowSerializer
{
DECLARE_SERIALIZER_CLASS( wxTabbedWindowSerializer );
public:
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void Initialize( wxObject* pObj );
};
class twTabInfoSerializer : wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( twTabInfoSerializer );
public:
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,261 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 07/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __CONTROLAREA_G__
#define __CONTROLAREA_G__
#ifdef __GNUG__
#pragma interface "controlarea.h"
#endif
#include "wx/defs.h"
#include "wx/window.h"
#include "wx/string.h"
#define WXCONTROLAREA_VERSION 1.0
// layout types for title bars of the tabs
// (are selected up by evaluating the available free space )
class twTabInfo; // forward decl.
#define wxTITLE_IMG_AND_TEXT 0
#define wxTITLE_IMG_ONLY 1
#define wxTITLE_BORDER_ONLY 2
/*
* class manages and decorates contained "tab"-windows.
* Draws decorations similar to those in "Project Workplace"
* of Microsoft Developer Studio 4.xx
*/
class wxTabbedWindow : public wxPanel
{
DECLARE_DYNAMIC_CLASS( wxTabbedWindow )
public:
friend class wxTabbedWindowSerializer;
wxList mTabs;
int mActiveTab;
int mTitleHeight;
int mLayoutType;
void HideInactiveTabs( bool andRepaint );
// overrride,to provide different font for tab-labels
virtual wxFont GetLabelingFont();
// FOR NOW:: scrollbars are actually related to wxPaggedWindow
wxScrollBar* mpTabScroll;
wxScrollBar* mpHorizScroll;
wxScrollBar* mpVertScroll;
public:
// public properties (invoke ReclaclLayout(TRUE) to apply changes)
wxPen mWhitePen; // default: RGB(255,255,255)
wxPen mGrayPen; // default: RGB(192,192,192)
wxPen mDarkPen; // default: RGB(128,128,128)
wxPen mBlackPen; // default: RGB( 0, 0, 0)
int mVertGap; // default: 3
int mHorizGap; // default: 5
int mTitleVertGap; // default: 3
int mTitleHorizGap; // default: 4
int mImageTextGap; // default: 2
int mFirstTitleGap; // default: 11
int mBorderOnlyWidth; // default: 8
// notifications (can be handled by derivatives)
virtual void OnTabAdded( twTabInfo* pInfo ) {}
virtual void SizeTabs(int x,int y, int width, int height, bool repant);
public:
wxTabbedWindow();
virtual ~wxTabbedWindow();
// tabs can be also added when the window is
// already displayed - "on the fly"
virtual void AddTab( wxWindow* pContent, // contained window
wxString tabText, // tab label
wxString imageFileName = "", // if "", only text label is displayed
long imageType = wxBITMAP_TYPE_BMP );
// NOTE:: if this AddTab(..) overload is called, the
// image bitmap will not be serialized (if performed),
// use the above method instead, so that images could
// be restored using the given file names
virtual void AddTab( wxWindow* pContent,
wxString tabText,
wxBitmap* pImage = NULL );
virtual void RemoveTab( int tabNo );
/* misc accessors */
virtual int GetTabCount();
virtual wxWindow* GetTab( int tabNo );
virtual wxWindow* GetActiveTab();
virtual void SetActiveTab( int tabNo );
void DrawShadedRect( int x, int y, int width, int height,
wxPen& upperPen, wxPen& lowerPen, wxDC& dc );
virtual void DrawDecorations( wxDC& dc );
// return -1, if non of the title bars was hitted,
// otherwise the index of the hitted tab title bar
virtual int HitTest( const wxPoint& pos );
// should be invoked to redisplay window with changed properties
virtual void RecalcLayout( bool andRepaint = TRUE );
// event handlers
void OnPaint( wxPaintEvent& event );
void OnSize ( wxSizeEvent& event );
void OnBkErase( wxEraseEvent& event );
void OnLButtonDown( wxMouseEvent& event );
DECLARE_EVENT_TABLE()
};
/*
* class manages and decorates contained "sheets" (or pages).
* Draws decorations similar to those in "Output window"
* of Microsoft Developer Studio 4.xx
*/
class wxPaggedWindow : public wxTabbedWindow
{
DECLARE_DYNAMIC_CLASS( wxPaggedWindow )
protected:
bool mScrollEventInProgress;
// drag&drop state variables
bool mIsDragged;
int mDagOrigin;
wxCursor mResizeCursor;
wxCursor mNormalCursor;
bool mCursorChanged;
int mOriginalTitleRowLen;
void DrawPaperBar( twTabInfo& tab, int x, int y,
wxBrush& brush, wxPen& pen, wxDC& dc );
int GetWholeTabRowLen();
// adjusts scorllbars to fit around tabs
virtual void OnTabAdded( twTabInfo* pInfo );
// sets smaller font for page-labels
virtual wxFont GetLabelingFont();
public:
int mTitleRowStart;
int mResizeNailGap;
int mTabTrianGap;
int mTitleRowLen; // actual title row length
int mAdjustableTitleRowLen; // setup by dragging mini-sash
// with the mosue pointer
int mCurentRowOfs;
wxBrush mGrayBrush;
wxBrush mWhiteBrush;
public:
wxPaggedWindow();
~wxPaggedWindow();
// NOTE:: use public methods of the base class
// to add "pages" to this window
/* misc accessors */
// below two methods should be called after
// the tabs were added (AddTab(..)). Set up
// these scrollbars to match the needs of the
// tabs added into this area
wxScrollBar& GetVerticalScrollBar();
wxScrollBar& GetHorizontalScrollBar();
virtual void DrawDecorations( wxDC& dc );
// return -1, if non of the title bars was hitted,
// otherwise the index of the hitted tab title bar
virtual int HitTest( const wxPoint& pos );
virtual void RecalcLayout( bool andRepaint = TRUE );
// event handlers
void OnPaint( wxPaintEvent& event );
void OnSize ( wxSizeEvent& event );
void OnLButtonDown( wxMouseEvent& event );
void OnLButtonUp ( wxMouseEvent& event );
void OnMouseMove ( wxMouseEvent& event );
void OnScroll ( wxScrollEvent& event );
DECLARE_EVENT_TABLE()
};
// helper structure of wxTabbedWindow
class twTabInfo : public wxObject
{
DECLARE_DYNAMIC_CLASS( twTabInfo )
public:
twTabInfo();
~twTabInfo();
int ImgWidth();
int ImgHeight();
int ImageToTxtGap( int prefGap );
bool HasImg();
wxBitmap& GetImg();
bool HasText();
wxString& GetText();
wxWindow& GetContent();
public:
wxWindow* mpContent;
wxBitmap mBitMap;
wxString mText;
wxSize mDims;
// used for serialization
wxString mImageFile;
long mImageType;
};
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 23/01/99
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __DYNBARHND_G__
#define __DYNBARHND_G__
#include "controlbar.h"
#include "
#endif

View File

@@ -0,0 +1,433 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: ??/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "dyntbar.cpp"
#pragma interface "dyntbar.cpp"
#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
#include "wx/utils.h" // import wxMin,wxMax macros
#include "dyntbar.h"
#include "newbmpbtn.h"
IMPLEMENT_DYNAMIC_CLASS(wxDynamicToolBar, wxToolBarBase)
BEGIN_EVENT_TABLE( wxDynamicToolBar, wxToolBarBase )
EVT_SIZE ( wxDynamicToolBar::OnSize )
EVT_PAINT( wxDynamicToolBar::OnPaint )
//EVT_ERASE_BACKGROUND( wxDynamicToolBar::OnEraseBackground )
END_EVENT_TABLE()
/***** Implementation for class wxDynToolInfo *****/
IMPLEMENT_DYNAMIC_CLASS(wxDynToolInfo, wxToolLayoutItem)
/***** Implementation for class wxDynamicToolBar *****/
wxDynamicToolBar::wxDynamicToolBar()
: mpLayoutMan( NULL ),
mSepartorSize( 8 ),
mVertGap ( 0 ),
mHorizGap( 0 )
{
}
wxDynamicToolBar::wxDynamicToolBar(wxWindow *parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size,
const long style, const int orientation,
const int RowsOrColumns, const wxString& name )
: mpLayoutMan( NULL ),
mSepartorSize( 8 ),
mVertGap ( 0 ),
mHorizGap( 0 )
{
Create(parent, id, pos, size, style, orientation, RowsOrColumns, name);
SetBackgroundColour( wxColour(192,192,192) );
}
bool wxDynamicToolBar::Create(wxWindow *parent, const wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const long style,
const int orientation, const int RowsOrColumns,
const wxString& name)
{
// cut&pasted from wxtbatsmpl.h
if ( ! wxWindow::Create(parent, id, pos, size, style, name) )
return FALSE;
SetBackgroundColour( wxColour( 192,192,192 ) );
return TRUE;
}
bool wxDynamicToolBar::Realize(void)
{
// FOR NOW:: nothing
return TRUE;
}
wxDynamicToolBar::~wxDynamicToolBar(void)
{
if ( mpLayoutMan ) delete mpLayoutMan;
for( size_t i = 0; i != mTools.Count(); ++i )
delete mTools[i];
}
void wxDynamicToolBar::AddTool( int toolIndex,
wxWindow* pToolWindow,
const wxSize& size
)
{
wxDynToolInfo* pInfo = new wxDynToolInfo();
pInfo->mpToolWnd = pToolWindow;
pInfo->mIndex = toolIndex;
pInfo->mIsSeparator = FALSE;
int x,y;
pToolWindow->GetSize( &x, &y );
pInfo->mRealSize.x = x;
pInfo->mRealSize.y = y;
pInfo->mRect.width = x;
pInfo->mRect.height = y;
mTools.Add( pInfo );
}
void wxDynamicToolBar::AddTool( int toolIndex,
const wxString& imageFileName,
int imageFileType,
const wxString& labelText, bool alignTextRight,
bool isFlat )
{
wxNewBitmapButton* pBtn =
new wxNewBitmapButton( imageFileName, imageFileType,
labelText,
( alignTextRight )
? NB_ALIGN_TEXT_RIGHT
: NB_ALIGN_TEXT_BOTTOM,
isFlat
);
pBtn->Create( this, toolIndex );
pBtn->Reshape();
AddTool( toolIndex, pBtn );
}
wxToolBarTool*
wxDynamicToolBar::AddTool(const int toolIndex, const wxBitmap& bitmap,
const wxBitmap& pushedBitmap,
const bool toggle, const long xPos,
const long yPos, wxObject *clientData,
const wxString& helpString1, const wxString& helpString2)
{
wxNewBitmapButton* pBmpBtn = new wxNewBitmapButton( bitmap );
pBmpBtn->Create( this, toolIndex );
pBmpBtn->Reshape();
AddTool( toolIndex, pBmpBtn );
return NULL;
}
wxDynToolInfo* wxDynamicToolBar::GetToolInfo( int toolIndex )
{
for( size_t i = 0; i != mTools.Count(); ++i )
if ( mTools[i]->mIndex == toolIndex ) return mTools[i];
return NULL;
}
void wxDynamicToolBar::RemveTool( int toolIndex )
{
for( size_t i = 0; i != mTools.Count(); ++i )
if ( mTools[i]->mIndex == toolIndex )
{
if ( mTools[i]->mpToolWnd )
mTools[i]->mpToolWnd->Destroy();
mTools.Remove( i );
Layout();
return;
}
// TODO:: if not found, should it be an assertion?
}
void wxDynamicToolBar::AddSeparator( wxWindow* pSepartorWnd )
{
wxDynToolInfo* pInfo = new wxDynToolInfo();
pInfo->mpToolWnd = pSepartorWnd;
pInfo->mIndex = -1;
pInfo->mIsSeparator = TRUE;
if ( pSepartorWnd )
{
pSepartorWnd->Create( this, -1 );
int x,y;
pSepartorWnd->GetSize( &x, &y );
pInfo->mRealSize.x = x;
pInfo->mRealSize.y = y;
pInfo->mRect.width = x;
pInfo->mRect.height = y;
}
else
{
pInfo->mRealSize.x = mSepartorSize;
pInfo->mRealSize.y = 0;
pInfo->mRect.width = mSepartorSize;
pInfo->mRect.height = 0;
}
mTools.Add( pInfo );
}
void wxDynamicToolBar::OnEraseBackground( wxEraseEvent& event )
{
// FOR NOW:: nothing
}
void wxDynamicToolBar::OnSize( wxSizeEvent& event )
{
//SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_3DFACE ) );
Layout();
}
void wxDynamicToolBar::DrawSeparator( wxDynToolInfo& info, wxDC& dc )
{
// check the orientation of separator
if ( info.mRect.width < info.mRect.height )
{
int midX = info.mRect.x + info.mRect.width/2 - 1;
dc.SetPen( *wxGREY_PEN );
dc.DrawLine( midX, info.mRect.y,
midX, info.mRect.y + info.mRect.height+1 );
dc.SetPen( *wxWHITE_PEN );
dc.DrawLine( midX+1, info.mRect.y,
midX+1, info.mRect.y + info.mRect.height+1 );
}
else
{
int midY = info.mRect.y + info.mRect.height/2 - 1;
dc.SetPen( *wxGREY_PEN );
dc.DrawLine( info.mRect.x, midY,
info.mRect.x + info.mRect.width+1, midY );
dc.SetPen( *wxWHITE_PEN );
dc.DrawLine( info.mRect.x, midY + 1,
info.mRect.x + info.mRect.width+1, midY + 1 );
}
}
void wxDynamicToolBar::OnPaint( wxPaintEvent& event )
{
// draw separators if any
wxPaintDC dc(this);
for( size_t i = 0; i != mTools.Count(); ++i )
if ( mTools[i]->mIsSeparator )
{
// check if separator doesn't have it's own window
// if so, then draw it using built-in drawing method
if ( !mTools[i]->mpToolWnd )
DrawSeparator( *mTools[i], dc );
}
}
// FOR NOW:: quick fix
#include "wx/choice.h"
void wxDynamicToolBar::SizeToolWindows()
{
for( size_t i = 0; i != mTools.Count(); ++i )
{
wxDynToolInfo& info = *mTools[i];
if ( !info.mIsSeparator )
{
// center real rectangle within the rectangle
// provided by the layout manager
int x = info.mRect.x;
int y = info.mRect.y + (info.mRect.height - info.mRealSize.y)/2;
// FOR NOW FOR NOW:: quick & dirty fix
if ( info.mpToolWnd->IsKindOf( CLASSINFO( wxChoice ) ) )
{
info.mpToolWnd->SetSize( x,y,
info.mRealSize.x - 3,
info.mRealSize.y);
}
else
info.mpToolWnd->SetSize( x,y,
info.mRealSize.x,
info.mRealSize.y );
}
// TBD:: size separator window if present
}
}
void wxDynamicToolBar::Layout()
{
if ( !mpLayoutMan ) mpLayoutMan = CreateDefaulLayout();
int x,y;
GetSize( &x, &y );
wxSize wndDim(x,y);
wxSize result;
wxLayoutItemArrayT items;
// safe conversion
for( size_t i = 0; i != mTools.Count(); ++i ) items.Add( mTools[i] );
mpLayoutMan->Layout( wndDim, result, items, mVertGap, mHorizGap );;
SizeToolWindows();
}
void wxDynamicToolBar::GetPreferredDim( const wxSize& givenDim, wxSize& prefDim )
{
if ( !mpLayoutMan ) mpLayoutMan = CreateDefaulLayout();
wxLayoutItemArrayT items;
// safe conversion
for( size_t i = 0; i != mTools.Count(); ++i ) items.Add( mTools[i] );
mpLayoutMan->Layout( givenDim, prefDim, items, mVertGap, mHorizGap );;
}
void wxDynamicToolBar::SetLayout( LayoutManagerBase* pLayout )
{
if ( mpLayoutMan ) delete mpLayoutMan;
mpLayoutMan = pLayout;
Layout();
}
void wxDynamicToolBar::EnableTool(const int toolIndex, const bool enable )
{
wxDynToolInfo* pInfo = GetToolInfo( toolIndex );
if ( !pInfo ) return;
if ( pInfo->mIsSeparator || !pInfo->mpToolWnd ) return;
pInfo->mpToolWnd->Enable( enable );
}
/***** Implementation for class BagLayout *****/
void BagLayout::Layout( const wxSize& parentDim,
wxSize& resultingDim,
wxLayoutItemArrayT& items,
int horizGap,
int vertGap
)
{
int maxWidth = 0;
int curY = 0;
int nRows = 0;
size_t i = 0;
while( i < items.Count() )
{
int curX = 0;
int height = 0;
int nItems = 0;
int firstItem = i;
int itemsInRow = 0;
if ( nRows > 0 ) curY += vertGap;
// step #1 - arrange horizontal positions of items in the row
do
{
if ( itemsInRow > 0 ) curX += horizGap;
wxRect& r = items[i]->mRect;
if ( curX + r.width > parentDim.x )
if ( itemsInRow > 0 ) break;
r.x = curX;
r.y = curY;
curX += r.width;
height = wxMax( height, r.height );
++itemsInRow;
++i;
} while( i < items.Count() );
curY += height;
maxWidth = wxMax( maxWidth, curX );
}
resultingDim.x = maxWidth;
resultingDim.y = curY;
}

View File

@@ -0,0 +1,164 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: ??/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __DYNTBAR_G__
#define __DYNTBAR_G__
#include "wx/tbarbase.h"
#include "wx/dynarray.h"
// layout item
class wxToolLayoutItem : public wxObject
{
public:
wxRect mRect;
bool mIsSeparator;
};
class wxDynToolInfo;
typedef wxToolLayoutItem* wxToolLayoutItemPtrT;
typedef wxDynToolInfo* wxDynToolInfoPtrT;
WX_DEFINE_ARRAY( wxToolLayoutItemPtrT, wxLayoutItemArrayT );
WX_DEFINE_ARRAY( wxDynToolInfoPtrT, wxDynToolInfoArrayT );
// base class for layouting algorithm implementations
class LayoutManagerBase
{
public:
virtual void Layout( const wxSize& parentDim,
wxSize& resultingDim,
wxLayoutItemArrayT& items,
int horizGap,
int vertGap ) = 0;
virtual ~LayoutManagerBase() {}
};
// layouts items in left-to-right order from
// top towards bottom
class BagLayout : public LayoutManagerBase
{
public:
virtual void Layout( const wxSize& parentDim,
wxSize& resultingDim,
wxLayoutItemArrayT& items,
int horizGap,
int vertGap );
};
class wxDynToolInfo : public wxToolLayoutItem
{
DECLARE_DYNAMIC_CLASS(wxDynToolInfo)
public:
wxWindow* mpToolWnd;
int mIndex;
wxSize mRealSize;
};
// layouting orientations for tools
#define LO_HORIZONTAL 0
#define LO_VERTICAL 1
#define LO_FIT_TO_WINDOW 2
// class manages containment and layouting of tool-windows
class wxDynamicToolBar : public wxToolBarBase
{
DECLARE_DYNAMIC_CLASS(wxDynamicToolBar)
protected:
friend class wxDynamicToolBarSerializer;
wxDynToolInfoArrayT mTools;
LayoutManagerBase* mpLayoutMan;
protected:
virtual void SizeToolWindows();
public: /* public properties */
int mSepartorSize; // default: 8
int mVertGap; // default: 0
int mHorizGap; // default: 0
public:
wxDynamicToolBar();
wxDynamicToolBar(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
const long style = wxNO_BORDER, const int orientation = wxVERTICAL,
const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);
~wxDynamicToolBar(void);
bool Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
const long style = wxNO_BORDER, const int orientation = wxVERTICAL, const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);
// overridables
virtual void AddTool( int toolIndex,
wxWindow* pToolWindow,
const wxSize& size = wxDefaultSize );
virtual void AddTool( int toolIndex,
const wxString& imageFileName,
int imageFileType = wxBITMAP_TYPE_BMP,
const wxString& labelText = "", bool alignTextRight = FALSE,
bool isFlat = TRUE );
// method from wxToolBarBase (for compatibility), only
// first two arguments are valid
virtual wxToolBarTool *AddTool(const int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
const bool toggle = FALSE, const long xPos = -1, const long yPos = -1, wxObject *clientData = NULL,
const wxString& helpString1 = "", const wxString& helpString2 = "");
virtual void AddSeparator( wxWindow* pSepartorWnd = NULL );
wxDynToolInfo* GetToolInfo( int toolIndex );
void RemveTool( int toolIndex );
// the default implementation draws shaded line
virtual void DrawSeparator( wxDynToolInfo& info, wxDC& dc );
// see definitions of orientation types
virtual void Layout();
virtual void GetPreferredDim( const wxSize& givenDim, wxSize& prefDim );
virtual LayoutManagerBase* CreateDefaulLayout() { return new BagLayout(); }
virtual void SetLayout( LayoutManagerBase* pLayout );
virtual void EnableTool(const int toolIndex, const bool enable = TRUE);
// event handlers
void OnSize( wxSizeEvent& event );
void OnPaint( wxPaintEvent& event );
void OnEraseBackground( wxEraseEvent& event );
// overriden from wxToolBarBase
virtual bool Realize(void);
DECLARE_EVENT_TABLE()
};
#endif

View File

@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 23/01/99
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "dyntbar.cpp"
#pragma interface "dyntbar.cpp"
#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
#include "dyntbarhnd.h"
/***** Implementation for class cbDynToolBarDimHandler *****/
IMPLEMENT_DYNAMIC_CLASS( cbDynToolBarDimHandler, cbBarDimHandlerBase )
void cbDynToolBarDimHandler::OnChangeBarState(cbBarInfo* pBar, int newState )
{
// nothing
}
void cbDynToolBarDimHandler::OnResizeBar( cbBarInfo* pBar,
const wxSize& given,
wxSize& preferred )
{
wxASSERT( pBar->mpBarWnd ); // DBG:: should be present
wxDynamicToolBar* pTBar = (wxDynamicToolBar*)pBar->mpBarWnd;
pTBar->GetPreferredDim( given, preferred );
}

View File

@@ -0,0 +1,26 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 23/01/99
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __DYNTBARHND_G__
#define __DYNTBARHND_G__
#include "controlbar.h"
#include "dyntbar.h"
class cbDynToolBarDimHandler : public cbBarDimHandlerBase
{
DECLARE_DYNAMIC_CLASS( cbDynToolBarDimHandler )
public:
void OnChangeBarState(cbBarInfo* pBar, int newState );
void OnResizeBar( cbBarInfo* pBar, const wxSize& given, wxSize& preferred );
};
#endif

View File

@@ -0,0 +1,449 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 02/01/99
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "frmview.h"
// #pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "frmview.h"
#include "wx/utils.h"
/***** Implementation for class wxFrameView *****/
BEGIN_EVENT_TABLE( wxFrameView, wxEvtHandler )
EVT_IDLE( wxFrameView::OnIdle )
END_EVENT_TABLE()
void wxFrameView::OnIdle( wxIdleEvent& event)
{
event.Skip();
if ( mDoToolUpdates )
{
int o;
++o;
// TBD::
}
}
/*** public methods ***/
wxFrameView::wxFrameView()
: mpLayout( NULL ),
mpFrameMgr( NULL )
{}
wxFrameView::~wxFrameView()
{
if ( mpLayout ) delete mpLayout;
}
wxFrame* wxFrameView::GetParentFrame()
{
return mpFrameMgr->GetParentFrame();
}
wxWindow* wxFrameView::GetClientWindow()
{
return mpFrameMgr->GetClientWindow();
}
void wxFrameView::Activate()
{
mpFrameMgr->ActivateView( this );
}
void wxFrameView::Deactivate()
{
mpFrameMgr->DeactivateCurrentView();
}
void wxFrameView::CreateLayout()
{
mpLayout = new wxFrameLayout( GetParentFrame(), mpFrameMgr->GetClientWindow(), FALSE );
}
wxFrameLayout* wxFrameView::GetLayout()
{
return mpLayout;
}
void wxFrameView::SetToolUpdates( bool doToolUpdates )
{
mDoToolUpdates = doToolUpdates;
}
void wxFrameView::SetLayout( wxFrameLayout* pLayout )
{
if ( mpLayout ) delete mpLayout;
mpLayout = pLayout;
}
wxFrameManager& wxFrameView::GetFrameManager()
{
return *mpFrameMgr;
}
void wxFrameView::RegisterMenu( const wxString& topMenuName )
{
mTopMenus.Add( topMenuName );
}
#if 0
/***** Implementation for class wxFrameViewSerializer *****/
// NOTE:: currently "stipple" property of the brush is not serialized
class wxFrameViewSerializer : public wxEvtHandlerSerializer
{
DECLARE_SERIALIZER_CLASS( wxFrameViewSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
IMPLEMENT_SERIALIZER_CLASS( wxFrameView,
wxFrameViewSerializer,
wxFrameViewSerializer::Serialize,
NO_CLASS_INIT )
void wxFrameViewSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
{
// wxFrameViewSerializer is a kind of wxEvtHandler - peform serialization of
// the base class first
info.SerializeInherited( pObj, store );
wxFrameView* pView = (wxFrameView*)pObj;
store.XchgObjPtr( (wxObject**) &pView->mpFrameMgr );
store.XchgObjPtr( (wxObject**) &pView->mpLayout );
store.XchgBool ( pView->mDoToolUpdates );
// serialize members in derived classes
pView->OnSerialize( store );
}
#endif
/***** Implementation for class wxFrameManager *****/
void wxFrameManager::DoSerialize( wxObjectStorage& store )
{
#if 0
store.AddInitialRef( mpFrameWnd );
store.AddInitialRef( this );
if ( mpClientWnd ) store.AddInitialRef( mpClientWnd );
store.XchgObj( (wxObject*) &mViews );
store.XchgInt( mActiveViewNo );
store.Finalize(); // finish serialization
#endif
}
void wxFrameManager::DestroyViews()
{
DeactivateCurrentView();
wxNode* pNode = mViews.First();
while( pNode )
{
delete (wxFrameView*)pNode->Data();
pNode = pNode->Next();
}
if ( mActiveViewNo != -1 && GetParentFrame() )
GetParentFrame()->SetNextHandler( NULL );
}
int wxFrameManager::GetViewNo( wxFrameView* pView )
{
wxNode* pNode = mViews.First();
int n = 0;
while( pNode )
{
if ( (wxFrameView*)pNode->Data() == pView )
return n;
++n;
pNode = pNode->Next();
}
return -1;
}
void wxFrameManager::EnableMenusForView( wxFrameView* pView, bool enable )
{
wxMenuBar* pMenuBar = GetParentFrame()->GetMenuBar();
int count = pMenuBar->GetMenuCount();
if ( !pMenuBar ) return;
wxStringListNode* pNode = pView->mTopMenus.GetFirst();
while( pNode )
{
for( int i = 0; i != count; ++i )
{
if ( pMenuBar->GetMenu(i)->GetTitle() == pNode->GetData() )
pMenuBar->EnableTop( i, enable );
}
pNode = pNode->GetNext();
}
}
void wxFrameManager::SyncAllMenus()
{
wxNode* pNode = mViews.First();
int i = 0;
while( pNode )
{
if ( i != mActiveViewNo )
EnableMenusForView( (wxFrameView*)pNode->GetData(), FALSE );
pNode = pNode->Next();
}
EnableMenusForView( GetView( mActiveViewNo ), TRUE );
}
/*** public methods ***/
wxFrameManager::wxFrameManager()
: mpFrameWnd( NULL ),
mActiveViewNo( -1 ),
mpClientWnd( NULL )
{
}
wxFrameManager::~wxFrameManager()
{
SaveViewsNow();
DestroyViews();
}
void wxFrameManager::Init( wxWindow* pMainFrame, const wxString& settingsFile )
{
mSettingsFile = settingsFile;
mpFrameWnd = pMainFrame;
wxNode* pNode = mViews.First();
while( pNode )
{
wxFrameView* pView = (wxFrameView*)pNode->Data();
pView->OnInit();
pView->OnInitMenus();
pNode = pNode->Next();
}
if ( !ReloadViews() )
{
// if loading of settings file failed (e.g. was not found),
// do recreation of items in each view
pNode = mViews.First();
while( pNode )
{
wxFrameView* pView = (wxFrameView*)pNode->Data();
pView->OnRecreate();
pNode = pNode->Next();
}
}
if ( mActiveViewNo >= mViews.Number() )
mActiveViewNo = -1;
ActivateView( GetView( ( mActiveViewNo == -1 ) ? 0 : mActiveViewNo ) );
SyncAllMenus();
}
void wxFrameManager::AddView( wxFrameView* pFrmView )
{
mViews.Append( pFrmView );
pFrmView->mpFrameMgr = this; // back ref.
}
void wxFrameManager::RemoveView( wxFrameView* pFrmView )
{
// TBD::
wxASSERT(0);
}
int wxFrameManager::GetActiveViewNo()
{
return mActiveViewNo;
}
wxFrameView* wxFrameManager::GetActiveView()
{
wxNode* pNode = mViews.Nth( mActiveViewNo );
if ( pNode ) return (wxFrameView*)pNode->Data();
else return NULL;
}
wxNode* wxFrameManager::GetActiveViewNode()
{
return mViews.Nth( mActiveViewNo );
}
wxFrame* wxFrameManager::GetParentFrame()
{
return ((wxFrame*)mpFrameWnd);
}
wxWindow* wxFrameManager::GetParentWindow()
{
return mpFrameWnd;
}
wxFrameView* wxFrameManager::GetView( int viewNo )
{
wxNode* pNode = mViews.Nth( viewNo );
if ( pNode ) return (wxFrameView*)pNode->Data();
else return NULL;
}
void wxFrameManager::ActivateView( int viewNo )
{
ActivateView( GetView( viewNo ) );
}
void wxFrameManager::ActivateView( wxFrameView* pFrmView )
{
DeactivateCurrentView();
mActiveViewNo = GetViewNo( pFrmView );
if ( pFrmView->mpLayout )
pFrmView->mpLayout->Activate();
// FIXME:: we would have used PushEventHandler(),
// but wxFrame bypasses attached handlers when
// handling wxCommand events!
GetParentFrame()->PushEventHandler( pFrmView );
EnableMenusForView( pFrmView, TRUE );
}
void wxFrameManager::SetClinetWindow( wxWindow* pFrameClient )
{
if ( mpClientWnd ) mpClientWnd->Destroy();
mpClientWnd = pFrameClient;
}
wxWindow* wxFrameManager::GetClientWindow()
{
if ( !mpClientWnd )
mpClientWnd = new wxWindow( GetParentFrame(), -1 );
return mpClientWnd;
}
void wxFrameManager::DeactivateCurrentView()
{
if ( mActiveViewNo == -1 ) return;
wxFrameView* pView = GetActiveView();
// FOR NOW::
wxASSERT( GetParentFrame()->GetEventHandler() == pView );
GetParentFrame()->PopEventHandler();
if ( pView->mpLayout )
pView->mpLayout->Deactivate();
EnableMenusForView( pView, FALSE );
}
void wxFrameManager::SaveViewsNow()
{
#if 0
if ( mSettingsFile == "" ) return;
wxIOStreamWrapper stm;
stm.CreateForOutput( mSettingsFile );
mStore.SetDataStream( stm );
DoSerialize( mStore );
#endif
}
bool wxFrameManager::ReloadViews()
{
return FALSE;
#if 0
if ( mSettingsFile == "" || !wxFileExists( mSettingsFile ) )
return FALSE;
DestroyViews();
wxIOStreamWrapper stm;
stm.CreateForInput( mSettingsFile );
mStore.SetDataStream( stm );
DoSerialize( mStore );
#endif
return TRUE;
}
bool wxFrameManager::ViewsAreLoaded()
{
return ( mViews.Number() != 0 );
}

View File

@@ -0,0 +1,135 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 02/01/99
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __FRMVIEW_G__
#define __FRMVIEW_G__
#include "wx/module.h"
#if 0
#include "objstore.h"
#endif
class wxObjectStorage;
#include "controlbar.h"
class wxFrameManager;
class wxFrameView : public wxEvtHandler
{
protected:
wxStringList mTopMenus;
wxFrameLayout* mpLayout;
wxFrameManager* mpFrameMgr;
bool mDoToolUpdates;
friend class wxFrameManager;
friend class wxFrameViewSerializer;
protected:
void OnIdle( wxIdleEvent& event);
public:
wxFrameView();
~wxFrameView();
virtual void Activate();
virtual void Deactivate();
wxFrame* GetParentFrame();
wxWindow* GetClientWindow();
wxFrameManager& GetFrameManager();
void RegisterMenu( const wxString& topMenuName );
void CreateLayout();
wxFrameLayout* GetLayout();
void SetLayout( wxFrameLayout* pLayout );
void SetToolUpdates( bool doToolUpdates = TRUE );
// hooks for specific frame-views
virtual void OnInit() {}
virtual void OnSerialize( wxObjectStorage& store ) {}
virtual void OnActiveate() {}
virtual void OnDeactivate() {}
// imp. is mandatory
virtual void OnRecreate() {}
virtual void OnInitMenus() {}
DECLARE_EVENT_TABLE()
};
class wxFrame;
class wxFrameManager : wxObject
{
protected:
wxList mViews;
wxWindow* mpFrameWnd;
int mActiveViewNo;
wxWindow* mpClientWnd;
#if 0
wxObjectStorage mStore;
#endif
wxString mSettingsFile;
protected:
void DoSerialize( wxObjectStorage& store );
void DestroyViews();
int GetViewNo( wxFrameView* pView );
void EnableMenusForView( wxFrameView* pView, bool enable );
void SyncAllMenus();
public:
wxFrameManager();
~wxFrameManager();
// if file name is empty, views are are not saved/loaded
virtual void Init( wxWindow* pMainFrame, const wxString& settingsFile = "" );
// synonyms
wxFrame* GetParentFrame();
wxWindow* GetParentWindow();
int GetActiveViewNo();
wxFrameView* GetActiveView();
wxNode* GetActiveViewNode();
wxFrameView* GetView( int viewNo );
void SetClinetWindow( wxWindow* pFrameClient );
wxWindow* GetClientWindow();
void AddView( wxFrameView* pFrmView );
void RemoveView( wxFrameView* pFrmView );
void ActivateView( int viewNo );
void ActivateView( wxFrameView* pFrmView );
void DeactivateCurrentView();
wxObjectStorage& GetObjectStore();
void SaveViewsNow();
bool ReloadViews();
bool ViewsAreLoaded();
};
#endif

View File

@@ -0,0 +1,224 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 18/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "garbagec.cpp"
#pragma interface "garbagec.cpp"
#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
#include "garbagec.h"
/***** Implementation for class GarbageCollector *****/
inline static GCItem& node_to_item( wxNode* pNode )
{
return *( (GCItem*)(pNode->Data()) );
}
GarbageCollector::~GarbageCollector()
{
Reset();
}
/*** GC alg. helpers ***/
void GarbageCollector::DestroyItemList( wxList& lst )
{
wxNode* pNode = lst.First();
while( pNode )
{
delete &node_to_item( pNode );
pNode = pNode->Next();
}
lst.Clear();
}
wxNode* GarbageCollector::FindItemNode( void* pForObj )
{
wxNode* pNode = mAllNodes.First();
while( pNode )
{
if ( node_to_item( pNode ).mpObj == pForObj )
return pNode;
pNode = pNode->Next();
}
wxASSERT(0); // DBG:: item should be presnet
return 0;
}
wxNode* GarbageCollector::FindRefernceFreeItemNode()
{
wxNode* pNode = mAllNodes.First();
while( pNode )
{
if ( node_to_item( pNode ).mRefs.Number() == 0 )
return pNode;
pNode = pNode->Next();
}
return 0;
}
void GarbageCollector::RemoveReferencesToNode( wxNode* pItemNode )
{
wxNode* pNode = mAllNodes.First();
while( pNode )
{
wxList& refLst = node_to_item( pNode ).mRefs;
wxNode* pRefNode = refLst.First();
while( pRefNode )
{
if ( pRefNode->Data() == (wxObject*)pItemNode )
{
wxNode* pNext = pRefNode->Next();
refLst.DeleteNode( pRefNode );
pRefNode = pNext;
continue;
}
else pRefNode = pRefNode->Next();
}
pNode = pNode->Next();
}
}
void GarbageCollector::ResolveReferences()
{
wxNode* pNode = mAllNodes.First();
while( pNode )
{
GCItem& item = node_to_item( pNode );
wxNode* pRefNode = item.mRefs.First();
while( pRefNode )
{
pRefNode->SetData( (wxObject*) FindItemNode( (void*)pRefNode->Data() ) );
pRefNode = pRefNode->Next();
}
pNode = pNode->Next();
}
}
void GarbageCollector::AddObject( void* pObj, int refCnt )
{
// FOR NOW:: inital ref-count is not used
GCItem* pItem = new GCItem();
pItem->mpObj = pObj;
mAllNodes.Append( (wxObject*) pItem );
}
void GarbageCollector::AddDependency( void* pObj, void* pDepnedsOnObj )
{
node_to_item( FindItemNode( pObj ) ).mRefs.Append( (wxObject*)pDepnedsOnObj );
}
/*** GC alg. implementation ***/
void GarbageCollector::ArrangeCollection()
{
ResolveReferences();
do
{
// find node, which does not depend on anything
wxNode* pItemNode = FindRefernceFreeItemNode();
if ( pItemNode )
{
// append it to the list, where items are contained
// in the increasing order of dependencies
mRegularLst.Append( pItemNode->Data() );
mAllNodes.DeleteNode( pItemNode );
// remove references to this current "least-dependent" node
// from reference lists of all the other nodes
RemoveReferencesToNode( pItemNode );
}
else
{
// otherwise, what is left - all nodes, which
// are involved into cycled chains (rings)
wxNode* pNode = mAllNodes.First();
while( pNode )
{
mCycledLst.Append( pNode->Data() );
pNode = pNode->Next();
}
break;
}
// continue search for "least-dependent" nodes
} while(1);
}
wxList& GarbageCollector::GetRegularObjects()
{
return mRegularLst;
}
wxList& GarbageCollector::GetCycledObjects()
{
return mCycledLst;
}
void GarbageCollector::Reset()
{
DestroyItemList( mAllNodes );
mRegularLst.Clear();
mCycledLst.Clear();
}

View File

@@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas (@Lithuania)
// Modified by:
// Created: ??/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __GARBAGEC_G__
#define __GARBAGEC_G__
#include "wx/list.h"
struct GCItem
{
void* mpObj;
wxList mRefs; // references to other nodes
};
inline void* gc_node_to_obj( wxNode* pGCNode )
{
return ( (GCItem*) (pGCNode->Data()) )->mpObj;
}
// class implements extreamly slow, but probably one of the most simple GC alogrithms
class GarbageCollector
{
protected:
wxList mAllNodes;
wxList mRegularLst;
wxList mCycledLst;
wxNode* FindItemNode( void* pForObj );
void ResolveReferences();
wxNode* FindRefernceFreeItemNode();
void RemoveReferencesToNode( wxNode* pItemNode );
void DestroyItemList( wxList& lst );
public:
GarbageCollector() {}
virtual ~GarbageCollector();
// prepare data for GC alg.
virtual void AddObject( void* pObj, int refCnt = 1 );
virtual void AddDependency( void* pObj, void* pDepnedsOnObj );
// executes GC alg.
virtual void ArrangeCollection();
// acces results of the alg.
wxList& GetRegularObjects();
wxList& GetCycledObjects();
// removes all date form GC
void Reset();
};
#endif

View File

@@ -0,0 +1,409 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 19/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "updatesmgr.h"
// #pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "gcupdatesmgr.h"
// helper function
static inline bool rect_hits_rect( const wxRect& r1, const wxRect& r2 )
{
if ( ( r2.x >= r1.x && r2.x <= r1.x + r1.width ) ||
( r1.x >= r2.x && r1.x <= r2.x + r2.width ) )
if ( ( r2.y >= r1.y && r2.y <= r1.y + r1.height ) ||
( r1.y >= r2.y && r1.y <= r2.y + r2.height ) )
return 1;
return 0;
}
// helper structure
struct cbRectInfo
{
cbBarInfo* mpBar;
cbDockPane* mpPane;
wxRect* mpCurBounds;
wxRect* mpPrevBounds;
};
static inline cbRectInfo& node_to_rect_info( wxNode* pNode )
{
return *( (cbRectInfo*) (pNode->Data()) );
}
/***** Implementation for class cbSimpleUpdatesMgr *****/
IMPLEMENT_DYNAMIC_CLASS( cbGCUpdatesMgr, cbSimpleUpdatesMgr )
cbGCUpdatesMgr::cbGCUpdatesMgr( wxFrameLayout* pPanel )
: cbSimpleUpdatesMgr( pPanel )
{}
void cbGCUpdatesMgr::AddItem( wxList& itemList,
cbBarInfo* pBar,
cbDockPane* pPane,
wxRect& curBounds,
wxRect& prevBounds )
{
cbRectInfo* pInfo = new cbRectInfo();
pInfo->mpBar = pBar;
pInfo->mpPane = pPane;
pInfo->mpCurBounds = &curBounds;
pInfo->mpPrevBounds = &prevBounds;
itemList.Append( (wxObject*) pInfo );
}
void cbGCUpdatesMgr::OnStartChanges()
{
// memorize states of ALL items in the layout -
// this is quite excessive, but OK for the decent
// implementation of updates manager
mpLayout->GetPrevClientRect() = mpLayout->GetClientRect();
cbDockPane** panes = mpLayout->GetPanesArray();
for( int n = 0; n != MAX_PANES; ++n )
{
cbDockPane& pane = *(panes[n]);
// store pane state
pane.mUMgrData.StoreItemState( pane.mBoundsInParent );
pane.mUMgrData.SetDirty( FALSE );
cbRowInfo* pRow = pane.GetFirstRow();
while ( pRow )
{
cbBarInfo* pBar = pRow->GetFirstBar();
// store row state
pRow->mUMgrData.StoreItemState( pRow->mBoundsInParent );
pRow->mUMgrData.SetDirty( FALSE );
while( pBar )
{
// store bar state
pBar->mUMgrData.StoreItemState( pBar->mBoundsInParent );
pBar->mUMgrData.SetDirty( FALSE );
pBar = pBar->mpNext;
}
pRow = pRow->mpNext;
}
}
}
void cbGCUpdatesMgr::UpdateNow()
{
cbDockPane** panes = mpLayout->GetPanesArray();
wxRect& r1 = mpLayout->GetClientRect();
wxRect& r2 = mpLayout->GetPrevClientRect();
// detect changes in client window's area
bool clientWindowChanged = ( r1.x != r2.x ||
r1.y != r2.y ||
r1.width != r2.width ||
r1.height != r2.height );
// step #1 - detect changes in each row of each pane,
// and repaint decorations around changed windows
wxList mBarsToResize;
for( int n = 0; n != MAX_PANES; ++n )
{
cbDockPane& pane = *(panes[n]);
bool paneChanged = WasChanged( pane.mUMgrData, pane.mBoundsInParent );
if ( paneChanged )
{
wxClientDC dc( &mpLayout->GetParentFrame() );
pane.PaintPaneBackground( dc );
}
wxRect realBounds;
cbRowInfo* pRow = pane.GetFirstRow();
while ( pRow )
{
wxDC* pDc = 0;
cbBarInfo* pBar = pRow->GetFirstBar();
bool rowChanged = FALSE;
bool rowBkPainted = FALSE;
// FIXME:: the below should not be fixed
cbBarInfo* barsToRepaint[128];
// number of bars, that were changed in the current row
int nBars = 0;
wxRect r1 = pRow->mUMgrData.mPrevBounds;
wxRect r2 = pRow->mBoundsInParent;
if ( WasChanged( pRow->mUMgrData, pRow->mBoundsInParent ) )
rowChanged = TRUE;
else
while( pBar )
{
if ( WasChanged( pBar->mUMgrData, pBar->mBoundsInParent ) )
barsToRepaint[nBars++] = pBar;
pBar = pBar->mpNext;
}
if ( nBars || rowChanged )
{
realBounds = pRow->mBoundsInParent;
// include 1-pixel thick shades around the row
realBounds.x -= 1;
realBounds.y -= 1;
realBounds.width += 2;
realBounds.height += 2;
pDc = pane.StartDrawInArea( realBounds );
}
if ( rowChanged )
{
// postphone the resizement and refreshing the changed
// bar windows
cbBarInfo* pCurBar = pRow->GetFirstBar();
while( pCurBar )
{
if ( WasChanged( pCurBar->mUMgrData,
pCurBar->mBoundsInParent ) )
AddItem( mBarsToResize, pCurBar, &pane,
pCurBar->mBoundsInParent,
pCurBar->mUMgrData.mPrevBounds );
pCurBar = pCurBar->mpNext;
}
// draw only their decorations now
pane.PaintRow( pRow, *pDc );
}
else
if ( nBars != 0 )
{
for( int i = 0; i != nBars; ++i )
// postphone the resizement and refreshing the changed
// bar windows
AddItem( mBarsToResize,
barsToRepaint[i],
&pane,
barsToRepaint[i]->mBoundsInParent,
barsToRepaint[i]->mUMgrData.mPrevBounds );
// redraw decorations of entire row, regardless of how much
// of the bars were changed
pane.PaintRow( pRow, *pDc );
}
if ( pDc )
pane.FinishDrawInArea( realBounds );
pRow = pRow->mpNext;
} // end of while
if ( paneChanged )
{
wxClientDC dc( &mpLayout->GetParentFrame() );
pane.PaintPaneDecorations( dc );
}
} // end of for
if ( clientWindowChanged && !mpLayout->mClientWndRefreshPending )
{
// ptr to client-window object is "marked" as NULL
AddItem( mBarsToResize, NULL, NULL,
mpLayout->GetClientRect(),
mpLayout->GetPrevClientRect() );
}
// step #2 - do ordered refreshing and resizing of bar window objects now
DoRepositionItems( mBarsToResize );
}
void cbGCUpdatesMgr::DoRepositionItems( wxList& items )
{
wxNode* pNode1 = items.First();
while( pNode1 )
{
cbRectInfo& info = node_to_rect_info( pNode1 );
wxNode* pNode2 = items.First();
// and node itself
mGC.AddObject( &info );
while( pNode2 )
{
if ( pNode2 != pNode1 ) // node should not depend on itself
{
// add references to objects, on which this object
// depends. Dependecy here indicates intersection of current
// bounds of this object with the initial bounds of the
// other object
cbRectInfo& otherInfo = node_to_rect_info( pNode2 );
if ( rect_hits_rect( *info.mpCurBounds, *otherInfo.mpPrevBounds ) )
// the node depends on node
mGC.AddDependency( &info, &otherInfo );
}
pNode2 = pNode2->Next();
}
pNode1 = pNode1->Next();
}
mGC.ArrangeCollection(); // order nodes according "least-dependency" rule,
// and find out cycled chains
// regular item nodes need to be resized, but not repainted (since
// they stand in linear (not cyclic) dependency with other
// regular nodes)
wxNode* pNode = mGC.GetRegularObjects().First();
while ( pNode )
{
cbRectInfo& info = *((cbRectInfo*)gc_node_to_obj(pNode));
if ( info.mpBar == NULL )
mpLayout->PositionClientWindow();
else
info.mpPane->SizeBar( info.mpBar );
pNode = pNode->Next();
}
// cycled item nodes, need to be both resized and repainted
pNode = mGC.GetCycledObjects().First();
while ( pNode )
{
cbRectInfo& info = *((cbRectInfo*)gc_node_to_obj(pNode));
if ( info.mpBar == NULL )
{
wxWindow* pClntWnd = mpLayout->GetFrameClient();
mpLayout->PositionClientWindow();
// FIXME FIXME:: excessive!
pClntWnd->Show( FALSE );
pClntWnd->Show( TRUE );
// OLD STUFF:: mpLayout->PositionClientWindow();
}
else
if ( info.mpBar->mpBarWnd )
{
wxWindow* pWnd = info.mpBar->mpBarWnd;
// resize
info.mpPane->SizeBar( info.mpBar );
// repaint
/* OLD STUFF:: bool isChoice = info.mpBar->IsKindOf( CLASSINFO( wxChoice ) );
//#ifdef __WINDOWS__
//int result = ::SendMessage( (HWND)pWnd->m_hWnd, WM_NCPAINT, 0, 0 );
//#endif
*/
// FIXME FIXME:: there's no other way to repaint non-client area of the wxWindow!!
// so we do *excessive* "hide 'n show"
pWnd->Show(FALSE);
pWnd->Show(TRUE);
pWnd->Refresh();
}
pNode = pNode->Next();
}
// release data prepared for GC alg.
pNode = items.First();
while( pNode )
{
cbRectInfo* pInfo = (cbRectInfo*)(pNode->Data());
delete pInfo;
pNode = pNode->Next();
}
mGC.Reset(); // reinit GC
// FIXME:: this is a dirty-workaround for messy client-area,
// as a result of docking bar out of floated-container window
if ( mpLayout->mClientWndRefreshPending )
{
mpLayout->PositionClientWindow();
mpLayout->GetFrameClient()->Refresh();
}
}

View File

@@ -0,0 +1,118 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 19/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __GCUPDATESMGR_G__
#define __GCUPDATESMGR_G__
#include "controlbar.h"
#include "updatesmgr.h"
#include "garbagec.h"
/*
* class implements optimized logic for refreshing
* areas of frame layout - which actually need to be updated.
* Is used as default updates-manager by wxFrameLayout.
*
* it is called "Garbage Collecting" u.mgr for it's impelmentation
* tries to find out dependencies between bars, and to order
* them ito "hierarchy", this hierarchical sorting resembles
* impelmenation of heap-garbage collectors, which resolve
* dependencies between referencs.
*
* Example: there are situations where the order of moving
* the windows does matter:
*
* case 1)
* ------ ---
* | A | |B|
* ------ ---> | |
* --- --- ------
* |B| | A |
* | | ------
* ---
* (future)
* (past)
*
* past/future positions of A and B windows completely overlapp, i.e.
* depend on each other, and there is not solution for
* moving the windows witout refereshing both of them,
* -- we have cyclic dependency here. The gc. alg will
* find this cyclic dependecy and will force "refresh"
* after movement.
*
* case 2)
*
* ------
* | A |
* ------ --->
* ---
* |B| ------
* | | | A |
* --- ------
* ---
* |B|
* | |
* ---
*
* (future)
* (past)
*
* in this case past/future positions do not overlapp, thus
* it's enough only to move windows, without refreshing them.
* GC will "notice" it.
*
* there is also third case, when overlapping is partial
* in this case the refershing can be also avoided by
* moving windows in the order of "most-dependant" towards the
* "least-dependent". GC handles this automatically, by
* sorting windows by their dependency-level (or "hierarchy")
*
* See garbagec.h for more details of this method, garbagec.h/cpp
* implement sorting of generic-depenencies (does not deal
* with graphical objects directly)
*
* Summary: improves performance when complex/large windows are
* moved around, by reducing number of repaints. Also helps
* to avoid dirty non-client areas of moved windows
* in some sepcal cases of "overlapping anomalies"
*/
class cbGCUpdatesMgr : public cbSimpleUpdatesMgr
{
DECLARE_DYNAMIC_CLASS( cbGCUpdatesMgr )
protected:
GarbageCollector mGC;
void DoRepositionItems( wxList& items );
void AddItem( wxList& itemList,
cbBarInfo* pBar,
cbDockPane* pPane,
wxRect& curBounds,
wxRect& prevBounds );
public:
cbGCUpdatesMgr(void) {}
cbGCUpdatesMgr( wxFrameLayout* pPanel );
// notificiactions received from Frame Layout :
virtual void OnStartChanges();
// refreshes parts of the frame layout, which need an update
virtual void UpdateNow();
};
#endif

View File

@@ -0,0 +1,406 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 9/11/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "bardragpl.h"
// #pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "hintanimpl.h"
#define POS_UNDEFINED -32768
/***** Implementation for class cbHintAnimationPlugin *****/
// FIXME:: some of the below code should be eliminated by
// reusing parts of cbBarDragPlugin's implementation
IMPLEMENT_DYNAMIC_CLASS( cbHintAnimationPlugin, cbPluginBase )
BEGIN_EVENT_TABLE( cbHintAnimationPlugin, cbPluginBase )
EVT_PL_DRAW_HINT_RECT( cbHintAnimationPlugin::OnDrawHintRect )
END_EVENT_TABLE()
cbHintAnimationPlugin::cbHintAnimationPlugin(void)
: mpScrDc( NULL ),
mInClientHintBorder( 4 ),
mAnimStarted( FALSE ),
mpAnimTimer( 0 ),
mMorphDelay ( 5 ),
mMaxFrames ( 20 ),
mAccelerationOn( TRUE )
{}
cbHintAnimationPlugin::cbHintAnimationPlugin( wxFrameLayout* pPanel, int paneMask )
: cbPluginBase( pPanel, paneMask ),
mpScrDc( NULL ),
mInClientHintBorder( 4 ),
mAnimStarted( FALSE ),
mpAnimTimer( 0 ),
mMorphDelay ( 5 ),
mMaxFrames ( 20 ),
mAccelerationOn( TRUE )
{}
cbHintAnimationPlugin::~cbHintAnimationPlugin()
{
if ( mpScrDc ) delete mpScrDc;
}
/*** rect-tracking related methods ***/
void cbHintAnimationPlugin::OnDrawHintRect( cbDrawHintRectEvent& event )
{
if ( !mAnimStarted && !mpScrDc )
{
StartTracking();
mPrevInClient = event.mIsInClient;
mPrevRect = event.mRect;
mStopPending = FALSE;
}
if ( !event.mEraseRect )
{
// pass on current hint-rect info to the animation "thread", in
// order to make adjustments to the morph-target on-the-fly
mCurRect.x = event.mRect.x;
mCurRect.y = event.mRect.y;
mCurRect.width = event.mRect.width;
mCurRect.height = event.mRect.height;
}
// check the amount of change in the shape of hint,
// and start morph-effect if change is "sufficient"
int change = abs( mCurRect.width - mPrevRect.width ) +
abs( mCurRect.height - mPrevRect.height );
if ( change > 10 && !event.mLastTime && !event.mEraseRect )
{
if ( !mpAnimTimer )
mpAnimTimer = new cbHintAnimTimer();
// init the animation "thread", or reinit if already started
if ( mAnimStarted )
{
int o;
++o;
}
mpAnimTimer->Init( this, mAnimStarted );
mAnimStarted = TRUE;
}
else
if ( !mAnimStarted )
{
DoDrawHintRect( event.mRect, event.mIsInClient );
if ( event.mLastTime )
FinishTracking();
mPrevInClient = event.mIsInClient;
}
else
{
mCurInClient = event.mIsInClient;
if ( event.mLastTime && mpAnimTimer )
{
mStopPending = TRUE;
if ( mpAnimTimer->mPrevMorphed.x != POS_UNDEFINED )
// erase previouse rect
DoDrawHintRect( mpAnimTimer->mPrevMorphed, mPrevInClient );
}
}
mPrevRect = event.mRect;
}
#define _A 0xAA
#define _B 0x00
#define _C 0x55
#define _D 0x00
static const unsigned char _gCheckerImg[] = { _A,_B,_C,_D,
_A,_B,_C,_D,
_A,_B,_C,_D,
_A,_B,_C,_D
};
void cbHintAnimationPlugin::StartTracking()
{
mpScrDc = new wxScreenDC;
wxScreenDC::StartDrawingOnTop(&mpLayout->GetParentFrame());
}
void cbHintAnimationPlugin::DoDrawHintRect( wxRect& rect, bool isInClientRect)
{
wxRect scrRect;
RectToScr( rect, scrRect );
int prevLF = mpScrDc->GetLogicalFunction();
mpScrDc->SetLogicalFunction( wxXOR );
if ( isInClientRect )
{
// BUG BUG BUG (wx):: somehow stippled brush works only
// when the bitmap created on stack, not
// as a member of the class
wxBitmap checker( (const char*)_gCheckerImg, 8,8 );
wxBrush checkerBrush( checker );
mpScrDc->SetPen( mpLayout->mNullPen );
mpScrDc->SetBrush( checkerBrush );
int half = mInClientHintBorder / 2;
mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y - half,
scrRect.width + 2*half, mInClientHintBorder );
mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y + scrRect.height - half,
scrRect.width + 2*half, mInClientHintBorder );
mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y + half - 1,
mInClientHintBorder, scrRect.height - 2*half + 2);
mpScrDc->DrawRectangle( scrRect.x + scrRect.width - half,
scrRect.y + half - 1,
mInClientHintBorder, scrRect.height - 2*half + 2);
mpScrDc->SetBrush( wxNullBrush );
}
else
{
// otherwise draw 1-pixel thin borders
mpScrDc->SetPen( mpLayout->mBlackPen );
mpScrDc->DrawLine( scrRect.x, scrRect.y,
scrRect.x + scrRect.width, scrRect.y );
mpScrDc->DrawLine( scrRect.x, scrRect.y + 1,
scrRect.x, scrRect.y + scrRect.height );
mpScrDc->DrawLine( scrRect.x+1, scrRect.y + scrRect.height,
scrRect.x + scrRect.width, scrRect.y + scrRect.height );
mpScrDc->DrawLine( scrRect.x + scrRect.width , scrRect.y,
scrRect.x + scrRect.width, scrRect.y + scrRect.height + 1);
}
mpScrDc->SetLogicalFunction( prevLF );
}
void cbHintAnimationPlugin::DrawHintRect ( wxRect& rect, bool isInClientRect)
{
DoDrawHintRect( rect, isInClientRect );
}
void cbHintAnimationPlugin::EraseHintRect( wxRect& rect, bool isInClientRect)
{
DoDrawHintRect( rect, isInClientRect );
}
void cbHintAnimationPlugin::FinishTracking()
{
wxScreenDC::EndDrawingOnTop();
delete mpScrDc;
mpScrDc = NULL;
}
void cbHintAnimationPlugin::RectToScr( wxRect& frameRect, wxRect& scrRect )
{
scrRect = frameRect;
int x = frameRect.x, y = frameRect.y;
mpLayout->GetParentFrame().ClientToScreen( &x, &y );
scrRect.x = x;
scrRect.y = y;
}
/***** Implementation for class cbHintAnimTimer *****/
cbHintAnimTimer::cbHintAnimTimer(void)
{
#ifdef __WINDOWS__
mLock = NULL;
#endif
mPrevMorphed.x = POS_UNDEFINED;
}
void cbHintAnimTimer::MorphPoint( wxPoint& origin, MorphInfoT& info, wxPoint& point )
{
// simulate lienar movement (FOR NOW:: without acceleration)
double k;
if ( mpPl->mAccelerationOn )
k = double( mCurIter*mCurIter ) /
double( (mpPl->mMaxFrames - 1)*(mpPl->mMaxFrames - 1) );
else
k = double( mCurIter ) / double( mpPl->mMaxFrames - 1 );
point.x = int ( double ( info.mFrom.x + double (info.mTill.x - info.mFrom.x) * k ) );
point.y = int ( double ( info.mFrom.y + double (info.mTill.y - info.mFrom.y) * k ) );
point.x += origin.x;
point.y += origin.y;
}
void cbHintAnimTimer::Notify(void)
{
// FIXME:: "clean" implementation should use mutex to sync
// between GUI and animation threads
if ( mpPl->mStopPending )
{
Stop(); // top timer
mpPl->FinishTracking();
mpPl->mStopPending = FALSE;
mpPl->mpAnimTimer = NULL;
mpPl->mAnimStarted = FALSE;
mPrevMorphed.x = POS_UNDEFINED;
delete this;
return;
}
wxPoint origin( mpPl->mCurRect.x, mpPl->mCurRect.y );
wxPoint curUpper, curLower;
MorphPoint( origin, mUpperLeft, curUpper );
MorphPoint( origin, mLowerRight, curLower );
if ( mPrevMorphed.x != POS_UNDEFINED )
// erase previouse rect
mpPl->DoDrawHintRect( mPrevMorphed, mpPl->mPrevInClient );
wxRect morphed( curUpper.x, curUpper.y,
curLower.x - curUpper.x,
curLower.y - curUpper.y );
// draw rect of current iteration
mpPl->DoDrawHintRect( morphed,
( mCurIter != mpPl->mMaxFrames - 1 )
? mpPl->mPrevInClient : mpPl->mCurInClient );
mPrevMorphed = morphed;
if ( mCurIter == mpPl->mMaxFrames - 1 )
{
Stop(); // top timer
mpPl->FinishTracking();
mpPl->mpAnimTimer = NULL;
mpPl->mAnimStarted = FALSE;
mPrevMorphed.x = POS_UNDEFINED;
delete this;
}
else
++mCurIter;
}
bool cbHintAnimTimer::Init( cbHintAnimationPlugin* pAnimPl, bool reinit )
{
mpPl = pAnimPl;
int o;
++o;
++o;
// morph-points are set up relatively to the upper-left corner
// of the current hint-rectangle
if ( !reinit )
{
mUpperLeft.mFrom.x = mpPl->mPrevRect.x - mpPl->mCurRect.x;
mUpperLeft.mFrom.y = mpPl->mPrevRect.y - mpPl->mCurRect.y;
mLowerRight.mFrom.x = ( mUpperLeft.mFrom.x + mpPl->mPrevRect.width );
mLowerRight.mFrom.y = ( mUpperLeft.mFrom.y + mpPl->mPrevRect.height );
}
else
{
wxPoint origin( mpPl->mPrevRect.x, mpPl->mPrevRect.y );
wxPoint curUpper, curLower;
MorphPoint( origin, mUpperLeft, curUpper );
MorphPoint( origin, mLowerRight, curLower );
mUpperLeft.mFrom.x = curUpper.x - mpPl->mCurRect.x;
mUpperLeft.mFrom.y = curUpper.y - mpPl->mCurRect.y;
mLowerRight.mFrom.x = ( mUpperLeft.mFrom.x + curLower.x - curUpper.x );
mLowerRight.mFrom.y = ( mUpperLeft.mFrom.y + curLower.y - curUpper.y );
}
mUpperLeft.mTill.x = 0;
mUpperLeft.mTill.y = 0;
mLowerRight.mTill.x = mpPl->mCurRect.width;
mLowerRight.mTill.y = mpPl->mCurRect.height;
mCurIter = 1;
if ( !reinit )
Start( mpPl->mMorphDelay );
return TRUE;
}

View File

@@ -0,0 +1,115 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 9/11/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __HINTANIMPL_G__
#define __HINTANIMPL_G__
#include "controlbar.h"
#include "wx/timer.h"
class cbHintAnimTimer;
class cbHintAnimationPlugin : public cbPluginBase
{
DECLARE_DYNAMIC_CLASS( cbHintAnimationPlugin )
protected:
friend class cbHintAnimTimer;
wxScreenDC* mpScrDc; // created while tracking hint-rect
cbHintAnimTimer* mpAnimTimer;
// FOR NOW:: try it without mutually exculisve locks
volatile wxRect mCurRect;
// state variables
bool mAnimStarted;
bool mStopPending;
bool mPrevInClient;
bool mCurInClient;
wxRect mPrevRect;
public:
int mMorphDelay; // delay between frames in miliseconds, default: 20
int mMaxFrames; // number of iterations for hint morphing, default: 30
// (morph duration = mMorphDelay * mMaxFrames msec)
int mInClientHintBorder; // default: 4 pixels
bool mAccelerationOn; // TRUE, if morph accelerates, otherwise morph
// speed is constant. Default: TRUE
// TBD:: get/set methods for above members
protected:
void StartTracking();
void DrawHintRect ( wxRect& rect, bool isInClientRect);
void EraseHintRect( wxRect& rect, bool isInClientRect);
void FinishTracking();
void DoDrawHintRect( wxRect& rect, bool isInClientRect);
void RectToScr( wxRect& frameRect, wxRect& scrRect );
public:
cbHintAnimationPlugin(void);
~cbHintAnimationPlugin();
cbHintAnimationPlugin( wxFrameLayout* pPanel, int paneMask = wxALL_PANES );
void OnDrawHintRect( cbDrawHintRectEvent& event );
DECLARE_EVENT_TABLE()
};
// helper classes
struct MorphInfoT
{
wxPoint mFrom;
wxPoint mTill;
};
class cbHintAnimTimer : public wxTimer
{
protected:
friend class cbHintAnimationPlugin;
wxRect mPrevMorphed;
MorphInfoT mUpperLeft;
MorphInfoT mLowerRight;
int mCurIter;
long mLock;
cbHintAnimationPlugin* mpPl;
void MorphPoint( wxPoint& origin, MorphInfoT& info, wxPoint& point );
public:
cbHintAnimTimer(void);
virtual void Notify(void);
virtual bool Init( cbHintAnimationPlugin* pAnimPl, bool reinit );
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,759 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: ??/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "newbmpbtn.cpp"
#pragma interface "newbmpbtn.cpp"
#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
#include "newbmpbtn.h"
#include "wx/utils.h" // import wxMin,wxMax macros
///////////// button-label rendering helpers //////////////////
static int* create_array( int width, int height, int fill = 0 )
{
int* array = new int[width*height];
int len = width*height;
for( int i = 0; i != len; ++i ) array[i] = fill;
return array;
}
#define GET_ELEM(array,x,y) (array[width*(y)+(x)])
#define MIN_COLOR_DIFF 10
#define IS_IN_ARRAY(x,y) ( (x) < width && (y) < height && (x) >= 0 && (y) >= 0 )
#define GET_RED(col) col & 0xFF
#define GET_GREEN(col) (col >> 8) & 0xFF
#define GET_BLUE(col) (col >> 16) & 0xFF
#define MAKE_INT_COLOR(red,green,blue) ( (red) | \
( ( (green) << 8 ) & 0xFF00 ) | \
( ( (blue) << 16) & 0xFF0000) \
)
#define IS_GREATER(col1,col2) ( ( (GET_RED(col1) ) > (GET_RED(col2) ) + MIN_COLOR_DIFF ) && \
( (GET_GREEN(col1)) > (GET_GREEN(col2)) + MIN_COLOR_DIFF ) && \
( (GET_BLUE(col1) ) > (GET_BLUE(col2) ) + MIN_COLOR_DIFF ) \
)
#define MASK_BG 0
#define MASK_DARK 1
#define MASK_LIGHT 2
// helper function, used internally
static void gray_out_pixmap( int* src, int* dest, int width, int height )
{
// assuming the pixels along the edges are of the background color
int bgCol = GET_ELEM(src,0,0);
int x = 0;
int y = 1;
do
{
int cur = GET_ELEM(src,x,y);
int r = GET_RED(cur);
int g = GET_GREEN(cur);
int b = GET_BLUE(cur);
if ( IS_IN_ARRAY(x-1,y-1) )
{
int upperElem = GET_ELEM(src,x-1,y-1);
// if the upper element is lighter than current
if ( IS_GREATER(upperElem,cur) )
{
GET_ELEM(dest,x,y) = MASK_DARK;
}
else
// if the current element is ligher than the upper
if ( IS_GREATER(cur,upperElem) )
{
GET_ELEM(dest,x,y) = MASK_LIGHT;
}
else
{
if ( GET_ELEM(dest,x-1,y-1) == MASK_LIGHT )
GET_ELEM(dest,x,y) = MASK_BG;
if ( GET_ELEM(dest,x-1,y-1 ) == MASK_DARK )
GET_ELEM(dest,x,y) = MASK_DARK;
else
GET_ELEM(dest,x,y) = MASK_BG;
}
}
// go zig-zag
if ( IS_IN_ARRAY(x+1,y-1) )
{
++x;--y;
}
else
{
while( IS_IN_ARRAY(x-1,y+1) )
{
--x;++y;
}
if ( IS_IN_ARRAY(x,y+1) )
{
++y; continue;
}
else
{
if ( IS_IN_ARRAY(x+1,y) )
{
++x; continue;
}
else break;
}
}
} while(1);
}
// alg. for making the image look "grayed" (e.g. disabled button)
// NOTE:: used GetPixel(), which is Windows-Only!
void greay_out_image_on_dc( wxDC& dc, int width, int height )
{
// assuming the pixels along the edges are of the background color
wxColour bgCol;
dc.GetPixel( 0, 0, &bgCol );
wxPen darkPen ( wxColour(128,128,128),1, wxSOLID );
wxPen lightPen( wxColour(255,255,255),1, wxSOLID );
wxPen bgPen ( bgCol, 1, wxSOLID );
int* src = create_array( width, height, MASK_BG );
int* dest = create_array( width, height, MASK_BG );
int y = 0;
for( y = 0; y != height; ++y )
for( int x = 0; x != width; ++x )
{
wxColour col;
dc.GetPixel( x,y, &col );
int r = col.Red(),
g = col.Green(),
b = col.Blue();
int o = MAKE_INT_COLOR( r,g,b );
GET_ELEM(src,x,y) = MAKE_INT_COLOR( col.Red(), col.Green(), col.Blue() );
}
gray_out_pixmap( src, dest, width, height );
for( y = 0; y != height; ++y )
for( int x = 0; x != width; ++x )
{
int mask = GET_ELEM(dest,x,y);
switch (mask)
{
case MASK_BG : { dc.SetPen( bgPen );
dc.DrawPoint( x,y ); break;
}
case MASK_DARK : { dc.SetPen( darkPen );
dc.DrawPoint( x,y ); break;
}
case MASK_LIGHT : { dc.SetPen( lightPen );
dc.DrawPoint( x,y ); break;
}
default : break;
}
}
delete [] src;
delete [] dest;
}
///////////////////////////////
/***** Impelementation for class wxNewBitmapButton *****/
IMPLEMENT_DYNAMIC_CLASS(wxNewBitmapButton, wxPanel)
BEGIN_EVENT_TABLE( wxNewBitmapButton, wxPanel )
EVT_LEFT_DOWN( wxNewBitmapButton::OnLButtonDown )
EVT_LEFT_UP ( wxNewBitmapButton::OnLButtonUp )
EVT_MOTION ( wxNewBitmapButton::OnMouseMove )
EVT_SIZE ( wxNewBitmapButton::OnSize )
EVT_PAINT( wxNewBitmapButton::OnPaint )
//EVT_KILL_FOCUS( wxNewBitmapButton::OnKillFocus )
EVT_ERASE_BACKGROUND( wxNewBitmapButton::OnEraseBackground )
END_EVENT_TABLE()
wxNewBitmapButton::wxNewBitmapButton( const wxBitmap& labelBitmap,
const wxString& labelText,
int alignText,
bool isFlat,
int firedEventType,
int marginX,
int marginY,
int textToLabelGap,
bool isSticky)
: mpDepressedImg( NULL ),
mpPressedImg ( NULL ),
mpDisabledImg ( NULL ),
mpFocusedImg ( NULL ),
mMarginX( marginX ),
mMarginY( marginY ),
mTextAlignment( alignText ),
mIsFlat( isFlat ),
mIsPressed ( FALSE ),
mDragStarted ( FALSE ),
mPrevPressedState( FALSE ),
mTextToLabelGap ( textToLabelGap ),
mBlackPen( wxColour( 0, 0, 0), 1, wxSOLID ),
mDarkPen ( wxColour(128,128,128), 1, wxSOLID ),
mGrayPen ( wxColour(192,192,192),
1, wxSOLID ),
mLightPen( wxColour(255,255,255), 1, wxSOLID ),
mFiredEventType( firedEventType ),
mIsSticky( isSticky ),
mIsCreated( FALSE ),
mSizeIsSet( FALSE ),
mHasFocusedBmp( FALSE ),
mIsInFocus( FALSE ),
mDepressedBmp( labelBitmap ),
mLabelText( labelText ),
mImageFileType( -1 )
{
}
wxNewBitmapButton::wxNewBitmapButton( const wxString& bitmapFileName,
const int bitmapFileType,
const wxString& labelText,
int alignText,
bool isFlat,
int firedEventType,
int marginX,
int marginY,
int textToLabelGap,
bool isSticky)
: mpDepressedImg( NULL ),
mpPressedImg ( NULL ),
mpDisabledImg ( NULL ),
mpFocusedImg ( NULL ),
mMarginX( 2 ),
mMarginY( 2 ),
mTextAlignment( alignText ),
mIsFlat( isFlat ),
mIsPressed ( FALSE ),
mDragStarted ( FALSE ),
mPrevPressedState( FALSE ),
mTextToLabelGap ( 2 ),
mBlackPen( wxColour( 0, 0, 0), 1, wxSOLID ),
mDarkPen ( wxColour(128,128,128), 1, wxSOLID ),
mGrayPen ( wxColour(192,192,192),
1, wxSOLID ),
mLightPen( wxColour(255,255,255), 1, wxSOLID ),
mFiredEventType( wxEVT_COMMAND_MENU_SELECTED ),
mIsSticky( FALSE ),
mIsCreated( FALSE ),
mSizeIsSet( FALSE ),
mHasFocusedBmp( FALSE ),
mIsInFocus( FALSE ),
mLabelText( labelText ),
mImageFileName( bitmapFileName ),
mImageFileType( bitmapFileType )
{
//mDepressedBmp.LoadFile( bitmapFileName, bitmapFileType );
}
wxNewBitmapButton::~wxNewBitmapButton(void)
{
DestroyLabels();
}
void wxNewBitmapButton::DrawShade( int outerLevel,
wxDC& dc,
wxPen& upperLeftSidePen,
wxPen& lowerRightSidePen )
{
wxBitmap* pBmp = GetStateLabel();
int x = mMarginX - (outerLevel + 1);
int y = mMarginY - (outerLevel + 1);
int height = pBmp->GetHeight() + (outerLevel + 1)*2 - 1;
int width = pBmp->GetWidth() + (outerLevel + 1)*2 - 1;
dc.SetPen( upperLeftSidePen );
dc.DrawLine( x,y, x + width, y );
dc.DrawLine( x,y, x, y + height );
dc.SetPen( lowerRightSidePen );
dc.DrawLine( x + width, y, x + width, y + height + 1 );
dc.DrawLine( x, y + height, x + width, y + height );
}
void wxNewBitmapButton::DestroyLabels()
{
if ( mpDepressedImg ) delete mpDepressedImg;
if ( mpPressedImg ) delete mpPressedImg;
if ( mpDisabledImg ) delete mpDisabledImg;
if ( mpFocusedImg ) delete mpFocusedImg;
mpDepressedImg = NULL;
mpPressedImg = NULL;
mpDisabledImg = NULL;
mpFocusedImg = NULL;
}
wxBitmap* wxNewBitmapButton::GetStateLabel()
{
if ( IsEnabled() )
{
if ( mIsPressed )
{
return mpPressedImg;
}
else
{
if ( mIsInFocus )
{
if ( mHasFocusedBmp )
return mpFocusedImg;
else
return mpDepressedImg;
}
else
return mpDepressedImg;
}
}
else
return mpDisabledImg;
}
void wxNewBitmapButton::RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp,
bool isEnabled, bool isPressed )
{
if ( destBmp != 0 ) return;
// render lables on-demand
wxMemoryDC srcDc;
srcDc.SelectObject( *srcBmp );
wxFont fnt( 9, wxDECORATIVE , wxNORMAL, wxNORMAL );
bool hasText = ( mTextAlignment != NB_NO_TEXT ) &&
( mLabelText.length() != 0 );
bool hasImage = (mTextAlignment != NB_NO_IMAGE);
wxSize destDim;
wxPoint txtPos;
wxPoint imgPos;
if ( hasText )
{
long txtWidth, txtHeight;
srcDc.SetFont( fnt );
srcDc.GetTextExtent( mLabelText, &txtWidth, &txtHeight );
if ( mTextAlignment == NB_ALIGN_TEXT_RIGHT )
{
destDim.x = srcBmp->GetWidth() + 2*mTextToLabelGap + txtWidth;
destDim.y =
wxMax( srcBmp->GetHeight(), txtHeight );
txtPos.x = srcBmp->GetWidth() + mTextToLabelGap;
txtPos.y = (destDim.y - txtHeight)/2;
imgPos.x = 0;
imgPos.y = (destDim.y - srcBmp->GetHeight())/2;
}
else
if ( mTextAlignment == NB_ALIGN_TEXT_BOTTOM )
{
destDim.x =
wxMax( srcBmp->GetWidth(), txtWidth );
destDim.y = srcBmp->GetHeight() + mTextToLabelGap + txtHeight;
txtPos.x = (destDim.x - txtWidth)/2;
txtPos.y = srcBmp->GetHeight() + mTextToLabelGap;
imgPos.x = (destDim.x - srcBmp->GetWidth())/2;
imgPos.y = 0;
}
else wxASSERT(0);// unsupported alignment type
}
else
{
imgPos.x = 0;
imgPos.y = 0;
destDim.x = srcBmp->GetWidth();
destDim.y = srcBmp->GetHeight();
}
destBmp = new wxBitmap( int(destDim.x), int(destDim.y) );
wxMemoryDC destDc;
destDc.SelectObject( *destBmp );
// FOR NOW:: hard-coded label background
wxBrush grayBrush( wxColour(192,192,192), wxSOLID );
wxPen nullPen( wxColour(0,0,0), 1, wxTRANSPARENT );
destDc.SetBrush( grayBrush );
destDc.SetPen( nullPen );
destDc.DrawRectangle( 0,0, destDim.x+1, destDim.y+1 );
if ( isPressed )
{
++imgPos.x; ++imgPos.y;
++txtPos.x; ++txtPos.y;
}
if ( hasImage )
{
destDc.Blit( imgPos.x, imgPos.y,
srcBmp->GetWidth()+1,
srcBmp->GetHeight()+1,
&srcDc, 0,0, wxCOPY );
}
if ( hasText )
{
wxWindow* pTopWnd = this;
do
{
wxWindow* pParent = pTopWnd->GetParent();
if ( pParent == 0 ) break;
pTopWnd = pParent;
} while(1);
destDc.SetFont( fnt );
// FOR NOW:: hard-coded text colors
destDc.SetTextForeground( wxColour( 0, 0, 0) );
destDc.SetTextBackground( wxColour(192,192,192) );
destDc.DrawText( mLabelText, txtPos.x, txtPos.y );
}
if ( !isEnabled )
greay_out_image_on_dc( destDc, destDim.x, destDim.y );
// adjust button size to fit the new dimensions of the label
if ( !mSizeIsSet && 0 )
{
mSizeIsSet = TRUE;
SetSize( -1,-1,
destBmp->GetWidth() + mMarginX*2,
destBmp->GetHeight() + mMarginY*2, 0
);
}
}
void wxNewBitmapButton::RenderLabelImages()
{
if ( !mIsCreated ) return;
if ( !IsEnabled() )
{
RenderLabelImage( mpDisabledImg, &mDepressedBmp, FALSE );
}
else
if ( mIsPressed )
RenderLabelImage( mpPressedImg, &mDepressedBmp, TRUE, TRUE );
else
{
if ( mIsInFocus )
{
if ( mHasFocusedBmp )
RenderLabelImage( mpFocusedImg, &mFocusedBmp, TRUE, FALSE );
else
RenderLabelImage( mpDepressedImg, &mDepressedBmp, TRUE, FALSE );
}
else
RenderLabelImage( mpDepressedImg, &mDepressedBmp, TRUE, FALSE );
}
}
void wxNewBitmapButton::DrawDecorations( wxDC& dc )
{
if ( mIsFlat )
{
DrawShade( 1, dc, mGrayPen, mGrayPen );
if ( mIsInFocus )
{
if ( mIsPressed )
DrawShade( 0, dc, mDarkPen, mLightPen );
else
DrawShade( 0, dc, mLightPen, mDarkPen );
}
else
DrawShade( 0, dc, mGrayPen, mGrayPen );
}
else
{
if ( mIsPressed )
{
DrawShade( 0, dc, mDarkPen, mGrayPen );
DrawShade( 1, dc, mBlackPen, mLightPen );
}
else
{
DrawShade( 0, dc, mGrayPen, mDarkPen );
DrawShade( 1, dc, mLightPen, mBlackPen );
}
}
}
void wxNewBitmapButton::SetLabel(const wxBitmap& labelBitmap,
const wxString& labelText )
{
DestroyLabels();
mLabelText = labelText;
mDepressedBmp = labelBitmap;
RenderLabelImages();
}
void wxNewBitmapButton::SetAlignments( int alignText,
int marginX,
int marginY,
int textToLabelGap)
{
DestroyLabels();
mMarginX = marginX;
mMarginY = marginY;
mTextAlignment = alignText;
mTextToLabelGap = textToLabelGap;
RenderLabelImages();
}
// event handlers
void wxNewBitmapButton::OnLButtonDown( wxMouseEvent& event )
{
mPrevPressedState = FALSE;
mDragStarted = TRUE;
mIsPressed = TRUE;
Refresh();
if ( !mIsInFocus )
CaptureMouse();
}
void wxNewBitmapButton::OnLButtonUp( wxMouseEvent& event )
{
if ( !mDragStarted ) return;
mDragStarted = FALSE;
mIsPressed = FALSE;
mIsInFocus = FALSE;
Refresh();
ReleaseMouse();
if ( IsInWindow( event.m_x, event.m_y ) )
{
// fire event, if mouse was released
// within the bounds of button
wxCommandEvent cmd( mFiredEventType, GetId() );
GetParent()->ProcessEvent( cmd );
}
}
bool wxNewBitmapButton::IsInWindow( int x, int y )
{
int width, height;
GetSize( &width, &height );
return ( x >= 0 && y >= 0 &&
x < width &&
y < height );
}
void wxNewBitmapButton::OnMouseMove( wxMouseEvent& event )
{
if ( !mIsInFocus && IsInWindow( event.m_x, event.m_y ) )
{
if ( !mDragStarted )
CaptureMouse();
mIsInFocus = TRUE;
}
else
if ( mIsInFocus && !IsInWindow( event.m_x, event.m_y ) )
{
mIsInFocus = FALSE;
if ( !mDragStarted )
ReleaseMouse();
}
if ( mDragStarted )
{
if ( IsInWindow( event.m_x, event.m_y ) )
mIsPressed = TRUE;
else
mIsPressed = FALSE;
if ( mIsPressed != mPrevPressedState )
Refresh();
mPrevPressedState = mIsPressed;
}
// FOR NOW::
Refresh();
}
void wxNewBitmapButton::OnSize( wxSizeEvent& event )
{
//Reshape();
}
void wxNewBitmapButton::Reshape( )
{
bool wasCreated = mIsCreated;
mIsCreated = TRUE;
if ( !wasCreated )
{
// in the case of loading button from stream, check if we
// have non-empty image-file name, load if possible
if ( mImageFileName != "" )
{
mDepressedBmp.LoadFile( mImageFileName, mImageFileType );
//wxMessageBox("Image Loaded!!!");
}
RenderLabelImages();
wxBitmap* pCurImg = GetStateLabel();
int w = pCurImg->GetWidth(),
h = pCurImg->GetHeight();
SetSize( 0,0, w + mMarginX*2, h + mMarginY*2 , 0 );
}
}
void wxNewBitmapButton::DrawLabel( wxDC& dc )
{
wxBitmap* pCurBmp = GetStateLabel();
if ( pCurBmp == NULL )
{
wxSizeEvent evt;
OnSize( evt ); // fake it up!
RenderLabelImages();
pCurBmp = GetStateLabel();
}
wxMemoryDC mdc;
mdc.SelectObject( *pCurBmp );
dc.Blit( mMarginX, mMarginY,
pCurBmp->GetWidth(),
pCurBmp->GetHeight(),
&mdc, 0,0, wxCOPY
);
mdc.SelectObject( wxNullBitmap );
}
void wxNewBitmapButton::OnPaint( wxPaintEvent& event )
{
wxPaintDC dc(this);
// first, make sure images for current state are prepared
RenderLabelImages();
DrawLabel( dc );
DrawDecorations( dc );
}
void wxNewBitmapButton::OnEraseBackground( wxEraseEvent& event )
{
// do nothing
}
void wxNewBitmapButton::OnKillFocus( wxFocusEvent& event )
{
// useless
wxMessageBox("kill-focus for button!");
}

View File

@@ -0,0 +1,158 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: ??/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __NEWBMPBTN_G__
#define __NEWBMPBTN_G__
#include "wx/button.h"
#include "wx/string.h"
// button lable-text alignment types
#define NB_ALIGN_TEXT_RIGHT 0
#define NB_ALIGN_TEXT_BOTTOM 1
#define NB_NO_TEXT 2
#define NB_NO_IMAGE 3
// classes declared in this header file
class wxNewBitmapButton;
class wxBorderLessBitmapButton;
// alternative class for wxBmpButton
class wxNewBitmapButton: public wxPanel
{
DECLARE_DYNAMIC_CLASS(wxNewBitmapButton)
protected:
friend class wxNewBitmapButtonSerializer;
int mTextToLabelGap;
int mMarginX;
int mMarginY;
int mTextAlignment;
bool mIsSticky;
wxString mLabelText;
wxString mImageFileName;
int mImageFileType;
bool mIsFlat;
wxBitmap mDepressedBmp; // source image for rendering
// labels for particular state
wxBitmap mFocusedBmp; // may not be always present -
// only if mHasFocusedBmp is TRUE
wxBitmap* mpDepressedImg;
wxBitmap* mpPressedImg;
wxBitmap* mpDisabledImg;
wxBitmap* mpFocusedImg;
// button state variables;
bool mDragStarted;
bool mIsPressed;
bool mIsInFocus;
bool mPrevPressedState;
bool mHasFocusedBmp;
// type of event which is fired upon depression of this button
int mFiredEventType;
// pens for drawing decorations (borders)
wxPen mBlackPen;
wxPen mDarkPen;
wxPen mGrayPen;
wxPen mLightPen;
bool mIsCreated;
int mSizeIsSet;
protected:
void DestroyLabels();
// returns the label which match the current button state
virtual wxBitmap* GetStateLabel();
virtual void DrawShade( int outerLevel,
wxDC& dc,
wxPen& upperLeftSidePen,
wxPen& lowerRightSidePen );
bool IsInWindow( int x,int y );
public:
wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap,
const wxString& labelText = "",
int alignText = NB_ALIGN_TEXT_BOTTOM,
bool isFlat = TRUE,
// this is the default type of fired events
int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
int marginX = 2,
int marginY = 2,
int textToLabelGap = 2,
bool isSticky = FALSE
);
// use this constructor if buttons have to be persistant
wxNewBitmapButton( const wxString& bitmapFileName,
const int bitmapFileType = wxBITMAP_TYPE_BMP,
const wxString& labelText = "",
int alignText = NB_ALIGN_TEXT_BOTTOM,
bool isFlat = TRUE,
// this is the default type of fired events
int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
int marginX = 2,
int marginY = 2,
int textToLabelGap = 2,
bool isSticky = FALSE
);
~wxNewBitmapButton();
// should be called after Create();
virtual void Reshape();
// overridables
virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = "" );
virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM,
int marginX = 2,
int marginY = 2,
int textToLabelGap = 2);
virtual void DrawDecorations( wxDC& dc );
virtual void DrawLabel( wxDC& dc );
virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp,
bool isEnabled = TRUE,
bool isPressed = FALSE);
virtual void RenderLabelImages();
// event handlers
void OnLButtonDown( wxMouseEvent& event );
void OnLButtonUp( wxMouseEvent& event );
void OnMouseMove( wxMouseEvent& event );
void OnSize( wxSizeEvent& event );
void OnPaint( wxPaintEvent& event );
void OnEraseBackground( wxEraseEvent& event );
void OnKillFocus( wxFocusEvent& event );
DECLARE_EVENT_TABLE()
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,501 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 26/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __OBJSTORE_G__
#define __OBJSTORE_G__
#include "wx/object.h"
#include "wx/string.h"
#include "wx/list.h"
#include "wx/hash.h"
#include "wx/window.h"
#include "wx/button.h"
#include "wx/textctrl.h"
#include "wx/treectrl.h"
#include "wx/dynarray.h"
// abstract classes declared
class wxDataStreamBase;
class wxSerializerBase;
class wxObjectStorage;
// classes which implement the above interfaces
class wxPointSerializer;
class wxSizeSerializer;
class wxRectSerializer;
class wxPenSerializer;
class wxBrushSerializer;
class wxObjectListSerializer;
class wxEvtHandlerSerializer;
class wxWindowSerializer;
class wxButtonSerializer;
class wxScrollBarSerializer;
class wxChoiceSerializer;
class wxTextCtrlSerializer;
class wxTreeCtrlSerializer;
class wxIOStreamWrapper;
// prototypes for serialzatoin/initialization functions
typedef void (*wxObjectSerializationFn) (wxObject*, wxObjectStorage& );
typedef void (*wxObjectInitializationFn)(wxObject*);
#define NO_CLASS_VER NULL
#define NO_CLASS_INIT NULL
/*
* class conceptually simiar to wxClassInfo, execpt that it's static
* instances hold information about class-serializers rather then
* about the classes themselves.
*/
class wxSerializerInfo
{
public:
char* className;
wxClassInfo* classInfo; // link to corresponding class-info object,
// established upon invocation of InitializeSerializers()
wxObjectSerializationFn serFn;
wxObjectInitializationFn initFn;
char* classVersion;
static bool alreadyInitialized;
static wxSerializerInfo* first;
static wxHashTable serInfoHash; // classInfo <=> serializerInfo
wxSerializerInfo* next;
wxSerializerInfo* nextByVersion;
wxSerializerInfo( char* theClassName,
wxObjectSerializationFn serializationFun,
wxObjectInitializationFn initializationFun,
char* classVersionName
);
// looks up for serializers of the base classes (base1 and base2)
// of the given object invokes them if present
void SerializeInherited ( wxObject* pObj, wxObjectStorage& store );
void InitializeInherited( wxObject* pObj );
bool HasVersion() { return classVersion != NO_CLASS_VER; }
bool HasInitializer() { return initFn != NO_CLASS_INIT; }
// static methods
static void InitializeSerializers(void);
static wxSerializerInfo* FindSerializer( char* className );
};
/*
* formal base class for all serializers, implemented as
* classes with static serialization/initialization methods
*/
class wxSerializerBase {};
// macros for declaring and implementing serializers both as
// classes and as a pair of (serialize/init) functions
#define DECLARE_SERIALIZER_CLASS(serializerName) \
public:\
static wxSerializerInfo info;;
#define IMPLEMENT_SERIALIZER_CLASS( name, serializerName, serFn, initFn) \
wxSerializerInfo \
serializerName::info( #name, serFn, initFn, NO_CLASS_VER );
#define IMPLEMENT_SERIALIZER_FUNCTIONS( name, serFn, initFn) \
wxSerializerInfo \
static __gSerFnInfoFor##name( #name, serFn, initFn, NO_CLASS_VER );
// for serializers, which are dedicated for specific versions of persistant classes
// (further referred as "versioned" serializers)
#define IMPLEMENT_SERIALIZER_CLASS_FOR_VERSION( name, serializerName, serFn, initFn, versionName) \
wxSerializerInfo \
serializerName::info( #name, serFn, initFn, #versionName );
#define IMPLEMENT_SERIALIZER_FUNCTIONS_FOR_VERSION( name, serializerName, serFn, initFn, versionName) \
wxSerializerInfo \
static __gSerFnInfoFor##name( #name, serFn, initFn, #versionName );
/*
* defines abstract inferface for data-stream objects,
* can be implemented as a wrapper class for already
* existing stream classes
*/
class wxDataStreamBase : public wxObject
{
DECLARE_ABSTRACT_CLASS( wxDataStreamBase )
protected:
bool mIsForInput;
public:
virtual bool StoreChar ( char ch ) = 0;
virtual bool StoreInt ( int i ) = 0;
virtual bool StoreLong ( long l ) = 0;
virtual bool StoreDouble( double d ) = 0;
virtual bool StoreBytes ( void* bytes, int count ) = 0;
virtual bool LoadChar ( char *pCh ) = 0;
virtual bool LoadInt ( int *pI ) = 0;
virtual bool LoadLong ( long *pL ) = 0;
virtual bool LoadDouble( double *pD ) = 0;
virtual bool LoadBytes ( void *pBytes, int count ) = 0;
virtual bool Flush() = 0;
virtual long GetStreamPos() = 0;
bool IsForInput() { return mIsForInput; }
};
/*
* class provides stream-based persistance service for
* classes derivated from wxObject, which are declared
* as dynamic classes. Relies on the presence of appropriate
* serializers for objects, which are being stored/loaded.
*/
class wxObjectStorage : public wxObject
{
DECLARE_DYNAMIC_CLASS( wxObjectStorage )
protected:
wxDataStreamBase* mpStm;
bool mIsLoading;
wxHashTable mRefHash;
wxList mInitialRefs;
wxHashTable mInitialRefsHash;
long mInitialRefsCnt;
wxList mNewObjs;
wxList mSerializersForNewObjs;
bool mFinalizePending;
protected:
wxSerializerBase* FindSerializer( wxObject* pForObj );
void ClearHashesAndLists();
virtual bool VersionsMatch( char* v1, char* v2 );
virtual wxSerializerInfo* FindSrzInfoForClass( wxClassInfo* pInfo );
void DoExchangeObject( wxObject* pInstance, wxSerializerInfo& srzInfo );
bool ExchangeObjectInfo( wxClassInfo** ppCInfo, wxSerializerInfo** ppSrz );
wxSerializerInfo* GetLatestSrzForObj( wxObject* pWxObj );
public:
// can be changed (with countion!)
static char mVerSepartorCh; // default: '#'
static char mMinorMajorSepartorCh; // default: '-'
public:
wxObjectStorage();
wxObjectStorage( wxDataStreamBase& stm );
virtual ~wxObjectStorage();
// adds initial reference, objects referred by such reference
// are not serialized when storing. When loading, pointers which
// refere to these "inital objects" are set up to refere to
// objects provided in by AddInitailRef() method.
//
// NOTE:: initial references should be added always in the
// same order, since the seq-# of the reference is used
// as an alias to the real object while storing/loading
void AddInitialRef( wxObject* pObjRef );
void ClearInitalRefs();
// init/reinit of object-storage
void SetDataStream( wxDataStreamBase& stm );
// performs linkng of in-memory references after loading, or
// links in-stream references after storing has proceeded
void Finalize();
// storage methods for basic types
void XchgChar ( char& chObj );
void XchgInt ( int& intObj );
void XchgLong ( long& longObj );
void XchgBool ( bool& boolObj );
void XchgDouble ( double& doubleObj );
void XchgCStr ( char* pCStrObj );
void XchgUInt ( unsigned int& uI );
void XchgSizeType( size_t& szObj );
void XchgObjList ( wxList& objList );
void XchgObjArray ( wxBaseArray& objArr );
void XchgLongArray( wxBaseArray& longArr );
// storage methods for objects and pointers to objects
void XchgObj ( wxObject* pWxObj );
void XchgObjPtr( wxObject** ppWxObj );
bool IsLoading() { return mIsLoading; }
// storage methods for common wxWindows classes,
// which may or may not be dymaic, therefor use the
// below methods instead of XchgObj(..)
void XchgWxStr ( wxString& str );
void XchgWxSize ( wxSize& size );
void XchgWxPoint( wxPoint& point );
void XchgWxRect ( wxRect& rect );
};
/*
* The below classes provide "curde" serialization for most
* common wxWindows objects, i.e. they discard the information
* which may be contained in the subclassed versions of these classes
* However, more "fine-grainded" serializers could be written
* to match these subclasses exactly.
*/
class wxColourSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( wxColourSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
// NOTE:: currently "stipple" and "dashes" properties of the pen
// are not serialized
class wxPenSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( wxPenSerializer );
public:
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
// NOTE:: currently "stipple" property of the brush is not serialized
class wxBrushSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( wxBrushSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
// serializer for wxList, assuming that the list
// holds derivatives of wxObject.
class wxObjectListSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( wxObjectListSerializer );
static void Serialize( wxObject* pObj, wxObjectStorage& store );
};
// generic serializer for classes derived from wxEvtHandler handler,
// assuming that they do not add any new properties to wxEvtHandler
// or these properties are transient
class wxEvtHandlerSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( wxEvtHandlerSerializer );
public:
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void Initialize( wxObject* pObj );
};
// serializer for generic wxWindow. Serializes position, size, id,
// reference to parent, list of children, style flags and name string.
// Could be used for serializing wxWindow and generic wxPanel objects.
// Separate serializers have to be written for control classes.
class wxWindowSerializer : public wxEvtHandlerSerializer
{
DECLARE_SERIALIZER_CLASS( wxWindowSerializer );
public:
static void Serialize( wxObject* pObj, wxObjectStorage& store );
// helpers, to ease the creation of serializers for derivatives of wxWindow
typedef (*wndCreationFn)(wxWindow*, wxWindow*, const wxWindowID,
const wxPoint&, const wxSize&, long, const wxString& );
static void DoSerialize( wxObject* pObj, wxObjectStorage& store,
wndCreationFn creationFn, bool refreshNow = TRUE
);
static void CreateWindowFn( wxWindow* wnd, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style ,
const wxString& name );
};
class wxTextCtrlSerializer : public wxWindowSerializer
{
DECLARE_SERIALIZER_CLASS( wxTextCtrlSerializer );
public:
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void CreateTextCtrlWindowFn( wxTextCtrl* wnd, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style ,
const wxString& name );
};
class wxButtonSerializer : public wxWindowSerializer
{
DECLARE_SERIALIZER_CLASS( wxButtonSerializer );
public:
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void CreateButtonWindowFn( wxButton* btn, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style ,
const wxString& name );
};
class wxStaticTextSerializer : public wxWindowSerializer
{
DECLARE_SERIALIZER_CLASS( wxStaticTextSerializer );
public:
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void CreateSTextWindowFn( wxStaticText* pSTxt, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style ,
const wxString& name );
};
class wxScrollBarSerializer : public wxWindowSerializer
{
DECLARE_SERIALIZER_CLASS( wxScrollBarSerializer );
public:
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void CreateScollBarWindowFn( wxScrollBar* sbar, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style ,
const wxString& name );
};
class wxTreeCtrlSerializer : public wxWindowSerializer
{
DECLARE_SERIALIZER_CLASS( wxTreeCtrlSerializer );
protected:
static void SerializeBranch( wxTreeItemId parentId, wxTreeCtrl* pTree,
wxObjectStorage& store, wxTreeItemId nextVisId,
int depth );
public:
static void Serialize( wxObject* pObj, wxObjectStorage& store );
static void CreateTreeCtrlWindowFn( wxTreeCtrl* tree, wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style ,
const wxString& name );
};
// default implementations of interfaces, used by wxObjectStorage class
//
// FOR NOW:: methods do not yet perform byte-swaps for outputting/reading words in
// machine-independent format. Better solution would be to write wrapper
// around the "promissed" protable-data-stream class of wxWindows
class wxIOStreamWrapper : public wxDataStreamBase
{
DECLARE_DYNAMIC_CLASS( wxIOStreamWrapper )
protected:
iostream* mpStm;
bool mOwnsStmObject;
long mStreamPos; // precalcualted stream postion,
// assuming that the actual stream object is not
// capable of telling postion of current get/put pointer
// (e.g. socket-stream)
void Close();
public:
// default constructor
wxIOStreamWrapper();
// attach this wrapper to already exiting iostream object
wxIOStreamWrapper( iostream& stm, bool forInput = TRUE );
// creates "fstream" object with the given file name in binary mode,
// returns FALSE, if stream creation failed
//
// The created fstream object is "owned" by this wrapper,
// thus it is destored during destruction of this object
bool Create( const char* fileName, bool forInput = TRUE );
inline bool CreateForInput( const char* fileName )
{ return Create( fileName, TRUE ); }
inline bool CreateForOutput( const char* fileName )
{ return Create( fileName, FALSE ); }
// the same as in the second constructor, previousely used
// stream object is flushed and destroyed (if owned).
// The attached stream is not "owned" by this wrapper object
void Attach( iostream& stm, bool forInput = TRUE );
virtual ~wxIOStreamWrapper();
virtual bool StoreChar ( char ch );
virtual bool StoreInt ( int i );
virtual bool StoreLong ( long l );
virtual bool StoreDouble( double d );
virtual bool StoreBytes ( void* bytes, int count );
virtual bool LoadChar ( char* pCh );
virtual bool LoadInt ( int* pI );
virtual bool LoadLong ( long* pL );
virtual bool LoadDouble( double* pD );
virtual bool LoadBytes ( void* pBytes, int count );
virtual bool Flush();
virtual long GetStreamPos();
bool Good();
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,118 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Central header file for control-bar related classes
//
// Author: Aleksandras Gluchovas <mailto:alex@soften.ktu.lt>
// Modified by:
// Created: 06/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __PANEDRAWPL_G__
#define __PANEDRAWPL_G__
#ifdef __GNUG__
#pragma interface "panedrawpl.h"
#endif
#include "controlbar.h"
/*
* Simple, but all-in-one plugin implementation. Resembles look & feel of
* to MFC control-bars. Handles painting of pane and items in it.
* Fires bar/layout customization event, when user right-clicks bar/pane.
* Hooking an instance of this and row-layouting plugins per each pane,
* would be enough for the frame layout to function properly.
* (they are plugged in autimatically by wxFrameLayout class)
*/
class cbPaneDrawPlugin : public cbPluginBase
{
public:
DECLARE_DYNAMIC_CLASS( cbPaneDrawPlugin )
protected:
// resizing bars/rows state variables
bool mResizeStarted;
bool mResizeCursorOn;
wxPoint mDragOrigin;
bool mRowHandleHitted;
bool mIsUpperHandle;
bool mBarHandleHitted;
bool mIsLeftHandle;
bool mBarContentHitted;
cbBarInfo* mpDraggedBar; // also used when in bar-drag action
cbRowInfo* mpResizedRow;
// contstraints for dragging the handle
wxRect mHandleDragArea;
bool mHandleIsVertical;
int mHandleOfs;
int mDraggedDelta;
wxPoint mPrevPos;
// used for handling, start-draw-in-area events
wxClientDC* mpClntDc;
cbDockPane* mpPane; // is set up temorary short-cut, while handling event
protected:
// helpers
void DrawDraggedHandle( const wxPoint& pos, cbDockPane& pane );
virtual void DrawPaneShade( wxDC& dc, int alignment );
virtual void DrawPaneShadeForRow( cbRowInfo* pRow, wxDC& dc );
virtual void DrawUpperRowHandle( cbRowInfo* pRow, wxDC& dc );
virtual void DrawLowerRowHandle( cbRowInfo* pRow, wxDC& dc );
virtual void DrawUpperRowShades( cbRowInfo* pRow, wxDC& dc, int level );
virtual void DrawLowerRowShades( cbRowInfo* pRow, wxDC& dc, int level );
virtual void DrawBarInnerShadeRect( cbBarInfo* pBar, wxDC& dc );
virtual void DrawShade( int level, wxRect& rect, int alignment, wxDC& dc );
virtual void DrawShade1( int level, wxRect& rect, int alignment, wxDC& dc );
inline void SetLightPixel( int x, int y, wxDC& dc );
inline void SetDarkPixel ( int x, int y, wxDC& dc );
public:
cbPaneDrawPlugin(void);
cbPaneDrawPlugin( wxFrameLayout* pPanel, int paneMask = wxALL_PANES );
virtual ~cbPaneDrawPlugin();
virtual cbPluginBase* Clone() { return new cbPaneDrawPlugin(0,0); }
// handlers for plugin-events
void OnLButtonDown( cbLeftDownEvent& event );
void OnLDblClick ( cbLeftDClickEvent& event );
void OnLButtonUp ( cbLeftUpEvent& event );
void OnRButtonUp ( cbRightUpEvent& event );
void OnMouseMove ( cbMotionEvent& event );
void OnDrawPaneBackground ( cbDrawPaneBkGroundEvent& event );
void OnDrawPaneDecorations( cbDrawPaneDecorEvent& event );
void OnDrawRowDecorations ( cbDrawRowDecorEvent& event );
void OnDrawRowHandles ( cbDrawRowHandlesEvent& event );
void OnDrawRowBackground ( cbDrawRowBkGroundEvent& event );
void OnSizeBarWindow ( cbSizeBarWndEvent& event );
void OnDrawBarDecorations ( cbDrawBarDecorEvent& event );
void OnDrawBarHandles ( cbDrawBarHandlesEvent& event );
void OnStartDrawInArea ( cbStartDrawInAreaEvent& event );
void OnFinishDrawInArea ( cbFinishDrawInAreaEvent& event );
DECLARE_EVENT_TABLE()
};
#endif

View File

@@ -0,0 +1,286 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 26/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "pf_sample.h"
// #pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "pf_sample.h"
IMPLEMENT_DYNAMIC_CLASS( classA, wxObject )
IMPLEMENT_DYNAMIC_CLASS( classB, wxObject )
IMPLEMENT_SERIALIZER_CLASS( classA,
classASerializer,
classASerializer::Serialize,
NO_CLASS_INIT )
IMPLEMENT_SERIALIZER_CLASS( classB,
classBSerializer,
classBSerializer::Serialize,
NO_CLASS_INIT )
// somehow original wxASSERT(0) statements get not compiled in...
#undef wxASSERT
#define wxASSERT(x) if ( !(x) ) throw;
extern notStorableClass gNotStorable;
typedef notStorableClass* BackRefType;
void test_storing( const char* fname, wxObjectStorage& store )
{
// create objects
classA* pA = new classA();
pA->x = 1;
classB* pB = new classB();
pB->y = 2;
// put cross-references
pB->mpAObj = pA;
pA->mpBObj = pB;
// put back-references to not-storable obj
pA->mpBackRef = &gNotStorable;
pB->mpBackRef = &gNotStorable;
// create stream object for output
wxIOStreamWrapper outFile;
bool success = outFile.Create( fname, FALSE );
wxASSERT( success );
store.SetDataStream( outFile );
// store everything starting from "pA" object
store.XchgObjPtr( (wxObject**) &pA );
// flushes stream
store.Finalize();
}
void test_loading( const char* fname, wxObjectStorage& store )
{
classA* pA = 0;
// create stream-object for input
wxIOStreamWrapper inFile;
bool success = inFile.Create( fname, TRUE );
wxASSERT( success );
store.SetDataStream( inFile );
// load everything
store.XchgObjPtr( (wxObject**) &pA );
// calls initializing procedures for serializer
// which provide them
store.Finalize();
// short-cut
classB* pB = pA->mpBObj;
// assertain correctness of class members
wxASSERT( pA->x == 1 );
wxASSERT( pB->y == 2 );
// assertain correctness of cross-references
wxASSERT( pA->mpBObj == pB );
wxASSERT( pB->mpAObj == pA );
// asssertain correctness of inital references
wxASSERT( pA->mpBackRef == &gNotStorable );
wxASSERT( pB->mpBackRef == &gNotStorable );
}
void setup_inital_refs( wxObjectStorage& store )
{
store.AddInitialRef( (wxObject*) &gNotStorable );
}
// global instance of the object, which we do not want to store/load for
// some reason, even though other stored/loaded objects have refernces to it
notStorableClass gNotStorable;
void test_storing_of_list( const char* fname, wxObjectStorage& store );
void test_loading_of_list( const char* fname, wxObjectStorage& store );
/*---------------------------*/
/* Main testing function */
/*---------------------------*/
void test_obj_storage()
{
// NOTE:: for brevity, the heap clean-ups are omitted in the tests
wxObjectStorage store;
setup_inital_refs( store );
test_storing( "testdata.dat", store );
test_loading( "testdata.dat", store );
test_storing_of_list( "testdata.dat", store );
test_loading_of_list( "testdata.dat", store );
}
void test_storing_of_list( const char* fname, wxObjectStorage& store )
{
// create objects
classA* pA = new classA();
pA->x = 1;
classB* pB = new classB();
pB->y = 2;
// put cross-references
pB->mpAObj = pA;
pA->mpBObj = pB;
// create list object
wxList* pLst = new wxList;
// put objects to the list
wxNode* pNode = pLst->Append( pA );
pA->mpBackRef = (BackRefType)pNode;
pNode = pLst->Append( pB );
pB->mpBackRef = (BackRefType)pNode;
// create stream object for output
wxIOStreamWrapper outFile;
bool success = outFile.Create( fname, FALSE );
wxASSERT( success );
store.SetDataStream( outFile );
// store everything starting from "pLst" object
store.XchgObjPtr( (wxObject**) &pLst );
// flushes stream
store.Finalize();
}
void test_loading_of_list( const char* fname, wxObjectStorage& store )
{
// create stream-object for input
wxIOStreamWrapper inFile;
bool success = inFile.Create( fname, TRUE );
wxASSERT( success );
store.SetDataStream( inFile );
// load everything
wxList* pLst;
// (NOTE:: serializers for wxList/wxNode is file objstore.cpp)
store.XchgObjPtr( (wxObject**) &pLst );
// assertain correctness of list and it's contents
wxASSERT( pLst->Number() == 2 );
int n = 0;
wxNode* pNode = pLst->First();
while( pNode )
{
if ( n == 0 )
{
classA* pA = (classA*)pNode->Data();
// assertain correctness of class members
wxASSERT( pA->x == 1 );
// assertain correctness of cross-references
wxASSERT( pA->mpBObj == (classB*)pNode->Next()->Data() );
// asssertain correctness of inital references
wxASSERT( (wxNode*)pA->mpBackRef == pNode )
}
if ( n == 1 )
{
classB* pB = (classB*)pNode->Data();
// assertain correctness of class members
wxASSERT( pB->y == 2 );
// assertain correctness of cross-references
wxASSERT( pB->mpAObj == (classA*)pNode->Previous()->Data() );
// asssertain correctness of inital references
wxASSERT( (wxNode*)pB->mpBackRef == pNode )
}
pNode = pNode->Next();
++n;
}
// calls initializing procedures for serializer
// which provide them
store.Finalize();
}

View File

@@ -0,0 +1,86 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 26/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __PF_SAMPLE_G__
#define __PF_SAMPLE_G__
#include "objstore.h"
// forward decl.
class classA;
class classB;
// sample classes
class notStorableClass
{};
class classA : public wxObject
{
DECLARE_DYNAMIC_CLASS( classA )
public:
int x;
classB* mpBObj;
notStorableClass* mpBackRef;
};
class classB : public wxObject
{
DECLARE_DYNAMIC_CLASS( classB )
public:
int y;
classA* mpAObj;
notStorableClass* mpBackRef;
};
// serialization handlers for the above classes
class classASerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( classASerializer )
static void Serialize( wxObject* pObj, wxObjectStorage& store )
{
classA* pA = (classA*)pObj; // cast
store.XchgInt ( pA->x );
store.XchgObjPtr( (wxObject**) &(pA->mpBObj) );
store.XchgObjPtr( (wxObject**) &(pA->mpBackRef) );
}
};
class classBSerializer : public wxSerializerBase
{
DECLARE_SERIALIZER_CLASS( classBSerializer )
static void Serialize( wxObject* pObj, wxObjectStorage& store )
{
classB* pB = (classB*)pObj; // cast
store.XchgInt ( pB->y );
store.XchgObjPtr( (wxObject**) &(pB->mpAObj) );
store.XchgObjPtr( (wxObject**) &(pB->mpBackRef) );
}
};
/*---------------------------*/
/* Main testing function */
/*---------------------------*/
// include this header and .cpp file into any of your
// wxWindows projects, and invoke the below function
// to peform tests
void test_obj_storage();
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,159 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 06/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __ROWDRAGPL_G__
#define __ROWDRAGPL_G__
#include "controlbar.h"
/*
* Plugin adds row-dragging fuctionality to the pane.
* Handles mouse/movement and pane-background erasing plugin-events.
* Behaviour and appearence resembles drag & drop posotioning
* of the toolbar-rows int Netscape Comunicator 4.xx.
*/
class cbRowDragPlugin : public cbPluginBase
{
DECLARE_DYNAMIC_CLASS( cbRowDragPlugin )
public:
// background colours for the highlighted/unhighlighted icons
wxColour mHightColor; // light-blue for NC-look
wxColour mLowColor; // light-gray -/-
wxColour mTrianInnerColor; // blue -/-
wxPen mTrianInnerPen; // black -/-
protected:
friend class cbRowDragPluginSerializer;
// drag & drop state variables
bool mDragStarted;
bool mDecisionMode;
wxPoint mDragOrigin;
int mCurDragOfs;
bool mCaptureIsOn;
// saved margins of the pane
int mSvTopMargin;
int mSvBottomMargin;
int mSvLeftMargin;
int mSvRightMargin;
//on-screen drawing state variables
wxBitmap* mpPaneImage;
wxBitmap* mpRowImage;
wxBitmap* mpCombinedImage;
wxScreenDC* mpScrDc;
wxRect mCombRect;
wxSize mRowImgDim;
int mInitalRowOfs;
// NOTE:: if mpRowInFocus is not NULL, then mCollapsedIconInFocus is -1,
// and v.v. (two different items cannot be in focus at the same time)
cbRowInfo* mpRowInFocus;
int mCollapsedIconInFocus;
cbDockPane* mpPane; // is set up temorarely, while handling event
wxList mHiddenBars;
wxBitmap* CaptureDCArea( wxDC& dc, wxRect& area );
// helpers for drag&drop
int GetHRowsCountForPane( cbDockPane* pPane );
void SetMouseCapture( bool captureOn );
void PrepareForRowDrag();
void ShowDraggedRow( int offset );
void ShowPaneImage();
void FinishOnScreenDraw();
void CollapseRow( cbRowInfo* pRow );
void ExpandRow( int collapsedIconIdx );
void InsertDraggedRowBefore( cbRowInfo* pBeforeRow );
bool ItemIsInFocus();
void CheckPrevItemInFocus( cbRowInfo* pRow, int iconIdx );
void UnhiglightItemInFocus();
cbRowInfo* GetFirstRow();
// "hard-coded metafile" for NN-look
virtual void DrawTrianUp( wxRect& inRect, wxDC& dc );
virtual void DrawTrianDown( wxRect& inRect, wxDC& dc );
virtual void DrawTrianRight( wxRect& inRect, wxDC& dc );
virtual void Draw3DPattern( wxRect& inRect, wxDC& dc );
virtual void DrawRombShades( wxPoint& p1, wxPoint& p2, wxPoint& p3, wxPoint& p4, wxDC& dc );
virtual void DrawOrtoRomb( wxRect& inRect, wxDC& dc, wxBrush& bkBrush );
virtual void DrawRomb( wxRect& inRect, wxDC& dc, wxBrush& bkBrush );
virtual void Draw3DRect( wxRect& inRect, wxDC& dc, wxBrush& bkBrush );
virtual void DrawRectShade( wxRect& inRect, wxDC& dc,
int level, wxPen& upperPen, wxPen& lowerPen );
virtual void GetRowHintRect( cbRowInfo* pRow, wxRect& rect );
virtual void GetCollapsedInconRect( int iconIdx, wxRect& rect );
virtual int GetCollapsedIconsPos();
public:
cbRowDragPlugin(void);
cbRowDragPlugin( wxFrameLayout* pLayout, int paneMask = wxALL_PANES );
virtual ~cbRowDragPlugin();
virtual cbPluginBase* Clone() { return new cbRowDragPlugin(NULL,0); }
virtual void OnInitPlugin();
// handlers for plugin events (appearence-independent logic)
void OnMouseMove ( cbMotionEvent& event );
void OnLButtonDown( cbLeftDownEvent& event );
void OnLButtonUp ( cbLeftUpEvent& event );
void OnDrawPaneBackground( cbDrawPaneDecorEvent& event );
// overridables (appearence-depedent)
virtual void DrawCollapsedRowIcon( int index, wxDC& dc, bool isHighlighted );
virtual void DrawCollapsedRowsBorder( wxDC& dc );
virtual void DrawRowsDragHintsBorder( wxDC& dc );
virtual void DrawRowDragHint( cbRowInfo* pRow, wxDC& dc, bool isHighlighted );
virtual void DrawEmptyRow( wxDC& dc, wxRect& rowBounds );
virtual int GetCollapsedRowIconHeight();
virtual int GetRowDragHintWidth();
virtual void SetPaneMargins();
virtual bool HitTestCollapsedRowIcon( int iconIdx, const wxPoint& pos );
virtual bool HitTestRowDragHint( cbRowInfo* pRow, const wxPoint& pos );
DECLARE_EVENT_TABLE()
};
// internal helper-class
class cbHiddenBarInfo : public wxObject
{
DECLARE_DYNAMIC_CLASS( cbHiddenBarInfo )
public:
cbBarInfo* mpBar;
int mRowNo;
int mIconNo;
int mAlignment;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 02/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __ROWLAYOUTPL_G__
#define __ROWLAYOUTPL_G__
#include "controlbar.h"
/*
* Simple implementaiton of plugin, which handles row-layouting
* requests sent from Frame Layout
*/
class cbRowLayoutPlugin : public cbPluginBase
{
DECLARE_DYNAMIC_CLASS( cbRowLayoutPlugin )
protected:
cbDockPane* mpPane; // is set up temorarely, while handling event
protected:
// not-fixed-bars layouting related helpers
void FitBarsToRange( int from, int till, cbBarInfo* pTheBar, cbRowInfo* pRow );
void RelayoutNotFixedBarsAround( cbBarInfo* pTheBar, cbRowInfo* pRow );
void MinimzeNotFixedBars( cbRowInfo* pRow, cbBarInfo* pBarToPreserve );
int GetRowFreeSpace( cbRowInfo* pRow );
void RecalcLenghtRatios( cbRowInfo* pRow );
void ApplyLenghtRatios( cbRowInfo* pRow );
void ExpandNotFixedBars( cbRowInfo* pRow );
void AdjustLenghtOfInserted( cbRowInfo* pRow, cbBarInfo* pTheBar );
void DetectBarHandles( cbRowInfo* pRow );
void CheckIfAtTheBoundary( cbBarInfo* pTheBar, cbRowInfo& rowInfo );
// row-layouting helpers (simulate "bar-friction")
int CalcRowHeight( cbRowInfo& row );
void LayoutItemsVertically( cbRowInfo& row );
void StickRightSideBars( cbBarInfo* pToBar );
void SlideLeftSideBars ( cbBarInfo* pTheBar );
void SlideRightSideBars( cbBarInfo* pTheBar );
void ShiftLeftTrashold ( cbBarInfo* pTheBar, cbRowInfo& row );
void ShiftRightTrashold( cbBarInfo* pTheBar, cbRowInfo& row );
void InsertBefore( cbBarInfo* pBeforeBar,
cbBarInfo* pTheBar,
cbRowInfo& row
);
void DoInsertBar( cbBarInfo* pTheBar, cbRowInfo& row );
public:
cbRowLayoutPlugin(void);
cbRowLayoutPlugin( wxFrameLayout* pPanel, int paneMask = wxALL_PANES );
// event handlers
void OnResizeRow ( cbResizeRowEvent& event );
void OnInsertBar ( cbInsertBarEvent& event );
void OnRemoveBar ( cbRemoveBarEvent& event );
void OnLayoutRow ( cbLayoutRowEvent& event );
void OnLayoutRows( cbLayoutRowsEvent& event );
DECLARE_EVENT_TABLE()
};
#endif

View File

@@ -0,0 +1,496 @@
/////////////////////////////////////////////////////////////////////////////
// Name: settingsdlg.cpp
// Purpose: Settings dialog for Frame Layout
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 05/11/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "settingsdlg.cpp"
#pragma interface "settingsdlg.cpp"
#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
#include <stdlib.h>
#include "settingsdlg.h"
/***** Implementation for class SettingsDlg *****/
#define ID_NOTES ( wxEVT_FIRST + 1000 )
#define ID_HINTANIM_CHECK ( ID_NOTES + 1 )
#define ID_RTUPDATES_CHECK ( ID_NOTES + 2 )
BEGIN_EVENT_TABLE( SettingsDlg, wxDialog )
EVT_BUTTON( wxID_APPLY, SettingsDlg::OnApply )
EVT_BUTTON( ID_NOTES, SettingsDlg::OnNotes )
EVT_CHECKBOX( ID_HINTANIM_CHECK, SettingsDlg::OnHintAnimCheck )
EVT_CHECKBOX( ID_RTUPDATES_CHECK, SettingsDlg::OnRTUpdatesCheck )
END_EVENT_TABLE()
SettingsDlg::SettingsDlg( wxWindow* pParent )
: wxDialog( pParent, -1, "Active Layout Settings...",
wxDefaultPosition,
wxSize( 325,585),
wxDIALOG_MODAL | wxCAPTION )
{
int curY = 10;
int lMargin = 50;
int lBoxMargin = lMargin - 20;
int checkHeight = 20;
int labelHeight = 20;
int boxWidth = 260;
int interBoxGap = 10;
int lastItemGap = 10;
int topY = curY;
curY += labelHeight;
mpRTU_Check = new wxCheckBox( this, ID_RTUPDATES_CHECK,
"&Real-time updates",
wxPoint( lMargin, curY ) );
curY += checkHeight;
mpOPD_Check = new wxCheckBox( this, -1, "&Out of Pane drag",
wxPoint( lMargin, curY ) );
curY += checkHeight;
mpEDP_Check = new wxCheckBox( this, -1, "&Exact docking prediction",
wxPoint( lMargin, curY ) );
curY += checkHeight;
mpNDF_Check = new wxCheckBox( this, -1, "Non-destructive bar &friction",
wxPoint( lMargin, curY ) );
curY += checkHeight;
mpSPB_Check = new wxCheckBox( this, -1, "&Shaded pane borders",
wxPoint( lMargin, curY ) );
curY += checkHeight + lastItemGap;
wxStaticBox* pDNDBox = new wxStaticBox( this, -1, "Drag && Drop settings",
wxPoint( lBoxMargin, topY ),
wxSize( boxWidth, curY - topY ) );
curY += interBoxGap;
////////////////////////////////////////////////////////////////////
topY = curY;
curY += labelHeight;
mpHAP_Check = new wxCheckBox( this, ID_HINTANIM_CHECK,
"&Hint-Rect animation plugin",
wxPoint( lMargin, curY ) );
curY += checkHeight;
mpGCU_Check = new wxCheckBox( this, -1, "\"Garbage collecting\" &Updates-Mgr.",
wxPoint( lMargin, curY ) );
curY += checkHeight;
mpAFP_Check = new wxCheckBox( this, -1, "&Antiflicker plugin",
wxPoint( lMargin, curY ) );
curY += checkHeight;
mpCSP_Check = new wxCheckBox( this, -1, "C&ustomization plugin",
wxPoint( lMargin, curY ) );
curY += checkHeight + lastItemGap;
wxStaticBox* pPBox = new wxStaticBox( this, -1, "Plugins",
wxPoint( lBoxMargin, topY ),
wxSize( boxWidth, curY - topY ) );
curY += interBoxGap;
////////////////////////////////////////////////////////////////////
wxSize fieldSz( 30,20 );
int fieldHeight = 20;
int fieldCapMargin = lMargin + fieldSz.x + 5;
int fieldCapOfs = 4;
topY = curY;
curY += labelHeight;
mpRWInput = new wxTextCtrl ( this, -1, "",
wxPoint( lMargin, curY ),
fieldSz );
mpRWLabel = new wxStaticText ( this, -1, "Resizing sash width(height)",
wxPoint( fieldCapMargin, curY + fieldCapOfs ) );
curY += fieldHeight;
mpPTMInput = new wxTextCtrl ( this, -1, "",
wxPoint( lMargin, curY ),
fieldSz );
mpPTMLabel = new wxStaticText( this, -1, "Pene's top margin",
wxPoint( fieldCapMargin, curY + fieldCapOfs ) );
curY += fieldHeight;
mpPBMInput = new wxTextCtrl ( this, -1, "",
wxPoint( lMargin, curY ),
fieldSz );
mpPBMLabel = new wxStaticText( this, -1, "Pene's bottom margin",
wxPoint( fieldCapMargin, curY + fieldCapOfs ) );
curY += fieldHeight;
mpPLMInput = new wxTextCtrl ( this, -1, "",
wxPoint( lMargin, curY ),
fieldSz );
mpPLMLabel = new wxStaticText( this, -1, "Pane's left margin",
wxPoint( fieldCapMargin, curY + fieldCapOfs ) );
curY += fieldHeight;
mpPRMInput = new wxTextCtrl ( this, -1, "",
wxPoint( lMargin, curY ),
fieldSz );
mpPRMLabel = new wxStaticText( this, -1, "Pane's right margin",
wxPoint( fieldCapMargin, curY + fieldCapOfs ) );
curY += fieldHeight + lastItemGap;
wxStaticBox* pCPPBox = new wxStaticBox( this, -1, "Common Pane properties",
wxPoint( lBoxMargin, topY ),
wxSize( boxWidth, curY - topY ) );
curY += interBoxGap;
////////////////////////////////////////////////////////////////////
topY = curY;
curY += labelHeight;
fieldSz.x = 65;
fieldCapMargin = lMargin + fieldSz.x + 10;
mpDCInput = new wxTextCtrl ( this, -1, "",
wxPoint( lMargin, curY ),
fieldSz );
mpDCLabel = new wxStaticText ( this, -1, "Dark Color (hex-RGB)",
wxPoint( fieldCapMargin, curY + fieldCapOfs ) );
curY += fieldHeight;
mpLCInput = new wxTextCtrl ( this, -1, "",
wxPoint( lMargin, curY ),
fieldSz );
mpLCLabel = new wxStaticText ( this, -1, "Light Color (hex-RGB)",
wxPoint( fieldCapMargin, curY + fieldCapOfs ) );
curY += fieldHeight;
mpGCInput = new wxTextCtrl ( this, -1, "",
wxPoint( lMargin, curY ),
fieldSz );
mpGCLabel = new wxStaticText ( this, -1, "Gray Color (hex-RGB)",
wxPoint( fieldCapMargin, curY + fieldCapOfs ) );
curY += fieldHeight;
mpBCInput = new wxTextCtrl ( this, -1, "",
wxPoint( lMargin, curY ),
fieldSz );
mpBCLabel = new wxStaticText ( this, -1, "Pane border Color (hex-RGB)",
wxPoint( fieldCapMargin, curY + fieldCapOfs ) );
curY += fieldHeight + lastItemGap;
wxStaticBox* pCSPBox = new wxStaticBox( this, -1, "Coluor sheme properties",
wxPoint( lBoxMargin, topY ),
wxSize( boxWidth, curY - topY ) );
curY += interBoxGap; /*button ofs*/;
////////////////////////////////////////////////////////////////////////////////
int lBtnMargin = 35;
int btnGap = 20;
int btnHeight = 22;
int btnWidth = 70;
wxButton* mpApplyBtn = new wxButton( this, wxID_APPLY, "A&pply",
wxPoint( lBtnMargin, curY ),
wxSize( btnWidth, btnHeight ) );
wxButton* mpCancelBtn = new wxButton( this, wxID_CANCEL, "&Cancel",
wxPoint( lBtnMargin + btnWidth + btnGap, curY ),
wxSize( btnWidth, btnHeight ) );
wxButton* mpNotesBtn = new wxButton( this, ID_NOTES, "&Notes...",
wxPoint( lBtnMargin + 2*btnWidth + 2*btnGap, curY ),
wxSize( btnWidth, btnHeight ) );
mpApplyBtn->SetDefault();
mpApplyBtn->SetFocus();
Center( wxBOTH );
}
void SettingsDlg::ExchangeFields( bool toDialog )
{
mToDlg = toDialog;
ExchgCheck( mpRTU_Check, mRealTimeUpdatesOn );
ExchgCheck( mpOPD_Check, mOutOfPaneDragOn );
ExchgCheck( mpEDP_Check, mExactDockingPredictionOn );
ExchgCheck( mpNDF_Check, mNonDestructFrictionOn );
ExchgCheck( mpSPB_Check, m3DShadesOn );
ExchgCheck( mpHAP_Check, mHintRectAnimationOn );
ExchgCheck( mpGCU_Check, mGCUpdatesMgrOn );
ExchgCheck( mpAFP_Check, mAntiflickerPluginOn );
ExchgCheck( mpCSP_Check, mCustomizationPluginOn );
ExchgIntField( mpRWInput, mSashWidth );
ExchgIntField( mpPTMInput, mTopMargin );
ExchgIntField( mpPBMInput, mBottomMargin );
ExchgIntField( mpPLMInput, mLeftMargin );
ExchgIntField( mpPRMInput, mRightMargin );
ExchgColourField( mpDCInput, mDarkCol );
ExchgColourField( mpLCInput, mLightCol );
ExchgColourField( mpGCInput, mGrayCol );
ExchgColourField( mpBCInput, mBorderCol );
}
void SettingsDlg::OnApply( wxCommandEvent& event )
{
ExchangeFields( FALSE );
EndModal( wxID_APPLY );
}
void SettingsDlg::OnNotes( wxCommandEvent& event )
{
wxMessageBox("Notes go here...(TBD)");
}
void SettingsDlg::OnRTUpdatesCheck( wxCommandEvent& event )
{
if ( mpRTU_Check->GetValue() == TRUE )
{
// user probably wants to see how the real-time drag & drop
// works -- so we "let 'im know" that animation is N/A when
// real-time option is on
mpHAP_Check->SetValue(FALSE);
mpHAP_Check->Refresh();
}
}
void SettingsDlg::OnHintAnimCheck( wxCommandEvent& event )
{
if ( mpHAP_Check->GetValue() == TRUE )
{
// user probably wants to see some animation effects,
// but he/she forgot to turn off "real-time updates"
// setting -- so we do it for you :-)
mpRTU_Check->SetValue(FALSE);
mpRTU_Check->Refresh();
}
}
void SettingsDlg::ExchgCheck( wxCheckBox* pChk, bool& value )
{
if ( mToDlg ) pChk->SetValue( value );
else value = pChk->GetValue();
}
void SettingsDlg::ExchgIntField( wxTextCtrl* pFld, int& value )
{
if ( mToDlg )
{
char buf[32];
sprintf( buf, "%d", value );
pFld->SetValue( buf );
}
else
{
wxString txt = pFld->GetLineText( 0 );
value = atoi( txt );
}
}
void SettingsDlg::ExchgColourField( wxTextCtrl* pFld, wxColour& value )
{
int rgbVal;
if ( mToDlg )
{
rgbVal = ( value.Red() & 0x0000FF ) |
( (value.Green() << 8 ) & 0x00FF00 ) |
( (value.Blue() << 16 ) & 0xFF0000 );
char buf[32];
sprintf( buf, "0x%06X", rgbVal );
pFld->SetValue( buf );
}
else
{
wxString txt = pFld->GetLineText( 0 );
sscanf( txt, "0x%06X", &rgbVal );
value.Set( rgbVal & 0xFF,
( rgbVal >> 8 ) & 0xFF,
( rgbVal >> 16 ) & 0xFF );
}
}
bool SettingsDlg::TransferDataToWindow()
{
ExchangeFields( TRUE );
return TRUE;
}
bool SettingsDlg::TransferDataFromWindow()
{
ExchangeFields( FALSE );
return TRUE;
}
#include "controlbar.h"
#include "rowlayoutpl.h"
#include "antiflickpl.h"
#include "bardragpl.h"
#include "cbcustom.h"
#include "gcupdatesmgr.h"
#include "hintanimpl.h"
void SettingsDlg::ReadLayoutSettings( wxFrameLayout& fl )
{
cbDockPane& pane = *fl.GetPane( wxTOP );
cbCommonPaneProperties& props = pane.mProps;
mRealTimeUpdatesOn = props.mRealTimeUpdatesOn;
mOutOfPaneDragOn = props.mOutOfPaneDragOn;
mExactDockingPredictionOn = props.mExactDockPredictionOn;
mNonDestructFrictionOn = props.mNonDestructFirctionOn;
m3DShadesOn = props.mShow3DPaneBorderOn;
mHintRectAnimationOn = fl.FindPlugin( CLASSINFO( cbHintAnimationPlugin ) ) != NULL;
mAntiflickerPluginOn = fl.FindPlugin( CLASSINFO( cbAntiflickerPlugin ) ) != NULL;
mCustomizationPluginOn = fl.FindPlugin( CLASSINFO( cbSimpleCustomizationPlugin ) ) != NULL;
mGCUpdatesMgrOn = fl.GetUpdatesManager().GetClassInfo()
== CLASSINFO( cbGCUpdatesMgr );
mSashWidth = props.mResizeHandleSize;
mTopMargin = pane.mTopMargin;
mBottomMargin = pane.mBottomMargin;
mLeftMargin = pane.mLeftMargin;
mRightMargin = pane.mRightMargin;
mDarkCol = fl.mDarkPen.GetColour();
mLightCol = fl.mLightPen.GetColour();
mGrayCol = fl.mGrayPen.GetColour();
mBorderCol = fl.mBorderPen.GetColour();
}
void SettingsDlg::ApplyLayoutSettings( wxFrameLayout& fl )
{
cbCommonPaneProperties props;
props.mRealTimeUpdatesOn = mRealTimeUpdatesOn;
props.mOutOfPaneDragOn = mOutOfPaneDragOn;
props.mExactDockPredictionOn = mExactDockingPredictionOn;
props.mNonDestructFirctionOn = mNonDestructFrictionOn;
props.mShow3DPaneBorderOn = m3DShadesOn;
props.mResizeHandleSize = mSashWidth;
fl.SetPaneProperties( props, wxALL_PANES );
if ( mHintRectAnimationOn ) fl.AddPlugin ( CLASSINFO( cbHintAnimationPlugin ) );
else fl.RemovePlugin( CLASSINFO( cbHintAnimationPlugin ) );
if ( mAntiflickerPluginOn ) fl.AddPlugin ( CLASSINFO( cbAntiflickerPlugin ) );
else fl.RemovePlugin( CLASSINFO( cbAntiflickerPlugin ) );
if ( mCustomizationPluginOn ) fl.AddPlugin ( CLASSINFO( cbSimpleCustomizationPlugin ) );
else fl.RemovePlugin( CLASSINFO( cbSimpleCustomizationPlugin ) );
// FOR NOW:: unfortunatelly, currently pane marin-information is currently
// placed into cbDockPane, instead of cbCommonPaneProperties
fl.SetMargins( mTopMargin, mBottomMargin,
mLeftMargin, mRightMargin, wxALL_PANES );
fl.mDarkPen.SetColour( mDarkCol );
fl.mLightPen.SetColour( mLightCol );
fl.mGrayPen.SetColour( mGrayCol );
fl.mBorderPen.SetColour( mBorderCol );
fl.RecalcLayout( TRUE );
// NOTE:: currently it's bit tricky changing updates-manager
// in future, updates-manager will become a normal plugin
// and more convenient methods (Add/FindPlugin) will be used
if ( mGCUpdatesMgrOn &&
fl.GetUpdatesManager().GetClassInfo() != CLASSINFO( cbGCUpdatesMgr )
)
fl.SetUpdatesManager( new cbGCUpdatesMgr( &fl ) );
else
if ( !mGCUpdatesMgrOn &&
fl.GetUpdatesManager().GetClassInfo() == CLASSINFO( cbGCUpdatesMgr )
)
fl.SetUpdatesManager( new cbSimpleUpdatesMgr( &fl ) );
}

View File

@@ -0,0 +1,99 @@
#ifndef __SETTINGSDLG_G__
#define __SETTINGSDLG_G__
#include "wx/dialog.h"
class wxFrameLayout;
class SettingsDlg : public wxDialog
{
protected:
// "nice thing" about wxWindows:
wxCheckBox* mpRTU_Check;
wxCheckBox* mpOPD_Check;
wxCheckBox* mpEDP_Check;
wxCheckBox* mpNDF_Check;
wxCheckBox* mpSPB_Check;
wxCheckBox* mpHAP_Check;
wxCheckBox* mpGCU_Check;
wxCheckBox* mpAFP_Check;
wxCheckBox* mpCSP_Check;
wxTextCtrl* mpRWInput;
wxStaticText* mpRWLabel;
wxTextCtrl* mpPTMInput;
wxStaticText* mpPTMLabel;
wxTextCtrl* mpPBMInput;
wxStaticText* mpPBMLabel;
wxTextCtrl* mpPLMInput;
wxStaticText* mpPLMLabel;
wxTextCtrl* mpPRMInput;
wxStaticText* mpPRMLabel;
wxTextCtrl* mpDCInput;
wxStaticText* mpDCLabel;
wxTextCtrl* mpLCInput;
wxStaticText* mpLCLabel;
wxTextCtrl* mpGCInput;
wxStaticText* mpGCLabel;
wxTextCtrl* mpBCInput;
wxStaticText* mpBCLabel;
// fields/properties
bool mRealTimeUpdatesOn;
bool mOutOfPaneDragOn;
bool mExactDockingPredictionOn;
bool mNonDestructFrictionOn;
bool m3DShadesOn;
bool mHintRectAnimationOn;
bool mGCUpdatesMgrOn;
bool mAntiflickerPluginOn;
bool mCustomizationPluginOn;
int mSashWidth;
int mTopMargin;
int mBottomMargin;
int mLeftMargin;
int mRightMargin;
wxColour mDarkCol;
wxColour mLightCol;
wxColour mGrayCol;
wxColour mBorderCol;
protected:
bool mToDlg;
// helpers
void ExchgCheck( wxCheckBox* pChk, bool& value );
void ExchgIntField( wxTextCtrl* pFld, int& value );
void ExchgColourField( wxTextCtrl* pFld, wxColour& value );
virtual bool TransferDataToWindow();
virtual bool TransferDataFromWindow();
public:
SettingsDlg( wxWindow* pParent );
void ReadLayoutSettings( wxFrameLayout& fl );
void ApplyLayoutSettings( wxFrameLayout& fl );
void ExchangeFields( bool toDialog );
void OnApply( wxCommandEvent& event );
void OnNotes( wxCommandEvent& event );
void OnHintAnimCheck( wxCommandEvent& event );
void OnRTUpdatesCheck( wxCommandEvent& event );
DECLARE_EVENT_TABLE();
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,210 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 06/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __TOOLWND_G__
#define __TOOLWND_G__
#include "wx/frame.h"
#include "wx/dynarray.h"
// fixed settings
#define BTN_BOX_HEIGHT 12
#define BTN_BOX_WIDTH 12
#define BTN_X_WIEGHT 2
class cbMiniButton;
typedef cbMiniButton* cbMinitButtonPtrT;
WX_DEFINE_ARRAY( cbMinitButtonPtrT, cbMiniButtonArrayT );
class wxToolWindow : public wxFrame
{
DECLARE_DYNAMIC_CLASS( wxToolWindow )
public: /** protected really, accesssed only by serializers **/
cbMiniButtonArrayT mButtons;
wxWindow* mpClientWnd;
wxFont mTitleFont;
int mTitleHeight;
int mClntHorizGap;
int mClntVertGap;
int mWndVertGap;
int mWndHorizGap;
int mButtonGap;
int mInTitleMargin;
int mHintBorder;
bool mResizeStarted;
bool mRealTimeUpdatesOn;
int mMTolerance;
int mCursorType;
bool mMouseCaptured;
// drag&drop state variables
wxPoint mDragOrigin;
wxRect mInitialRect;
wxRect mPrevHintRect;
wxScreenDC* mpScrDc;
protected:
void GetScrWindowRect( wxRect& r );
void GetScrMousePos ( wxMouseEvent& event, wxPoint& pos );
void SetHintCursor ( int type );
void CalcResizedRect( wxRect& rect, wxPoint& delta, const wxSize& minDim );
void AdjustRectPos( const wxRect& original, const wxSize& newDim, wxRect& newRect );
wxSize GetMinimalWndDim();
void DrawHintRect( const wxRect& r );
int HitTestWindow( wxMouseEvent& event );
void LayoutMiniButtons();
public:
wxToolWindow();
~wxToolWindow();
void SetClient( wxWindow* pWnd );
wxWindow* GetClient();
void SetTitleFont( wxFont& font );
// buttons are added in right-to-left order
void AddMiniButton( cbMiniButton* pBtn );
void OnPaint( wxPaintEvent& event );
void OnMotion( wxMouseEvent& event );
void OnLeftDown( wxMouseEvent& event );
void OnLeftUp( wxMouseEvent& event );
void OnSize( wxSizeEvent& event );
void OnEraseBackground( wxEraseEvent& event );
// overridables:
virtual wxSize GetPreferredSize( const wxSize& given );
virtual void OnMiniButtonClicked( int btnIdx ) {}
virtual bool HandleTitleClick( wxMouseEvent& event ) { return FALSE; }
DECLARE_EVENT_TABLE()
};
// FIXME:: the code below should be moved to a separate file
#include "controlbar.h"
class cbMiniButton : public wxObject
{
public:
wxPoint mPos;
wxSize mDim;
bool mVisible;
bool mEnabled;
wxFrameLayout* mpLayout;
cbDockPane* mpPane;
cbPluginBase* mpPlugin;
wxWindow* mpWnd;
bool mWasClicked;
bool mDragStarted;
bool mPressed;
public:
cbMiniButton();
void SetPos( const wxPoint& pos );
bool HitTest( const wxPoint& pos );
void OnLeftDown( const wxPoint& pos );
void OnLeftUp( const wxPoint& pos );
void OnMotion( const wxPoint& pos );
void Refresh();
virtual void Draw( wxDC& dc );
bool WasClicked();
void Reset();
void Enable( bool enable ) { mEnabled = enable; }
bool IsPressed() { return mPressed; }
};
// classes specific to wxFrameLayout engine (FOR NOW in here...)
class cbCloseBox : public cbMiniButton
{
public:
virtual void Draw( wxDC& dc );
};
class cbCollapseBox : public cbMiniButton
{
public:
bool mIsAtLeft;
virtual void Draw( wxDC& dc );
};
class cbDockBox : public cbMiniButton
{
public:
virtual void Draw( wxDC& dc );
};
class cbFloatedBarWindow : public wxToolWindow
{
DECLARE_DYNAMIC_CLASS( cbFloatedBarWindow )
protected:
cbBarInfo* mpBar;
wxFrameLayout* mpLayout;
friend class cbFloatedBarWindowSerializer;
public:
cbFloatedBarWindow();
void SetBar( cbBarInfo* pBar );
void SetLayout( wxFrameLayout* pLayout );
cbBarInfo* GetBar();
// given coordinates are those of the bar itself
// floated container window's position and size
// are ajusted accordingly
void PositionFloatedWnd( int scrX, int scrY,
int width, int height );
// overriden methods of wxToolWindow
virtual wxSize GetPreferredSize( const wxSize& given );
virtual void OnMiniButtonClicked( int btnIdx );
virtual bool HandleTitleClick( wxMouseEvent& event );
void OnDblClick( wxMouseEvent& event );
DECLARE_EVENT_TABLE()
};
#endif

View File

@@ -0,0 +1,292 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 19/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "updatesmgr.h"
// #pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "updatesmgr.h"
// helper function
static inline bool rect_hits_rect( const wxRect& r1, const wxRect& r2 )
{
if ( ( r2.x >= r1.x && r2.x <= r1.x + r1.width ) ||
( r1.x >= r2.x && r1.x <= r2.x + r2.width ) )
if ( ( r2.y >= r1.y && r2.y <= r1.y + r1.height ) ||
( r1.y >= r2.y && r1.y <= r2.y + r2.height ) )
return 1;
return 0;
}
/***** Implementation for class cbSimpleUpdatesMgr *****/
IMPLEMENT_DYNAMIC_CLASS( cbSimpleUpdatesMgr, cbUpdatesManagerBase )
cbSimpleUpdatesMgr::cbSimpleUpdatesMgr( wxFrameLayout* pPanel )
: cbUpdatesManagerBase( pPanel )
{}
bool cbSimpleUpdatesMgr::WasChanged( cbUpdateMgrData& data, wxRect& currentBounds )
{
return ( data.IsDirty() ||
( data.mPrevBounds.x != currentBounds.x ||
data.mPrevBounds.y != currentBounds.y ||
data.mPrevBounds.width != currentBounds.width ||
data.mPrevBounds.height != currentBounds.height )
);
}
void cbSimpleUpdatesMgr::OnStartChanges()
{
// memorize states of ALL items in the layout -
// this is quite excessive, but OK for the simple
// implementation of updates manager
mpLayout->GetPrevClientRect() = mpLayout->GetClientRect();
cbDockPane** panes = mpLayout->GetPanesArray();
for( int n = 0; n != MAX_PANES; ++n )
{
cbDockPane& pane = *panes[n];
// store pane state
pane.mUMgrData.StoreItemState( pane.mBoundsInParent );
pane.mUMgrData.SetDirty( FALSE );
for( size_t i = 0; i != pane.GetRowList().Count(); ++i )
{
cbRowInfo& row = *pane.GetRowList()[ i ];
// store row state
row.mUMgrData.StoreItemState( row.mBoundsInParent );
row.mUMgrData.SetDirty( FALSE );
for( size_t k = 0; k != row.mBars.Count(); ++k )
{
cbBarInfo& bar = *row.mBars[ k ];
// store bar state
bar.mUMgrData.StoreItemState( bar.mBoundsInParent );
bar.mUMgrData.SetDirty( FALSE );
}
}
}
}
void cbSimpleUpdatesMgr::OnFinishChanges()
{
// nothing here, could be overriden by more sophisticated updates-managers
}
void cbSimpleUpdatesMgr::OnRowWillChange( cbRowInfo* pRow, cbDockPane* pInPane )
{
// -/-
}
void cbSimpleUpdatesMgr::OnBarWillChange( cbBarInfo* pBar,
cbRowInfo* pInRow, cbDockPane* pInPane )
{
// -/-
}
void cbSimpleUpdatesMgr::OnPaneMarginsWillChange( cbDockPane* pPane )
{
// -/-
}
void cbSimpleUpdatesMgr::OnPaneWillChange( cbDockPane* pPane )
{
// -/-
}
void cbSimpleUpdatesMgr::UpdateNow()
{
cbDockPane** panes = mpLayout->GetPanesArray();
wxRect& r1 = mpLayout->GetClientRect();
wxRect& r2 = mpLayout->GetPrevClientRect();
// detect changes in client window's area
bool clientWindowChanged = ( r1.x != r2.x ||
r1.y != r2.y ||
r1.width != r2.width ||
r1.height != r2.height );
// step #1 - detect changes in each row of each pane,
// and repaint decorations around changed windows
wxList mBarsToRefresh;
wxList mPanesList;
for( int n = 0; n != MAX_PANES; ++n )
{
cbDockPane& pane = *(panes[n]);
bool paneChanged = WasChanged( pane.mUMgrData, pane.mBoundsInParent );
if ( paneChanged )
{
wxClientDC dc( &mpLayout->GetParentFrame() );
pane.PaintPaneBackground( dc );
}
wxRect realBounds;
for( size_t i = 0; i != pane.GetRowList().Count(); ++i )
{
cbRowInfo& row = *pane.GetRowList()[ i ];
wxDC* pDc = NULL;
bool rowChanged = FALSE;
bool rowBkPainted = FALSE;
// FIXME:: the below should not be fixed
cbBarInfo* barsToRepaint[256];
// number of bars, that were changed in the current row
int nBars = 0;
if ( WasChanged( row.mUMgrData, row.mBoundsInParent ) )
rowChanged = TRUE;
else
for( size_t k = 0; k != row.mBars.Count(); ++k )
if ( WasChanged( row.mBars[k]->mUMgrData,
row.mBars[k]->mBoundsInParent )
)
barsToRepaint[nBars++] = row.mBars[k];
if ( nBars || rowChanged )
{
realBounds = row.mBoundsInParent;
// include 1-pixel thick shades around the row
realBounds.x -= 1;
realBounds.y -= 1;
realBounds.width += 2;
realBounds.height += 2;
pDc = pane.StartDrawInArea( realBounds );
}
if ( rowChanged )
{
// postphone the resizing and refreshing the changed
// bar windows
for( size_t k = 0; k != row.mBars.Count(); ++k )
{
mBarsToRefresh.Append( (wxObject*)row.mBars[k] );
mPanesList.Append( &pane );
}
// draw only their decorations now
pane.PaintRow( &row, *pDc );
}
else
if ( nBars != 0 )
{
for( int i = 0; i != nBars; ++i )
{
// postphone the resizement and refreshing the changed
// bar windows
mBarsToRefresh.Append( (wxObject*)barsToRepaint[i] );
mPanesList.Append( &pane );
}
// redraw decorations of entire row, regardless of how much
// of the bars were changed
pane.PaintRow( &row, *pDc );
}
if ( pDc )
pane.FinishDrawInArea( realBounds );
} // end of while
if ( paneChanged )
{
wxClientDC dc( &mpLayout->GetParentFrame() );
pane.PaintPaneDecorations( dc );
}
} // end of for
if ( clientWindowChanged )
{
mpLayout->PositionClientWindow();
// ptr to client-window object is "marked" as 0
}
// step #2 - do ordered refreshing and resizing of bar window objects now
wxNode* pNode = mBarsToRefresh.First();
wxNode* pPaneNode = mPanesList.First();
while( pNode )
{
cbBarInfo* pBar = (cbBarInfo*) pNode->Data();
cbDockPane* pPane = (cbDockPane*)pPaneNode->Data();
pPane->SizeBar( pBar );
pNode = pNode->Next();
pPaneNode = pPaneNode->Next();
}
pNode = mBarsToRefresh.First();
while( pNode )
{
cbBarInfo* pBar = (cbBarInfo*)pNode->Data();
if ( pBar->mpBarWnd )
{
pBar->mpBarWnd->Refresh();
// FIXME::
//info.mpBarWnd->Show(FALSE);
//info.mpBarWnd->Show(TRUE);
}
pNode = pNode->Next();
}
if ( clientWindowChanged )
{
// FIXME:: excessive?
mpLayout->GetFrameClient()->Refresh();
}
}

View File

@@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas (@Lithuania)
// Modified by:
// Created: 19/10/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __UPDATESMGR_G__
#define __UPDATESMGR_G__
#include "controlbar.h"
/*
* class implements slightly optimized logic for refreshing
* areas of frame layout - which actually need to be updated.
*/
class cbSimpleUpdatesMgr : public cbUpdatesManagerBase
{
DECLARE_DYNAMIC_CLASS( cbSimpleUpdatesMgr )
protected:
bool WasChanged( cbUpdateMgrData& data, wxRect& currentBounds );
public:
cbSimpleUpdatesMgr(void) {}
cbSimpleUpdatesMgr( wxFrameLayout* pPanel );
// notificiactions received from Frame Layout (in the order, in which
// they usually would be invoked)
virtual void OnStartChanges();
virtual void OnRowWillChange( cbRowInfo* pRow, cbDockPane* pInPane );
virtual void OnBarWillChange( cbBarInfo* pBar, cbRowInfo* pInRow, cbDockPane* pInPane );
virtual void OnPaneMarginsWillChange( cbDockPane* pPane );
virtual void OnPaneWillChange( cbDockPane* pPane );
virtual void OnFinishChanges();
// refreshes parts of the frame layout, which need an update
virtual void UpdateNow();
};
#endif

View File

@@ -0,0 +1,159 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 23/11/98
// RCS-ID: $Id$
// Copyright: 1998 (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "wxinifo.cpp"
#pragma interface "wxinifo.cpp"
#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
#include "wx/hash.h"
#include "wxinfo.h"
inline static void expand_item( wxTreeCtrl* pTree, wxTreeItemId& itemId )
{
pTree->Expand( itemId );
}
void wxCreateClassInfoTree( wxTreeCtrl* pTree,
wxTreeItemId parentBranchId,
long classImageNo
)
{
expand_item( pTree, parentBranchId );
wxHashTable hash;
wxList lst;
// collect all classes into list
{
wxClassInfo* pCur = wxClassInfo::GetFirst();
wxClassInfo::InitializeClasses();
while( pCur )
{
lst.Append( (wxObject*)pCur );
pCur = pCur->GetNext();
}
}
wxClassInfo::InitializeClasses();
// reflect class-hierarchy into the tree nodes
int nHanged;
do
{
nHanged = 0;
wxNode* pCur = lst.First();
// repeat passes through class list, untill all of
// the class items are "hanged" onto their parent-items in the tree
while( pCur )
{
wxClassInfo& info = *((wxClassInfo*)pCur->Data());
if ( info.GetBaseClass1() == NULL )
{
// parentless classes are put into the root branch
wxTreeItemId* pId = new wxTreeItemId();
*pId = pTree->AppendItem( parentBranchId, info.GetClassName(), classImageNo );
expand_item( pTree, *pId );
// "remember" it
hash.Put( long(&info), (wxObject*)pId );
// class is "hanged", remove it from the list
wxNode* pTmp = pCur;
pCur = pCur->Next();
delete pTmp;
++nHanged;
}
else
{
wxTreeItemId* pParentId = (wxTreeItemId*)hash.Get( (long)info.GetBaseClass1() );
if ( pParentId != NULL )
{
wxTreeItemId* pId = new wxTreeItemId();
*pId = pTree->AppendItem( *pParentId, info.GetClassName(), classImageNo );
expand_item( pTree, *pId );
hash.Put( long(&info), (wxObject*)pId );
wxNode* pTmp = pCur;
pCur = pCur->Next();
// class is "hanged", remove it from the list
delete pTmp;
++nHanged;
}
else
{
// otherwise there's a parent, but it's not in the tree yet...
// hope to "hang" it in the subsequent passes
pCur = pCur->Next();
}
}
}
} while( nHanged != 0 );
}
void wxCreateSerializerInfoTree( wxTreeCtrl* pTree,
wxTreeItemId parentBranchId,
long classImageNo
)
{
expand_item( pTree, parentBranchId );
wxSerializerInfo::InitializeSerializers();
// FOR NOW:: no hierarchy - one branch
wxSerializerInfo* pCur = wxSerializerInfo::first;
while( pCur )
{
wxString fullName = pCur->className + wxString( "Serializer" );
pTree->AppendItem( parentBranchId, fullName, classImageNo );
pCur = pCur->next;
}
}

View File

@@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////
// Name: No names yet.
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by:
// Created: 23/11/98
// RCS-ID: $Id$
// Copyright: 1998 (c) Aleksandras Gluchovas
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __WXINFO_G__
#define __WXINFO_G__
#include "wx/object.h"
#include "wx/treectrl.h"
#include "objstore.h"
/*
* creates tree with hierarchically cauptured
* information about wxWindows dynamic classes (at "current run-time")
*/
void wxCreateClassInfoTree( wxTreeCtrl* pTree,
wxTreeItemId parentBranchId,
long classImageNo = -1
);
/*
* creates tree with information about
* serializer-classes (at current run-time)
* NOTE:: "objstore.cpp" should be compiled in
*/
void wxCreateSerializerInfoTree( wxTreeCtrl* pTree, // existing tree control
wxTreeItemId parentBranchId,
long classImageNo = -1 // (-1) - text only
);
#endif