From 2d17d68f470c31f7c145b095eb1a3e0c2f581f30 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 3 Jan 1999 11:03:59 +0000 Subject: [PATCH] new cursors bug in menuitem->check minor things here and there git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1312 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- configure | 44 +++---- configure.in | 2 + include/wx/gtk/menuitem.h | 2 +- include/wx/gtk1/menuitem.h | 2 +- src/gtk/cursor.cpp | 107 ++++++++-------- src/gtk/menu.cpp | 21 +++- src/gtk/scrolbar.cpp | 244 +++++++++++++++++++------------------ src/gtk/settings.cpp | 34 +++--- src/gtk/slider.cpp | 170 +++++++++++++------------- src/gtk/utilsgtk.cpp | 3 +- src/gtk1/cursor.cpp | 107 ++++++++-------- src/gtk1/menu.cpp | 21 +++- src/gtk1/scrolbar.cpp | 244 +++++++++++++++++++------------------ src/gtk1/settings.cpp | 34 +++--- src/gtk1/slider.cpp | 170 +++++++++++++------------- src/gtk1/utilsgtk.cpp | 3 +- 16 files changed, 623 insertions(+), 585 deletions(-) diff --git a/configure b/configure index 4d31a44e59..ec32c40724 100755 --- a/configure +++ b/configure @@ -6480,6 +6480,8 @@ else if test "$wxUSE_DEBUG_INFO" = 1 ; then WXDEBUG="-g" wxUSE_OPTIMISE=0 + else + WX_LINK="-s $WX_LINK" fi fi @@ -6859,7 +6861,7 @@ fi echo $ac_n "checking for main in -ldl""... $ac_c" 1>&6 -echo "configure:6863: checking for main in -ldl" >&5 +echo "configure:6865: 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 @@ -6867,14 +6869,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6880: \"$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 @@ -6904,7 +6906,7 @@ UNIX_THREAD="gtk/threadno.cpp" echo $ac_n "checking "for threads"""... $ac_c" 1>&6 -echo "configure:6908: checking "for threads"" >&5 +echo "configure:6910: checking "for threads"" >&5 # Check whether --with-threads or --without-threads was given. if test "${with_threads+set}" = set; then withval="$with_threads" @@ -6938,7 +6940,7 @@ if test "$wxUSE_THREADS" = "1"; then solaris*) echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6 -echo "configure:6942: checking for thr_create in -lthread" >&5 +echo "configure:6944: checking for thr_create in -lthread" >&5 ac_lib_var=`echo thread'_'thr_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 @@ -6946,7 +6948,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6963: \"$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 @@ -6988,7 +6990,7 @@ fi echo $ac_n "checking for pthread_create in -lpthread-0.7""... $ac_c" 1>&6 -echo "configure:6992: checking for pthread_create in -lpthread-0.7" >&5 +echo "configure:6994: 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 @@ -6996,7 +6998,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread-0.7 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:7013: \"$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 @@ -7031,17 +7033,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:7035: checking for sys/prctl.h" >&5 +echo "configure:7037: 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 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:7045: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:7047: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -7067,7 +7069,7 @@ fi echo $ac_n "checking for pthread_setcanceltype in -lpthread""... $ac_c" 1>&6 -echo "configure:7071: checking for pthread_setcanceltype in -lpthread" >&5 +echo "configure:7073: 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 @@ -7075,7 +7077,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:7092: \"$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 @@ -7115,7 +7117,7 @@ fi echo $ac_n "checking for printf in -lposix4""... $ac_c" 1>&6 -echo "configure:7119: checking for printf in -lposix4" >&5 +echo "configure:7121: checking for printf in -lposix4" >&5 ac_lib_var=`echo posix4'_'printf | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7123,7 +7125,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix4 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:7140: \"$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 @@ -7183,7 +7185,7 @@ OPENGL_LINK= if test "$wxUSE_OPENGL" = 1; then echo $ac_n "checking for OpenGL includes""... $ac_c" 1>&6 -echo "configure:7187: checking for OpenGL includes" >&5 +echo "configure:7189: checking for OpenGL includes" >&5 ac_find_includes= for ac_dir in $SEARCH_INCLUDE; @@ -7198,7 +7200,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:7202: checking for OpenGL library" >&5 +echo "configure:7204: checking for OpenGL library" >&5 ac_find_libraries= for ac_dir in $SEARCH_LIB; diff --git a/configure.in b/configure.in index 6ef774c2b5..81e6872533 100644 --- a/configure.in +++ b/configure.in @@ -1136,6 +1136,8 @@ else if test "$wxUSE_DEBUG_INFO" = 1 ; then WXDEBUG="-g" wxUSE_OPTIMISE=0 + else + WX_LINK="-s $WX_LINK" fi fi AC_SUBST(WXDEBUG) diff --git a/include/wx/gtk/menuitem.h b/include/wx/gtk/menuitem.h index 77f08d493e..446498063b 100644 --- a/include/wx/gtk/menuitem.h +++ b/include/wx/gtk/menuitem.h @@ -72,10 +72,10 @@ public: const wxString& GetHelp() const { return m_helpStr; } // implementation + void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; } GtkWidget *GetMenuItem() const { return m_menuItem; } -private: int m_id; wxString m_text; bool m_isCheckMenu; diff --git a/include/wx/gtk1/menuitem.h b/include/wx/gtk1/menuitem.h index 77f08d493e..446498063b 100644 --- a/include/wx/gtk1/menuitem.h +++ b/include/wx/gtk1/menuitem.h @@ -72,10 +72,10 @@ public: const wxString& GetHelp() const { return m_helpStr; } // implementation + void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; } GtkWidget *GetMenuItem() const { return m_menuItem; } -private: int m_id; wxString m_text; bool m_isCheckMenu; diff --git a/src/gtk/cursor.cpp b/src/gtk/cursor.cpp index 2034a9076a..eac07cc904 100644 --- a/src/gtk/cursor.cpp +++ b/src/gtk/cursor.cpp @@ -32,12 +32,12 @@ class wxCursorRefData: public wxObjectRefData wxCursorRefData::wxCursorRefData() { - m_cursor = (GdkCursor *) NULL; + m_cursor = (GdkCursor *) NULL; } wxCursorRefData::~wxCursorRefData() { - if (m_cursor) gdk_cursor_destroy( m_cursor ); + if (m_cursor) gdk_cursor_destroy( m_cursor ); } //----------------------------------------------------------------------------- @@ -52,57 +52,45 @@ wxCursor::wxCursor() wxCursor::wxCursor( int cursorId ) { - m_refData = new wxCursorRefData(); - - GdkCursorType gdk_cur = GDK_LEFT_PTR; - switch (cursorId) - { - case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break; - case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break; - case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break; - case wxCURSOR_SIZENS: gdk_cur = GDK_SB_V_DOUBLE_ARROW; break; - case wxCURSOR_WAIT: gdk_cur = GDK_WATCH; break; - case wxCURSOR_WATCH: gdk_cur = GDK_WATCH; break; - case wxCURSOR_SIZING: gdk_cur = GDK_SIZING; break; - case wxCURSOR_SPRAYCAN: gdk_cur = GDK_SPRAYCAN; break; - case wxCURSOR_IBEAM: gdk_cur = GDK_XTERM; break; - case wxCURSOR_PENCIL: gdk_cur = GDK_PENCIL; break; - case wxCURSOR_NO_ENTRY: gdk_cur = GDK_PIRATE; break; - } - - M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); - + m_refData = new wxCursorRefData(); + + GdkCursorType gdk_cur = GDK_LEFT_PTR; + switch (cursorId) + { + case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break; + case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break; + case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break; + case wxCURSOR_SIZENS: gdk_cur = GDK_SB_V_DOUBLE_ARROW; break; + case wxCURSOR_WAIT: + case wxCURSOR_WATCH: gdk_cur = GDK_WATCH; break; + case wxCURSOR_SIZING: gdk_cur = GDK_SIZING; break; + case wxCURSOR_SPRAYCAN: gdk_cur = GDK_SPRAYCAN; break; + case wxCURSOR_IBEAM: gdk_cur = GDK_XTERM; break; + case wxCURSOR_PENCIL: gdk_cur = GDK_PENCIL; break; + case wxCURSOR_NO_ENTRY: gdk_cur = GDK_PIRATE; break; + case wxCURSOR_SIZENWSE: + case wxCURSOR_SIZENESW: gdk_cur = GDK_FLEUR; break; + case wxCURSOR_QUESTION_ARROW: gdk_cur = GDK_QUESTION_ARROW; break; + case wxCURSOR_PAINT_BRUSH: gdk_cur = GDK_SPRAYCAN; break; + case wxCURSOR_MAGNIFIER: gdk_cur = GDK_PLUS; break; + case wxCURSOR_CHAR: gdk_cur = GDK_XTERM; break; + case wxCURSOR_LEFT_BUTTON: gdk_cur = GDK_LEFTBUTTON; break; + case wxCURSOR_MIDDLE_BUTTON: gdk_cur = GDK_MIDDLEBUTTON; break; + case wxCURSOR_RIGHT_BUTTON: gdk_cur = GDK_RIGHTBUTTON; break; /* - do that yourself - - wxCURSOR_BULLSEYE, - wxCURSOR_CHAR, - wxCURSOR_LEFT_BUTTON, - wxCURSOR_MAGNIFIER, - wxCURSOR_MIDDLE_BUTTON, - wxCURSOR_NO_ENTRY, - wxCURSOR_PAINT_BRUSH, - wxCURSOR_POINT_LEFT, - wxCURSOR_POINT_RIGHT, - wxCURSOR_QUESTION_ARROW, - wxCURSOR_RIGHT_BUTTON, - wxCURSOR_SIZENESW, - wxCURSOR_SIZENS, - wxCURSOR_SIZENWSE, - wxCURSOR_SIZEWE, - wxCURSOR_BLANK -, - wxCURSOR_CROSS_REVERSE, - wxCURSOR_DOUBLE_ARROW, - wxCURSOR_BASED_ARROW_UP, - wxCURSOR_BASED_ARROW_DOWN + case wxCURSOR_DOUBLE_ARROW: gdk_cur = GDK_DOUBLE_ARROW; break; + case wxCURSOR_CROSS_REVERSE: gdk_cur = GDK_CROSS_REVERSE; break; + case wxCURSOR_BASED_ARROW_UP: gdk_cur = GDK_BASED_ARROW_UP; break; + case wxCURSOR_BASED_ARROW_DOWN: gdk_cur = GDK_BASED_ARROW_DOWN; break; */ + } + M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); } wxCursor::wxCursor( const wxCursor &cursor ) { - Ref( cursor ); + Ref( cursor ); } wxCursor::~wxCursor() @@ -111,29 +99,30 @@ wxCursor::~wxCursor() wxCursor& wxCursor::operator = ( const wxCursor& cursor ) { - if (*this == cursor) return (*this); - Ref( cursor ); - return *this; + if (*this == cursor) return (*this); + Ref( cursor ); + + return *this; } bool wxCursor::operator == ( const wxCursor& cursor ) const { - return m_refData == cursor.m_refData; + return m_refData == cursor.m_refData; } bool wxCursor::operator != ( const wxCursor& cursor ) const { - return m_refData != cursor.m_refData; + return m_refData != cursor.m_refData; } bool wxCursor::Ok() const { - return (m_refData != NULL); + return (m_refData != NULL); } GdkCursor *wxCursor::GetCursor() const { - return M_CURSORDATA->m_cursor; + return M_CURSORDATA->m_cursor; } //----------------------------------------------------------------------------- @@ -144,25 +133,25 @@ bool g_isBusy = FALSE; void wxEndBusyCursor() { - g_isBusy = FALSE; + g_isBusy = FALSE; } void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) { - g_isBusy = TRUE; + g_isBusy = TRUE; } bool wxIsBusy() { - return g_isBusy; + return g_isBusy; } void wxSetCursor( const wxCursor& cursor ) { - extern wxCursor *g_globalCursor; - if (g_globalCursor) (*g_globalCursor) = cursor; + extern wxCursor *g_globalCursor; + if (g_globalCursor) (*g_globalCursor) = cursor; - if (cursor.Ok()) {} + if (cursor.Ok()) {} } diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index ff038197a8..147c0d5a1c 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -167,6 +167,23 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) if (!menu->IsEnabled(id)) return; + wxMenuItem* item = menu->FindItem( id ); + wxCHECK_RET( item, "error in menu item callback" ); + + if (item->m_isCheckMenu) + { + if (item->m_isChecked == item->IsChecked()) + { + /* the menu item has been checked by calling wxMenuItem->Check() */ + return; + } + else + { + /* the user pressed on the menu item -> report */ + item->m_isChecked; /* make consistent again */ + } + } + wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, id ); event.SetEventObject( menu ); event.SetInt(id ); @@ -253,6 +270,8 @@ void wxMenuItem::Check( bool check ) wxCHECK_RET( IsCheckable(), "Can't check uncheckable item!" ) + if (check == m_isChecked) return; + m_isChecked = check; gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)check ); } @@ -273,8 +292,6 @@ bool wxMenuItem::IsChecked() const bool bIsChecked = ((GtkCheckMenuItem*)m_menuItem)->active != 0; - wxASSERT( bIsChecked == m_isChecked ); // consistency check - return bIsChecked; } diff --git a/src/gtk/scrolbar.cpp b/src/gtk/scrolbar.cpp index a6973405bc..ee6d3eec70 100644 --- a/src/gtk/scrolbar.cpp +++ b/src/gtk/scrolbar.cpp @@ -32,45 +32,45 @@ extern bool g_blockEventsOnScroll; static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) { - if (!win->HasVMT()) return; - if (g_blockEventsOnDrag) return; + if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; - float diff = win->m_adjust->value - win->m_oldPos; - if (fabs(diff) < 0.2) return; + float diff = win->m_adjust->value - win->m_oldPos; + if (fabs(diff) < 0.2) return; - wxEventType command = wxEVT_NULL; + wxEventType command = wxEVT_NULL; - float line_step = win->m_adjust->step_increment; - float page_step = win->m_adjust->page_increment; + float line_step = win->m_adjust->step_increment; + float page_step = win->m_adjust->page_increment; - if (win->m_isScrolling) - { - command = wxEVT_SCROLL_THUMBTRACK; - } - else - { - if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; - else command = wxEVT_SCROLL_THUMBTRACK; - } - - int value = (int)(win->m_adjust->value+0.5); + if (win->m_isScrolling) + { + command = wxEVT_SCROLL_THUMBTRACK; + } + else + { + if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; + else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; + else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; + else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; + else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; + else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; + else command = wxEVT_SCROLL_THUMBTRACK; + } + + int value = (int)(win->m_adjust->value+0.5); - int orient = wxHORIZONTAL; - if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL; + int orient = wxHORIZONTAL; + if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL; - wxScrollEvent event( command, win->GetId(), value, orient ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); + wxScrollEvent event( command, win->GetId(), value, orient ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); /* - wxCommandEvent cevent( wxEVT_COMMAND_SCROLLBAR_UPDATED, win->GetId() ); - cevent.SetEventObject( win ); - win->ProcessEvent( cevent ); + wxCommandEvent cevent( wxEVT_COMMAND_SCROLLBAR_UPDATED, win->GetId() ); + cevent.SetEventObject( win ); + win->ProcessEvent( cevent ); */ } @@ -96,12 +96,12 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *WXUNUSED(widget), GdkEventButton *WXUNUSED(gdk_event), wxScrollBar *win ) { - win->m_isScrolling = FALSE; + win->m_isScrolling = FALSE; // g_blockEventsOnScroll = FALSE; - gtk_signal_emit_by_name( GTK_OBJECT(win->m_adjust), "value_changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(win->m_adjust), "value_changed" ); - return FALSE; + return FALSE; } //----------------------------------------------------------------------------- @@ -118,175 +118,181 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) { - m_needParent = TRUE; - m_acceptsFocus = TRUE; + m_needParent = TRUE; + m_acceptsFocus = TRUE; - PreCreation( parent, id, pos, size, style, name ); + PreCreation( parent, id, pos, size, style, name ); - SetValidator( validator ); + SetValidator( validator ); - m_oldPos = 0.0; + m_oldPos = 0.0; - if (style & wxSB_VERTICAL == wxSB_VERTICAL) - m_widget = gtk_hscrollbar_new( (GtkAdjustment *) NULL ); - else - m_widget = gtk_vscrollbar_new( (GtkAdjustment *) NULL ); + if (style & wxSB_VERTICAL == wxSB_VERTICAL) + m_widget = gtk_hscrollbar_new( (GtkAdjustment *) NULL ); + else + m_widget = gtk_vscrollbar_new( (GtkAdjustment *) NULL ); - m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); + m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); - gtk_signal_connect (GTK_OBJECT (m_adjust), "value_changed", - (GtkSignalFunc) gtk_scrollbar_callback, (gpointer) this ); + gtk_signal_connect( GTK_OBJECT(m_adjust), + "value_changed", + (GtkSignalFunc) gtk_scrollbar_callback, + (gpointer) this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "button_press_event", - (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this ); + gtk_signal_connect( GTK_OBJECT(m_widget), + "button_press_event", + (GtkSignalFunc)gtk_scrollbar_button_press_callback, + (gpointer) this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "button_release_event", - (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); + gtk_signal_connect( GTK_OBJECT(m_widget), + "button_release_event", + (GtkSignalFunc)gtk_scrollbar_button_release_callback, + (gpointer) this ); - m_parent->AddChild( this ); + m_parent->AddChild( this ); - (m_parent->m_insertCallback)( m_parent, this ); + (m_parent->m_insertCallback)( m_parent, this ); - PostCreation(); + PostCreation(); - SetBackgroundColour( parent->GetBackgroundColour() ); + SetBackgroundColour( parent->GetBackgroundColour() ); - Show( TRUE ); + Show( TRUE ); - return TRUE; + return TRUE; } int wxScrollBar::GetThumbPosition(void) const { - return (int)(m_adjust->value+0.5); + return (int)(m_adjust->value+0.5); } int wxScrollBar::GetThumbSize() const { - return (int)(m_adjust->page_size+0.5); + return (int)(m_adjust->page_size+0.5); } int wxScrollBar::GetPageSize() const { - return (int)(m_adjust->page_increment+0.5); + return (int)(m_adjust->page_increment+0.5); } int wxScrollBar::GetRange() const { - return (int)(m_adjust->upper+0.5); + return (int)(m_adjust->upper+0.5); } void wxScrollBar::SetThumbPosition( int viewStart ) { - if (m_isScrolling) return; + if (m_isScrolling) return; - float fpos = (float)viewStart; - m_oldPos = fpos; - if (fabs(fpos-m_adjust->value) < 0.2) return; - m_adjust->value = fpos; + float fpos = (float)viewStart; + m_oldPos = fpos; + if (fabs(fpos-m_adjust->value) < 0.2) return; + m_adjust->value = fpos; - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); } void wxScrollBar::SetScrollbar( int position, int thumbSize, int range, int pageSize, bool WXUNUSED(refresh) ) { - float fpos = (float)position; - float frange = (float)range; - float fthumb = (float)thumbSize; - float fpage = (float)pageSize; + float fpos = (float)position; + float frange = (float)range; + float fthumb = (float)thumbSize; + float fpage = (float)pageSize; - if ((fabs(frange-m_adjust->upper) < 0.2) && - (fabs(fthumb-m_adjust->page_size) < 0.2) && - (fabs(fpage-m_adjust->page_increment) < 0.2)) - { - SetThumbPosition( position ); - return; - } + if ((fabs(frange-m_adjust->upper) < 0.2) && + (fabs(fthumb-m_adjust->page_size) < 0.2) && + (fabs(fpage-m_adjust->page_increment) < 0.2)) + { + SetThumbPosition( position ); + return; + } - m_oldPos = fpos; + m_oldPos = fpos; - m_adjust->lower = 0.0; - m_adjust->upper = frange; - m_adjust->value = fpos; - m_adjust->step_increment = 1.0; - m_adjust->page_increment = (float)(wxMax(fpage,0)); - m_adjust->page_size = fthumb; - - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); + m_adjust->lower = 0.0; + m_adjust->upper = frange; + m_adjust->value = fpos; + m_adjust->step_increment = 1.0; + m_adjust->page_increment = (float)(wxMax(fpage,0)); + m_adjust->page_size = fthumb; + + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); } -// Backward compatibility +/* Backward compatibility */ int wxScrollBar::GetValue(void) const { - return GetThumbPosition(); + return GetThumbPosition(); } void wxScrollBar::SetValue( int viewStart ) { - SetThumbPosition( viewStart ); + SetThumbPosition( viewStart ); } void wxScrollBar::GetValues( int *viewStart, int *viewLength, int *objectLength, int *pageLength ) const { - int pos = (int)(m_adjust->value+0.5); - int thumb = (int)(m_adjust->page_size+0.5); - int page = (int)(m_adjust->page_increment+0.5); - int range = (int)(m_adjust->upper+0.5); + int pos = (int)(m_adjust->value+0.5); + int thumb = (int)(m_adjust->page_size+0.5); + int page = (int)(m_adjust->page_increment+0.5); + int range = (int)(m_adjust->upper+0.5); - *viewStart = pos; - *viewLength = range; - *objectLength = thumb; - *pageLength = page; + *viewStart = pos; + *viewLength = range; + *objectLength = thumb; + *pageLength = page; } int wxScrollBar::GetViewLength() const { - return (int)(m_adjust->upper+0.5); + return (int)(m_adjust->upper+0.5); } int wxScrollBar::GetObjectLength() const { - return (int)(m_adjust->page_size+0.5); + return (int)(m_adjust->page_size+0.5); } void wxScrollBar::SetPageSize( int pageLength ) { - int pos = (int)(m_adjust->value+0.5); - int thumb = (int)(m_adjust->page_size+0.5); - int range = (int)(m_adjust->upper+0.5); - SetScrollbar( pos, thumb, range, pageLength ); + int pos = (int)(m_adjust->value+0.5); + int thumb = (int)(m_adjust->page_size+0.5); + int range = (int)(m_adjust->upper+0.5); + SetScrollbar( pos, thumb, range, pageLength ); } void wxScrollBar::SetObjectLength( int objectLength ) { - int pos = (int)(m_adjust->value+0.5); - int page = (int)(m_adjust->page_increment+0.5); - int range = (int)(m_adjust->upper+0.5); - SetScrollbar( pos, objectLength, range, page ); + int pos = (int)(m_adjust->value+0.5); + int page = (int)(m_adjust->page_increment+0.5); + int range = (int)(m_adjust->upper+0.5); + SetScrollbar( pos, objectLength, range, page ); } void wxScrollBar::SetViewLength( int viewLength ) { - int pos = (int)(m_adjust->value+0.5); - int thumb = (int)(m_adjust->page_size+0.5); - int page = (int)(m_adjust->page_increment+0.5); - SetScrollbar( pos, thumb, viewLength, page ); + int pos = (int)(m_adjust->value+0.5); + int thumb = (int)(m_adjust->page_size+0.5); + int page = (int)(m_adjust->page_increment+0.5); + SetScrollbar( pos, thumb, viewLength, page ); } bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window ) { - GtkRange *range = GTK_RANGE(m_widget); - return ( (window == GTK_WIDGET(range)->window) || - (window == range->trough) || - (window == range->slider) || - (window == range->step_forw) || - (window == range->step_back) ); + GtkRange *range = GTK_RANGE(m_widget); + return ( (window == GTK_WIDGET(range)->window) || + (window == range->trough) || + (window == range->slider) || + (window == range->step_forw) || + (window == range->step_back) ); } void wxScrollBar::ApplyWidgetStyle() { - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); + SetWidgetStyle(); + gtk_widget_set_style( m_widget, m_widgetStyle ); } diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index 234bce0a2d..646386409a 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -157,26 +157,26 @@ wxColour wxSystemSettings::GetSystemColour( int index ) wxFont wxSystemSettings::GetSystemFont( int index ) { - switch (index) - { - case wxSYS_OEM_FIXED_FONT: - case wxSYS_ANSI_FIXED_FONT: - case wxSYS_SYSTEM_FIXED_FONT: - { - return *wxNORMAL_FONT; - } - case wxSYS_ANSI_VAR_FONT: - case wxSYS_SYSTEM_FONT: - case wxSYS_DEVICE_DEFAULT_FONT: - case wxSYS_DEFAULT_GUI_FONT: + switch (index) { - if (!g_systemFont) - g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); - return *g_systemFont; + case wxSYS_OEM_FIXED_FONT: + case wxSYS_ANSI_FIXED_FONT: + case wxSYS_SYSTEM_FIXED_FONT: + { + return *wxNORMAL_FONT; + } + case wxSYS_ANSI_VAR_FONT: + case wxSYS_SYSTEM_FONT: + case wxSYS_DEVICE_DEFAULT_FONT: + case wxSYS_DEFAULT_GUI_FONT: + { + if (!g_systemFont) + g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); + return *g_systemFont; + } } - } - return wxNullFont; + return wxNullFont; } int wxSystemSettings::GetSystemMetric( int index ) diff --git a/src/gtk/slider.cpp b/src/gtk/slider.cpp index cddd5f54f0..5f9c8915b6 100644 --- a/src/gtk/slider.cpp +++ b/src/gtk/slider.cpp @@ -30,37 +30,37 @@ extern bool g_blockEventsOnDrag; static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win ) { - if (!win->HasVMT()) return; - if (g_blockEventsOnDrag) return; + if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; - float diff = win->m_adjust->value - win->m_oldPos; - if (fabs(diff) < 0.2) return; + float diff = win->m_adjust->value - win->m_oldPos; + if (fabs(diff) < 0.2) return; - wxEventType command = wxEVT_NULL; + wxEventType command = wxEVT_NULL; - float line_step = win->m_adjust->step_increment; - float page_step = win->m_adjust->page_increment; + float line_step = win->m_adjust->step_increment; + float page_step = win->m_adjust->page_increment; - if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; - else command = wxEVT_SCROLL_THUMBTRACK; - - int value = (int)(win->m_adjust->value+0.5); + if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; + else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; + else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; + else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; + else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; + else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; + else command = wxEVT_SCROLL_THUMBTRACK; + + int value = (int)(win->m_adjust->value+0.5); - int orient = wxHORIZONTAL; - if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL; + int orient = wxHORIZONTAL; + if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL; - wxScrollEvent event( command, win->GetId(), value, orient ); - event.SetEventObject( win ); - win->ProcessEvent( event ); + wxScrollEvent event( command, win->GetId(), value, orient ); + event.SetEventObject( win ); + win->ProcessEvent( event ); - wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() ); - cevent.SetEventObject( win ); - win->ProcessEvent( cevent ); + wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() ); + cevent.SetEventObject( win ); + win->ProcessEvent( cevent ); } //----------------------------------------------------------------------------- @@ -83,111 +83,117 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, long style, const wxValidator& validator, const wxString& name ) { m_acceptsFocus = TRUE; - m_needParent = TRUE; + m_needParent = TRUE; - PreCreation( parent, id, pos, size, style, name ); + PreCreation( parent, id, pos, size, style, name ); - SetValidator( validator ); + SetValidator( validator ); - m_oldPos = 0.0; + m_oldPos = 0.0; - if (style & wxSL_VERTICAL == wxSL_VERTICAL) - m_widget = gtk_hscale_new( (GtkAdjustment *) NULL ); - else - m_widget = gtk_vscale_new( (GtkAdjustment *) NULL ); + if (style & wxSL_VERTICAL == wxSL_VERTICAL) + m_widget = gtk_hscale_new( (GtkAdjustment *) NULL ); + else + m_widget = gtk_vscale_new( (GtkAdjustment *) NULL ); - gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE ); + gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE ); - m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); + m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); - gtk_signal_connect (GTK_OBJECT (m_adjust), "value_changed", - (GtkSignalFunc) gtk_slider_callback, (gpointer) this ); - SetRange( minValue, maxValue ); - SetValue( value ); + gtk_signal_connect( GTK_OBJECT(m_adjust), + "value_changed", + (GtkSignalFunc) gtk_slider_callback, + (gpointer) this ); + + SetRange( minValue, maxValue ); + SetValue( value ); - m_parent->AddChild( this ); + m_parent->AddChild( this ); - (m_parent->m_insertCallback)( m_parent, this ); + (m_parent->m_insertCallback)( m_parent, this ); - PostCreation(); + PostCreation(); - SetBackgroundColour( parent->GetBackgroundColour() ); + SetBackgroundColour( parent->GetBackgroundColour() ); - Show( TRUE ); + Show( TRUE ); - return TRUE; + return TRUE; } int wxSlider::GetValue(void) const { - return (int)(m_adjust->value+0.5); + return (int)(m_adjust->value+0.5); } void wxSlider::SetValue( int value ) { - float fpos = (float)value; - m_oldPos = fpos; - if (fabs(fpos-m_adjust->value) < 0.2) return; - m_adjust->value = fpos; + float fpos = (float)value; + m_oldPos = fpos; + if (fabs(fpos-m_adjust->value) < 0.2) return; + + m_adjust->value = fpos; - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); } void wxSlider::SetRange( int minValue, int maxValue ) { - float fmin = (float)minValue; - float fmax = (float)maxValue; + float fmin = (float)minValue; + float fmax = (float)maxValue; - if ((fabs(fmin-m_adjust->lower) < 0.2) && - (fabs(fmax-m_adjust->upper) < 0.2)) - return; + if ((fabs(fmin-m_adjust->lower) < 0.2) && + (fabs(fmax-m_adjust->upper) < 0.2)) + { + return; + } - m_adjust->lower = fmin; - m_adjust->upper = fmax; + m_adjust->lower = fmin; + m_adjust->upper = fmax; - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); } int wxSlider::GetMin(void) const { - return (int)(m_adjust->lower+0.5); + return (int)(m_adjust->lower+0.5); } int wxSlider::GetMax(void) const { - return (int)(m_adjust->upper+0.5); + return (int)(m_adjust->upper+0.5); } void wxSlider::SetPageSize( int pageSize ) { - float fpage = (float)pageSize; + float fpage = (float)pageSize; - if (fabs(fpage-m_adjust->page_increment) < 0.2) return; + if (fabs(fpage-m_adjust->page_increment) < 0.2) return; - m_adjust->page_increment = fpage; + m_adjust->page_increment = fpage; - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); } int wxSlider::GetPageSize(void) const { - return (int)(m_adjust->page_increment+0.5); + return (int)(m_adjust->page_increment+0.5); } void wxSlider::SetThumbLength( int len ) { - float flen = (float)len; + float flen = (float)len; - if (fabs(flen-m_adjust->page_size) < 0.2) return; + if (fabs(flen-m_adjust->page_size) < 0.2) return; - m_adjust->page_size = flen; + m_adjust->page_size = flen; - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); } int wxSlider::GetThumbLength(void) const { - return (int)(m_adjust->page_size+0.5); + return (int)(m_adjust->page_size+0.5); } void wxSlider::SetLineSize( int WXUNUSED(lineSize) ) @@ -196,7 +202,7 @@ void wxSlider::SetLineSize( int WXUNUSED(lineSize) ) int wxSlider::GetLineSize(void) const { - return 0; + return 0; } void wxSlider::SetTick( int WXUNUSED(tickPos) ) @@ -209,7 +215,7 @@ void wxSlider::SetTickFreq( int WXUNUSED(n), int WXUNUSED(pos) ) int wxSlider::GetTickFreq(void) const { - return 0; + return 0; } void wxSlider::ClearTicks(void) @@ -222,12 +228,12 @@ void wxSlider::SetSelection( int WXUNUSED(minPos), int WXUNUSED(maxPos) ) int wxSlider::GetSelEnd(void) const { - return 0; + return 0; } int wxSlider::GetSelStart(void) const { - return 0; + return 0; } void wxSlider::ClearSel(void) @@ -236,16 +242,16 @@ void wxSlider::ClearSel(void) bool wxSlider::IsOwnGtkWindow( GdkWindow *window ) { - GtkRange *range = GTK_RANGE(m_widget); - return ( (window == GTK_WIDGET(range)->window) || - (window == range->trough) || - (window == range->slider) || - (window == range->step_forw) || - (window == range->step_back) ); + GtkRange *range = GTK_RANGE(m_widget); + return ( (window == GTK_WIDGET(range)->window) || + (window == range->trough) || + (window == range->slider) || + (window == range->step_forw) || + (window == range->step_back) ); } void wxSlider::ApplyWidgetStyle() { - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); + SetWidgetStyle(); + gtk_widget_set_style( m_widget, m_widgetStyle ); } diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index 252eda116c..ea023f37e2 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -94,8 +94,7 @@ bool wxColourDisplay(void) int wxDisplayDepth(void) { - wxFAIL_MSG( "wxDisplayDepth always returns 8" ); - return 8; + return gdk_window_get_visual( (GdkWindow*) &gdk_root_parent )->depth; } //------------------------------------------------------------------------ diff --git a/src/gtk1/cursor.cpp b/src/gtk1/cursor.cpp index 2034a9076a..eac07cc904 100644 --- a/src/gtk1/cursor.cpp +++ b/src/gtk1/cursor.cpp @@ -32,12 +32,12 @@ class wxCursorRefData: public wxObjectRefData wxCursorRefData::wxCursorRefData() { - m_cursor = (GdkCursor *) NULL; + m_cursor = (GdkCursor *) NULL; } wxCursorRefData::~wxCursorRefData() { - if (m_cursor) gdk_cursor_destroy( m_cursor ); + if (m_cursor) gdk_cursor_destroy( m_cursor ); } //----------------------------------------------------------------------------- @@ -52,57 +52,45 @@ wxCursor::wxCursor() wxCursor::wxCursor( int cursorId ) { - m_refData = new wxCursorRefData(); - - GdkCursorType gdk_cur = GDK_LEFT_PTR; - switch (cursorId) - { - case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break; - case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break; - case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break; - case wxCURSOR_SIZENS: gdk_cur = GDK_SB_V_DOUBLE_ARROW; break; - case wxCURSOR_WAIT: gdk_cur = GDK_WATCH; break; - case wxCURSOR_WATCH: gdk_cur = GDK_WATCH; break; - case wxCURSOR_SIZING: gdk_cur = GDK_SIZING; break; - case wxCURSOR_SPRAYCAN: gdk_cur = GDK_SPRAYCAN; break; - case wxCURSOR_IBEAM: gdk_cur = GDK_XTERM; break; - case wxCURSOR_PENCIL: gdk_cur = GDK_PENCIL; break; - case wxCURSOR_NO_ENTRY: gdk_cur = GDK_PIRATE; break; - } - - M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); - + m_refData = new wxCursorRefData(); + + GdkCursorType gdk_cur = GDK_LEFT_PTR; + switch (cursorId) + { + case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break; + case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break; + case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break; + case wxCURSOR_SIZENS: gdk_cur = GDK_SB_V_DOUBLE_ARROW; break; + case wxCURSOR_WAIT: + case wxCURSOR_WATCH: gdk_cur = GDK_WATCH; break; + case wxCURSOR_SIZING: gdk_cur = GDK_SIZING; break; + case wxCURSOR_SPRAYCAN: gdk_cur = GDK_SPRAYCAN; break; + case wxCURSOR_IBEAM: gdk_cur = GDK_XTERM; break; + case wxCURSOR_PENCIL: gdk_cur = GDK_PENCIL; break; + case wxCURSOR_NO_ENTRY: gdk_cur = GDK_PIRATE; break; + case wxCURSOR_SIZENWSE: + case wxCURSOR_SIZENESW: gdk_cur = GDK_FLEUR; break; + case wxCURSOR_QUESTION_ARROW: gdk_cur = GDK_QUESTION_ARROW; break; + case wxCURSOR_PAINT_BRUSH: gdk_cur = GDK_SPRAYCAN; break; + case wxCURSOR_MAGNIFIER: gdk_cur = GDK_PLUS; break; + case wxCURSOR_CHAR: gdk_cur = GDK_XTERM; break; + case wxCURSOR_LEFT_BUTTON: gdk_cur = GDK_LEFTBUTTON; break; + case wxCURSOR_MIDDLE_BUTTON: gdk_cur = GDK_MIDDLEBUTTON; break; + case wxCURSOR_RIGHT_BUTTON: gdk_cur = GDK_RIGHTBUTTON; break; /* - do that yourself - - wxCURSOR_BULLSEYE, - wxCURSOR_CHAR, - wxCURSOR_LEFT_BUTTON, - wxCURSOR_MAGNIFIER, - wxCURSOR_MIDDLE_BUTTON, - wxCURSOR_NO_ENTRY, - wxCURSOR_PAINT_BRUSH, - wxCURSOR_POINT_LEFT, - wxCURSOR_POINT_RIGHT, - wxCURSOR_QUESTION_ARROW, - wxCURSOR_RIGHT_BUTTON, - wxCURSOR_SIZENESW, - wxCURSOR_SIZENS, - wxCURSOR_SIZENWSE, - wxCURSOR_SIZEWE, - wxCURSOR_BLANK -, - wxCURSOR_CROSS_REVERSE, - wxCURSOR_DOUBLE_ARROW, - wxCURSOR_BASED_ARROW_UP, - wxCURSOR_BASED_ARROW_DOWN + case wxCURSOR_DOUBLE_ARROW: gdk_cur = GDK_DOUBLE_ARROW; break; + case wxCURSOR_CROSS_REVERSE: gdk_cur = GDK_CROSS_REVERSE; break; + case wxCURSOR_BASED_ARROW_UP: gdk_cur = GDK_BASED_ARROW_UP; break; + case wxCURSOR_BASED_ARROW_DOWN: gdk_cur = GDK_BASED_ARROW_DOWN; break; */ + } + M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); } wxCursor::wxCursor( const wxCursor &cursor ) { - Ref( cursor ); + Ref( cursor ); } wxCursor::~wxCursor() @@ -111,29 +99,30 @@ wxCursor::~wxCursor() wxCursor& wxCursor::operator = ( const wxCursor& cursor ) { - if (*this == cursor) return (*this); - Ref( cursor ); - return *this; + if (*this == cursor) return (*this); + Ref( cursor ); + + return *this; } bool wxCursor::operator == ( const wxCursor& cursor ) const { - return m_refData == cursor.m_refData; + return m_refData == cursor.m_refData; } bool wxCursor::operator != ( const wxCursor& cursor ) const { - return m_refData != cursor.m_refData; + return m_refData != cursor.m_refData; } bool wxCursor::Ok() const { - return (m_refData != NULL); + return (m_refData != NULL); } GdkCursor *wxCursor::GetCursor() const { - return M_CURSORDATA->m_cursor; + return M_CURSORDATA->m_cursor; } //----------------------------------------------------------------------------- @@ -144,25 +133,25 @@ bool g_isBusy = FALSE; void wxEndBusyCursor() { - g_isBusy = FALSE; + g_isBusy = FALSE; } void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) { - g_isBusy = TRUE; + g_isBusy = TRUE; } bool wxIsBusy() { - return g_isBusy; + return g_isBusy; } void wxSetCursor( const wxCursor& cursor ) { - extern wxCursor *g_globalCursor; - if (g_globalCursor) (*g_globalCursor) = cursor; + extern wxCursor *g_globalCursor; + if (g_globalCursor) (*g_globalCursor) = cursor; - if (cursor.Ok()) {} + if (cursor.Ok()) {} } diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index ff038197a8..147c0d5a1c 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -167,6 +167,23 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) if (!menu->IsEnabled(id)) return; + wxMenuItem* item = menu->FindItem( id ); + wxCHECK_RET( item, "error in menu item callback" ); + + if (item->m_isCheckMenu) + { + if (item->m_isChecked == item->IsChecked()) + { + /* the menu item has been checked by calling wxMenuItem->Check() */ + return; + } + else + { + /* the user pressed on the menu item -> report */ + item->m_isChecked; /* make consistent again */ + } + } + wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, id ); event.SetEventObject( menu ); event.SetInt(id ); @@ -253,6 +270,8 @@ void wxMenuItem::Check( bool check ) wxCHECK_RET( IsCheckable(), "Can't check uncheckable item!" ) + if (check == m_isChecked) return; + m_isChecked = check; gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)check ); } @@ -273,8 +292,6 @@ bool wxMenuItem::IsChecked() const bool bIsChecked = ((GtkCheckMenuItem*)m_menuItem)->active != 0; - wxASSERT( bIsChecked == m_isChecked ); // consistency check - return bIsChecked; } diff --git a/src/gtk1/scrolbar.cpp b/src/gtk1/scrolbar.cpp index a6973405bc..ee6d3eec70 100644 --- a/src/gtk1/scrolbar.cpp +++ b/src/gtk1/scrolbar.cpp @@ -32,45 +32,45 @@ extern bool g_blockEventsOnScroll; static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) { - if (!win->HasVMT()) return; - if (g_blockEventsOnDrag) return; + if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; - float diff = win->m_adjust->value - win->m_oldPos; - if (fabs(diff) < 0.2) return; + float diff = win->m_adjust->value - win->m_oldPos; + if (fabs(diff) < 0.2) return; - wxEventType command = wxEVT_NULL; + wxEventType command = wxEVT_NULL; - float line_step = win->m_adjust->step_increment; - float page_step = win->m_adjust->page_increment; + float line_step = win->m_adjust->step_increment; + float page_step = win->m_adjust->page_increment; - if (win->m_isScrolling) - { - command = wxEVT_SCROLL_THUMBTRACK; - } - else - { - if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; - else command = wxEVT_SCROLL_THUMBTRACK; - } - - int value = (int)(win->m_adjust->value+0.5); + if (win->m_isScrolling) + { + command = wxEVT_SCROLL_THUMBTRACK; + } + else + { + if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; + else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; + else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; + else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; + else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; + else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; + else command = wxEVT_SCROLL_THUMBTRACK; + } + + int value = (int)(win->m_adjust->value+0.5); - int orient = wxHORIZONTAL; - if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL; + int orient = wxHORIZONTAL; + if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL; - wxScrollEvent event( command, win->GetId(), value, orient ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); + wxScrollEvent event( command, win->GetId(), value, orient ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); /* - wxCommandEvent cevent( wxEVT_COMMAND_SCROLLBAR_UPDATED, win->GetId() ); - cevent.SetEventObject( win ); - win->ProcessEvent( cevent ); + wxCommandEvent cevent( wxEVT_COMMAND_SCROLLBAR_UPDATED, win->GetId() ); + cevent.SetEventObject( win ); + win->ProcessEvent( cevent ); */ } @@ -96,12 +96,12 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *WXUNUSED(widget), GdkEventButton *WXUNUSED(gdk_event), wxScrollBar *win ) { - win->m_isScrolling = FALSE; + win->m_isScrolling = FALSE; // g_blockEventsOnScroll = FALSE; - gtk_signal_emit_by_name( GTK_OBJECT(win->m_adjust), "value_changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(win->m_adjust), "value_changed" ); - return FALSE; + return FALSE; } //----------------------------------------------------------------------------- @@ -118,175 +118,181 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) { - m_needParent = TRUE; - m_acceptsFocus = TRUE; + m_needParent = TRUE; + m_acceptsFocus = TRUE; - PreCreation( parent, id, pos, size, style, name ); + PreCreation( parent, id, pos, size, style, name ); - SetValidator( validator ); + SetValidator( validator ); - m_oldPos = 0.0; + m_oldPos = 0.0; - if (style & wxSB_VERTICAL == wxSB_VERTICAL) - m_widget = gtk_hscrollbar_new( (GtkAdjustment *) NULL ); - else - m_widget = gtk_vscrollbar_new( (GtkAdjustment *) NULL ); + if (style & wxSB_VERTICAL == wxSB_VERTICAL) + m_widget = gtk_hscrollbar_new( (GtkAdjustment *) NULL ); + else + m_widget = gtk_vscrollbar_new( (GtkAdjustment *) NULL ); - m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); + m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); - gtk_signal_connect (GTK_OBJECT (m_adjust), "value_changed", - (GtkSignalFunc) gtk_scrollbar_callback, (gpointer) this ); + gtk_signal_connect( GTK_OBJECT(m_adjust), + "value_changed", + (GtkSignalFunc) gtk_scrollbar_callback, + (gpointer) this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "button_press_event", - (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this ); + gtk_signal_connect( GTK_OBJECT(m_widget), + "button_press_event", + (GtkSignalFunc)gtk_scrollbar_button_press_callback, + (gpointer) this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "button_release_event", - (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); + gtk_signal_connect( GTK_OBJECT(m_widget), + "button_release_event", + (GtkSignalFunc)gtk_scrollbar_button_release_callback, + (gpointer) this ); - m_parent->AddChild( this ); + m_parent->AddChild( this ); - (m_parent->m_insertCallback)( m_parent, this ); + (m_parent->m_insertCallback)( m_parent, this ); - PostCreation(); + PostCreation(); - SetBackgroundColour( parent->GetBackgroundColour() ); + SetBackgroundColour( parent->GetBackgroundColour() ); - Show( TRUE ); + Show( TRUE ); - return TRUE; + return TRUE; } int wxScrollBar::GetThumbPosition(void) const { - return (int)(m_adjust->value+0.5); + return (int)(m_adjust->value+0.5); } int wxScrollBar::GetThumbSize() const { - return (int)(m_adjust->page_size+0.5); + return (int)(m_adjust->page_size+0.5); } int wxScrollBar::GetPageSize() const { - return (int)(m_adjust->page_increment+0.5); + return (int)(m_adjust->page_increment+0.5); } int wxScrollBar::GetRange() const { - return (int)(m_adjust->upper+0.5); + return (int)(m_adjust->upper+0.5); } void wxScrollBar::SetThumbPosition( int viewStart ) { - if (m_isScrolling) return; + if (m_isScrolling) return; - float fpos = (float)viewStart; - m_oldPos = fpos; - if (fabs(fpos-m_adjust->value) < 0.2) return; - m_adjust->value = fpos; + float fpos = (float)viewStart; + m_oldPos = fpos; + if (fabs(fpos-m_adjust->value) < 0.2) return; + m_adjust->value = fpos; - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); } void wxScrollBar::SetScrollbar( int position, int thumbSize, int range, int pageSize, bool WXUNUSED(refresh) ) { - float fpos = (float)position; - float frange = (float)range; - float fthumb = (float)thumbSize; - float fpage = (float)pageSize; + float fpos = (float)position; + float frange = (float)range; + float fthumb = (float)thumbSize; + float fpage = (float)pageSize; - if ((fabs(frange-m_adjust->upper) < 0.2) && - (fabs(fthumb-m_adjust->page_size) < 0.2) && - (fabs(fpage-m_adjust->page_increment) < 0.2)) - { - SetThumbPosition( position ); - return; - } + if ((fabs(frange-m_adjust->upper) < 0.2) && + (fabs(fthumb-m_adjust->page_size) < 0.2) && + (fabs(fpage-m_adjust->page_increment) < 0.2)) + { + SetThumbPosition( position ); + return; + } - m_oldPos = fpos; + m_oldPos = fpos; - m_adjust->lower = 0.0; - m_adjust->upper = frange; - m_adjust->value = fpos; - m_adjust->step_increment = 1.0; - m_adjust->page_increment = (float)(wxMax(fpage,0)); - m_adjust->page_size = fthumb; - - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); + m_adjust->lower = 0.0; + m_adjust->upper = frange; + m_adjust->value = fpos; + m_adjust->step_increment = 1.0; + m_adjust->page_increment = (float)(wxMax(fpage,0)); + m_adjust->page_size = fthumb; + + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); } -// Backward compatibility +/* Backward compatibility */ int wxScrollBar::GetValue(void) const { - return GetThumbPosition(); + return GetThumbPosition(); } void wxScrollBar::SetValue( int viewStart ) { - SetThumbPosition( viewStart ); + SetThumbPosition( viewStart ); } void wxScrollBar::GetValues( int *viewStart, int *viewLength, int *objectLength, int *pageLength ) const { - int pos = (int)(m_adjust->value+0.5); - int thumb = (int)(m_adjust->page_size+0.5); - int page = (int)(m_adjust->page_increment+0.5); - int range = (int)(m_adjust->upper+0.5); + int pos = (int)(m_adjust->value+0.5); + int thumb = (int)(m_adjust->page_size+0.5); + int page = (int)(m_adjust->page_increment+0.5); + int range = (int)(m_adjust->upper+0.5); - *viewStart = pos; - *viewLength = range; - *objectLength = thumb; - *pageLength = page; + *viewStart = pos; + *viewLength = range; + *objectLength = thumb; + *pageLength = page; } int wxScrollBar::GetViewLength() const { - return (int)(m_adjust->upper+0.5); + return (int)(m_adjust->upper+0.5); } int wxScrollBar::GetObjectLength() const { - return (int)(m_adjust->page_size+0.5); + return (int)(m_adjust->page_size+0.5); } void wxScrollBar::SetPageSize( int pageLength ) { - int pos = (int)(m_adjust->value+0.5); - int thumb = (int)(m_adjust->page_size+0.5); - int range = (int)(m_adjust->upper+0.5); - SetScrollbar( pos, thumb, range, pageLength ); + int pos = (int)(m_adjust->value+0.5); + int thumb = (int)(m_adjust->page_size+0.5); + int range = (int)(m_adjust->upper+0.5); + SetScrollbar( pos, thumb, range, pageLength ); } void wxScrollBar::SetObjectLength( int objectLength ) { - int pos = (int)(m_adjust->value+0.5); - int page = (int)(m_adjust->page_increment+0.5); - int range = (int)(m_adjust->upper+0.5); - SetScrollbar( pos, objectLength, range, page ); + int pos = (int)(m_adjust->value+0.5); + int page = (int)(m_adjust->page_increment+0.5); + int range = (int)(m_adjust->upper+0.5); + SetScrollbar( pos, objectLength, range, page ); } void wxScrollBar::SetViewLength( int viewLength ) { - int pos = (int)(m_adjust->value+0.5); - int thumb = (int)(m_adjust->page_size+0.5); - int page = (int)(m_adjust->page_increment+0.5); - SetScrollbar( pos, thumb, viewLength, page ); + int pos = (int)(m_adjust->value+0.5); + int thumb = (int)(m_adjust->page_size+0.5); + int page = (int)(m_adjust->page_increment+0.5); + SetScrollbar( pos, thumb, viewLength, page ); } bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window ) { - GtkRange *range = GTK_RANGE(m_widget); - return ( (window == GTK_WIDGET(range)->window) || - (window == range->trough) || - (window == range->slider) || - (window == range->step_forw) || - (window == range->step_back) ); + GtkRange *range = GTK_RANGE(m_widget); + return ( (window == GTK_WIDGET(range)->window) || + (window == range->trough) || + (window == range->slider) || + (window == range->step_forw) || + (window == range->step_back) ); } void wxScrollBar::ApplyWidgetStyle() { - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); + SetWidgetStyle(); + gtk_widget_set_style( m_widget, m_widgetStyle ); } diff --git a/src/gtk1/settings.cpp b/src/gtk1/settings.cpp index 234bce0a2d..646386409a 100644 --- a/src/gtk1/settings.cpp +++ b/src/gtk1/settings.cpp @@ -157,26 +157,26 @@ wxColour wxSystemSettings::GetSystemColour( int index ) wxFont wxSystemSettings::GetSystemFont( int index ) { - switch (index) - { - case wxSYS_OEM_FIXED_FONT: - case wxSYS_ANSI_FIXED_FONT: - case wxSYS_SYSTEM_FIXED_FONT: - { - return *wxNORMAL_FONT; - } - case wxSYS_ANSI_VAR_FONT: - case wxSYS_SYSTEM_FONT: - case wxSYS_DEVICE_DEFAULT_FONT: - case wxSYS_DEFAULT_GUI_FONT: + switch (index) { - if (!g_systemFont) - g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); - return *g_systemFont; + case wxSYS_OEM_FIXED_FONT: + case wxSYS_ANSI_FIXED_FONT: + case wxSYS_SYSTEM_FIXED_FONT: + { + return *wxNORMAL_FONT; + } + case wxSYS_ANSI_VAR_FONT: + case wxSYS_SYSTEM_FONT: + case wxSYS_DEVICE_DEFAULT_FONT: + case wxSYS_DEFAULT_GUI_FONT: + { + if (!g_systemFont) + g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); + return *g_systemFont; + } } - } - return wxNullFont; + return wxNullFont; } int wxSystemSettings::GetSystemMetric( int index ) diff --git a/src/gtk1/slider.cpp b/src/gtk1/slider.cpp index cddd5f54f0..5f9c8915b6 100644 --- a/src/gtk1/slider.cpp +++ b/src/gtk1/slider.cpp @@ -30,37 +30,37 @@ extern bool g_blockEventsOnDrag; static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win ) { - if (!win->HasVMT()) return; - if (g_blockEventsOnDrag) return; + if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; - float diff = win->m_adjust->value - win->m_oldPos; - if (fabs(diff) < 0.2) return; + float diff = win->m_adjust->value - win->m_oldPos; + if (fabs(diff) < 0.2) return; - wxEventType command = wxEVT_NULL; + wxEventType command = wxEVT_NULL; - float line_step = win->m_adjust->step_increment; - float page_step = win->m_adjust->page_increment; + float line_step = win->m_adjust->step_increment; + float page_step = win->m_adjust->page_increment; - if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; - else command = wxEVT_SCROLL_THUMBTRACK; - - int value = (int)(win->m_adjust->value+0.5); + if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; + else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; + else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; + else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; + else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; + else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; + else command = wxEVT_SCROLL_THUMBTRACK; + + int value = (int)(win->m_adjust->value+0.5); - int orient = wxHORIZONTAL; - if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL; + int orient = wxHORIZONTAL; + if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL; - wxScrollEvent event( command, win->GetId(), value, orient ); - event.SetEventObject( win ); - win->ProcessEvent( event ); + wxScrollEvent event( command, win->GetId(), value, orient ); + event.SetEventObject( win ); + win->ProcessEvent( event ); - wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() ); - cevent.SetEventObject( win ); - win->ProcessEvent( cevent ); + wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() ); + cevent.SetEventObject( win ); + win->ProcessEvent( cevent ); } //----------------------------------------------------------------------------- @@ -83,111 +83,117 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, long style, const wxValidator& validator, const wxString& name ) { m_acceptsFocus = TRUE; - m_needParent = TRUE; + m_needParent = TRUE; - PreCreation( parent, id, pos, size, style, name ); + PreCreation( parent, id, pos, size, style, name ); - SetValidator( validator ); + SetValidator( validator ); - m_oldPos = 0.0; + m_oldPos = 0.0; - if (style & wxSL_VERTICAL == wxSL_VERTICAL) - m_widget = gtk_hscale_new( (GtkAdjustment *) NULL ); - else - m_widget = gtk_vscale_new( (GtkAdjustment *) NULL ); + if (style & wxSL_VERTICAL == wxSL_VERTICAL) + m_widget = gtk_hscale_new( (GtkAdjustment *) NULL ); + else + m_widget = gtk_vscale_new( (GtkAdjustment *) NULL ); - gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE ); + gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE ); - m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); + m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); - gtk_signal_connect (GTK_OBJECT (m_adjust), "value_changed", - (GtkSignalFunc) gtk_slider_callback, (gpointer) this ); - SetRange( minValue, maxValue ); - SetValue( value ); + gtk_signal_connect( GTK_OBJECT(m_adjust), + "value_changed", + (GtkSignalFunc) gtk_slider_callback, + (gpointer) this ); + + SetRange( minValue, maxValue ); + SetValue( value ); - m_parent->AddChild( this ); + m_parent->AddChild( this ); - (m_parent->m_insertCallback)( m_parent, this ); + (m_parent->m_insertCallback)( m_parent, this ); - PostCreation(); + PostCreation(); - SetBackgroundColour( parent->GetBackgroundColour() ); + SetBackgroundColour( parent->GetBackgroundColour() ); - Show( TRUE ); + Show( TRUE ); - return TRUE; + return TRUE; } int wxSlider::GetValue(void) const { - return (int)(m_adjust->value+0.5); + return (int)(m_adjust->value+0.5); } void wxSlider::SetValue( int value ) { - float fpos = (float)value; - m_oldPos = fpos; - if (fabs(fpos-m_adjust->value) < 0.2) return; - m_adjust->value = fpos; + float fpos = (float)value; + m_oldPos = fpos; + if (fabs(fpos-m_adjust->value) < 0.2) return; + + m_adjust->value = fpos; - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); } void wxSlider::SetRange( int minValue, int maxValue ) { - float fmin = (float)minValue; - float fmax = (float)maxValue; + float fmin = (float)minValue; + float fmax = (float)maxValue; - if ((fabs(fmin-m_adjust->lower) < 0.2) && - (fabs(fmax-m_adjust->upper) < 0.2)) - return; + if ((fabs(fmin-m_adjust->lower) < 0.2) && + (fabs(fmax-m_adjust->upper) < 0.2)) + { + return; + } - m_adjust->lower = fmin; - m_adjust->upper = fmax; + m_adjust->lower = fmin; + m_adjust->upper = fmax; - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); } int wxSlider::GetMin(void) const { - return (int)(m_adjust->lower+0.5); + return (int)(m_adjust->lower+0.5); } int wxSlider::GetMax(void) const { - return (int)(m_adjust->upper+0.5); + return (int)(m_adjust->upper+0.5); } void wxSlider::SetPageSize( int pageSize ) { - float fpage = (float)pageSize; + float fpage = (float)pageSize; - if (fabs(fpage-m_adjust->page_increment) < 0.2) return; + if (fabs(fpage-m_adjust->page_increment) < 0.2) return; - m_adjust->page_increment = fpage; + m_adjust->page_increment = fpage; - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); } int wxSlider::GetPageSize(void) const { - return (int)(m_adjust->page_increment+0.5); + return (int)(m_adjust->page_increment+0.5); } void wxSlider::SetThumbLength( int len ) { - float flen = (float)len; + float flen = (float)len; - if (fabs(flen-m_adjust->page_size) < 0.2) return; + if (fabs(flen-m_adjust->page_size) < 0.2) return; - m_adjust->page_size = flen; + m_adjust->page_size = flen; - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); } int wxSlider::GetThumbLength(void) const { - return (int)(m_adjust->page_size+0.5); + return (int)(m_adjust->page_size+0.5); } void wxSlider::SetLineSize( int WXUNUSED(lineSize) ) @@ -196,7 +202,7 @@ void wxSlider::SetLineSize( int WXUNUSED(lineSize) ) int wxSlider::GetLineSize(void) const { - return 0; + return 0; } void wxSlider::SetTick( int WXUNUSED(tickPos) ) @@ -209,7 +215,7 @@ void wxSlider::SetTickFreq( int WXUNUSED(n), int WXUNUSED(pos) ) int wxSlider::GetTickFreq(void) const { - return 0; + return 0; } void wxSlider::ClearTicks(void) @@ -222,12 +228,12 @@ void wxSlider::SetSelection( int WXUNUSED(minPos), int WXUNUSED(maxPos) ) int wxSlider::GetSelEnd(void) const { - return 0; + return 0; } int wxSlider::GetSelStart(void) const { - return 0; + return 0; } void wxSlider::ClearSel(void) @@ -236,16 +242,16 @@ void wxSlider::ClearSel(void) bool wxSlider::IsOwnGtkWindow( GdkWindow *window ) { - GtkRange *range = GTK_RANGE(m_widget); - return ( (window == GTK_WIDGET(range)->window) || - (window == range->trough) || - (window == range->slider) || - (window == range->step_forw) || - (window == range->step_back) ); + GtkRange *range = GTK_RANGE(m_widget); + return ( (window == GTK_WIDGET(range)->window) || + (window == range->trough) || + (window == range->slider) || + (window == range->step_forw) || + (window == range->step_back) ); } void wxSlider::ApplyWidgetStyle() { - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); + SetWidgetStyle(); + gtk_widget_set_style( m_widget, m_widgetStyle ); } diff --git a/src/gtk1/utilsgtk.cpp b/src/gtk1/utilsgtk.cpp index 252eda116c..ea023f37e2 100644 --- a/src/gtk1/utilsgtk.cpp +++ b/src/gtk1/utilsgtk.cpp @@ -94,8 +94,7 @@ bool wxColourDisplay(void) int wxDisplayDepth(void) { - wxFAIL_MSG( "wxDisplayDepth always returns 8" ); - return 8; + return gdk_window_get_visual( (GdkWindow*) &gdk_root_parent )->depth; } //------------------------------------------------------------------------ -- 2.45.2