Added serial code for wxList and wxHashTable to source tree

Added a few accessors to wxList (for above)
  Fixed bug with GetClientSize() and sunken frames without
  scrollbars
  Made pixel corrections to wxListCtrl and wxFrame
  Added a few pixels before first tool in toolbar
  Added a few wxCHECKs here and there


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1121 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-12-07 08:27:06 +00:00
parent ef5390661e
commit 907789a0f7
18 changed files with 801 additions and 752 deletions

View File

@@ -195,11 +195,25 @@ public:
size_t GetCount() const { return m_count; } size_t GetCount() const { return m_count; }
// operations // operations
// delete all nodes // delete all nodes
void Clear(); void Clear();
// instruct it to destroy user data when deleting nodes // instruct it to destroy user data when deleting nodes
void DeleteContents(bool destroy) { m_destroy = destroy; } void DeleteContents(bool destroy) { m_destroy = destroy; }
// query if to delete
bool GetDeleteContents() const
{ return m_destroy; }
// get the keytype
wxKeyType GetKeyType() const
{ return m_keyType; }
// set the keytype (required by the serial code)
void SetKeyType(wxKeyType keyType)
{ wxASSERT( m_count==0 ); m_keyType = keyType; }
protected: protected:
// all methods here are "overloaded" in derived classes to provide compile // all methods here are "overloaded" in derived classes to provide compile
// time type checking // time type checking
@@ -271,7 +285,7 @@ protected:
void *FirstThat(wxListIterateFunction func); void *FirstThat(wxListIterateFunction func);
void ForEach(wxListIterateFunction func); void ForEach(wxListIterateFunction func);
void *LastThat(wxListIterateFunction func); void *LastThat(wxListIterateFunction func);
private: private:
// helpers // helpers
// common part of all ctors // common part of all ctors

View File

@@ -54,4 +54,7 @@ IMPLEMENT_DYNAMIC_CLASS(classname##_Serialize, parent##_Serialize)
#define IMPLEMENT_ALIAS_SERIAL_CLASS(classname, parent) \ #define IMPLEMENT_ALIAS_SERIAL_CLASS(classname, parent) \
IMPLEMENT_DYNAMIC_CLASS(classname##_Serialize, parent##_Serialize) IMPLEMENT_DYNAMIC_CLASS(classname##_Serialize, parent##_Serialize)
DECLARE_SERIAL_CLASS(wxList, wxObject)
DECLARE_SERIAL_CLASS(wxHashTable, wxObject)
#endif #endif

View File

@@ -25,6 +25,10 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#ifndef __WXMSW__
#include "mondrian.xpm"
#endif
#include "wx/listctrl.h" #include "wx/listctrl.h"
#include "listtest.h" #include "listtest.h"
@@ -65,15 +69,10 @@ bool MyApp::OnInit(void)
// This reduces flicker effects - even better would be to define OnEraseBackground // This reduces flicker effects - even better would be to define OnEraseBackground
// to do nothing. When the list control's scrollbars are show or hidden, the // to do nothing. When the list control's scrollbars are show or hidden, the
// frame is sent a background erase event. // frame is sent a background erase event.
frame->SetBackgroundColour(wxColour(255, 255, 255)); frame->SetBackgroundColour( *wxWHITE );
// Give it an icon // Give it an icon
#ifdef __WXMSW__ frame->SetIcon( wxICON(mondrian) );
frame->SetIcon(wxIcon("mondrian"));
#else
#include "mondrian.xpm"
frame->SetIcon(wxIcon(mondrian_xpm));
#endif
// Make an image list containing large icons // Make an image list containing large icons
m_imageListNormal = new wxImageList(32, 32, TRUE); m_imageListNormal = new wxImageList(32, 32, TRUE);

View File

@@ -45,7 +45,7 @@ bool MyApp::OnInit(void)
{ {
// Create the main frame window // Create the main frame window
MyFrame* frame = new MyFrame((wxFrame *) NULL, -1, (const wxString) "wxMiniFrame sample", MyFrame* frame = new MyFrame((wxFrame *) NULL, -1, (const wxString) "wxMiniFrame sample",
wxPoint(100, 100), wxSize(200, 42)); wxPoint(100, 100), wxSize(205, 45));
#ifdef __WXMSW__ #ifdef __WXMSW__
frame->SetIcon(wxIcon("mondrian")); frame->SetIcon(wxIcon("mondrian"));

View File

@@ -10,13 +10,15 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "stream.h" #pragma implementation "serbase.h"
#endif #endif
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
#include <wx/serbase.h> #include "wx/serbase.h"
#include "wx/datstrm.h"
#include "wx/objstrm.h"
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
@@ -28,4 +30,91 @@
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxObject_Serialize,wxObject) IMPLEMENT_DYNAMIC_CLASS(wxObject_Serialize,wxObject)
IMPLEMENT_SERIAL_CLASS(wxList, wxObject)
IMPLEMENT_SERIAL_CLASS(wxHashTable, wxObject)
#endif #endif
void WXSERIAL(wxList)::StoreObject(wxObjectOutputStream& s)
{
wxList *lst_object = (wxList *)Object();
wxNode *node = lst_object->First();
if (s.FirstStage()) {
while (node) {
s.AddChild(node->Data());
node = node->Next();
}
return;
}
wxDataOutputStream data_s(s);
data_s.Write8(lst_object->GetDeleteContents());
data_s.Write8(lst_object->GetKeyType());
data_s.Write32( lst_object->Number() );
if (lst_object->GetKeyType() == wxKEY_INTEGER) {
while (node) {
data_s.Write32(node->GetKeyInteger());
node = node->Next();
}
} else {
while (node) {
data_s.WriteString(node->GetKeyString());
node = node->Next();
}
}
}
void WXSERIAL(wxList)::LoadObject(wxObjectInputStream& s)
{
wxDataInputStream data_s(s);
wxList *list = (wxList *)Object();
int number, i;
list->DeleteContents( data_s.Read8() );
list->SetKeyType( (wxKeyType) data_s.Read8() );
number = data_s.Read32();
if (list->GetKeyType() == wxKEY_INTEGER) {
for (i=0;i<number;i++)
list->Append( data_s.Read32(), s.GetChild() );
} else {
for (i=0;i<number;i++)
list->Append( data_s.ReadString(), s.GetChild() );
}
}
// ----------------------------------------------------------------------------
void WXSERIAL(wxHashTable)::StoreObject(wxObjectOutputStream& s)
{
wxHashTable *table = (wxHashTable *)Object();
int i;
if (s.FirstStage()) {
for (i=0;i<table->n;i++)
s.AddChild(table->hash_table[i]);
return;
}
wxDataOutputStream data_s(s);
data_s.Write8(table->key_type);
data_s.Write32(table->n);
}
void WXSERIAL(wxHashTable)::LoadObject(wxObjectInputStream& s)
{
wxHashTable *table = (wxHashTable *)Object();
wxDataInputStream data_s(s);
int i, key, n;
key = data_s.Read8();
n = data_s.Read32();
table->Create(key, n);
for (i=0;i<n;i++)
table->hash_table[i] = (wxList *)s.GetChild();
}

View File

@@ -700,15 +700,17 @@ void wxListHeaderWindow::DoDrawRect( wxPaintDC *dc, int x, int y, int w, int h )
dc->DrawLine( x+w-m_corner+1, y, x+w, y+h ); // right (outer) dc->DrawLine( x+w-m_corner+1, y, x+w, y+h ); // right (outer)
dc->DrawRectangle( x, y+h, w, 1 ); // bottom (outer) dc->DrawRectangle( x, y+h, w, 1 ); // bottom (outer)
dc->SetPen( *wxMEDIUM_GREY_PEN ); wxPen pen( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNSHADOW ), 1, wxSOLID );
dc->SetPen( pen );
dc->DrawLine( x+w-m_corner, y, x+w-1, y+h ); // right (inner) dc->DrawLine( x+w-m_corner, y, x+w-1, y+h ); // right (inner)
dc->DrawRectangle( x+1, y+h-1, w-2, 1 ); // bottom (inner) dc->DrawRectangle( x+1, y+h-1, w-2, 1 ); // bottom (inner)
dc->SetPen( *wxWHITE_PEN ); dc->SetPen( *wxWHITE_PEN );
dc->DrawRectangle( x, y, w-m_corner+1, 1 ); // top (outer) dc->DrawRectangle( x, y, w-m_corner+1, 1 ); // top (outer)
// dc->DrawRectangle( x, y+1, w-m_corner, 1 ); // top (inner)
dc->DrawRectangle( x, y, 1, h ); // left (outer) dc->DrawRectangle( x, y, 1, h ); // left (outer)
// dc->DrawRectangle( x+1, y, 1, h-1 ); // left (inner) dc->DrawLine( x, y+h-1, x+1, y+h-1 );
dc->DrawLine( x+w-1, y, x+w-1, y+1 );
} }
void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
@@ -2263,6 +2265,8 @@ bool wxListCtrl::Create( wxWindow *parent, wxWindowID id,
bool ret = wxControl::Create( parent, id, pos, size, s, name ); bool ret = wxControl::Create( parent, id, pos, size, s, name );
SetValidator( validator ); SetValidator( validator );
if (s & wxSUNKEN_BORDER) s -= wxSUNKEN_BORDER;
m_mainWin = new wxListMainWindow( this, -1, wxPoint(0,0), size, s ); m_mainWin = new wxListMainWindow( this, -1, wxPoint(0,0), size, s );

View File

@@ -25,7 +25,7 @@
// constants // constants
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const int wxMENU_HEIGHT = 30; const int wxMENU_HEIGHT = 27;
const int wxSTATUS_HEIGHT = 25; const int wxSTATUS_HEIGHT = 25;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -222,7 +222,7 @@ wxPoint wxFrame::GetClientAreaOrigin() const
{ {
int h = 0; int h = 0;
m_frameMenuBar->GetSize( (int*)NULL, &h ); m_frameMenuBar->GetSize( (int*)NULL, &h );
pt.y += h + 2; pt.y += h;
} }
if (m_frameToolBar) if (m_frameToolBar)
{ {
@@ -381,10 +381,10 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
int xx = 1 + m_miniEdge; int xx = m_miniEdge;
int yy = 1 + m_miniEdge + m_miniTitle; int yy = m_miniEdge + m_miniTitle;
int ww = m_width - 2 - 2*m_miniEdge; int ww = m_width - 2*m_miniEdge;
int hh = wxMENU_HEIGHT-2; int hh = wxMENU_HEIGHT;
m_frameMenuBar->m_x = xx; m_frameMenuBar->m_x = xx;
m_frameMenuBar->m_y = yy; m_frameMenuBar->m_y = yy;
m_frameMenuBar->m_width = ww; m_frameMenuBar->m_width = ww;
@@ -396,10 +396,10 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
if (m_frameToolBar) if (m_frameToolBar)
{ {
int xx = 1 + m_miniEdge; int xx = m_miniEdge;
int yy = m_miniEdge + m_miniTitle; int yy = m_miniEdge + m_miniTitle;
if (m_frameMenuBar) yy += wxMENU_HEIGHT; if (m_frameMenuBar) yy += wxMENU_HEIGHT;
int ww = m_width -2 - 2*m_miniEdge; int ww = m_width - 2*m_miniEdge;
int hh = m_frameToolBar->m_height; int hh = m_frameToolBar->m_height;
m_frameToolBar->m_x = xx; m_frameToolBar->m_x = xx;

View File

@@ -21,7 +21,7 @@
// constants // constants
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const int wxMENU_HEIGHT = 30; const int wxMENU_HEIGHT = 27;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// globals // globals
@@ -120,12 +120,12 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
if (m_mdiMenuBar) if (m_mdiMenuBar)
{ {
m_mdiMenuBar->m_x = 1; m_mdiMenuBar->m_x = 0;
m_mdiMenuBar->m_y = 1; m_mdiMenuBar->m_y = 0;
m_mdiMenuBar->m_width = m_width-2; m_mdiMenuBar->m_width = m_width;
m_mdiMenuBar->m_height = wxMENU_HEIGHT-2; m_mdiMenuBar->m_height = wxMENU_HEIGHT;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 1, 1 ); gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 0, 0 );
gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 ); gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width, wxMENU_HEIGHT );
} }
} }
@@ -135,12 +135,12 @@ void wxMDIParentFrame::SetMDIMenuBar( wxMenuBar *menu_bar )
m_mdiMenuBar = menu_bar; m_mdiMenuBar = menu_bar;
if (m_mdiMenuBar) if (m_mdiMenuBar)
{ {
m_mdiMenuBar->m_x = 1; m_mdiMenuBar->m_x = 0;
m_mdiMenuBar->m_y = 1; m_mdiMenuBar->m_y = 0;
m_mdiMenuBar->m_width = m_width-2; m_mdiMenuBar->m_width = m_width;
m_mdiMenuBar->m_height = wxMENU_HEIGHT-2; m_mdiMenuBar->m_height = wxMENU_HEIGHT;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 1, 1 ); gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 0, 0 );
gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 ); gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width, wxMENU_HEIGHT );
m_mdiMenuBar->Show( TRUE ); m_mdiMenuBar->Show( TRUE );
} }
} }

