Did much work on colors. It doesn't work and I guess

it's a GTK bug.
  Small change to Blit()
  Added GTK_NO_TYPE_CHECK when compiling without debug_flag
  Added more wxCHECK_XXX


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@915 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-10-26 00:19:25 +00:00
parent 019bf1286f
commit f96aa4d9eb
49 changed files with 1004 additions and 533 deletions

39
configure vendored
View File

@@ -6206,6 +6206,9 @@ EOF
WXDEBUG_DEFINE="-D__WXDEBUG__"
else
WXDEBUG_DEFINE="-DGTK_NO_CHECK_CASTS"
fi
if test "$wxUSE_MEM_TRACING" = 1 ; then
@@ -6575,7 +6578,7 @@ fi
echo $ac_n "checking for main in -ldl""... $ac_c" 1>&6
echo "configure:6579: checking for main in -ldl" >&5
echo "configure:6582: checking for main in -ldl" >&5
ac_lib_var=`echo dl'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -6583,14 +6586,14 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
#line 6587 "configure"
#line 6590 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
if { (eval echo configure:6594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:6597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -6620,7 +6623,7 @@ UNIX_THREAD="gtk/threadno.cpp"
echo $ac_n "checking "for threads"""... $ac_c" 1>&6
echo "configure:6624: checking "for threads"" >&5
echo "configure:6627: checking "for threads"" >&5
# Check whether --with-threads or --without-threads was given.
if test "${with_threads+set}" = set; then
withval="$with_threads"
@@ -6654,7 +6657,7 @@ if test "$wxwxUSE_THREADS" = "1"; then
echo $ac_n "checking for pthread_create in -lpthread-0.7""... $ac_c" 1>&6
echo "configure:6658: checking for pthread_create in -lpthread-0.7" >&5
echo "configure:6661: checking for pthread_create in -lpthread-0.7" >&5
ac_lib_var=`echo pthread-0.7'_'pthread_create | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -6662,7 +6665,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpthread-0.7 $LIBS"
cat > conftest.$ac_ext <<EOF
#line 6666 "configure"
#line 6669 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -6673,7 +6676,7 @@ int main() {
pthread_create()
; return 0; }
EOF
if { (eval echo configure:6677: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:6680: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -6697,17 +6700,17 @@ else
ac_safe=`echo "sys/prctl.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for sys/prctl.h""... $ac_c" 1>&6
echo "configure:6701: checking for sys/prctl.h" >&5
echo "configure:6704: checking for sys/prctl.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 6706 "configure"
#line 6709 "configure"
#include "confdefs.h"
#include <sys/prctl.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:6711: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:6714: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -6733,7 +6736,7 @@ fi
echo $ac_n "checking for pthread_setcanceltype in -lpthread""... $ac_c" 1>&6
echo "configure:6737: checking for pthread_setcanceltype in -lpthread" >&5
echo "configure:6740: checking for pthread_setcanceltype in -lpthread" >&5
ac_lib_var=`echo pthread'_'pthread_setcanceltype | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -6741,7 +6744,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpthread $LIBS"
cat > conftest.$ac_ext <<EOF
#line 6745 "configure"
#line 6748 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -6752,7 +6755,7 @@ int main() {
pthread_setcanceltype()
; return 0; }
EOF
if { (eval echo configure:6756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:6759: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -6779,7 +6782,7 @@ fi
fi
echo $ac_n "checking for pthread_setcanceltype in -lpthreads""... $ac_c" 1>&6
echo "configure:6783: checking for pthread_setcanceltype in -lpthreads" >&5
echo "configure:6786: checking for pthread_setcanceltype in -lpthreads" >&5
ac_lib_var=`echo pthreads'_'pthread_setcanceltype | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -6787,7 +6790,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpthreads $LIBS"
cat > conftest.$ac_ext <<EOF
#line 6791 "configure"
#line 6794 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -6798,7 +6801,7 @@ int main() {
pthread_setcanceltype()
; return 0; }
EOF
if { (eval echo configure:6802: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:6805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -6842,7 +6845,7 @@ OPENGL_LINK=
if test "$wxUSE_OPENGL" = 1; then
echo $ac_n "checking for OpenGL includes""... $ac_c" 1>&6
echo "configure:6846: checking for OpenGL includes" >&5
echo "configure:6849: checking for OpenGL includes" >&5
ac_find_includes=
for ac_dir in $SEARCH_INCLUDE;
@@ -6857,7 +6860,7 @@ for ac_dir in $SEARCH_INCLUDE;
OPENGL_INCLUDE="-I$ac_find_includes"
echo "$ac_t""found $ac_find_includes" 1>&6
echo $ac_n "checking for OpenGL library""... $ac_c" 1>&6
echo "configure:6861: checking for OpenGL library" >&5
echo "configure:6864: checking for OpenGL library" >&5
ac_find_libraries=
for ac_dir in $SEARCH_LIB;

View File

@@ -1086,6 +1086,9 @@ if test "$wxUSE_DEBUG_FLAG" = 1 ; then
AC_DEFINE_UNQUOTED(WXDEBUG,$wxUSE_DEBUG_FLAG)
WXDEBUG_DEFINE="-D__WXDEBUG__"
AC_SUBST(WXDEBUG_DEFINE)
else
WXDEBUG_DEFINE="-DGTK_NO_CHECK_CASTS"
AC_SUBST(WXDEBUG_DEFINE)
fi
if test "$wxUSE_MEM_TRACING" = 1 ; then

View File

@@ -60,6 +60,7 @@ class wxButton: public wxControl
void SetLabel( const wxString &label );
void Enable( bool enable );
void SetFont( const wxFont &font );
void SetBackgroundColour( const wxColour &colour );
};
#endif // __GTKBUTTONH__

View File

@@ -62,6 +62,7 @@ class wxCheckBox: public wxControl
void SetLabel( const wxString& label );
void SetFont( const wxFont &font );
void Enable( bool enable );
void SetBackgroundColour( const wxColour &colour );
};
#endif // __GTKCHECKBOXH__

View File

@@ -74,6 +74,8 @@ class wxChoice: public wxControl
void SetStringSelection( const wxString &string );
void SetFont( const wxFont &font );
void SetBackgroundColour( const wxColour &colour );
};
#endif // __GTKCHOICEH__

View File

@@ -81,6 +81,7 @@ class wxRadioBox: public wxControl
void SetNumberOfRowsOrCols( int n );
void SetFont( const wxFont &font );
void SetBackgroundColour( const wxColour &colour );
void OnSize( wxSizeEvent &event );
// implementation

View File

@@ -2,9 +2,8 @@
// Name: radiobut.h
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -63,6 +62,7 @@ class wxRadioButton: public wxControl
virtual bool GetValue(void) const;
void SetFont( const wxFont &font );
void Enable( bool enable );
void SetBackgroundColour( const wxColour &colour );
};
#endif // __GTKRADIOBUTTONH__

View File

@@ -237,8 +237,6 @@ public:
void ConnectDnDWidget( GtkWidget *widget );
void DisconnectDnDWidget( GtkWidget *widget );
void SetBackgroundColourHelper( GdkWindow *window );
void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style, const wxString &name );
void PostCreation();

View File

@@ -60,6 +60,7 @@ class wxButton: public wxControl
void SetLabel( const wxString &label );
void Enable( bool enable );
void SetFont( const wxFont &font );
void SetBackgroundColour( const wxColour &colour );
};
#endif // __GTKBUTTONH__

View File

@@ -62,6 +62,7 @@ class wxCheckBox: public wxControl
void SetLabel( const wxString& label );
void SetFont( const wxFont &font );
void Enable( bool enable );
void SetBackgroundColour( const wxColour &colour );
};
#endif // __GTKCHECKBOXH__

View File

@@ -74,6 +74,8 @@ class wxChoice: public wxControl
void SetStringSelection( const wxString &string );
void SetFont( const wxFont &font );
void SetBackgroundColour( const wxColour &colour );
};
#endif // __GTKCHOICEH__

View File

@@ -81,6 +81,7 @@ class wxRadioBox: public wxControl
void SetNumberOfRowsOrCols( int n );
void SetFont( const wxFont &font );
void SetBackgroundColour( const wxColour &colour );
void OnSize( wxSizeEvent &event );
// implementation

View File

@@ -2,9 +2,8 @@
// Name: radiobut.h
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -63,6 +62,7 @@ class wxRadioButton: public wxControl
virtual bool GetValue(void) const;
void SetFont( const wxFont &font );
void Enable( bool enable );
void SetBackgroundColour( const wxColour &colour );
};
#endif // __GTKRADIOBUTTONH__

View File

@@ -237,8 +237,6 @@ public:
void ConnectDnDWidget( GtkWidget *widget );
void DisconnectDnDWidget( GtkWidget *widget );
void SetBackgroundColourHelper( GdkWindow *window );
void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style, const wxString &name );
void PostCreation();

View File

@@ -214,7 +214,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) )
{
m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE );
m_text->SetBackgroundColour("yellow");
m_text->SetBackgroundColour("wheat");
m_notebook = new wxNotebook( this, ID_NOTEBOOK, wxPoint(0,0), wxSize(200,150) );
@@ -261,12 +261,12 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
m_notebook->SetImageList(imagelist);
wxPanel *panel = new wxPanel(m_notebook);
panel->SetBackgroundColour("cadet blue");
m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 4, choices );
m_listbox->SetBackgroundColour("red");
m_listbox->SetBackgroundColour("wheat");
(void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
wxButton *btn = new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
btn->SetBackgroundColour("green");
(void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) );
@@ -274,6 +274,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
m_notebook->AddPage(panel, "wxList", FALSE, Image_List);
panel = new wxPanel(m_notebook);
panel->SetBackgroundColour("cadet blue");
m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 4, choices );
(void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
@@ -285,7 +286,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice);
panel = new wxPanel(m_notebook);
panel->SetBackgroundColour("cadet blue");
m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 4, choices );
m_combo->SetBackgroundColour("wheat");
(void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
@@ -295,10 +298,16 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
(void)new wxCheckBox( panel, ID_COMBO_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) );
m_notebook->AddPage(panel, "wxComboBox", FALSE, Image_Combo);
wxTextCtrl *text = new wxTextCtrl( m_notebook, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(120,100), wxTE_MULTILINE );
m_notebook->AddPage(text, "wxTextCtrl" , FALSE, Image_Text);
panel = new wxPanel(m_notebook);
panel->SetBackgroundColour("cadet blue");
wxTextCtrl *tc = new wxTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(350,28));
tc->SetBackgroundColour("wheat");
tc = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(350,160), wxTE_MULTILINE );
tc->SetBackgroundColour("wheat");
m_notebook->AddPage(panel, "wxTextCtrl" , FALSE, Image_Text);
panel = new wxPanel(m_notebook);
panel->SetBackgroundColour("cadet blue");
m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 4, choices );
(void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) );

View File

@@ -49,8 +49,10 @@ bool wxPanel::Create(wxWindow *parent, wxWindowID id,
bool ret = wxWindow::Create(parent, id, pos, size, style, name);
if ( ret ) {
#ifndef __WXGTK__
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
#endif
}
return ret;

View File

@@ -2,7 +2,7 @@
// Name: bmpbuttn.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -85,6 +85,8 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -100,16 +102,22 @@ void wxBitmapButton::SetDefault(void)
void wxBitmapButton::SetLabel( const wxString &label )
{
wxCHECK_RET( m_widget != NULL, "invalid button" );
wxControl::SetLabel( label );
}
wxString wxBitmapButton::GetLabel(void) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid button" );
return wxControl::GetLabel();
}
void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap )
{
wxCHECK_RET( m_widget != NULL, "invalid button" );
m_bitmap = bitmap;
if (!m_bitmap.Ok()) return;
@@ -122,6 +130,3 @@ void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap )
gtk_pixmap_set( g_pixmap, m_bitmap.GetPixmap(), mask );
}

View File

@@ -2,7 +2,7 @@
// Name: brush.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -73,6 +73,8 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -88,43 +90,46 @@ void wxButton::SetDefault(void)
void wxButton::SetLabel( const wxString &label )
{
wxCHECK_RET( m_widget != NULL, "invalid button" );
wxControl::SetLabel( label );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkLabel *g_label = GTK_LABEL( bin->child );
gtk_label_set( g_label, GetLabel() );
gtk_label_set( GTK_LABEL( GTK_BUTTON(m_widget)->child ), GetLabel() );
}
void wxButton::Enable( bool enable )
{
wxCHECK_RET( m_widget != NULL, "invalid button" );
wxControl::Enable( enable );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
}
void wxButton::SetFont( const wxFont &font )
{
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
wxCHECK_RET( m_widget != NULL, "invalid button" );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
wxControl::SetFont( font );
GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle)
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
void wxButton::SetBackgroundColour( const wxColour &colour )
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( label ) );
}
else
{
style = gtk_widget_get_style( label );
return;
wxCHECK_RET( m_widget != NULL, "invalid button" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( label, style );
}

View File

@@ -67,8 +67,12 @@ bool wxCheckBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
PostCreation();
gtk_widget_realize( GTK_BUTTON( m_widget )->child );
SetLabel( label );
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -76,6 +80,8 @@ bool wxCheckBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
void wxCheckBox::SetValue( bool state )
{
wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
if (state)
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), GTK_STATE_ACTIVE );
else
@@ -84,49 +90,52 @@ void wxCheckBox::SetValue( bool state )
bool wxCheckBox::GetValue() const
{
GtkToggleButton *tb = GTK_TOGGLE_BUTTON(m_widget);
return tb->active;
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid checkbox" );
return GTK_TOGGLE_BUTTON(m_widget)->active;
}
void wxCheckBox::SetLabel( const wxString& label )
{
wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
wxControl::SetLabel( label );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkLabel *g_label = GTK_LABEL( bin->child );
gtk_label_set( g_label, GetLabel() );
gtk_label_set( GTK_LABEL( GTK_BUTTON(m_widget)->child ), GetLabel() );
}
void wxCheckBox::Enable( bool enable )
{
wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
wxControl::Enable( enable );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
}
void wxCheckBox::SetFont( const wxFont &font )
{
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
wxControl::SetFont( font );
GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle)
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
void wxCheckBox::SetBackgroundColour( const wxColour &colour )
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( label ) );
}
else
{
style = gtk_widget_get_style( label );
return;
wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( label, style );
}

View File

@@ -65,22 +65,26 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
if (newSize.y == -1) newSize.y = 26;
SetSize( newSize.x, newSize.y );
GtkWidget *menu;
menu = gtk_menu_new();
GtkWidget *menu = gtk_menu_new();
for (int i = 0; i < n; i++)
{
GtkWidget *item;
item = gtk_menu_item_new_with_label( choices[i] );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
gtk_signal_connect( GTK_OBJECT( item ), "activate",
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
gtk_menu_append( GTK_MENU(menu), item );
gtk_widget_show( item );
gtk_widget_realize( item );
gtk_widget_realize( GTK_BIN(item)->child );
}
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -88,27 +92,40 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
void wxChoice::Append( const wxString &item )
{
wxCHECK_RET( m_widget != NULL, "invalid choice" );
GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );
GtkWidget *menu_item;
menu_item = gtk_menu_item_new_with_label( item );
GtkWidget *menu_item = gtk_menu_item_new_with_label( item );
gtk_menu_append( GTK_MENU(menu), menu_item );
gtk_widget_realize( menu_item );
gtk_widget_realize( GTK_BIN(menu_item)->child );
if (m_hasOwnStyle)
{
GtkBin *bin = GTK_BIN( menu_item );
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_WIDGET( bin ),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
gtk_menu_append( GTK_MENU(menu), menu_item );
gtk_widget_show( menu_item );
}
void wxChoice::Clear(void)
{
wxCHECK_RET( m_widget != NULL, "invalid choice" );
gtk_option_menu_remove_menu( GTK_OPTION_MENU(m_widget) );
GtkWidget *menu = gtk_menu_new();
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
@@ -121,6 +138,8 @@ void wxChoice::Delete( int WXUNUSED(n) )
int wxChoice::FindString( const wxString &string ) const
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
// If you read this code once and you think you understand
// it, then you are very wrong. Robert Roebling.
@@ -153,6 +172,8 @@ int wxChoice::GetColumns(void) const
int wxChoice::GetSelection(void)
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
int count = 0;
GList *child = menu_shell->children;
@@ -171,6 +192,8 @@ int wxChoice::GetSelection(void)
wxString wxChoice::GetString( int n ) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
int count = 0;
GList *child = menu_shell->children;
@@ -198,6 +221,8 @@ wxString wxChoice::GetString( int n ) const
wxString wxChoice::GetStringSelection(void) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
@@ -207,6 +232,8 @@ wxString wxChoice::GetStringSelection(void) const
int wxChoice::Number(void) const
{
wxCHECK_MSG( m_widget != NULL, 0, "invalid choice" );
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
int count = 0;
GList *child = menu_shell->children;
@@ -224,6 +251,8 @@ void wxChoice::SetColumns( int WXUNUSED(n) )
void wxChoice::SetSelection( int n )
{
wxCHECK_RET( m_widget != NULL, "invalid choice" );
int tmp = n;
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
@@ -232,13 +261,17 @@ void wxChoice::SetSelection( int n )
void wxChoice::SetStringSelection( const wxString &string )
{
wxCHECK_RET( m_widget != NULL, "invalid choice" );
int n = FindString( string );
if (n != -1) SetSelection( n );
}
void wxChoice::SetFont( const wxFont &font )
{
wxWindow::SetFont( font );
wxCHECK_RET( m_widget != NULL, "invalid choice" );
wxControl::SetFont( font );
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
GList *child = menu_shell->children;
@@ -256,3 +289,30 @@ void wxChoice::SetFont( const wxFont &font )
child = child->next;
}
}
void wxChoice::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_widget != NULL, "invalid choice" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
GtkStyle *style = gtk_widget_get_style( m_widget );
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
gtk_widget_set_style( GTK_WIDGET( menu_shell ), gtk_style_ref( style ) );
GList *child = menu_shell->children;
while (child)
{
gtk_widget_set_style( GTK_WIDGET( child->data ), gtk_style_ref( style ) );
child = child->next;
}
}

View File

@@ -78,12 +78,14 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
for (int i = 0; i < n; i++)
{
GtkWidget *list_item;
list_item = gtk_list_item_new_with_label( choices[i] );
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] );
m_clientData.Append( (wxObject*)NULL );
gtk_container_add( GTK_CONTAINER(list), list_item );
m_clientData.Append( (wxObject*)NULL );
gtk_widget_realize( list_item );
gtk_widget_realize( GTK_BIN(list_item)->child );
gtk_widget_show( list_item );
@@ -97,6 +99,12 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
if (!value.IsNull()) SetValue( value );
gtk_widget_realize( GTK_COMBO(m_widget)->list );
gtk_widget_realize( GTK_COMBO(m_widget)->entry );
gtk_widget_realize( GTK_COMBO(m_widget)->button );
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -104,6 +112,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
void wxComboBox::Clear(void)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), 0, Number() );
@@ -112,11 +122,15 @@ void wxComboBox::Clear(void)
void wxComboBox::Append( const wxString &item )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
Append( item, (char*)NULL );
}
void wxComboBox::Append( const wxString &item, char *clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GtkWidget *list_item = gtk_list_item_new_with_label( item );
@@ -127,12 +141,9 @@ void wxComboBox::Append( const wxString &item, char *clientData )
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
if (m_backgroundColour != wxNullColour)
{
GtkBin *bin = GTK_BIN( list_item );
SetBackgroundColourHelper( bin->child->window );
gtk_widget_set_style( GTK_WIDGET(bin),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
gtk_signal_connect( GTK_OBJECT(list_item), "select",
@@ -147,6 +158,8 @@ void wxComboBox::Append( const wxString &item, char *clientData )
void wxComboBox::Delete( int n )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
GList *child = g_list_nth( listbox->children, n );
@@ -172,6 +185,8 @@ void wxComboBox::Delete( int n )
int wxComboBox::FindString( const wxString &item )
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *child = GTK_LIST(list)->children;
@@ -192,6 +207,8 @@ int wxComboBox::FindString( const wxString &item )
char* wxComboBox::GetClientData( int n )
{
wxCHECK_MSG( m_widget != NULL, (char*)NULL, "invalid combobox" );
wxNode *node = m_clientData.Nth( n );
if (node) return (char*)node->Data();
@@ -202,6 +219,8 @@ char* wxComboBox::GetClientData( int n )
void wxComboBox::SetClientData( int n, char * clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientData.Nth( n );
if (node) node->SetData( (wxObject*) clientData );
@@ -210,6 +229,8 @@ void wxComboBox::SetClientData( int n, char * clientData )
int wxComboBox::GetSelection(void) const
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *selection = GTK_LIST(list)->selection;
@@ -232,6 +253,8 @@ int wxComboBox::GetSelection(void) const
wxString wxComboBox::GetString( int n ) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *child = g_list_nth( GTK_LIST(list)->children, n );
@@ -249,6 +272,8 @@ wxString wxComboBox::GetString( int n ) const
wxString wxComboBox::GetStringSelection(void) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *selection = GTK_LIST(list)->selection;
@@ -266,6 +291,8 @@ wxString wxComboBox::GetStringSelection(void) const
int wxComboBox::Number(void) const
{
wxCHECK_MSG( m_widget != NULL, 0, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *child = GTK_LIST(list)->children;
@@ -276,12 +303,16 @@ int wxComboBox::Number(void) const
void wxComboBox::SetSelection( int n )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_select_item( GTK_LIST(list), n );
}
void wxComboBox::SetStringSelection( const wxString &string )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
int res = FindString( string );
if (res == -1) return;
SetSelection( res );
@@ -296,6 +327,8 @@ wxString wxComboBox::GetValue(void) const
void wxComboBox::SetValue( const wxString& value )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
wxString tmp = "";
if (!value.IsNull()) tmp = value;
@@ -304,6 +337,8 @@ void wxComboBox::SetValue( const wxString& value )
void wxComboBox::Copy(void)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if (GTK_MINOR_VERSION == 1)
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
@@ -314,6 +349,8 @@ void wxComboBox::Copy(void)
void wxComboBox::Cut(void)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if (GTK_MINOR_VERSION == 1)
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
@@ -324,6 +361,8 @@ void wxComboBox::Cut(void)
void wxComboBox::Paste(void)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if (GTK_MINOR_VERSION == 1)
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
@@ -334,6 +373,8 @@ void wxComboBox::Paste(void)
void wxComboBox::SetInsertionPoint( long pos )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int tmp = (int) pos;
gtk_entry_set_position( GTK_ENTRY(entry), tmp );
@@ -341,6 +382,8 @@ void wxComboBox::SetInsertionPoint( long pos )
void wxComboBox::SetInsertionPointEnd(void)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int pos = GTK_ENTRY(entry)->text_length;
SetInsertionPoint( pos-1 );
@@ -361,6 +404,8 @@ long wxComboBox::GetLastPosition(void) const
void wxComboBox::Replace( long from, long to, const wxString& value )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
if (value.IsNull()) return;
@@ -370,6 +415,8 @@ void wxComboBox::Replace( long from, long to, const wxString& value )
void wxComboBox::Remove(long from, long to)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
}
@@ -388,7 +435,7 @@ void wxComboBox::OnSize( wxSizeEvent &event )
{
wxControl::OnSize( event );
int w = 22;
int w = 21;
gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height );
@@ -398,6 +445,8 @@ void wxComboBox::OnSize( wxSizeEvent &event )
void wxComboBox::SetFont( const wxFont &font )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxWindow::SetFont( font );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
@@ -433,15 +482,34 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
void wxComboBox::SetBackgroundColour( const wxColour &colour )
{
wxWindow::SetBackgroundColour( colour );
return;
GtkWidget *list = GTK_COMBO(m_widget)->list;
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GList *child = GTK_LIST(list)->children;
m_backgroundColour = colour;
if (!m_backgroundColour.Ok()) return;
GtkStyle *style = gtk_widget_get_style( m_widget );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( m_widget ) );
}
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
gtk_widget_set_style( m_widget, style );
gtk_widget_set_style( GTK_COMBO(m_widget)->button, gtk_style_ref( style ) );
gtk_widget_set_style( GTK_COMBO(m_widget)->entry, gtk_style_ref( style ) );
gtk_widget_set_style( GTK_COMBO(m_widget)->list, gtk_style_ref( style ) );
GList *child = GTK_LIST( GTK_COMBO(m_widget)->list )->children;
while (child)
{
GtkBin *bin = (GtkBin*) child->data;
SetBackgroundColourHelper( bin->child->window );
GtkWidget *item = GTK_WIDGET(child->data);
gtk_widget_set_style( item, gtk_style_ref( style ) );
child = child->next;
}
}

View File

@@ -479,7 +479,9 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height,
{
if (!Ok()) return FALSE;
if (m_isMemDC)
wxClientDC *csrc = (wxClientDC*)source;
if (csrc->m_isMemDC)
{
wxMemoryDC* srcDC = (wxMemoryDC*)source;
GdkBitmap* bmap = srcDC->m_selected.GetBitmap();
@@ -496,7 +498,6 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height,
}
}
wxClientDC *csrc = (wxClientDC*)source;
gdk_window_copy_area ( m_window, m_penGC,
XLOG2DEV(xdest), YLOG2DEV(ydest),
csrc->GetWindow(),

View File

@@ -2,9 +2,8 @@
// Name: listbox.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -124,6 +123,8 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_widget_realize( GTK_WIDGET(m_list) );
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -136,7 +137,7 @@ void wxListBox::Append( const wxString &item )
void wxListBox::Append( const wxString &item, char *clientData )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
GtkWidget *list_item = gtk_list_item_new_with_label( item );
@@ -145,11 +146,7 @@ void wxListBox::Append( const wxString &item, char *clientData )
GtkBin *bin = GTK_BIN( list_item );
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
gtk_widget_set_style( GTK_WIDGET(bin),
gtk_style_ref(
gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
gtk_widget_get_style( m_widget ) ) );
}
gtk_signal_connect( GTK_OBJECT(list_item), "select",
@@ -172,7 +169,7 @@ void wxListBox::Append( const wxString &item, char *clientData )
void wxListBox::Clear(void)
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
gtk_list_clear_items( m_list, 0, Number() );
@@ -181,7 +178,7 @@ void wxListBox::Clear(void)
void wxListBox::Delete( int n )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
GList *child = g_list_nth( m_list->children, n );
@@ -206,14 +203,14 @@ void wxListBox::Delete( int n )
void wxListBox::Deselect( int n )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
gtk_list_unselect_item( m_list, n );
}
int wxListBox::FindString( const wxString &item ) const
{
wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
GList *child = m_list->children;
int count = 0;
@@ -235,7 +232,7 @@ int wxListBox::FindString( const wxString &item ) const
char *wxListBox::GetClientData( int n ) const
{
wxCHECK_MSG( m_list != NULL, (char*) NULL, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, (char*) NULL, "invalid listbox" );
wxNode *node = m_clientData.Nth( n );
if (node) return ((char*)node->Data());
@@ -246,7 +243,7 @@ char *wxListBox::GetClientData( int n ) const
int wxListBox::GetSelection(void) const
{
wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
GList *child = m_list->children;
int count = 0;
@@ -261,7 +258,7 @@ int wxListBox::GetSelection(void) const
int wxListBox::GetSelections(wxArrayInt& aSelections) const
{
wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
// get the number of selected items first
GList *child = m_list->children;
@@ -290,7 +287,7 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const
wxString wxListBox::GetString( int n ) const
{
wxCHECK_MSG( m_list != NULL, "", "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
GList *child = g_list_nth( m_list->children, n );
if (child)
@@ -305,7 +302,7 @@ wxString wxListBox::GetString( int n ) const
wxString wxListBox::GetStringSelection(void) const
{
wxCHECK_MSG( m_list != NULL, "", "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
GList *selection = m_list->selection;
if (selection)
@@ -320,7 +317,7 @@ wxString wxListBox::GetStringSelection(void) const
int wxListBox::Number(void)
{
wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
GList *child = m_list->children;
int count = 0;
@@ -330,7 +327,7 @@ int wxListBox::Number(void)
bool wxListBox::Selected( int n )
{
wxCHECK_MSG( m_list != NULL, FALSE, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, FALSE, "invalid listbox" );
GList *target = g_list_nth( m_list->children, n );
if (target)
@@ -353,7 +350,7 @@ void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
void wxListBox::SetClientData( int n, char *clientData )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
wxNode *node = m_clientData.Nth( n );
if (node)
@@ -378,7 +375,7 @@ void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) )
void wxListBox::SetSelection( int n, bool select )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
if (select)
gtk_list_select_item( m_list, n );
@@ -388,7 +385,7 @@ void wxListBox::SetSelection( int n, bool select )
void wxListBox::SetString( int n, const wxString &string )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
GList *child = g_list_nth( m_list->children, n );
if (child)
@@ -405,7 +402,7 @@ void wxListBox::SetString( int n, const wxString &string )
void wxListBox::SetStringSelection( const wxString &string, bool select )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
SetSelection( FindString(string), select );
}
@@ -428,7 +425,7 @@ int wxListBox::GetIndex( GtkWidget *item ) const
void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
GList *child = m_list->children;
while (child)
@@ -452,43 +449,6 @@ GtkWidget *wxListBox::GetConnectWidget(void)
return GTK_WIDGET(m_list);
}
void wxListBox::SetFont( const wxFont &font )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( GTK_WIDGET(m_list) ) );
}
else
{
style = gtk_widget_get_style( GTK_WIDGET(m_list) );
}
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( GTK_WIDGET(m_list), style );
GList *child = m_list->children;
while (child)
{
GtkBin *bin = (GtkBin*) child->data;
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
child = child->next;
}
}
bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
{
if (wxWindow::IsOwnGtkWindow( window )) return TRUE;
@@ -504,38 +464,50 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
return FALSE;
}
void wxListBox::SetBackgroundColour( const wxColour &colour )
void wxListBox::SetFont( const wxFont &font )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
m_backgroundColour = colour;
if (!m_backgroundColour.Ok()) return;
SetBackgroundColourHelper( GTK_WIDGET(m_list)->window );
GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( GTK_WIDGET(m_list) ) );
}
else
{
style = gtk_widget_get_style( GTK_WIDGET(m_list) );
}
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
gtk_widget_set_style( GTK_WIDGET(m_list), style );
wxControl::SetFont( font );
GList *child = m_list->children;
while (child)
{
GtkWidget *item = GTK_WIDGET(child->data);
gtk_widget_set_style( item,
gtk_widget_set_style( GTK_BIN(child->data)->child,
gtk_style_ref(
gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
gtk_widget_get_style( m_widget ) ) );
child = child->next;
}
}
void wxListBox::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_list != NULL, "invalid listbox" );
wxControl::SetBackgroundColour( colour );
return;
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_WIDGET(m_list),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
GList *child = m_list->children;
while (child)
{
gtk_widget_set_style( GTK_WIDGET(child->data),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_BIN(child->data)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
child = child->next;
}
}

View File

@@ -2,9 +2,8 @@
// Name: radiobox.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -127,6 +126,8 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
SetLabel( title );
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -168,6 +169,8 @@ void wxRadioBox::OnSize( wxSizeEvent &event )
bool wxRadioBox::Show( bool show )
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid radiobox" );
wxWindow::Show( show );
wxNode *node = m_boxes.First();
@@ -185,6 +188,8 @@ bool wxRadioBox::Show( bool show )
int wxRadioBox::FindString( const wxString &s ) const
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" );
int count = 0;
wxNode *node = m_boxes.First();
@@ -204,6 +209,8 @@ int wxRadioBox::FindString( const wxString &s ) const
void wxRadioBox::SetSelection( int n )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxNode *node = m_boxes.Nth( n );
if (!node)
@@ -219,6 +226,8 @@ void wxRadioBox::SetSelection( int n )
int wxRadioBox::GetSelection(void) const
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" );
int count = 0;
wxNode *node = m_boxes.First();
@@ -237,6 +246,8 @@ int wxRadioBox::GetSelection(void) const
wxString wxRadioBox::GetString( int n ) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" );
wxNode *node = m_boxes.Nth( n );
if (!node)
@@ -253,18 +264,24 @@ wxString wxRadioBox::GetString( int n ) const
wxString wxRadioBox::GetLabel( int item ) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" );
return GetString( item );
}
void wxRadioBox::SetLabel( const wxString& label )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxControl::SetLabel( label );
GtkFrame *frame = GTK_FRAME( m_widget );
gtk_frame_set_label( frame, wxControl::GetLabel() );
gtk_frame_set_label( GTK_FRAME(m_widget), wxControl::GetLabel() );
}
void wxRadioBox::SetLabel( int item, const wxString& label )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxNode *node = m_boxes.Nth( item );
if (!node)
@@ -376,7 +393,9 @@ void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) )
void wxRadioBox::SetFont( const wxFont &font )
{
wxWindow::SetFont( font );
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxControl::SetFont( font );
wxNode *node = m_boxes.First();
while (node)
@@ -391,6 +410,29 @@ void wxRadioBox::SetFont( const wxFont &font )
}
}
void wxRadioBox::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
wxNode *node = m_boxes.First();
while (node)
{
GtkWidget *button = GTK_WIDGET( node->Data() );
gtk_widget_set_style( button,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
node = node->Next();
}
}
bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window )
{
if (window == m_widget->window) return TRUE;

View File

@@ -2,9 +2,8 @@
// Name: radiobut.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -70,6 +69,8 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab
void wxRadioButton::SetLabel( const wxString& label )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobutton" );
wxControl::SetLabel( label );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkLabel *g_label = GTK_LABEL( bin->child );
@@ -78,46 +79,50 @@ void wxRadioButton::SetLabel( const wxString& label )
void wxRadioButton::SetValue( bool val )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobutton" );
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), val );
}
bool wxRadioButton::GetValue(void) const
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid radiobutton" );
return GTK_TOGGLE_BUTTON(m_widget)->active;
}
void wxRadioButton::Enable( bool enable )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobutton" );
wxControl::Enable( enable );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
}
void wxRadioButton::SetFont( const wxFont &font )
{
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
wxCHECK_RET( m_widget != NULL, "invalid radiobutton" );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
wxControl::SetFont( font );
GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle)
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
void wxRadioButton::SetBackgroundColour( const wxColour &colour )
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( label ) );
}
else
{
style = gtk_widget_get_style( label );
}
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( label, style );
return;
wxCHECK_RET( m_widget != NULL, "invalid radiobutton" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}

View File

@@ -2,9 +2,8 @@
// Name: region.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/98
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,9 +2,8 @@
// Name: scrolbar.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -129,6 +128,8 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;

View File

@@ -2,9 +2,8 @@
// Name: settings.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,9 +2,8 @@
// Name: slider.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -100,6 +99,8 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;

View File

@@ -2,9 +2,8 @@
// Name: textctrl.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -146,6 +145,8 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
Show( TRUE );
SetBackgroundColour( parent->GetBackgroundColour() );
return TRUE;
}
@@ -166,6 +167,8 @@ wxString wxTextCtrl::GetValue() const
void wxTextCtrl::SetValue( const wxString &value )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
wxString tmp = "";
if (!value.IsNull()) tmp = value;
if (m_windowStyle & wxTE_MULTILINE)
@@ -183,6 +186,8 @@ void wxTextCtrl::SetValue( const wxString &value )
void wxTextCtrl::WriteText( const wxString &text )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
if (text.IsNull()) return;
if (m_windowStyle & wxTE_MULTILINE)
@@ -244,6 +249,8 @@ void wxTextCtrl::SetInsertionPoint( long pos )
void wxTextCtrl::SetInsertionPointEnd()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
int pos = 0;
if (m_windowStyle & wxTE_MULTILINE)
pos = gtk_text_get_length( GTK_TEXT(m_text) );
@@ -254,6 +261,8 @@ void wxTextCtrl::SetInsertionPointEnd()
void wxTextCtrl::SetEditable( bool editable )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
if (m_windowStyle & wxTE_MULTILINE)
gtk_text_set_editable( GTK_TEXT(m_text), editable );
else
@@ -262,21 +271,27 @@ void wxTextCtrl::SetEditable( bool editable )
void wxTextCtrl::SetSelection( long from, long to )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
}
void wxTextCtrl::ShowPosition( long WXUNUSED(pos) )
{
wxFAIL_MSG(_("wxTextCtrl::ShowPosition not implemented"));
wxFAIL_MSG( "wxTextCtrl::ShowPosition not implemented" );
}
long wxTextCtrl::GetInsertionPoint() const
{
wxCHECK_MSG( m_text != NULL, 0, "invalid text ctrl" );
return (long) GTK_EDITABLE(m_text)->current_pos;
}
long wxTextCtrl::GetLastPosition() const
{
wxCHECK_MSG( m_text != NULL, 0, "invalid text ctrl" );
int pos = 0;
if (m_windowStyle & wxTE_MULTILINE)
pos = gtk_text_get_length( GTK_TEXT(m_text) );
@@ -287,11 +302,15 @@ long wxTextCtrl::GetLastPosition() const
void wxTextCtrl::Remove( long from, long to )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
}
void wxTextCtrl::Replace( long from, long to, const wxString &value )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
if (value.IsNull()) return;
gint pos = (gint)to;
@@ -300,6 +319,8 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value )
void wxTextCtrl::Cut()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
#if (GTK_MINOR_VERSION == 1)
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) );
#else
@@ -309,6 +330,8 @@ void wxTextCtrl::Cut()
void wxTextCtrl::Copy()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
#if (GTK_MINOR_VERSION == 1)
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) );
#else
@@ -318,6 +341,8 @@ void wxTextCtrl::Copy()
void wxTextCtrl::Paste()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
#if (GTK_MINOR_VERSION == 1)
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) );
#else
@@ -442,21 +467,19 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window )
void wxTextCtrl::SetFont( const wxFont &font )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkStyle *style = (GtkStyle*) NULL;
GtkStyle *style = gtk_widget_get_style( m_text );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( m_text ) );
}
else
{
style = gtk_widget_get_style( m_text );
}
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
@@ -466,9 +489,34 @@ void wxTextCtrl::SetFont( const wxFont &font )
void wxTextCtrl::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
m_backgroundColour = colour;
if (!m_backgroundColour.Ok()) return;
SetBackgroundColourHelper( GTK_TEXT(m_text)->text_area );
if (m_windowStyle & wxTE_MULTILINE)
{
GdkWindow *window = GTK_TEXT(m_text)->text_area;
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
}
else
{
GtkStyle *style = gtk_widget_get_style( m_text );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( m_text ) );
}
m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_text->window ) );
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
gtk_widget_set_style( m_text, style );
}
}

View File

@@ -1113,6 +1113,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL;
m_hasOwnStyle = FALSE;
m_scrollGC = (GdkGC*) NULL;
}
void wxWindow::PostCreation()
@@ -1947,23 +1948,35 @@ wxColour wxWindow::GetBackgroundColour() const
return m_backgroundColour;
}
void wxWindow::SetBackgroundColourHelper( GdkWindow *window )
{
if (!m_backgroundColour.Ok()) return;
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
}
void wxWindow::SetBackgroundColour( const wxColour &colour )
{
wxCHECK_RET( m_widget != NULL, "invalid window" );
m_backgroundColour = colour;
if (!m_backgroundColour.Ok()) return;
GtkWidget *widget = m_wxwindow == NULL ? m_widget : m_wxwindow;
SetBackgroundColourHelper( widget->window );
if (m_wxwindow)
{
GdkWindow *window = m_wxwindow->window;
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
}
else
{
GtkStyle *style = gtk_widget_get_style( m_widget );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( style );
}
m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) );
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
gtk_widget_set_style( m_widget, style );
}
}
wxColour wxWindow::GetForegroundColour() const
@@ -2136,15 +2149,11 @@ void wxWindow::SetFont( const wxFont &font )
else
m_font = *wxSWISS_FONT;
GtkStyle *style = (GtkStyle*) NULL;
GtkStyle *style = gtk_widget_get_style( m_widget );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( m_widget ) );
}
else
{
style = gtk_widget_get_style( m_widget );
style = gtk_style_copy( style );
}
gdk_font_unref( style->font );

View File

@@ -2,7 +2,7 @@
// Name: bmpbuttn.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -85,6 +85,8 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -100,16 +102,22 @@ void wxBitmapButton::SetDefault(void)
void wxBitmapButton::SetLabel( const wxString &label )
{
wxCHECK_RET( m_widget != NULL, "invalid button" );
wxControl::SetLabel( label );
}
wxString wxBitmapButton::GetLabel(void) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid button" );
return wxControl::GetLabel();
}
void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap )
{
wxCHECK_RET( m_widget != NULL, "invalid button" );
m_bitmap = bitmap;
if (!m_bitmap.Ok()) return;
@@ -122,6 +130,3 @@ void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap )
gtk_pixmap_set( g_pixmap, m_bitmap.GetPixmap(), mask );
}

View File

@@ -2,7 +2,7 @@
// Name: brush.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -73,6 +73,8 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -88,43 +90,46 @@ void wxButton::SetDefault(void)
void wxButton::SetLabel( const wxString &label )
{
wxCHECK_RET( m_widget != NULL, "invalid button" );
wxControl::SetLabel( label );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkLabel *g_label = GTK_LABEL( bin->child );
gtk_label_set( g_label, GetLabel() );
gtk_label_set( GTK_LABEL( GTK_BUTTON(m_widget)->child ), GetLabel() );
}
void wxButton::Enable( bool enable )
{
wxCHECK_RET( m_widget != NULL, "invalid button" );
wxControl::Enable( enable );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
}
void wxButton::SetFont( const wxFont &font )
{
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
wxCHECK_RET( m_widget != NULL, "invalid button" );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
wxControl::SetFont( font );
GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle)
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
void wxButton::SetBackgroundColour( const wxColour &colour )
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( label ) );
}
else
{
style = gtk_widget_get_style( label );
return;
wxCHECK_RET( m_widget != NULL, "invalid button" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( label, style );
}

View File

@@ -67,8 +67,12 @@ bool wxCheckBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
PostCreation();
gtk_widget_realize( GTK_BUTTON( m_widget )->child );
SetLabel( label );
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -76,6 +80,8 @@ bool wxCheckBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
void wxCheckBox::SetValue( bool state )
{
wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
if (state)
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), GTK_STATE_ACTIVE );
else
@@ -84,49 +90,52 @@ void wxCheckBox::SetValue( bool state )
bool wxCheckBox::GetValue() const
{
GtkToggleButton *tb = GTK_TOGGLE_BUTTON(m_widget);
return tb->active;
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid checkbox" );
return GTK_TOGGLE_BUTTON(m_widget)->active;
}
void wxCheckBox::SetLabel( const wxString& label )
{
wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
wxControl::SetLabel( label );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkLabel *g_label = GTK_LABEL( bin->child );
gtk_label_set( g_label, GetLabel() );
gtk_label_set( GTK_LABEL( GTK_BUTTON(m_widget)->child ), GetLabel() );
}
void wxCheckBox::Enable( bool enable )
{
wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
wxControl::Enable( enable );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
}
void wxCheckBox::SetFont( const wxFont &font )
{
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
wxControl::SetFont( font );
GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle)
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
void wxCheckBox::SetBackgroundColour( const wxColour &colour )
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( label ) );
}
else
{
style = gtk_widget_get_style( label );
return;
wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( label, style );
}

View File

@@ -65,22 +65,26 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
if (newSize.y == -1) newSize.y = 26;
SetSize( newSize.x, newSize.y );
GtkWidget *menu;
menu = gtk_menu_new();
GtkWidget *menu = gtk_menu_new();
for (int i = 0; i < n; i++)
{
GtkWidget *item;
item = gtk_menu_item_new_with_label( choices[i] );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
gtk_signal_connect( GTK_OBJECT( item ), "activate",
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
gtk_menu_append( GTK_MENU(menu), item );
gtk_widget_show( item );
gtk_widget_realize( item );
gtk_widget_realize( GTK_BIN(item)->child );
}
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -88,27 +92,40 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
void wxChoice::Append( const wxString &item )
{
wxCHECK_RET( m_widget != NULL, "invalid choice" );
GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );
GtkWidget *menu_item;
menu_item = gtk_menu_item_new_with_label( item );
GtkWidget *menu_item = gtk_menu_item_new_with_label( item );
gtk_menu_append( GTK_MENU(menu), menu_item );
gtk_widget_realize( menu_item );
gtk_widget_realize( GTK_BIN(menu_item)->child );
if (m_hasOwnStyle)
{
GtkBin *bin = GTK_BIN( menu_item );
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_WIDGET( bin ),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
gtk_menu_append( GTK_MENU(menu), menu_item );
gtk_widget_show( menu_item );
}
void wxChoice::Clear(void)
{
wxCHECK_RET( m_widget != NULL, "invalid choice" );
gtk_option_menu_remove_menu( GTK_OPTION_MENU(m_widget) );
GtkWidget *menu = gtk_menu_new();
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
@@ -121,6 +138,8 @@ void wxChoice::Delete( int WXUNUSED(n) )
int wxChoice::FindString( const wxString &string ) const
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
// If you read this code once and you think you understand
// it, then you are very wrong. Robert Roebling.
@@ -153,6 +172,8 @@ int wxChoice::GetColumns(void) const
int wxChoice::GetSelection(void)
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
int count = 0;
GList *child = menu_shell->children;
@@ -171,6 +192,8 @@ int wxChoice::GetSelection(void)
wxString wxChoice::GetString( int n ) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
int count = 0;
GList *child = menu_shell->children;
@@ -198,6 +221,8 @@ wxString wxChoice::GetString( int n ) const
wxString wxChoice::GetStringSelection(void) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
@@ -207,6 +232,8 @@ wxString wxChoice::GetStringSelection(void) const
int wxChoice::Number(void) const
{
wxCHECK_MSG( m_widget != NULL, 0, "invalid choice" );
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
int count = 0;
GList *child = menu_shell->children;
@@ -224,6 +251,8 @@ void wxChoice::SetColumns( int WXUNUSED(n) )
void wxChoice::SetSelection( int n )
{
wxCHECK_RET( m_widget != NULL, "invalid choice" );
int tmp = n;
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
@@ -232,13 +261,17 @@ void wxChoice::SetSelection( int n )
void wxChoice::SetStringSelection( const wxString &string )
{
wxCHECK_RET( m_widget != NULL, "invalid choice" );
int n = FindString( string );
if (n != -1) SetSelection( n );
}
void wxChoice::SetFont( const wxFont &font )
{
wxWindow::SetFont( font );
wxCHECK_RET( m_widget != NULL, "invalid choice" );
wxControl::SetFont( font );
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
GList *child = menu_shell->children;
@@ -256,3 +289,30 @@ void wxChoice::SetFont( const wxFont &font )
child = child->next;
}
}
void wxChoice::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_widget != NULL, "invalid choice" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
GtkStyle *style = gtk_widget_get_style( m_widget );
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
gtk_widget_set_style( GTK_WIDGET( menu_shell ), gtk_style_ref( style ) );
GList *child = menu_shell->children;
while (child)
{
gtk_widget_set_style( GTK_WIDGET( child->data ), gtk_style_ref( style ) );
child = child->next;
}
}

View File

@@ -78,12 +78,14 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
for (int i = 0; i < n; i++)
{
GtkWidget *list_item;
list_item = gtk_list_item_new_with_label( choices[i] );
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] );
m_clientData.Append( (wxObject*)NULL );
gtk_container_add( GTK_CONTAINER(list), list_item );
m_clientData.Append( (wxObject*)NULL );
gtk_widget_realize( list_item );
gtk_widget_realize( GTK_BIN(list_item)->child );
gtk_widget_show( list_item );
@@ -97,6 +99,12 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
if (!value.IsNull()) SetValue( value );
gtk_widget_realize( GTK_COMBO(m_widget)->list );
gtk_widget_realize( GTK_COMBO(m_widget)->entry );
gtk_widget_realize( GTK_COMBO(m_widget)->button );
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -104,6 +112,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
void wxComboBox::Clear(void)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), 0, Number() );
@@ -112,11 +122,15 @@ void wxComboBox::Clear(void)
void wxComboBox::Append( const wxString &item )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
Append( item, (char*)NULL );
}
void wxComboBox::Append( const wxString &item, char *clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GtkWidget *list_item = gtk_list_item_new_with_label( item );
@@ -127,12 +141,9 @@ void wxComboBox::Append( const wxString &item, char *clientData )
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
if (m_backgroundColour != wxNullColour)
{
GtkBin *bin = GTK_BIN( list_item );
SetBackgroundColourHelper( bin->child->window );
gtk_widget_set_style( GTK_WIDGET(bin),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
gtk_signal_connect( GTK_OBJECT(list_item), "select",
@@ -147,6 +158,8 @@ void wxComboBox::Append( const wxString &item, char *clientData )
void wxComboBox::Delete( int n )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
GList *child = g_list_nth( listbox->children, n );
@@ -172,6 +185,8 @@ void wxComboBox::Delete( int n )
int wxComboBox::FindString( const wxString &item )
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *child = GTK_LIST(list)->children;
@@ -192,6 +207,8 @@ int wxComboBox::FindString( const wxString &item )
char* wxComboBox::GetClientData( int n )
{
wxCHECK_MSG( m_widget != NULL, (char*)NULL, "invalid combobox" );
wxNode *node = m_clientData.Nth( n );
if (node) return (char*)node->Data();
@@ -202,6 +219,8 @@ char* wxComboBox::GetClientData( int n )
void wxComboBox::SetClientData( int n, char * clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientData.Nth( n );
if (node) node->SetData( (wxObject*) clientData );
@@ -210,6 +229,8 @@ void wxComboBox::SetClientData( int n, char * clientData )
int wxComboBox::GetSelection(void) const
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *selection = GTK_LIST(list)->selection;
@@ -232,6 +253,8 @@ int wxComboBox::GetSelection(void) const
wxString wxComboBox::GetString( int n ) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *child = g_list_nth( GTK_LIST(list)->children, n );
@@ -249,6 +272,8 @@ wxString wxComboBox::GetString( int n ) const
wxString wxComboBox::GetStringSelection(void) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *selection = GTK_LIST(list)->selection;
@@ -266,6 +291,8 @@ wxString wxComboBox::GetStringSelection(void) const
int wxComboBox::Number(void) const
{
wxCHECK_MSG( m_widget != NULL, 0, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *child = GTK_LIST(list)->children;
@@ -276,12 +303,16 @@ int wxComboBox::Number(void) const
void wxComboBox::SetSelection( int n )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_select_item( GTK_LIST(list), n );
}
void wxComboBox::SetStringSelection( const wxString &string )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
int res = FindString( string );
if (res == -1) return;
SetSelection( res );
@@ -296,6 +327,8 @@ wxString wxComboBox::GetValue(void) const
void wxComboBox::SetValue( const wxString& value )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
wxString tmp = "";
if (!value.IsNull()) tmp = value;
@@ -304,6 +337,8 @@ void wxComboBox::SetValue( const wxString& value )
void wxComboBox::Copy(void)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if (GTK_MINOR_VERSION == 1)
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
@@ -314,6 +349,8 @@ void wxComboBox::Copy(void)
void wxComboBox::Cut(void)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if (GTK_MINOR_VERSION == 1)
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
@@ -324,6 +361,8 @@ void wxComboBox::Cut(void)
void wxComboBox::Paste(void)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if (GTK_MINOR_VERSION == 1)
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
@@ -334,6 +373,8 @@ void wxComboBox::Paste(void)
void wxComboBox::SetInsertionPoint( long pos )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int tmp = (int) pos;
gtk_entry_set_position( GTK_ENTRY(entry), tmp );
@@ -341,6 +382,8 @@ void wxComboBox::SetInsertionPoint( long pos )
void wxComboBox::SetInsertionPointEnd(void)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int pos = GTK_ENTRY(entry)->text_length;
SetInsertionPoint( pos-1 );
@@ -361,6 +404,8 @@ long wxComboBox::GetLastPosition(void) const
void wxComboBox::Replace( long from, long to, const wxString& value )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
if (value.IsNull()) return;
@@ -370,6 +415,8 @@ void wxComboBox::Replace( long from, long to, const wxString& value )
void wxComboBox::Remove(long from, long to)
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
}
@@ -388,7 +435,7 @@ void wxComboBox::OnSize( wxSizeEvent &event )
{
wxControl::OnSize( event );
int w = 22;
int w = 21;
gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height );
@@ -398,6 +445,8 @@ void wxComboBox::OnSize( wxSizeEvent &event )
void wxComboBox::SetFont( const wxFont &font )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxWindow::SetFont( font );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
@@ -433,15 +482,34 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
void wxComboBox::SetBackgroundColour( const wxColour &colour )
{
wxWindow::SetBackgroundColour( colour );
return;
GtkWidget *list = GTK_COMBO(m_widget)->list;
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GList *child = GTK_LIST(list)->children;
m_backgroundColour = colour;
if (!m_backgroundColour.Ok()) return;
GtkStyle *style = gtk_widget_get_style( m_widget );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( m_widget ) );
}
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
gtk_widget_set_style( m_widget, style );
gtk_widget_set_style( GTK_COMBO(m_widget)->button, gtk_style_ref( style ) );
gtk_widget_set_style( GTK_COMBO(m_widget)->entry, gtk_style_ref( style ) );
gtk_widget_set_style( GTK_COMBO(m_widget)->list, gtk_style_ref( style ) );
GList *child = GTK_LIST( GTK_COMBO(m_widget)->list )->children;
while (child)
{
GtkBin *bin = (GtkBin*) child->data;
SetBackgroundColourHelper( bin->child->window );
GtkWidget *item = GTK_WIDGET(child->data);
gtk_widget_set_style( item, gtk_style_ref( style ) );
child = child->next;
}
}

View File

@@ -479,7 +479,9 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height,
{
if (!Ok()) return FALSE;
if (m_isMemDC)
wxClientDC *csrc = (wxClientDC*)source;
if (csrc->m_isMemDC)
{
wxMemoryDC* srcDC = (wxMemoryDC*)source;
GdkBitmap* bmap = srcDC->m_selected.GetBitmap();
@@ -496,7 +498,6 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height,
}
}
wxClientDC *csrc = (wxClientDC*)source;
gdk_window_copy_area ( m_window, m_penGC,
XLOG2DEV(xdest), YLOG2DEV(ydest),
csrc->GetWindow(),

View File

@@ -2,9 +2,8 @@
// Name: listbox.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -124,6 +123,8 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_widget_realize( GTK_WIDGET(m_list) );
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -136,7 +137,7 @@ void wxListBox::Append( const wxString &item )
void wxListBox::Append( const wxString &item, char *clientData )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
GtkWidget *list_item = gtk_list_item_new_with_label( item );
@@ -145,11 +146,7 @@ void wxListBox::Append( const wxString &item, char *clientData )
GtkBin *bin = GTK_BIN( list_item );
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
gtk_widget_set_style( GTK_WIDGET(bin),
gtk_style_ref(
gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
gtk_widget_get_style( m_widget ) ) );
}
gtk_signal_connect( GTK_OBJECT(list_item), "select",
@@ -172,7 +169,7 @@ void wxListBox::Append( const wxString &item, char *clientData )
void wxListBox::Clear(void)
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
gtk_list_clear_items( m_list, 0, Number() );
@@ -181,7 +178,7 @@ void wxListBox::Clear(void)
void wxListBox::Delete( int n )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
GList *child = g_list_nth( m_list->children, n );
@@ -206,14 +203,14 @@ void wxListBox::Delete( int n )
void wxListBox::Deselect( int n )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
gtk_list_unselect_item( m_list, n );
}
int wxListBox::FindString( const wxString &item ) const
{
wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
GList *child = m_list->children;
int count = 0;
@@ -235,7 +232,7 @@ int wxListBox::FindString( const wxString &item ) const
char *wxListBox::GetClientData( int n ) const
{
wxCHECK_MSG( m_list != NULL, (char*) NULL, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, (char*) NULL, "invalid listbox" );
wxNode *node = m_clientData.Nth( n );
if (node) return ((char*)node->Data());
@@ -246,7 +243,7 @@ char *wxListBox::GetClientData( int n ) const
int wxListBox::GetSelection(void) const
{
wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
GList *child = m_list->children;
int count = 0;
@@ -261,7 +258,7 @@ int wxListBox::GetSelection(void) const
int wxListBox::GetSelections(wxArrayInt& aSelections) const
{
wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
// get the number of selected items first
GList *child = m_list->children;
@@ -290,7 +287,7 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const
wxString wxListBox::GetString( int n ) const
{
wxCHECK_MSG( m_list != NULL, "", "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
GList *child = g_list_nth( m_list->children, n );
if (child)
@@ -305,7 +302,7 @@ wxString wxListBox::GetString( int n ) const
wxString wxListBox::GetStringSelection(void) const
{
wxCHECK_MSG( m_list != NULL, "", "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
GList *selection = m_list->selection;
if (selection)
@@ -320,7 +317,7 @@ wxString wxListBox::GetStringSelection(void) const
int wxListBox::Number(void)
{
wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
GList *child = m_list->children;
int count = 0;
@@ -330,7 +327,7 @@ int wxListBox::Number(void)
bool wxListBox::Selected( int n )
{
wxCHECK_MSG( m_list != NULL, FALSE, "invalid list ctrl" );
wxCHECK_MSG( m_list != NULL, FALSE, "invalid listbox" );
GList *target = g_list_nth( m_list->children, n );
if (target)
@@ -353,7 +350,7 @@ void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
void wxListBox::SetClientData( int n, char *clientData )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
wxNode *node = m_clientData.Nth( n );
if (node)
@@ -378,7 +375,7 @@ void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) )
void wxListBox::SetSelection( int n, bool select )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
if (select)
gtk_list_select_item( m_list, n );
@@ -388,7 +385,7 @@ void wxListBox::SetSelection( int n, bool select )
void wxListBox::SetString( int n, const wxString &string )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
GList *child = g_list_nth( m_list->children, n );
if (child)
@@ -405,7 +402,7 @@ void wxListBox::SetString( int n, const wxString &string )
void wxListBox::SetStringSelection( const wxString &string, bool select )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
SetSelection( FindString(string), select );
}
@@ -428,7 +425,7 @@ int wxListBox::GetIndex( GtkWidget *item ) const
void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
GList *child = m_list->children;
while (child)
@@ -452,43 +449,6 @@ GtkWidget *wxListBox::GetConnectWidget(void)
return GTK_WIDGET(m_list);
}
void wxListBox::SetFont( const wxFont &font )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( GTK_WIDGET(m_list) ) );
}
else
{
style = gtk_widget_get_style( GTK_WIDGET(m_list) );
}
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( GTK_WIDGET(m_list), style );
GList *child = m_list->children;
while (child)
{
GtkBin *bin = (GtkBin*) child->data;
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
child = child->next;
}
}
bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
{
if (wxWindow::IsOwnGtkWindow( window )) return TRUE;
@@ -504,38 +464,50 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
return FALSE;
}
void wxListBox::SetBackgroundColour( const wxColour &colour )
void wxListBox::SetFont( const wxFont &font )
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
wxCHECK_RET( m_list != NULL, "invalid listbox" );
m_backgroundColour = colour;
if (!m_backgroundColour.Ok()) return;
SetBackgroundColourHelper( GTK_WIDGET(m_list)->window );
GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( GTK_WIDGET(m_list) ) );
}
else
{
style = gtk_widget_get_style( GTK_WIDGET(m_list) );
}
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
gtk_widget_set_style( GTK_WIDGET(m_list), style );
wxControl::SetFont( font );
GList *child = m_list->children;
while (child)
{
GtkWidget *item = GTK_WIDGET(child->data);
gtk_widget_set_style( item,
gtk_widget_set_style( GTK_BIN(child->data)->child,
gtk_style_ref(
gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
gtk_widget_get_style( m_widget ) ) );
child = child->next;
}
}
void wxListBox::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_list != NULL, "invalid listbox" );
wxControl::SetBackgroundColour( colour );
return;
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_WIDGET(m_list),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
GList *child = m_list->children;
while (child)
{
gtk_widget_set_style( GTK_WIDGET(child->data),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_BIN(child->data)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
child = child->next;
}
}

View File

@@ -2,9 +2,8 @@
// Name: radiobox.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -127,6 +126,8 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
SetLabel( title );
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;
@@ -168,6 +169,8 @@ void wxRadioBox::OnSize( wxSizeEvent &event )
bool wxRadioBox::Show( bool show )
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid radiobox" );
wxWindow::Show( show );
wxNode *node = m_boxes.First();
@@ -185,6 +188,8 @@ bool wxRadioBox::Show( bool show )
int wxRadioBox::FindString( const wxString &s ) const
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" );
int count = 0;
wxNode *node = m_boxes.First();
@@ -204,6 +209,8 @@ int wxRadioBox::FindString( const wxString &s ) const
void wxRadioBox::SetSelection( int n )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxNode *node = m_boxes.Nth( n );
if (!node)
@@ -219,6 +226,8 @@ void wxRadioBox::SetSelection( int n )
int wxRadioBox::GetSelection(void) const
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid radiobox" );
int count = 0;
wxNode *node = m_boxes.First();
@@ -237,6 +246,8 @@ int wxRadioBox::GetSelection(void) const
wxString wxRadioBox::GetString( int n ) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" );
wxNode *node = m_boxes.Nth( n );
if (!node)
@@ -253,18 +264,24 @@ wxString wxRadioBox::GetString( int n ) const
wxString wxRadioBox::GetLabel( int item ) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid radiobox" );
return GetString( item );
}
void wxRadioBox::SetLabel( const wxString& label )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxControl::SetLabel( label );
GtkFrame *frame = GTK_FRAME( m_widget );
gtk_frame_set_label( frame, wxControl::GetLabel() );
gtk_frame_set_label( GTK_FRAME(m_widget), wxControl::GetLabel() );
}
void wxRadioBox::SetLabel( int item, const wxString& label )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxNode *node = m_boxes.Nth( item );
if (!node)
@@ -376,7 +393,9 @@ void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) )
void wxRadioBox::SetFont( const wxFont &font )
{
wxWindow::SetFont( font );
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxControl::SetFont( font );
wxNode *node = m_boxes.First();
while (node)
@@ -391,6 +410,29 @@ void wxRadioBox::SetFont( const wxFont &font )
}
}
void wxRadioBox::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
wxNode *node = m_boxes.First();
while (node)
{
GtkWidget *button = GTK_WIDGET( node->Data() );
gtk_widget_set_style( button,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
node = node->Next();
}
}
bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window )
{
if (window == m_widget->window) return TRUE;

View File

@@ -2,9 +2,8 @@
// Name: radiobut.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -70,6 +69,8 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab
void wxRadioButton::SetLabel( const wxString& label )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobutton" );
wxControl::SetLabel( label );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkLabel *g_label = GTK_LABEL( bin->child );
@@ -78,46 +79,50 @@ void wxRadioButton::SetLabel( const wxString& label )
void wxRadioButton::SetValue( bool val )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobutton" );
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), val );
}
bool wxRadioButton::GetValue(void) const
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid radiobutton" );
return GTK_TOGGLE_BUTTON(m_widget)->active;
}
void wxRadioButton::Enable( bool enable )
{
wxCHECK_RET( m_widget != NULL, "invalid radiobutton" );
wxControl::Enable( enable );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
}
void wxRadioButton::SetFont( const wxFont &font )
{
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
wxCHECK_RET( m_widget != NULL, "invalid radiobutton" );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child;
wxControl::SetFont( font );
GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle)
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}
void wxRadioButton::SetBackgroundColour( const wxColour &colour )
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( label ) );
}
else
{
style = gtk_widget_get_style( label );
}
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( label, style );
return;
wxCHECK_RET( m_widget != NULL, "invalid radiobutton" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
}

View File

@@ -2,9 +2,8 @@
// Name: region.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/98
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,9 +2,8 @@
// Name: scrolbar.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -129,6 +128,8 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;

View File

@@ -2,9 +2,8 @@
// Name: settings.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,9 +2,8 @@
// Name: slider.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -100,6 +99,8 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
Show( TRUE );
return TRUE;

View File

@@ -2,9 +2,8 @@
// Name: textctrl.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -146,6 +145,8 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
Show( TRUE );
SetBackgroundColour( parent->GetBackgroundColour() );
return TRUE;
}
@@ -166,6 +167,8 @@ wxString wxTextCtrl::GetValue() const
void wxTextCtrl::SetValue( const wxString &value )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
wxString tmp = "";
if (!value.IsNull()) tmp = value;
if (m_windowStyle & wxTE_MULTILINE)
@@ -183,6 +186,8 @@ void wxTextCtrl::SetValue( const wxString &value )
void wxTextCtrl::WriteText( const wxString &text )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
if (text.IsNull()) return;
if (m_windowStyle & wxTE_MULTILINE)
@@ -244,6 +249,8 @@ void wxTextCtrl::SetInsertionPoint( long pos )
void wxTextCtrl::SetInsertionPointEnd()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
int pos = 0;
if (m_windowStyle & wxTE_MULTILINE)
pos = gtk_text_get_length( GTK_TEXT(m_text) );
@@ -254,6 +261,8 @@ void wxTextCtrl::SetInsertionPointEnd()
void wxTextCtrl::SetEditable( bool editable )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
if (m_windowStyle & wxTE_MULTILINE)
gtk_text_set_editable( GTK_TEXT(m_text), editable );
else
@@ -262,21 +271,27 @@ void wxTextCtrl::SetEditable( bool editable )
void wxTextCtrl::SetSelection( long from, long to )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
}
void wxTextCtrl::ShowPosition( long WXUNUSED(pos) )
{
wxFAIL_MSG(_("wxTextCtrl::ShowPosition not implemented"));
wxFAIL_MSG( "wxTextCtrl::ShowPosition not implemented" );
}
long wxTextCtrl::GetInsertionPoint() const
{
wxCHECK_MSG( m_text != NULL, 0, "invalid text ctrl" );
return (long) GTK_EDITABLE(m_text)->current_pos;
}
long wxTextCtrl::GetLastPosition() const
{
wxCHECK_MSG( m_text != NULL, 0, "invalid text ctrl" );
int pos = 0;
if (m_windowStyle & wxTE_MULTILINE)
pos = gtk_text_get_length( GTK_TEXT(m_text) );
@@ -287,11 +302,15 @@ long wxTextCtrl::GetLastPosition() const
void wxTextCtrl::Remove( long from, long to )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
}
void wxTextCtrl::Replace( long from, long to, const wxString &value )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
if (value.IsNull()) return;
gint pos = (gint)to;
@@ -300,6 +319,8 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value )
void wxTextCtrl::Cut()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
#if (GTK_MINOR_VERSION == 1)
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) );
#else
@@ -309,6 +330,8 @@ void wxTextCtrl::Cut()
void wxTextCtrl::Copy()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
#if (GTK_MINOR_VERSION == 1)
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) );
#else
@@ -318,6 +341,8 @@ void wxTextCtrl::Copy()
void wxTextCtrl::Paste()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
#if (GTK_MINOR_VERSION == 1)
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) );
#else
@@ -442,21 +467,19 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window )
void wxTextCtrl::SetFont( const wxFont &font )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkStyle *style = (GtkStyle*) NULL;
GtkStyle *style = gtk_widget_get_style( m_text );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( m_text ) );
}
else
{
style = gtk_widget_get_style( m_text );
}
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
@@ -466,9 +489,34 @@ void wxTextCtrl::SetFont( const wxFont &font )
void wxTextCtrl::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
m_backgroundColour = colour;
if (!m_backgroundColour.Ok()) return;
SetBackgroundColourHelper( GTK_TEXT(m_text)->text_area );
if (m_windowStyle & wxTE_MULTILINE)
{
GdkWindow *window = GTK_TEXT(m_text)->text_area;
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
}
else
{
GtkStyle *style = gtk_widget_get_style( m_text );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( m_text ) );
}
m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_text->window ) );
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
gtk_widget_set_style( m_text, style );
}
}

View File

@@ -1113,6 +1113,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL;
m_hasOwnStyle = FALSE;
m_scrollGC = (GdkGC*) NULL;
}
void wxWindow::PostCreation()
@@ -1947,23 +1948,35 @@ wxColour wxWindow::GetBackgroundColour() const
return m_backgroundColour;
}
void wxWindow::SetBackgroundColourHelper( GdkWindow *window )
{
if (!m_backgroundColour.Ok()) return;
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
}
void wxWindow::SetBackgroundColour( const wxColour &colour )
{
wxCHECK_RET( m_widget != NULL, "invalid window" );
m_backgroundColour = colour;
if (!m_backgroundColour.Ok()) return;
GtkWidget *widget = m_wxwindow == NULL ? m_widget : m_wxwindow;
SetBackgroundColourHelper( widget->window );
if (m_wxwindow)
{
GdkWindow *window = m_wxwindow->window;
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
}
else
{
GtkStyle *style = gtk_widget_get_style( m_widget );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( style );
}
m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) );
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
gtk_widget_set_style( m_widget, style );
}
}
wxColour wxWindow::GetForegroundColour() const
@@ -2136,15 +2149,11 @@ void wxWindow::SetFont( const wxFont &font )
else
m_font = *wxSWISS_FONT;
GtkStyle *style = (GtkStyle*) NULL;
GtkStyle *style = gtk_widget_get_style( m_widget );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( m_widget ) );
}
else
{
style = gtk_widget_get_style( m_widget );
style = gtk_style_copy( style );
}
gdk_font_unref( style->font );

View File

@@ -160,7 +160,7 @@ void MyDialog::OnTextCtrlButtons( wxCommandEvent &event )
};
case ID_TEXTCTRL_DEL:
{
m_textctrl->Delete();
m_textctrl->Clear();
break;
};
};
@@ -324,8 +324,8 @@ MyCanvas::MyCanvas( wxWindow *parent, const wxWindowID id, const wxPoint &pos, c
: wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER )
{
my_bitmap = new wxBitmap( folder_xpm );
my_horse = new wxBitmap();
my_horse->LoadFile( "horse.png", 0 );
// my_horse = new wxBitmap();
// my_horse->LoadFile( "horse.png", 0 );
my_backstore = new wxBitmap( 150, 150 );
my_font = new wxFont( 20, wxROMAN, wxNORMAL, wxNORMAL );
m_isCreated = FALSE;
@@ -337,7 +337,7 @@ MyCanvas::~MyCanvas(void)
{
delete my_bitmap;
delete my_backstore;
delete my_horse;
// delete my_horse;
delete my_font;
};
@@ -387,7 +387,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
dc.DrawText( "Hej, ho, hej, ho. (ItalicFont)", 80, 100 );
dc.DrawBitmap( *my_bitmap, 30, 80, TRUE );
dc.DrawBitmap( *my_horse, 30, 120 );
// dc.DrawBitmap( *my_horse, 30, 120 );
dc.Blit( 200, 200, 150, 150, &memDC, 0, 0, 0 );