View File

@@ -20,33 +20,33 @@
class wxPenRefData: public wxObjectRefData class wxPenRefData: public wxObjectRefData
{ {
public: public:
wxPenRefData(void); wxPenRefData(void);
wxPenRefData(const wxPenRefData& data); wxPenRefData(const wxPenRefData& data);
int m_width; int m_width;
int m_style; int m_style;
int m_joinStyle; int m_joinStyle;
int m_capStyle; int m_capStyle;
wxColour m_colour; wxColour m_colour;
}; };
wxPenRefData::wxPenRefData(void) wxPenRefData::wxPenRefData()
{ {
m_width = 1; m_width = 1;
m_style = wxSOLID; m_style = wxSOLID;
m_joinStyle = wxJOIN_ROUND; m_joinStyle = wxJOIN_ROUND;
m_capStyle = wxCAP_ROUND; m_capStyle = wxCAP_ROUND;
} }
wxPenRefData::wxPenRefData( const wxPenRefData& data ) wxPenRefData::wxPenRefData( const wxPenRefData& data )
{ {
m_style = data.m_style; m_style = data.m_style;
m_width = data.m_width; m_width = data.m_width;
m_joinStyle = data.m_joinStyle; m_joinStyle = data.m_joinStyle;
m_capStyle = data.m_capStyle; m_capStyle = data.m_capStyle;
m_colour = data.m_colour; m_colour = data.m_colour;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -57,162 +57,142 @@ IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
wxPen::wxPen(void) wxPen::wxPen(void)
{ {
if (wxThePenList) wxThePenList->AddPen( this ); if (wxThePenList) wxThePenList->AddPen( this );
} }
wxPen::wxPen( const wxColour &colour, int width, int style ) wxPen::wxPen( const wxColour &colour, int width, int style )
{ {
m_refData = new wxPenRefData(); m_refData = new wxPenRefData();
M_PENDATA->m_width = width; M_PENDATA->m_width = width;
M_PENDATA->m_style = style; M_PENDATA->m_style = style;
M_PENDATA->m_colour = colour; M_PENDATA->m_colour = colour;
if (wxThePenList) wxThePenList->AddPen( this ); if (wxThePenList) wxThePenList->AddPen( this );
} }
wxPen::wxPen( const wxPen& pen ) wxPen::wxPen( const wxPen& pen )
{ {
Ref( pen ); Ref( pen );
if (wxThePenList) wxThePenList->AddPen( this ); if (wxThePenList) wxThePenList->AddPen( this );
} }
wxPen::wxPen( const wxPen* pen ) wxPen::wxPen( const wxPen* pen )
{ {
UnRef(); UnRef();
if (pen) Ref( *pen ); if (pen) Ref( *pen );
if (wxThePenList) wxThePenList->AddPen( this ); if (wxThePenList) wxThePenList->AddPen( this );
} }
wxPen::~wxPen(void) wxPen::~wxPen()
{ {
if (wxThePenList) wxThePenList->RemovePen( this ); if (wxThePenList) wxThePenList->RemovePen( this );
} }
wxPen& wxPen::operator = ( const wxPen& pen ) wxPen& wxPen::operator = ( const wxPen& pen )
{ {
if (*this == pen) return (*this); if (*this == pen) return (*this);
Ref( pen ); Ref( pen );
return *this; return *this;
} }
bool wxPen::operator == ( const wxPen& pen ) bool wxPen::operator == ( const wxPen& pen )
{ {
return m_refData == pen.m_refData; return m_refData == pen.m_refData;
} }
bool wxPen::operator != ( const wxPen& pen ) bool wxPen::operator != ( const wxPen& pen )
{ {
return m_refData != pen.m_refData; return m_refData != pen.m_refData;
} }
void wxPen::SetColour( const wxColour &colour ) void wxPen::SetColour( const wxColour &colour )
{ {
Unshare(); Unshare();
M_PENDATA->m_colour = colour; M_PENDATA->m_colour = colour;
} }
void wxPen::SetColour( int red, int green, int blue ) void wxPen::SetColour( int red, int green, int blue )
{ {
Unshare(); Unshare();
M_PENDATA->m_colour.Set( red, green, blue ); M_PENDATA->m_colour.Set( red, green, blue );
} }
void wxPen::SetCap( int capStyle ) void wxPen::SetCap( int capStyle )
{ {
Unshare(); Unshare();
M_PENDATA->m_capStyle = capStyle; M_PENDATA->m_capStyle = capStyle;
} }
void wxPen::SetJoin( int joinStyle ) void wxPen::SetJoin( int joinStyle )
{ {
Unshare(); Unshare();
M_PENDATA->m_joinStyle = joinStyle; M_PENDATA->m_joinStyle = joinStyle;
} }
void wxPen::SetStyle( int style ) void wxPen::SetStyle( int style )
{ {
Unshare(); Unshare();
M_PENDATA->m_style = style; M_PENDATA->m_style = style;
} }
void wxPen::SetWidth( int width ) void wxPen::SetWidth( int width )
{ {
Unshare(); Unshare();
M_PENDATA->m_width = width; M_PENDATA->m_width = width;
} }
int wxPen::GetCap(void) const int wxPen::GetCap() const
{ {
if (!m_refData) wxCHECK_MSG( Ok(), -1, "invalid pen" );
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_capStyle; return M_PENDATA->m_capStyle;
} }
int wxPen::GetJoin(void) const int wxPen::GetJoin() const
{ {
if (!m_refData) wxCHECK_MSG( Ok(), -1, "invalid pen" );
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_joinStyle; return M_PENDATA->m_joinStyle;
} }
int wxPen::GetStyle(void) const int wxPen::GetStyle() const
{ {
if (!m_refData) wxCHECK_MSG( Ok(), -1, "invalid pen" );
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_style; return M_PENDATA->m_style;
} }
int wxPen::GetWidth(void) const int wxPen::GetWidth() const
{ {
if (!m_refData) wxCHECK_MSG( Ok(), -1, "invalid pen" );
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_width; return M_PENDATA->m_width;
} }
wxColour &wxPen::GetColour(void) const wxColour &wxPen::GetColour() const
{ {
if (!m_refData) wxCHECK_MSG( Ok(), wxNullColour, "invalid pen" );
{
wxFAIL_MSG( "invalid pen" );
return wxNullColour;
}
return M_PENDATA->m_colour; return M_PENDATA->m_colour;
} }
bool wxPen::Ok(void) const bool wxPen::Ok() const
{ {
return (m_refData != NULL); return (m_refData != NULL);
} }
void wxPen::Unshare(void) void wxPen::Unshare()
{ {
if (!m_refData) if (!m_refData)
{ {
m_refData = new wxPenRefData(); m_refData = new wxPenRefData();
} }
else else
{ {
wxPenRefData* ref = new wxPenRefData( *(wxPenRefData*)m_refData ); wxPenRefData* ref = new wxPenRefData( *(wxPenRefData*)m_refData );
UnRef(); UnRef();
m_refData = ref; m_refData = ref;
} }
} }

View File

@@ -29,23 +29,23 @@ extern bool g_blockEventsOnDrag;
static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb )
{ {
if (!rb->HasVMT()) return; if (!rb->HasVMT()) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
if (rb->m_alreadySent) if (rb->m_alreadySent)
{ {
rb->m_alreadySent = FALSE; rb->m_alreadySent = FALSE;
return; return;
} }
rb->m_alreadySent = TRUE; rb->m_alreadySent = TRUE;
wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() ); wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() );
event.SetInt( rb->GetSelection() ); event.SetInt( rb->GetSelection() );
wxString tmp( rb->GetStringSelection() ); wxString tmp( rb->GetStringSelection() );
event.SetString( WXSTRINGCAST(tmp) ); event.SetString( WXSTRINGCAST(tmp) );
event.SetEventObject( rb ); event.SetEventObject( rb );
rb->GetEventHandler()->ProcessEvent(event); rb->GetEventHandler()->ProcessEvent(event);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -55,7 +55,7 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl)
BEGIN_EVENT_TABLE(wxRadioBox, wxControl) BEGIN_EVENT_TABLE(wxRadioBox, wxControl)
EVT_SIZE(wxRadioBox::OnSize) EVT_SIZE(wxRadioBox::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
wxRadioBox::wxRadioBox(void) wxRadioBox::wxRadioBox(void)
@@ -63,127 +63,128 @@ wxRadioBox::wxRadioBox(void)
} }
bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
int n, const wxString choices[], int WXUNUSED(majorDim), int n, const wxString choices[],
long style, const wxValidator& validator, const wxString &name ) int WXUNUSED(majorDim),
long style, const wxValidator& validator,
const wxString &name )
{ {
m_alreadySent = FALSE; m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
SetValidator( validator ); SetValidator( validator );
m_widget = gtk_frame_new( title ); m_widget = gtk_frame_new( title );
int x = m_x+5; int x = m_x+5;
int y = m_y+15; int y = m_y+15;
int maxLen = 0; int maxLen = 0;
int height = 20; int height = 20;
int width = 0; int width = 0;
GtkRadioButton *m_radio = (GtkRadioButton*) NULL; GtkRadioButton *m_radio = (GtkRadioButton*) NULL;
if (m_windowStyle & wxRA_VERTICAL) if (m_windowStyle & wxRA_VERTICAL)
{
GSList *radio_button_group = (GSList *) NULL;
for (int i = 0; i < n; i++)
{ {
if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) ); GSList *radio_button_group = (GSList *) NULL;
for (int i = 0; i < n; i++)
{
if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) );
m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) ); m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) );
m_boxes.Append( (wxObject*) m_radio ); m_boxes.Append( (wxObject*) m_radio );
ConnectWidget( GTK_WIDGET(m_radio) ); ConnectWidget( GTK_WIDGET(m_radio) );
if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE ); if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y ); gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y );
int tmp = 25+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] ); int tmp = 25+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] );
if (tmp > maxLen) maxLen = tmp; if (tmp > maxLen) maxLen = tmp;
width = m_width-10; width = m_width-10;
if (size.x == -1) width = tmp; if (size.x == -1) width = tmp;
gtk_widget_set_usize( GTK_WIDGET(m_radio), width, 20 ); gtk_widget_set_usize( GTK_WIDGET(m_radio), width, 20 );
y += 20;
height += 20;
y += 20;
height += 20;
}
width = maxLen + 10;
} }
width = maxLen + 10; else
}
else
{
int max = 0;
for (int i = 0; i < n; i++)
{ {
GdkFont *font = m_widget->style->font; int max = 0;
int len = 27+gdk_string_measure( font, choices[i] ); for (int i = 0; i < n; i++)
if (len > max) max = len; {
} GdkFont *font = m_widget->style->font;
int len = 27+gdk_string_measure( font, choices[i] );
if (len > max) max = len;
}
GSList *radio_button_group = (GSList *) NULL; GSList *radio_button_group = (GSList *) NULL;
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {
if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) ); if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) );
m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) ); m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) );
m_boxes.Append( (wxObject*) m_radio ); m_boxes.Append( (wxObject*) m_radio );
ConnectWidget( GTK_WIDGET(m_radio) ); ConnectWidget( GTK_WIDGET(m_radio) );
if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE ); if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y ); gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y );
gtk_widget_set_usize( GTK_WIDGET(m_radio), max, 20 ); gtk_widget_set_usize( GTK_WIDGET(m_radio), max, 20 );
x += max; x += max;
}
width = max*n + 10;
height = 40;
} }
width = max*n + 10;
height = 40;
}
wxSize newSize = size; wxSize newSize = size;
if (newSize.x == -1) newSize.x = width; if (newSize.x == -1) newSize.x = width;
if (newSize.y == -1) newSize.y = height; if (newSize.y == -1) newSize.y = height;
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
m_parent->AddChild( this ); m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this ); (m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetLabel( title ); SetLabel( title );
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );
SetForegroundColour( parent->GetForegroundColour() ); SetForegroundColour( parent->GetForegroundColour() );
Show( TRUE ); Show( TRUE );
return TRUE; return TRUE;
} }
wxRadioBox::~wxRadioBox(void) wxRadioBox::~wxRadioBox(void)
{ {
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkWidget *button = GTK_WIDGET( node->Data() ); GtkWidget *button = GTK_WIDGET( node->Data() );
gtk_widget_destroy( button ); gtk_widget_destroy( button );
node = node->Next(); node = node->Next();
} }
} }
void wxRadioBox::OnSize( wxSizeEvent &event ) void wxRadioBox::OnSize( wxSizeEvent &event )
@@ -243,260 +244,249 @@ void wxRadioBox::OnSize( wxSizeEvent &event )
bool wxRadioBox::Show( bool show ) bool wxRadioBox::Show( bool show )
{ {
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid radiobox" ); wxCHECK_MSG( m_widget != NULL, FALSE, "invalid radiobox" );
wxWindow::Show( show ); wxWindow::Show( show );
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkWidget *button = GTK_WIDGET( node->Data() ); GtkWidget *button = GTK_WIDGET( node->Data() );
if (show) gtk_widget_show( button ); else gtk_widget_hide( button ); if (show) gtk_widget_show( button ); else gtk_widget_hide( button );
node = node->Next(); node = node->Next();
} }
return TRUE; return TRUE;
} }
int wxRadioBox::FindString( const wxString &s ) const int wxRadioBox::FindString( const wxString &s ) const
{ {
wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" ); wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" );
int count = 0; int count = 0;
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkButton *button = GTK_BUTTON( node->Data() ); GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *label = GTK_LABEL( button->child ); GtkLabel *label = GTK_LABEL( button->child );
if (s == label->label) return count; if (s == label->label) return count;
count++; count++;
node = node->Next(); node = node->Next();
} }
return -1; return -1;
} }
void wxRadioBox::SetSelection( int n ) void wxRadioBox::SetSelection( int n )
{ {
wxCHECK_RET( m_widget != NULL, "invalid radiobox" ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxNode *node = m_boxes.Nth( n ); wxNode *node = m_boxes.Nth( n );
if (!node) wxCHECK_RET( node, "radiobox wrong index" );
{
wxFAIL_MSG( "wxRadioBox wrong index" );
return;
}
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() ); GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
gtk_toggle_button_set_state( button, 1 ); gtk_toggle_button_set_state( button, 1 );
} }
int wxRadioBox::GetSelection(void) const int wxRadioBox::GetSelection(void) const
{ {
wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" ); wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" );
int count = 0; int count = 0;
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() ); GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
if (button->active) return count; if (button->active) return count;
count++; count++;
node = node->Next(); node = node->Next();
} }
wxFAIL_MSG( "wxRadioBox none selected" ); wxFAIL_MSG( "wxRadioBox none selected" );
return -1; return -1;
} }
wxString wxRadioBox::GetString( int n ) const wxString wxRadioBox::GetString( int n ) const
{ {
wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" ); wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" );
wxNode *node = m_boxes.Nth( n ); wxNode *node = m_boxes.Nth( n );
if (!node) wxCHECK_MSG( node, "", "radiobox wrong index" );
{
wxFAIL_MSG( "wxRadioBox wrong index" );
return "";
}
GtkButton *button = GTK_BUTTON( node->Data() ); GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *label = GTK_LABEL( button->child ); GtkLabel *label = GTK_LABEL( button->child );
return wxString( label->label ); return wxString( label->label );
} }
wxString wxRadioBox::GetLabel( int item ) const wxString wxRadioBox::GetLabel( int item ) const
{ {
wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" ); wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" );
return GetString( item ); return GetString( item );
} }
void wxRadioBox::SetLabel( const wxString& label ) void wxRadioBox::SetLabel( const wxString& label )
{ {
wxCHECK_RET( m_widget != NULL, "invalid radiobox" ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxControl::SetLabel( label ); wxControl::SetLabel( label );
gtk_frame_set_label( GTK_FRAME(m_widget), wxControl::GetLabel() ); gtk_frame_set_label( GTK_FRAME(m_widget), wxControl::GetLabel() );
} }
void wxRadioBox::SetLabel( int item, const wxString& label ) void wxRadioBox::SetLabel( int item, const wxString& label )
{ {
wxCHECK_RET( m_widget != NULL, "invalid radiobox" ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxNode *node = m_boxes.Nth( item ); wxNode *node = m_boxes.Nth( item );
if (!node) wxCHECK_RET( node, "radiobox wrong index" );
{
wxFAIL_MSG( "wxRadioBox wrong index" );
return;
}
GtkButton *button = GTK_BUTTON( node->Data() ); GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *g_label = GTK_LABEL( button->child ); GtkLabel *g_label = GTK_LABEL( button->child );
gtk_label_set( g_label, label ); gtk_label_set( g_label, label );
} }
void wxRadioBox::SetLabel( int WXUNUSED(item), wxBitmap *WXUNUSED(bitmap) ) void wxRadioBox::SetLabel( int WXUNUSED(item), wxBitmap *WXUNUSED(bitmap) )
{ {
wxFAIL_MSG("wxRadioBox::SetLabel not implemented."); wxFAIL_MSG("wxRadioBox::SetLabel not implemented.");
} }
void wxRadioBox::Enable( bool enable ) void wxRadioBox::Enable( bool enable )
{ {
wxControl::Enable( enable ); wxControl::Enable( enable );
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkButton *button = GTK_BUTTON( node->Data() ); GtkButton *button = GTK_BUTTON( node->Data() );
GtkWidget *label = button->child; GtkWidget *label = button->child;
gtk_widget_set_sensitive( GTK_WIDGET(button), enable ); gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( label, enable ); gtk_widget_set_sensitive( label, enable );
node = node->Next(); node = node->Next();
} }
} }
void wxRadioBox::Enable( int item, bool enable ) void wxRadioBox::Enable( int item, bool enable )
{ {
wxNode *node = m_boxes.Nth( item ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
if (!node) wxNode *node = m_boxes.Nth( item );
{
wxFAIL_MSG( "wxRadioBox wrong index" );
return;
}
GtkButton *button = GTK_BUTTON( node->Data() ); wxCHECK_RET( node, "radiobox wrong index" );
GtkWidget *label = button->child;
gtk_widget_set_sensitive( GTK_WIDGET(button), enable ); GtkButton *button = GTK_BUTTON( node->Data() );
gtk_widget_set_sensitive( label, enable ); GtkWidget *label = button->child;
gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( label, enable );
} }
void wxRadioBox::Show( int item, bool show ) void wxRadioBox::Show( int item, bool show )
{ {
wxNode *node = m_boxes.Nth( item ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
if (!node) wxNode *node = m_boxes.Nth( item );
{
wxFAIL_MSG( "wxRadioBox wrong index" );
return;
}
GtkWidget *button = GTK_WIDGET( node->Data() ); wxCHECK_RET( node, "radiobox wrong index" );
GtkWidget *button = GTK_WIDGET( node->Data() );
if (show) if (show)
gtk_widget_show( button ); gtk_widget_show( button );
else else
gtk_widget_hide( button ); gtk_widget_hide( button );
} }
wxString wxRadioBox::GetStringSelection(void) const wxString wxRadioBox::GetStringSelection(void) const
{ {
wxNode *node = m_boxes.First(); wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" );
while (node)
{
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
if (button->active)
{
GtkLabel *label = GTK_LABEL( GTK_BUTTON(button)->child );
return label->label;
}
node = node->Next();
}
wxFAIL_MSG( "wxRadioBox none selected" ); wxNode *node = m_boxes.First();
return ""; while (node)
{
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
if (button->active)
{
GtkLabel *label = GTK_LABEL( GTK_BUTTON(button)->child );
return label->label;
}
node = node->Next();
}
wxFAIL_MSG( "wxRadioBox none selected" );
return "";
} }
bool wxRadioBox::SetStringSelection( const wxString&s ) bool wxRadioBox::SetStringSelection( const wxString &s )
{ {
int res = FindString( s ); wxCHECK_MSG( m_widget != NULL, FALSE, "invalid radiobox" );
if (res == -1) return FALSE;
SetSelection( res ); int res = FindString( s );
return TRUE; if (res == -1) return FALSE;
SetSelection( res );
return TRUE;
} }
int wxRadioBox::Number(void) const int wxRadioBox::Number(void) const
{ {
return m_boxes.Number(); return m_boxes.Number();
} }
int wxRadioBox::GetNumberOfRowsOrCols(void) const int wxRadioBox::GetNumberOfRowsOrCols(void) const
{ {
return 1; return 1;
} }
void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) ) void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) )
{ {
wxFAIL_MSG("wxRadioBox::SetNumberOfRowsOrCols not implemented."); wxFAIL_MSG("wxRadioBox::SetNumberOfRowsOrCols not implemented.");
} }
void wxRadioBox::ApplyWidgetStyle() void wxRadioBox::ApplyWidgetStyle()
{ {
SetWidgetStyle(); SetWidgetStyle();
gtk_widget_set_style( m_widget, m_widgetStyle ); gtk_widget_set_style( m_widget, m_widgetStyle );
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkWidget *widget = GTK_WIDGET( node->Data() ); GtkWidget *widget = GTK_WIDGET( node->Data() );
gtk_widget_set_style( widget, m_widgetStyle ); gtk_widget_set_style( widget, m_widgetStyle );
GtkButton *button = GTK_BUTTON( node->Data() ); GtkButton *button = GTK_BUTTON( node->Data() );
gtk_widget_set_style( button->child, m_widgetStyle ); gtk_widget_set_style( button->child, m_widgetStyle );
node = node->Next(); node = node->Next();
} }
} }
bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window ) bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window )
{ {
if (window == m_widget->window) return TRUE; if (window == m_widget->window) return TRUE;
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkWidget *button = GTK_WIDGET( node->Data() ); GtkWidget *button = GTK_WIDGET( node->Data() );
if (window == button->window) return TRUE; if (window == button->window) return TRUE;
node = node->Next(); node = node->Next();
} }
return FALSE; return FALSE;
} }

View File

@@ -118,6 +118,8 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
gtk_toolbar_append_space( m_toolbar );
m_parent->AddChild( this ); m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this ); (m_parent->m_insertCallback)( m_parent, this );
@@ -250,7 +252,7 @@ void wxToolBar::Realize()
node = node->Next(); node = node->Next();
} }
m_height += 10; m_height += 12;
} }
void wxToolBar::EnableTool(int toolIndex, bool enable) void wxToolBar::EnableTool(int toolIndex, bool enable)
@@ -336,7 +338,7 @@ bool wxToolBar::GetToolEnabled(int toolIndex) const
void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) ) void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) )
{ {
wxFAIL_MSG( "wxToolBar::SetMargins not implemented" ); // wxFAIL_MSG( "wxToolBar::SetMargins not implemented" );
} }
void wxToolBar::SetToolPacking( int WXUNUSED(packing) ) void wxToolBar::SetToolPacking( int WXUNUSED(packing) )

View File

@@ -140,7 +140,6 @@ static guint32 gs_timeLastClick = 0;
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win ) static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return;
win->m_updateRegion.Union( gdk_event->area.x, win->m_updateRegion.Union( gdk_event->area.x,
gdk_event->area.y, gdk_event->area.y,
@@ -170,7 +169,6 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win ) static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return;
win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height ); win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
@@ -1446,14 +1444,14 @@ void wxWindow::SetClientSize( int width, int height )
if (!m_hasScrolling) if (!m_hasScrolling)
{ {
/*
do we have sunken dialogs ?
GtkStyleClass *window_class = m_wxwindow->style->klass; GtkStyleClass *window_class = m_wxwindow->style->klass;
dw += 2 * window_class->xthickness; if ((m_windowStyle & wxRAISED_BORDER) ||
dh += 2 * window_class->ythickness; (m_windowStyle & wxSUNKEN_BORDER))
*/ {
dw += 2 * window_class->xthickness;
dh += 2 * window_class->ythickness;
}
} }
else else
{ {
@@ -1511,14 +1509,14 @@ void wxWindow::GetClientSize( int *width, int *height ) const
if (!m_hasScrolling) if (!m_hasScrolling)
{ {
/*
do we have sunken dialogs ?
GtkStyleClass *window_class = m_wxwindow->style->klass; GtkStyleClass *window_class = m_wxwindow->style->klass;
dw += 2 * window_class->xthickness; if ((m_windowStyle & wxRAISED_BORDER) ||
dh += 2 * window_class->ythickness; (m_windowStyle & wxSUNKEN_BORDER))
*/ {
dw += 2 * window_class->xthickness;
dh += 2 * window_class->ythickness;
}
} }
else else
{ {

View File

@@ -25,7 +25,7 @@
// constants // constants
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const int wxMENU_HEIGHT = 30; const int wxMENU_HEIGHT = 27;
const int wxSTATUS_HEIGHT = 25; const int wxSTATUS_HEIGHT = 25;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -222,7 +222,7 @@ wxPoint wxFrame::GetClientAreaOrigin() const
{ {
int h = 0; int h = 0;
m_frameMenuBar->GetSize( (int*)NULL, &h ); m_frameMenuBar->GetSize( (int*)NULL, &h );
pt.y += h + 2; pt.y += h;
} }
if (m_frameToolBar) if (m_frameToolBar)
{ {
@@ -381,10 +381,10 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
int xx = 1 + m_miniEdge; int xx = m_miniEdge;
int yy = 1 + m_miniEdge + m_miniTitle; int yy = m_miniEdge + m_miniTitle;
int ww = m_width - 2 - 2*m_miniEdge; int ww = m_width - 2*m_miniEdge;
int hh = wxMENU_HEIGHT-2; int hh = wxMENU_HEIGHT;
m_frameMenuBar->m_x = xx; m_frameMenuBar->m_x = xx;
m_frameMenuBar->m_y = yy; m_frameMenuBar->m_y = yy;
m_frameMenuBar->m_width = ww; m_frameMenuBar->m_width = ww;
@@ -396,10 +396,10 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
if (m_frameToolBar) if (m_frameToolBar)
{ {
int xx = 1 + m_miniEdge; int xx = m_miniEdge;
int yy = m_miniEdge + m_miniTitle; int yy = m_miniEdge + m_miniTitle;
if (m_frameMenuBar) yy += wxMENU_HEIGHT; if (m_frameMenuBar) yy += wxMENU_HEIGHT;
int ww = m_width -2 - 2*m_miniEdge; int ww = m_width - 2*m_miniEdge;
int hh = m_frameToolBar->m_height; int hh = m_frameToolBar->m_height;
m_frameToolBar->m_x = xx; m_frameToolBar->m_x = xx;

View File

@@ -21,7 +21,7 @@
// constants // constants
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const int wxMENU_HEIGHT = 30; const int wxMENU_HEIGHT = 27;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// globals // globals
@@ -120,12 +120,12 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
if (m_mdiMenuBar) if (m_mdiMenuBar)
{ {
m_mdiMenuBar->m_x = 1; m_mdiMenuBar->m_x = 0;
m_mdiMenuBar->m_y = 1; m_mdiMenuBar->m_y = 0;
m_mdiMenuBar->m_width = m_width-2; m_mdiMenuBar->m_width = m_width;
m_mdiMenuBar->m_height = wxMENU_HEIGHT-2; m_mdiMenuBar->m_height = wxMENU_HEIGHT;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 1, 1 ); gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 0, 0 );
gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 ); gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width, wxMENU_HEIGHT );
} }
} }
@@ -135,12 +135,12 @@ void wxMDIParentFrame::SetMDIMenuBar( wxMenuBar *menu_bar )
m_mdiMenuBar = menu_bar; m_mdiMenuBar = menu_bar;
if (m_mdiMenuBar) if (m_mdiMenuBar)
{ {
m_mdiMenuBar->m_x = 1; m_mdiMenuBar->m_x = 0;
m_mdiMenuBar->m_y = 1; m_mdiMenuBar->m_y = 0;
m_mdiMenuBar->m_width = m_width-2; m_mdiMenuBar->m_width = m_width;
m_mdiMenuBar->m_height = wxMENU_HEIGHT-2; m_mdiMenuBar->m_height = wxMENU_HEIGHT;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 1, 1 ); gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 0, 0 );
gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 ); gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width, wxMENU_HEIGHT );
m_mdiMenuBar->Show( TRUE ); m_mdiMenuBar->Show( TRUE );
} }
} }

View File

@@ -20,33 +20,33 @@
class wxPenRefData: public wxObjectRefData class wxPenRefData: public wxObjectRefData
{ {
public: public:
wxPenRefData(void); wxPenRefData(void);
wxPenRefData(const wxPenRefData& data); wxPenRefData(const wxPenRefData& data);
int m_width; int m_width;
int m_style; int m_style;
int m_joinStyle; int m_joinStyle;
int m_capStyle; int m_capStyle;
wxColour m_colour; wxColour m_colour;
}; };
wxPenRefData::wxPenRefData(void) wxPenRefData::wxPenRefData()
{ {
m_width = 1; m_width = 1;
m_style = wxSOLID; m_style = wxSOLID;
m_joinStyle = wxJOIN_ROUND; m_joinStyle = wxJOIN_ROUND;
m_capStyle = wxCAP_ROUND; m_capStyle = wxCAP_ROUND;
} }
wxPenRefData::wxPenRefData( const wxPenRefData& data ) wxPenRefData::wxPenRefData( const wxPenRefData& data )
{ {
m_style = data.m_style; m_style = data.m_style;
m_width = data.m_width; m_width = data.m_width;
m_joinStyle = data.m_joinStyle; m_joinStyle = data.m_joinStyle;
m_capStyle = data.m_capStyle; m_capStyle = data.m_capStyle;
m_colour = data.m_colour; m_colour = data.m_colour;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -57,162 +57,142 @@ IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
wxPen::wxPen(void) wxPen::wxPen(void)
{ {
if (wxThePenList) wxThePenList->AddPen( this ); if (wxThePenList) wxThePenList->AddPen( this );
} }
wxPen::wxPen( const wxColour &colour, int width, int style ) wxPen::wxPen( const wxColour &colour, int width, int style )
{ {
m_refData = new wxPenRefData(); m_refData = new wxPenRefData();
M_PENDATA->m_width = width; M_PENDATA->m_width = width;
M_PENDATA->m_style = style; M_PENDATA->m_style = style;
M_PENDATA->m_colour = colour; M_PENDATA->m_colour = colour;
if (wxThePenList) wxThePenList->AddPen( this ); if (wxThePenList) wxThePenList->AddPen( this );
} }
wxPen::wxPen( const wxPen& pen ) wxPen::wxPen( const wxPen& pen )
{ {
Ref( pen ); Ref( pen );
if (wxThePenList) wxThePenList->AddPen( this ); if (wxThePenList) wxThePenList->AddPen( this );
} }
wxPen::wxPen( const wxPen* pen ) wxPen::wxPen( const wxPen* pen )
{ {
UnRef(); UnRef();
if (pen) Ref( *pen ); if (pen) Ref( *pen );
if (wxThePenList) wxThePenList->AddPen( this ); if (wxThePenList) wxThePenList->AddPen( this );
} }
wxPen::~wxPen(void) wxPen::~wxPen()
{ {
if (wxThePenList) wxThePenList->RemovePen( this ); if (wxThePenList) wxThePenList->RemovePen( this );
} }
wxPen& wxPen::operator = ( const wxPen& pen ) wxPen& wxPen::operator = ( const wxPen& pen )
{ {
if (*this == pen) return (*this); if (*this == pen) return (*this);
Ref( pen ); Ref( pen );
return *this; return *this;
} }
bool wxPen::operator == ( const wxPen& pen ) bool wxPen::operator == ( const wxPen& pen )
{ {
return m_refData == pen.m_refData; return m_refData == pen.m_refData;
} }
bool wxPen::operator != ( const wxPen& pen ) bool wxPen::operator != ( const wxPen& pen )
{ {
return m_refData != pen.m_refData; return m_refData != pen.m_refData;
} }
void wxPen::SetColour( const wxColour &colour ) void wxPen::SetColour( const wxColour &colour )
{ {
Unshare(); Unshare();
M_PENDATA->m_colour = colour; M_PENDATA->m_colour = colour;
} }
void wxPen::SetColour( int red, int green, int blue ) void wxPen::SetColour( int red, int green, int blue )
{ {
Unshare(); Unshare();
M_PENDATA->m_colour.Set( red, green, blue ); M_PENDATA->m_colour.Set( red, green, blue );
} }
void wxPen::SetCap( int capStyle ) void wxPen::SetCap( int capStyle )
{ {
Unshare(); Unshare();
M_PENDATA->m_capStyle = capStyle; M_PENDATA->m_capStyle = capStyle;
} }
void wxPen::SetJoin( int joinStyle ) void wxPen::SetJoin( int joinStyle )
{ {
Unshare(); Unshare();
M_PENDATA->m_joinStyle = joinStyle; M_PENDATA->m_joinStyle = joinStyle;
} }
void wxPen::SetStyle( int style ) void wxPen::SetStyle( int style )
{ {
Unshare(); Unshare();
M_PENDATA->m_style = style; M_PENDATA->m_style = style;
} }
void wxPen::SetWidth( int width ) void wxPen::SetWidth( int width )
{ {
Unshare(); Unshare();
M_PENDATA->m_width = width; M_PENDATA->m_width = width;
} }
int wxPen::GetCap(void) const int wxPen::GetCap() const
{ {
if (!m_refData) wxCHECK_MSG( Ok(), -1, "invalid pen" );
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_capStyle; return M_PENDATA->m_capStyle;
} }
int wxPen::GetJoin(void) const int wxPen::GetJoin() const
{ {
if (!m_refData) wxCHECK_MSG( Ok(), -1, "invalid pen" );
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_joinStyle; return M_PENDATA->m_joinStyle;
} }
int wxPen::GetStyle(void) const int wxPen::GetStyle() const
{ {
if (!m_refData) wxCHECK_MSG( Ok(), -1, "invalid pen" );
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_style; return M_PENDATA->m_style;
} }
int wxPen::GetWidth(void) const int wxPen::GetWidth() const
{ {
if (!m_refData) wxCHECK_MSG( Ok(), -1, "invalid pen" );
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_width; return M_PENDATA->m_width;
} }
wxColour &wxPen::GetColour(void) const wxColour &wxPen::GetColour() const
{ {
if (!m_refData) wxCHECK_MSG( Ok(), wxNullColour, "invalid pen" );
{
wxFAIL_MSG( "invalid pen" );
return wxNullColour;
}
return M_PENDATA->m_colour; return M_PENDATA->m_colour;
} }
bool wxPen::Ok(void) const bool wxPen::Ok() const
{ {
return (m_refData != NULL); return (m_refData != NULL);
} }
void wxPen::Unshare(void) void wxPen::Unshare()
{ {
if (!m_refData) if (!m_refData)
{ {
m_refData = new wxPenRefData(); m_refData = new wxPenRefData();
} }
else else
{ {
wxPenRefData* ref = new wxPenRefData( *(wxPenRefData*)m_refData ); wxPenRefData* ref = new wxPenRefData( *(wxPenRefData*)m_refData );
UnRef(); UnRef();
m_refData = ref; m_refData = ref;
} }
} }

View File

@@ -29,23 +29,23 @@ extern bool g_blockEventsOnDrag;
static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb )
{ {
if (!rb->HasVMT()) return; if (!rb->HasVMT()) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
if (rb->m_alreadySent) if (rb->m_alreadySent)
{ {
rb->m_alreadySent = FALSE; rb->m_alreadySent = FALSE;
return; return;
} }
rb->m_alreadySent = TRUE; rb->m_alreadySent = TRUE;
wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() ); wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() );
event.SetInt( rb->GetSelection() ); event.SetInt( rb->GetSelection() );
wxString tmp( rb->GetStringSelection() ); wxString tmp( rb->GetStringSelection() );
event.SetString( WXSTRINGCAST(tmp) ); event.SetString( WXSTRINGCAST(tmp) );
event.SetEventObject( rb ); event.SetEventObject( rb );
rb->GetEventHandler()->ProcessEvent(event); rb->GetEventHandler()->ProcessEvent(event);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -55,7 +55,7 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl)
BEGIN_EVENT_TABLE(wxRadioBox, wxControl) BEGIN_EVENT_TABLE(wxRadioBox, wxControl)
EVT_SIZE(wxRadioBox::OnSize) EVT_SIZE(wxRadioBox::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
wxRadioBox::wxRadioBox(void) wxRadioBox::wxRadioBox(void)
@@ -63,127 +63,128 @@ wxRadioBox::wxRadioBox(void)
} }
bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
int n, const wxString choices[], int WXUNUSED(majorDim), int n, const wxString choices[],
long style, const wxValidator& validator, const wxString &name ) int WXUNUSED(majorDim),
long style, const wxValidator& validator,
const wxString &name )
{ {
m_alreadySent = FALSE; m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
SetValidator( validator ); SetValidator( validator );
m_widget = gtk_frame_new( title ); m_widget = gtk_frame_new( title );
int x = m_x+5; int x = m_x+5;
int y = m_y+15; int y = m_y+15;
int maxLen = 0; int maxLen = 0;
int height = 20; int height = 20;
int width = 0; int width = 0;
GtkRadioButton *m_radio = (GtkRadioButton*) NULL; GtkRadioButton *m_radio = (GtkRadioButton*) NULL;
if (m_windowStyle & wxRA_VERTICAL) if (m_windowStyle & wxRA_VERTICAL)
{
GSList *radio_button_group = (GSList *) NULL;
for (int i = 0; i < n; i++)
{ {
if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) ); GSList *radio_button_group = (GSList *) NULL;
for (int i = 0; i < n; i++)
{
if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) );
m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) ); m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) );
m_boxes.Append( (wxObject*) m_radio ); m_boxes.Append( (wxObject*) m_radio );
ConnectWidget( GTK_WIDGET(m_radio) ); ConnectWidget( GTK_WIDGET(m_radio) );
if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE ); if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y ); gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y );
int tmp = 25+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] ); int tmp = 25+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] );
if (tmp > maxLen) maxLen = tmp; if (tmp > maxLen) maxLen = tmp;
width = m_width-10; width = m_width-10;
if (size.x == -1) width = tmp; if (size.x == -1) width = tmp;
gtk_widget_set_usize( GTK_WIDGET(m_radio), width, 20 ); gtk_widget_set_usize( GTK_WIDGET(m_radio), width, 20 );
y += 20;
height += 20;
y += 20;
height += 20;
}
width = maxLen + 10;
} }
width = maxLen + 10; else
}
else
{
int max = 0;
for (int i = 0; i < n; i++)
{ {
GdkFont *font = m_widget->style->font; int max = 0;
int len = 27+gdk_string_measure( font, choices[i] ); for (int i = 0; i < n; i++)
if (len > max) max = len; {
} GdkFont *font = m_widget->style->font;
int len = 27+gdk_string_measure( font, choices[i] );
if (len > max) max = len;
}
GSList *radio_button_group = (GSList *) NULL; GSList *radio_button_group = (GSList *) NULL;
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {
if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) ); if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) );
m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) ); m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) );
m_boxes.Append( (wxObject*) m_radio ); m_boxes.Append( (wxObject*) m_radio );
ConnectWidget( GTK_WIDGET(m_radio) ); ConnectWidget( GTK_WIDGET(m_radio) );
if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE ); if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y ); gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y );
gtk_widget_set_usize( GTK_WIDGET(m_radio), max, 20 ); gtk_widget_set_usize( GTK_WIDGET(m_radio), max, 20 );
x += max; x += max;
}
width = max*n + 10;
height = 40;
} }
width = max*n + 10;
height = 40;
}
wxSize newSize = size; wxSize newSize = size;
if (newSize.x == -1) newSize.x = width; if (newSize.x == -1) newSize.x = width;
if (newSize.y == -1) newSize.y = height; if (newSize.y == -1) newSize.y = height;
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
m_parent->AddChild( this ); m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this ); (m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetLabel( title ); SetLabel( title );
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );
SetForegroundColour( parent->GetForegroundColour() ); SetForegroundColour( parent->GetForegroundColour() );
Show( TRUE ); Show( TRUE );
return TRUE; return TRUE;
} }
wxRadioBox::~wxRadioBox(void) wxRadioBox::~wxRadioBox(void)
{ {
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkWidget *button = GTK_WIDGET( node->Data() ); GtkWidget *button = GTK_WIDGET( node->Data() );
gtk_widget_destroy( button ); gtk_widget_destroy( button );
node = node->Next(); node = node->Next();
} }
} }
void wxRadioBox::OnSize( wxSizeEvent &event ) void wxRadioBox::OnSize( wxSizeEvent &event )
@@ -243,260 +244,249 @@ void wxRadioBox::OnSize( wxSizeEvent &event )
bool wxRadioBox::Show( bool show ) bool wxRadioBox::Show( bool show )
{ {
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid radiobox" ); wxCHECK_MSG( m_widget != NULL, FALSE, "invalid radiobox" );
wxWindow::Show( show ); wxWindow::Show( show );
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkWidget *button = GTK_WIDGET( node->Data() ); GtkWidget *button = GTK_WIDGET( node->Data() );
if (show) gtk_widget_show( button ); else gtk_widget_hide( button ); if (show) gtk_widget_show( button ); else gtk_widget_hide( button );
node = node->Next(); node = node->Next();
} }
return TRUE; return TRUE;
} }
int wxRadioBox::FindString( const wxString &s ) const int wxRadioBox::FindString( const wxString &s ) const
{ {
wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" ); wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" );
int count = 0; int count = 0;
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkButton *button = GTK_BUTTON( node->Data() ); GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *label = GTK_LABEL( button->child ); GtkLabel *label = GTK_LABEL( button->child );
if (s == label->label) return count; if (s == label->label) return count;
count++; count++;
node = node->Next(); node = node->Next();
} }
return -1; return -1;
} }
void wxRadioBox::SetSelection( int n ) void wxRadioBox::SetSelection( int n )
{ {
wxCHECK_RET( m_widget != NULL, "invalid radiobox" ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxNode *node = m_boxes.Nth( n ); wxNode *node = m_boxes.Nth( n );
if (!node) wxCHECK_RET( node, "radiobox wrong index" );
{
wxFAIL_MSG( "wxRadioBox wrong index" );
return;
}
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() ); GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
gtk_toggle_button_set_state( button, 1 ); gtk_toggle_button_set_state( button, 1 );
} }
int wxRadioBox::GetSelection(void) const int wxRadioBox::GetSelection(void) const
{ {
wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" ); wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" );
int count = 0; int count = 0;
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() ); GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
if (button->active) return count; if (button->active) return count;
count++; count++;
node = node->Next(); node = node->Next();
} }
wxFAIL_MSG( "wxRadioBox none selected" ); wxFAIL_MSG( "wxRadioBox none selected" );
return -1; return -1;
} }
wxString wxRadioBox::GetString( int n ) const wxString wxRadioBox::GetString( int n ) const
{ {
wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" ); wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" );
wxNode *node = m_boxes.Nth( n ); wxNode *node = m_boxes.Nth( n );
if (!node) wxCHECK_MSG( node, "", "radiobox wrong index" );
{
wxFAIL_MSG( "wxRadioBox wrong index" );
return "";
}
GtkButton *button = GTK_BUTTON( node->Data() ); GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *label = GTK_LABEL( button->child ); GtkLabel *label = GTK_LABEL( button->child );
return wxString( label->label ); return wxString( label->label );
} }
wxString wxRadioBox::GetLabel( int item ) const wxString wxRadioBox::GetLabel( int item ) const
{ {
wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" ); wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" );
return GetString( item ); return GetString( item );
} }
void wxRadioBox::SetLabel( const wxString& label ) void wxRadioBox::SetLabel( const wxString& label )
{ {
wxCHECK_RET( m_widget != NULL, "invalid radiobox" ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxControl::SetLabel( label ); wxControl::SetLabel( label );
gtk_frame_set_label( GTK_FRAME(m_widget), wxControl::GetLabel() ); gtk_frame_set_label( GTK_FRAME(m_widget), wxControl::GetLabel() );
} }
void wxRadioBox::SetLabel( int item, const wxString& label ) void wxRadioBox::SetLabel( int item, const wxString& label )
{ {
wxCHECK_RET( m_widget != NULL, "invalid radiobox" ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxNode *node = m_boxes.Nth( item ); wxNode *node = m_boxes.Nth( item );
if (!node) wxCHECK_RET( node, "radiobox wrong index" );
{
wxFAIL_MSG( "wxRadioBox wrong index" );
return;
}
GtkButton *button = GTK_BUTTON( node->Data() ); GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *g_label = GTK_LABEL( button->child ); GtkLabel *g_label = GTK_LABEL( button->child );
gtk_label_set( g_label, label ); gtk_label_set( g_label, label );
} }
void wxRadioBox::SetLabel( int WXUNUSED(item), wxBitmap *WXUNUSED(bitmap) ) void wxRadioBox::SetLabel( int WXUNUSED(item), wxBitmap *WXUNUSED(bitmap) )
{ {
wxFAIL_MSG("wxRadioBox::SetLabel not implemented."); wxFAIL_MSG("wxRadioBox::SetLabel not implemented.");
} }
void wxRadioBox::Enable( bool enable ) void wxRadioBox::Enable( bool enable )
{ {
wxControl::Enable( enable ); wxControl::Enable( enable );
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkButton *button = GTK_BUTTON( node->Data() ); GtkButton *button = GTK_BUTTON( node->Data() );
GtkWidget *label = button->child; GtkWidget *label = button->child;
gtk_widget_set_sensitive( GTK_WIDGET(button), enable ); gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( label, enable ); gtk_widget_set_sensitive( label, enable );
node = node->Next(); node = node->Next();
} }
} }
void wxRadioBox::Enable( int item, bool enable ) void wxRadioBox::Enable( int item, bool enable )
{ {
wxNode *node = m_boxes.Nth( item ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
if (!node) wxNode *node = m_boxes.Nth( item );
{
wxFAIL_MSG( "wxRadioBox wrong index" );
return;
}
GtkButton *button = GTK_BUTTON( node->Data() ); wxCHECK_RET( node, "radiobox wrong index" );
GtkWidget *label = button->child;
gtk_widget_set_sensitive( GTK_WIDGET(button), enable ); GtkButton *button = GTK_BUTTON( node->Data() );
gtk_widget_set_sensitive( label, enable ); GtkWidget *label = button->child;
gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( label, enable );
} }
void wxRadioBox::Show( int item, bool show ) void wxRadioBox::Show( int item, bool show )
{ {
wxNode *node = m_boxes.Nth( item ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
if (!node) wxNode *node = m_boxes.Nth( item );
{
wxFAIL_MSG( "wxRadioBox wrong index" );
return;
}
GtkWidget *button = GTK_WIDGET( node->Data() ); wxCHECK_RET( node, "radiobox wrong index" );
GtkWidget *button = GTK_WIDGET( node->Data() );
if (show) if (show)
gtk_widget_show( button ); gtk_widget_show( button );
else else
gtk_widget_hide( button ); gtk_widget_hide( button );
} }
wxString wxRadioBox::GetStringSelection(void) const wxString wxRadioBox::GetStringSelection(void) const
{ {
wxNode *node = m_boxes.First(); wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" );
while (node)
{
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
if (button->active)
{
GtkLabel *label = GTK_LABEL( GTK_BUTTON(button)->child );
return label->label;
}
node = node->Next();
}
wxFAIL_MSG( "wxRadioBox none selected" ); wxNode *node = m_boxes.First();
return ""; while (node)
{
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
if (button->active)
{
GtkLabel *label = GTK_LABEL( GTK_BUTTON(button)->child );
return label->label;
}
node = node->Next();
}
wxFAIL_MSG( "wxRadioBox none selected" );
return "";
} }
bool wxRadioBox::SetStringSelection( const wxString&s ) bool wxRadioBox::SetStringSelection( const wxString &s )
{ {
int res = FindString( s ); wxCHECK_MSG( m_widget != NULL, FALSE, "invalid radiobox" );
if (res == -1) return FALSE;
SetSelection( res ); int res = FindString( s );
return TRUE; if (res == -1) return FALSE;
SetSelection( res );
return TRUE;
} }
int wxRadioBox::Number(void) const int wxRadioBox::Number(void) const
{ {
return m_boxes.Number(); return m_boxes.Number();
} }
int wxRadioBox::GetNumberOfRowsOrCols(void) const int wxRadioBox::GetNumberOfRowsOrCols(void) const
{ {
return 1; return 1;
} }
void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) ) void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) )
{ {
wxFAIL_MSG("wxRadioBox::SetNumberOfRowsOrCols not implemented."); wxFAIL_MSG("wxRadioBox::SetNumberOfRowsOrCols not implemented.");
} }
void wxRadioBox::ApplyWidgetStyle() void wxRadioBox::ApplyWidgetStyle()
{ {
SetWidgetStyle(); SetWidgetStyle();
gtk_widget_set_style( m_widget, m_widgetStyle ); gtk_widget_set_style( m_widget, m_widgetStyle );
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkWidget *widget = GTK_WIDGET( node->Data() ); GtkWidget *widget = GTK_WIDGET( node->Data() );
gtk_widget_set_style( widget, m_widgetStyle ); gtk_widget_set_style( widget, m_widgetStyle );
GtkButton *button = GTK_BUTTON( node->Data() ); GtkButton *button = GTK_BUTTON( node->Data() );
gtk_widget_set_style( button->child, m_widgetStyle ); gtk_widget_set_style( button->child, m_widgetStyle );
node = node->Next(); node = node->Next();
} }
} }
bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window ) bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window )
{ {
if (window == m_widget->window) return TRUE; if (window == m_widget->window) return TRUE;
wxNode *node = m_boxes.First(); wxNode *node = m_boxes.First();
while (node) while (node)
{ {
GtkWidget *button = GTK_WIDGET( node->Data() ); GtkWidget *button = GTK_WIDGET( node->Data() );
if (window == button->window) return TRUE; if (window == button->window) return TRUE;
node = node->Next(); node = node->Next();
} }
return FALSE; return FALSE;
} }

View File

@@ -118,6 +118,8 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
gtk_toolbar_append_space( m_toolbar );
m_parent->AddChild( this ); m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this ); (m_parent->m_insertCallback)( m_parent, this );
@@ -250,7 +252,7 @@ void wxToolBar::Realize()
node = node->Next(); node = node->Next();
} }
m_height += 10; m_height += 12;
} }
void wxToolBar::EnableTool(int toolIndex, bool enable) void wxToolBar::EnableTool(int toolIndex, bool enable)
@@ -336,7 +338,7 @@ bool wxToolBar::GetToolEnabled(int toolIndex) const
void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) ) void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) )
{ {
wxFAIL_MSG( "wxToolBar::SetMargins not implemented" ); // wxFAIL_MSG( "wxToolBar::SetMargins not implemented" );
} }
void wxToolBar::SetToolPacking( int WXUNUSED(packing) ) void wxToolBar::SetToolPacking( int WXUNUSED(packing) )

View File

@@ -140,7 +140,6 @@ static guint32 gs_timeLastClick = 0;
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win ) static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return;
win->m_updateRegion.Union( gdk_event->area.x, win->m_updateRegion.Union( gdk_event->area.x,
gdk_event->area.y, gdk_event->area.y,
@@ -170,7 +169,6 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win ) static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return;
win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height ); win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
@@ -1446,14 +1444,14 @@ void wxWindow::SetClientSize( int width, int height )
if (!m_hasScrolling) if (!m_hasScrolling)
{ {
/*
do we have sunken dialogs ?
GtkStyleClass *window_class = m_wxwindow->style->klass; GtkStyleClass *window_class = m_wxwindow->style->klass;
dw += 2 * window_class->xthickness; if ((m_windowStyle & wxRAISED_BORDER) ||
dh += 2 * window_class->ythickness; (m_windowStyle & wxSUNKEN_BORDER))
*/ {
dw += 2 * window_class->xthickness;
dh += 2 * window_class->ythickness;
}
} }
else else
{ {
@@ -1511,14 +1509,14 @@ void wxWindow::GetClientSize( int *width, int *height ) const
if (!m_hasScrolling) if (!m_hasScrolling)
{ {
/*
do we have sunken dialogs ?
GtkStyleClass *window_class = m_wxwindow->style->klass; GtkStyleClass *window_class = m_wxwindow->style->klass;
dw += 2 * window_class->xthickness; if ((m_windowStyle & wxRAISED_BORDER) ||
dh += 2 * window_class->ythickness; (m_windowStyle & wxSUNKEN_BORDER))
*/ {
dw += 2 * window_class->xthickness;
dh += 2 * window_class->ythickness;
}
} }
else else
{ {