extern WXDLLEXPORT_DATA(const wxChar) wxColourPickerWidgetNameStr[];
extern WXDLLEXPORT_DATA(const wxChar) wxColourPickerCtrlNameStr[];
+// show the colour in HTML form (#AABBCC) as colour button label
+#define wxCLRBTN_SHOW_LABEL 100
+
+// the default style
+#define wxCLRBTN_DEFAULT_STYLE (wxCLRBTN_SHOW_LABEL)
+
+
// ----------------------------------------------------------------------------
// wxColourPickerWidgetBase: a generic abstract interface which must be
// same prototype for their contructor (and also explains why we use
// define instead of a typedef)
// since GTK > 2.4, there is GtkColorButton
-#if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
+#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/clrpicker.h"
#define wxColourPickerWidget wxColourButton
#else
#include "wx/control.h"
+// class name
+extern WXDLLIMPEXP_DATA_CORE(const wxChar) wxCollapsiblePaneNameStr[];
// ----------------------------------------------------------------------------
// wxCollapsiblePaneBase: interface for wxCollapsiblePane
wx__DECLARE_EVT1(wxEVT_COMMAND_COLLPANE_CHANGED, id, wxCollapsiblePaneEventHandler(fn))
-#if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
+#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/collpane.h"
#else
#include "wx/generic/collpaneg.h"
#define wxDirDialog wxGenericDirDialog
#elif defined(__WXMSW__)
#include "wx/msw/dirdlg.h" // Native MSW
-#elif defined(__WXGTK24__)
+#elif defined(__WXGTK20__)
#include "wx/gtk/dirdlg.h" // Native GTK for gtk2.4
#elif defined(__WXGTK__)
#include "wx/generic/dirdlgg.h"
void GenerateSelectionChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd );
void GenerateFileActivatedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd, const wxString filename = wxEmptyString );
-#if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
+#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#define wxFileCtrl wxGtkFileCtrl
#include "wx/gtk/filectrl.h"
#else
#include "wx/msw/filedlg.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/filedlg.h"
-#elif defined(__WXGTK24__)
+#elif defined(__WXGTK20__)
#include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version
#elif defined(__WXGTK__)
#include "wx/gtk1/filedlg.h"
// uses the currently selected font to draw the label of the button
#define wxFNTP_USEFONT_FOR_LABEL 0x0010
-// since GTK > 2.4, there is GtkFontButton
-#if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
+#define wxFONTBTN_DEFAULT_STYLE \
+ (wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL)
+
+// native version currently only exists in wxGTK2
+#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/fontpicker.h"
#define wxFontPickerWidget wxFontButton
#else
// wxGenericColourButton: a button which brings up a wxColourDialog
//-----------------------------------------------------------------------------
-// show the colour in HTML form (#AABBCC) as colour button label
-#define wxCLRBTN_SHOW_LABEL 100
-
-// the default style
-#define wxCLRBTN_DEFAULT_STYLE (wxCLRBTN_SHOW_LABEL)
-
-
class WXDLLIMPEXP_CORE wxGenericColourButton : public wxButton,
public wxColourPickerWidgetBase
{
class WXDLLIMPEXP_FWD_CORE wxButton;
class WXDLLIMPEXP_FWD_CORE wxStaticLine;
-// class name
-extern WXDLLIMPEXP_DATA_CORE(const wxChar) wxCollapsiblePaneNameStr[];
-
// ----------------------------------------------------------------------------
// wxGenericCollapsiblePane
// ----------------------------------------------------------------------------
// wxGenericFontButton: a button which brings up a wxColourDialog
//-----------------------------------------------------------------------------
-#define wxFONTBTN_DEFAULT_STYLE \
- (wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL)
-
class WXDLLIMPEXP_CORE wxGenericFontButton : public wxButton,
public wxFontPickerWidgetBase
{
#ifndef _WX_GTK_CLRPICKER_H_
#define _WX_GTK_CLRPICKER_H_
-// since GtkColorButton is available only for GTK+ >= 2.4,
-// we need to use generic version if we detect (at runtime)
-// that GTK+ < 2.4
-#include "wx/generic/clrpickerg.h"
-
//-----------------------------------------------------------------------------
// wxColourButton
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxColourButton : public wxGenericColourButton
+class WXDLLIMPEXP_CORE wxColourButton : public wxButton,
+ public wxColourPickerWidgetBase
{
public:
wxColourButton() : m_topParent(NULL) {}
Create(parent, id, initial, pos, size, style, validator, name);
}
- virtual ~wxColourButton();
-
-
-public: // overrides
-
bool Create(wxWindow *parent,
wxWindowID id,
const wxColour& initial = *wxBLACK,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxColourPickerWidgetNameStr);
+ virtual ~wxColourButton();
+
protected:
void UpdateColour();
#ifndef _WX_COLLAPSABLE_PANEL_H_GTK_
#define _WX_COLLAPSABLE_PANEL_H_GTK_
-#include "wx/generic/collpaneg.h"
-
// ----------------------------------------------------------------------------
// wxCollapsiblePane
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxCollapsiblePane : public wxGenericCollapsiblePane
+class WXDLLIMPEXP_CORE wxCollapsiblePane : public wxCollapsiblePaneBase
{
public:
wxCollapsiblePane() { Init(); }
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxCollapsiblePaneNameStr);
- void Collapse(bool collapse = true);
- bool IsCollapsed() const;
- void SetLabel(const wxString &str);
+ virtual void Collapse(bool collapse = true);
+ virtual bool IsCollapsed() const;
+ virtual void SetLabel(const wxString& str);
+
+ virtual wxWindow *GetPane() const { return m_pPane; }
+ virtual wxString GetLabel() const { return m_strLabel; }
protected:
virtual wxSize DoGetBestSize() const;
bool m_bIgnoreNextChange;
wxSize m_szCollapsed;
+ wxWindow *m_pPane;
+
+ // the button label without ">>" or "<<"
+ wxString m_strLabel;
+
private:
void OnSize(wxSizeEvent&);
#ifndef _WX_GTK_COMBOBOX_H_
#define _WX_GTK_COMBOBOX_H_
+typedef struct _GtkEntry GtkEntry;
+
//-----------------------------------------------------------------------------
// wxComboBox
//-----------------------------------------------------------------------------
virtual void SetFocus();
- void OnSize( wxSizeEvent &event );
void OnChar( wxKeyEvent &event );
// Standard event handling
protected:
// From wxWindowGTK:
- virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
// From wxItemContainer:
// override this and return true.
virtual bool UseGTKStyleBase() const { return true; }
+ // return the GtkEntry part of the combobox
+ GtkEntry *GetEntry() const;
+
private:
// From wxTextEntry:
virtual const wxWindow *GetEditableWindow() const { return this; }
#ifndef __GTKDIRDLGH__
#define __GTKDIRDLGH__
-#include "wx/generic/dirdlgg.h"
-
//-------------------------------------------------------------------------
// wxDirDialog
//-------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxDirDialog : public wxGenericDirDialog
+class WXDLLIMPEXP_CORE wxDirDialog : public wxDirDialogBase
{
public:
wxDirDialog() { }
wxString GetPath() const;
void SetPath(const wxString& path);
- virtual int ShowModal();
- virtual bool Show( bool show = true );
-
protected:
// override this from wxTLW since the native
private:
+ void OnFakeOk( wxCommandEvent &event );
+
DECLARE_DYNAMIC_CLASS(wxDirDialog)
DECLARE_EVENT_TABLE()
- void OnFakeOk( wxCommandEvent &event );
};
#endif // __GTKDIRDLGH__
#ifndef _WX_GTK_FONTPICKER_H_
#define _WX_GTK_FONTPICKER_H_
-// since GtkFontButton is available only for GTK+ >= 2.4,
-// we need to use generic version if we detect (at runtime)
-// that GTK+ < 2.4
-#include "wx/generic/fontpickerg.h"
-
//-----------------------------------------------------------------------------
// wxFontButton
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxFontButton : public wxGenericFontButton
+class WXDLLIMPEXP_CORE wxFontButton : public wxButton,
+ public wxFontPickerWidgetBase
{
public:
wxFontButton() {}
Create(parent, id, initial, pos, size, style, validator, name);
}
- virtual ~wxFontButton();
-
-
-public: // overrides
-
bool Create(wxWindow *parent,
wxWindowID id,
const wxFont& initial = wxNullFont,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxFontPickerWidgetNameStr);
+ virtual ~wxFontButton();
+
protected:
void UpdateFont();
#pragma hdrstop
#endif //__BORLANDC__
-#if wxUSE_ANIMATIONCTRL && (!defined(__WXGTK20__) || defined(__WXUNIVERSAL__))
+#if wxUSE_ANIMATIONCTRL
#include "wx/animate.h"
}
}
-#endif // wxUSE_ANIMATIONCTRL
+#endif // wxUSE_ANIMATIONCTRL
}
// paints a border
-void wxButtonToolBar::OnPaint(wxPaintEvent& event)
+void wxButtonToolBar::OnPaint(wxPaintEvent& WXUNUSED(event))
{
wxPaintDC dc(this);
// FIXME: at least under wxCE and wxGTK1 the background is black if we don't do
// this, no idea why...
-#if defined(__WXWINCE__) || (defined(__WXGTK__) && !defined(__WXGTK20__))
+#if defined(__WXWINCE__) || defined(__WXGTK__)
SetBackgroundColour(parent->GetBackgroundColour());
#endif
{
#if defined( __WXMAC__ )
return 6;
-#elif defined(__WXGTK20__)
- return 3;
#elif defined(__WXMSW__)
wxASSERT(m_pButton);
return m_pButton->ConvertDialogToPixels(wxSize(2, 0)).x;
#pragma hdrstop
#endif
-#if wxUSE_COLOURDLG && (!defined(__WXGTK20__) || defined(__WXUNIVERSAL__))
+#if wxUSE_COLOURDLG
#ifndef WX_PRECOMP
#include "wx/utils.h"
#endif // wxUSE_SLIDER
-#endif // wxUSE_COLOURDLG && !defined(__WXGTK20__)
+#endif // wxUSE_COLOURDLG
// wxFileIconsTable icons
// ----------------------------------------------------------------------------
-#ifndef __WXGTK24__
+#ifndef __WXGTK20__
/* Computer (c) Julian Smart */
static const char * file_icons_tbl_computer_xpm[] = {
/* columns rows colors chars-per-pixel */
" dfffffffffffffd",
" "
};
-#endif // GTK+ < 2.4
+#endif // !GTK+ 2
// ----------------------------------------------------------------------------
// wxFileIconsTable & friends
wxART_CMN_DIALOG,
wxSize(16, 16)));
// computer
-#ifdef __WXGTK24__
+#ifdef __WXGTK20__
// GTK24 uses this icon in the file open dialog
m_smallImageList->Add(wxArtProvider::GetBitmap(wxART_HARDDISK,
wxART_CMN_DIALOG,
}
// More efficient: erase and redraw simultaneously if possible
-bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
+bool wxGenericDragImage::RedrawImage(const wxPoint& WXUNUSED(oldPos),
+ const wxPoint& newPos,
bool eraseOld, bool drawNew)
{
if (!m_windowDC)
stockid = id.ToAscii();
GdkPixbuf *pixbuf = CreateStockIcon(stockid, stocksize);
-
- if (!pixbuf && !gtk_check_version(2,4,0))
- {
+ if (!pixbuf)
pixbuf = CreateThemeIcon(stockid, stocksize, size);
- }
if (pixbuf && size != wxDefaultSize &&
(size.x != gdk_pixbuf_get_width(pixbuf) ||
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
-#if wxUSE_COLOURPICKERCTRL && defined(__WXGTK24__)
+#if wxUSE_COLOURPICKERCTRL
#include "wx/clrpicker.h"
// wxColourButton
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxColourButton, wxGenericColourButton)
+IMPLEMENT_DYNAMIC_CLASS(wxColourButton, wxButton)
bool wxColourButton::Create( wxWindow *parent, wxWindowID id,
const wxColour &col,
long style, const wxValidator& validator,
const wxString &name )
{
- if (!gtk_check_version(2,4,0))
+ if (!PreCreation( parent, pos, size ) ||
+ !wxControl::CreateBase(parent, id, pos, size, style, validator, name))
{
- if (!PreCreation( parent, pos, size ) ||
- !wxControl::CreateBase(parent, id, pos, size, style, validator, name))
- {
- wxFAIL_MSG( wxT("wxColourButton creation failed") );
- return false;
- }
+ wxFAIL_MSG( wxT("wxColourButton creation failed") );
+ return false;
+ }
- m_colour = col;
- m_widget = gtk_color_button_new_with_color( m_colour.GetColor() );
- gtk_widget_show(m_widget);
+ m_colour = col;
+ m_widget = gtk_color_button_new_with_color( m_colour.GetColor() );
+ gtk_widget_show(m_widget);
- // GtkColourButton signals
- g_signal_connect(m_widget, "color-set",
- G_CALLBACK(gtk_clrbutton_setcolor_callback), this);
+ // GtkColourButton signals
+ g_signal_connect(m_widget, "color-set",
+ G_CALLBACK(gtk_clrbutton_setcolor_callback), this);
- m_parent->DoAddChild( this );
+ m_parent->DoAddChild( this );
+
+ PostCreation(size);
+ SetInitialSize(size);
- PostCreation(size);
- SetInitialSize(size);
- }
- else
- return wxGenericColourButton::Create(parent, id, col, pos, size,
- style, validator, name);
return true;
}
void wxColourButton::UpdateColour()
{
- if (!gtk_check_version(2,4,0))
- gtk_color_button_set_color(GTK_COLOR_BUTTON(m_widget), m_colour.GetColor());
- else
- wxGenericColourButton::UpdateColour();
+ gtk_color_button_set_color(GTK_COLOR_BUTTON(m_widget), m_colour.GetColor());
}
-#endif // wxUSE_COLOURPICKERCTRL && defined(__WXGTK24__)
+#endif // wxUSE_COLOURPICKERCTRL
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
-#if wxUSE_COLLPANE && defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
+#if wxUSE_COLLPANE && !defined(__WXUNIVERSAL__)
#include "wx/collpane.h"
#include "wx/toplevel.h"
#include "wx/gtk/private.h"
+// the lines below duplicate the same definitions in collpaneg.cpp, if we have
+// another implementation of this class we should extract them to a common file
+
+const wxChar wxCollapsiblePaneNameStr[] = wxT("collapsiblePane");
+
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_COLLPANE_CHANGED)
+
+IMPLEMENT_DYNAMIC_CLASS(wxCollapsiblePaneEvent, wxCommandEvent)
+
// ============================================================================
// implementation
// ============================================================================
// wxCollapsiblePane
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxCollapsiblePane, wxGenericCollapsiblePane)
+IMPLEMENT_DYNAMIC_CLASS(wxCollapsiblePane, wxControl)
-BEGIN_EVENT_TABLE(wxCollapsiblePane, wxGenericCollapsiblePane)
+BEGIN_EVENT_TABLE(wxCollapsiblePane, wxCollapsiblePaneBase)
EVT_SIZE(wxCollapsiblePane::OnSize)
END_EVENT_TABLE()
const wxValidator& val,
const wxString& name)
{
- if (gtk_check_version(2,4,0))
- return wxGenericCollapsiblePane::Create(parent, id, label,
- pos, size, style, val, name);
-
m_bIgnoreNextChange = false;
if ( !PreCreation( parent, pos, size ) ||
wxSize wxCollapsiblePane::DoGetBestSize() const
{
- if (!gtk_check_version(2,4,0))
- {
- wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") );
-
- GtkRequisition req;
- req.width = 2;
- req.height = 2;
- (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
- (m_widget, &req );
+ wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") );
- // notice that we do not cache our best size here as it changes
- // all times the user expands/hide our pane
- return wxSize(req.width, req.height);
- }
+ GtkRequisition req;
+ req.width = 2;
+ req.height = 2;
+ (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
+ (m_widget, &req );
- return wxGenericCollapsiblePane::DoGetBestSize();
+ // notice that we do not cache our best size here as it changes
+ // all times the user expands/hide our pane
+ return wxSize(req.width, req.height);
}
void wxCollapsiblePane::Collapse(bool collapse)
{
- if (!gtk_check_version(2,4,0))
- {
- // optimization
- if (IsCollapsed() == collapse)
- return;
+ // optimization
+ if (IsCollapsed() == collapse)
+ return;
- // do not send event in next signal handler call
- m_bIgnoreNextChange = true;
- gtk_expander_set_expanded(GTK_EXPANDER(m_widget), !collapse);
- }
- else
- wxGenericCollapsiblePane::Collapse(collapse);
+ // do not send event in next signal handler call
+ m_bIgnoreNextChange = true;
+ gtk_expander_set_expanded(GTK_EXPANDER(m_widget), !collapse);
}
bool wxCollapsiblePane::IsCollapsed() const
{
- if (!gtk_check_version(2,4,0))
- return !gtk_expander_get_expanded(GTK_EXPANDER(m_widget));
-
- return wxGenericCollapsiblePane::IsCollapsed();
+ return !gtk_expander_get_expanded(GTK_EXPANDER(m_widget));
}
void wxCollapsiblePane::SetLabel(const wxString &str)
{
- if (!gtk_check_version(2,4,0))
- {
- gtk_expander_set_label(GTK_EXPANDER(m_widget), wxGTK_CONV(str));
+ gtk_expander_set_label(GTK_EXPANDER(m_widget), wxGTK_CONV(str));
- // FIXME: we need to update our collapsed width in some way but using GetBestSize()
- // we may get the size of the control with the pane size summed up if we are expanded!
- //m_szCollapsed.x = GetBestSize().x;
- }
- else
- wxGenericCollapsiblePane::SetLabel(str);
+ // FIXME: we need to update our collapsed width in some way but using GetBestSize()
+ // we may get the size of the control with the pane size summed up if we are expanded!
+ //m_szCollapsed.x = GetBestSize().x;
}
void wxCollapsiblePane::OnSize(wxSizeEvent &ev)
m_pPane->Layout();
}
-#endif // wxUSE_COLLPANE && defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
+#endif // wxUSE_COLLPANE && !defined(__WXUNIVERSAL__)
#pragma hdrstop
#endif
-#if wxUSE_COLOURDLG && defined(__WXGTK20__)
+#if wxUSE_COLOURDLG
#include "wx/colordlg.h"
g_free(pal);
}
-#endif // wxUSE_COLOURDLG && defined(__WXGTK20__)
+#endif // wxUSE_COLOURDLG
#include "wx/arrstr.h"
#endif
-// We use GtkCombo which has been deprecated since GTK+ 2.3.0
-// in favour of GtkComboBox for <GTK2.4 runtime
-// We also use GtkList
-#ifdef GTK_DISABLE_DEPRECATED
-#undef GTK_DISABLE_DEPRECATED
-#endif
#include "wx/gtk/private.h"
-//-----------------------------------------------------------------------------
-// data
-//-----------------------------------------------------------------------------
-
-extern bool g_blockEventsOnDrag;
-static int g_SelectionBeforePopup = wxID_NONE; // this means the popup is hidden
-
-//-----------------------------------------------------------------------------
-// "changed" - typing and list item matches get changed, select-child
-// if it doesn't match an item then just get a single changed
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static void
-gtkcombo_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
-{
- if (combo->m_ignoreNextUpdate)
- {
- combo->m_ignoreNextUpdate = false;
- return;
- }
-
- if (!combo->m_hasVMT) return;
-
- wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
- event.SetString( combo->GetValue() );
- event.SetEventObject( combo );
- combo->GetEventHandler()->ProcessEvent( event );
-}
-}
-
-extern "C" {
-static void
-gtkcombo_dummy_callback(GtkEntry *WXUNUSED(entry), GtkCombo *WXUNUSED(combo))
-{
-}
-}
-
-extern "C" {
-static void
-gtkcombo_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo)
-{
- // when the popup is hidden, throw a SELECTED event only if the combobox
- // selection changed.
- const int curSelection = combo->GetCurrentSelection();
-
- const bool hasChanged = curSelection != g_SelectionBeforePopup;
-
- // reset the selection flag to value meaning that it is hidden and do it
- // now, before generating the events, so that GetSelection() returns the
- // new value from the event handler
- g_SelectionBeforePopup = wxID_NONE;
-
- if ( hasChanged )
- {
- wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
- event.SetInt( curSelection );
- event.SetString( combo->GetStringSelection() );
- event.SetEventObject( combo );
- combo->GetEventHandler()->ProcessEvent( event );
-
- // for consistency with the other ports, send TEXT event
- wxCommandEvent event2( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
- event2.SetString( combo->GetStringSelection() );
- event2.SetEventObject( combo );
- combo->GetEventHandler()->ProcessEvent( event2 );
- }
-}
-}
-
-extern "C" {
-static void
-gtkcombo_popup_show_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo)
-{
- // store the combobox selection value before the popup is shown
- g_SelectionBeforePopup = combo->GetCurrentSelection();
-}
-}
-
-//-----------------------------------------------------------------------------
-// "select-child" - click/cursor get select-child, changed, select-child
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static void
-gtkcombo_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(widget), wxComboBox *combo )
-{
- if (!combo->m_hasVMT) return;
-
- if (g_blockEventsOnDrag) return;
-
- int curSelection = combo->GetCurrentSelection();
-
- if (combo->m_prevSelection == curSelection) return;
-
- GtkWidget *list = GTK_COMBO(combo->m_widget)->list;
- gtk_list_unselect_item( GTK_LIST(list), combo->m_prevSelection );
-
- combo->m_prevSelection = curSelection;
-
- // Quickly set the value of the combo box
- // as GTK+ does that only AFTER the event
- // is sent.
- GtkWidget* entry = GTK_COMBO(combo->GetHandle())->entry;
- g_signal_handlers_block_by_func(
- entry, (gpointer)gtkcombo_text_changed_callback, combo);
- combo->SetValue( combo->GetStringSelection() );
- g_signal_handlers_unblock_by_func(
- entry, (gpointer)gtkcombo_text_changed_callback, combo);
-
- // throw a SELECTED event only if the combobox popup is hidden (wxID_NONE)
- // because when combobox popup is shown, gtkcombo_combo_select_child_callback is
- // called each times the mouse is over an item with a pressed button so a lot
- // of SELECTED event could be generated if the user keep the mouse button down
- // and select other items ...
- if (g_SelectionBeforePopup == wxID_NONE)
- {
- wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
- event.SetInt( curSelection );
- event.SetString( combo->GetStringSelection() );
- event.SetEventObject( combo );
- combo->GetEventHandler()->ProcessEvent( event );
-
- // for consistency with the other ports, don't generate text update
- // events while the user is browsing the combobox neither
- wxCommandEvent event2( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
- event2.SetString( combo->GetValue() );
- event2.SetEventObject( combo );
- combo->GetEventHandler()->ProcessEvent( event2 );
- }
-}
-}
+// ----------------------------------------------------------------------------
+// GTK callbacks
+// ----------------------------------------------------------------------------
-#ifdef __WXGTK24__
extern "C" {
static void
gtkcombobox_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
event.SetEventObject( combo );
combo->GetEventHandler()->ProcessEvent( event );
}
-}
-extern "C" {
static void
gtkcombobox_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{
}
}
-#endif
-
//-----------------------------------------------------------------------------
// wxComboBox
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl)
BEGIN_EVENT_TABLE(wxComboBox, wxControl)
- EVT_SIZE(wxComboBox::OnSize)
EVT_CHAR(wxComboBox::OnChar)
EVT_MENU(wxID_CUT, wxComboBox::OnCut)
if(HasFlag(wxCB_SORT))
m_strings = new wxSortedArrayString();
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- m_widget = gtk_combo_box_entry_new_text();
-
- gtk_entry_set_editable( GTK_ENTRY( GTK_BIN(m_widget)->child ), TRUE );
- }
- else
-#endif
- {
- m_widget = gtk_combo_new();
- GtkCombo* combo = GTK_COMBO(m_widget);
-
- // Disable GTK's broken events ...
- g_signal_handler_disconnect (combo->entry, combo->entry_change_id);
- // ... and add surrogate handler.
- combo->entry_change_id = g_signal_connect (combo->entry, "changed",
- G_CALLBACK (gtkcombo_dummy_callback),
- combo);
-
- // make it more useable
- gtk_combo_set_use_arrows_always( GTK_COMBO(m_widget), TRUE );
+ m_widget = gtk_combo_box_entry_new_text();
- // and case-sensitive
- gtk_combo_set_case_sensitive( GTK_COMBO(m_widget), TRUE );
+ GtkEntry * const entry = GetEntry();
- if (style & wxNO_BORDER)
- g_object_set (combo->entry, "has-frame", FALSE, NULL );
- }
+ gtk_entry_set_editable( entry, TRUE );
Append(n, choices);
m_parent->DoAddChild( this );
- GtkEntry *entry = NULL;
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
- else
-#endif
- entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
m_focusWidget = GTK_WIDGET( entry );
PostCreation(size);
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- ConnectWidget( m_widget );
- else
-#endif
- ConnectWidget( GTK_COMBO(m_widget)->button );
+ ConnectWidget( m_widget );
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- gtk_entry_set_text( entry, wxGTK_CONV(value) );
+ gtk_entry_set_text( entry, wxGTK_CONV(value) );
- if (style & wxCB_READONLY)
- gtk_entry_set_editable( entry, FALSE );
+ if (style & wxCB_READONLY)
+ gtk_entry_set_editable( entry, FALSE );
- g_signal_connect_after (entry, "changed",
- G_CALLBACK (gtkcombobox_text_changed_callback), this);
+ g_signal_connect_after (entry, "changed",
+ G_CALLBACK (gtkcombobox_text_changed_callback), this);
- g_signal_connect_after (m_widget, "changed",
- G_CALLBACK (gtkcombobox_changed_callback), this);
+ g_signal_connect_after (m_widget, "changed",
+ G_CALLBACK (gtkcombobox_changed_callback), this);
- }
- else
-#endif
- {
- GtkCombo *combo = GTK_COMBO(m_widget);
- // MSW's combo box shows the value and the selection is -1
- gtk_entry_set_text( entry, wxGTK_CONV(value) );
- gtk_list_unselect_all( GTK_LIST(combo->list) );
-
- if (style & wxCB_READONLY)
- gtk_entry_set_editable( entry, FALSE );
-
- // "show" and "hide" events are generated when user click on the combobox button which popups a list
- // this list is the "popwin" gtk widget
- g_signal_connect (GTK_COMBO(combo)->popwin, "hide",
- G_CALLBACK (gtkcombo_popup_hide_callback), this);
- g_signal_connect (GTK_COMBO(combo)->popwin, "show",
- G_CALLBACK (gtkcombo_popup_show_callback), this);
- g_signal_connect_after (combo->list, "select-child",
- G_CALLBACK (gtkcombo_combo_select_child_callback),
- this);
- g_signal_connect_after (entry, "changed",
- G_CALLBACK (gtkcombo_text_changed_callback), this);
- }
SetInitialSize(size); // need this too because this is a wxControlWithItems
return true;
}
+GtkEntry *wxComboBox::GetEntry() const
+{
+ return GTK_ENTRY(GTK_BIN(m_widget)->child);
+}
+
GtkEditable *wxComboBox::GetEditable() const
{
-#ifdef __WXGTK24__
- if ( !gtk_check_version(2,4,0) )
- return GTK_EDITABLE( GTK_BIN(m_widget)->child );
- else
-#endif
- return GTK_EDITABLE( GTK_COMBO(m_widget)->entry );
+ return GTK_EDITABLE( GTK_BIN(m_widget)->child );
}
wxComboBox::~wxComboBox()
int n = wxNOT_FOUND;
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- for( int i = 0; i < count; ++i )
- {
- n = pos + i;
- // If sorted, use this wxSortedArrayStrings to determine
- // the right insertion point
- if(m_strings)
- n = m_strings->Add(items[i]);
-
- gtk_combo_box_insert_text( combobox, n, wxGTK_CONV( items[i] ) );
-
- m_clientData.Insert( NULL, n );
- AssignNewItemClientData(n, clientData, i, type);
- }
- }
- else
-#endif
+ GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
+ for( int i = 0; i < count; ++i )
{
- DisableEvents();
-
- GtkWidget *list = GTK_COMBO(m_widget)->list;
- for( int i = 0; i < count; ++i )
- {
- n = pos + i;
- // If sorted, use this wxSortedArrayStrings to determine
- // the right insertion point
- if(m_strings)
- n = m_strings->Add(items[i]);
-
- GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( items[i] ) );
-
- // TODO construct a list with all items and call gtk_list_insert_items once?
- GList *gitem_list = g_list_alloc ();
- gitem_list->data = list_item;
- gtk_list_insert_items( GTK_LIST (list), gitem_list, n );
-
- m_clientData.Insert( NULL, n );
- AssignNewItemClientData(n, clientData, i, type);
-
- if (GTK_WIDGET_REALIZED(m_widget))
- {
- gtk_widget_realize( list_item );
- gtk_widget_realize( GTK_BIN(list_item)->child );
-
- ApplyWidgetStyle();
- }
+ n = pos + i;
+ // If sorted, use this wxSortedArrayStrings to determine
+ // the right insertion point
+ if(m_strings)
+ n = m_strings->Add(items[i]);
- gtk_widget_show( list_item );
- }
+ gtk_combo_box_insert_text( combobox, n, wxGTK_CONV( items[i] ) );
- EnableEvents();
+ m_clientData.Insert( NULL, n );
+ AssignNewItemClientData(n, clientData, i, type);
}
InvalidateBestSize();
DisableEvents();
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- const unsigned int count = GetCount();
- for (unsigned int i = 0; i < count; i++)
- gtk_combo_box_remove_text( combobox, 0 );
- }
- else // GTK+ < 2.4.0
-#endif // __WXGTK24__
- {
- GtkWidget *list = GTK_COMBO(m_widget)->list;
- gtk_list_clear_items( GTK_LIST(list), 0, GetCount() );
- }
+ GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
+ const unsigned int count = GetCount();
+ for (unsigned int i = 0; i < count; i++)
+ gtk_combo_box_remove_text( combobox, 0 );
m_clientData.Clear();
{
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- wxCHECK_RET( IsValid(n), wxT("invalid index") );
-
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- gtk_combo_box_remove_text( combobox, n );
- }
- else
-#endif
- {
- GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
-
- GList *child = g_list_nth( listbox->children, n );
-
- if (!child)
- {
- wxFAIL_MSG(wxT("wrong index"));
- return;
- }
+ wxCHECK_RET( IsValid(n), wxT("invalid index") );
- DisableEvents();
-
- GList *list = g_list_append( (GList*) NULL, child->data );
- gtk_list_remove_items( listbox, list );
- g_list_free( list );
-
- EnableEvents();
- }
+ GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
+ gtk_combo_box_remove_text( combobox, n );
m_clientData.RemoveAt( n );
if(m_strings)
{
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- wxCHECK_RET( IsValid(n), wxT("invalid index") );
+ GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
+ wxCHECK_RET( IsValid(n), wxT("invalid index") );
- GtkTreeModel *model = gtk_combo_box_get_model( combobox );
- GtkTreeIter iter;
- if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
- {
- GValue value = { 0, };
- g_value_init( &value, G_TYPE_STRING );
- g_value_set_string( &value, wxGTK_CONV( text ) );
- gtk_list_store_set_value( GTK_LIST_STORE(model), &iter, 0, &value );
- g_value_unset( &value );
- }
- }
- else
-#endif
+ GtkTreeModel *model = gtk_combo_box_get_model( combobox );
+ GtkTreeIter iter;
+ if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
{
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GList *child = g_list_nth( GTK_LIST(list)->children, n );
- if (child)
- {
- GtkBin *bin = GTK_BIN( child->data );
- GtkLabel *label = GTK_LABEL( bin->child );
- gtk_label_set_text(label, wxGTK_CONV(text));
- }
- else
- {
- wxFAIL_MSG( wxT("wxComboBox: wrong index") );
- }
+ GValue value = { 0, };
+ g_value_init( &value, G_TYPE_STRING );
+ g_value_set_string( &value, wxGTK_CONV( text ) );
+ gtk_list_store_set_value( GTK_LIST_STORE(model), &iter, 0, &value );
+ g_value_unset( &value );
}
InvalidateBestSize();
{
wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid combobox") );
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
+ GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
+ GtkTreeModel* model = gtk_combo_box_get_model( combobox );
+ GtkTreeIter iter;
+ gtk_tree_model_get_iter_first( model, &iter );
+ if (!gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter ))
+ return -1;
+ int count = 0;
+ do
{
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- GtkTreeModel* model = gtk_combo_box_get_model( combobox );
- GtkTreeIter iter;
- gtk_tree_model_get_iter_first( model, &iter );
- if (!gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter ))
- return -1;
- int count = 0;
- do
- {
- GValue value = { 0, };
- gtk_tree_model_get_value( model, &iter, 0, &value );
- wxString str = wxGTK_CONV_BACK( g_value_get_string( &value ) );
- g_value_unset( &value );
+ GValue value = { 0, };
+ gtk_tree_model_get_value( model, &iter, 0, &value );
+ wxString str = wxGTK_CONV_BACK( g_value_get_string( &value ) );
+ g_value_unset( &value );
- if (item.IsSameAs( str, bCase ) )
- return count;
+ if (item.IsSameAs( str, bCase ) )
+ return count;
- count++;
-
- } while (gtk_tree_model_iter_next( model, &iter ));
- }
- else
-#endif
- {
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GList *child = GTK_LIST(list)->children;
- int count = 0;
- while (child)
- {
- GtkBin *bin = GTK_BIN( child->data );
- GtkLabel *label = GTK_LABEL( bin->child );
- wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
-
- if (item.IsSameAs( str , bCase ) )
- return count;
-
- count++;
- child = child->next;
- }
+ count++;
}
+ while ( gtk_tree_model_iter_next(model, &iter) );
return wxNOT_FOUND;
}
int wxComboBox::GetSelection() const
{
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- return gtk_combo_box_get_active( combobox );
- }
- else
-#endif
- // if the popup is currently opened, use the selection as it had been
- // before it dropped down
- return g_SelectionBeforePopup == wxID_NONE ? GetCurrentSelection()
- : g_SelectionBeforePopup;
+ GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
+ return gtk_combo_box_get_active( combobox );
}
int wxComboBox::GetCurrentSelection() const
{
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- return gtk_combo_box_get_active( combobox );
- }
- else
-#endif
- {
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GList *selection = GTK_LIST(list)->selection;
- if (selection)
- {
- GList *child = GTK_LIST(list)->children;
- int count = 0;
- while (child)
- {
- if (child->data == selection->data) return count;
- count++;
- child = child->next;
- }
- }
- }
-
- return -1;
+ GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
+ return gtk_combo_box_get_active( combobox );
}
wxString wxComboBox::GetString(unsigned int n) const
wxString str;
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- GtkTreeModel *model = gtk_combo_box_get_model( combobox );
- GtkTreeIter iter;
- if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
- {
- GValue value = { 0, };
- gtk_tree_model_get_value( model, &iter, 0, &value );
- wxString tmp = wxGTK_CONV_BACK( g_value_get_string( &value ) );
- g_value_unset( &value );
- return tmp;
- }
- }
- else
-#endif
+ GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
+ GtkTreeModel *model = gtk_combo_box_get_model( combobox );
+ GtkTreeIter iter;
+ if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
{
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GList *child = g_list_nth( GTK_LIST(list)->children, n );
- if (child)
- {
- GtkBin *bin = GTK_BIN( child->data );
- GtkLabel *label = GTK_LABEL( bin->child );
- str = wxGTK_CONV_BACK( gtk_label_get_text(label) );
- }
- else
- {
- wxFAIL_MSG( wxT("wxComboBox: wrong index") );
- }
+ GValue value = { 0, };
+ gtk_tree_model_get_value( model, &iter, 0, &value );
+ wxString tmp = wxGTK_CONV_BACK( g_value_get_string( &value ) );
+ g_value_unset( &value );
+ return tmp;
}
return str;
{
wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid combobox") );
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- GtkTreeModel* model = gtk_combo_box_get_model( combobox );
- GtkTreeIter iter;
- gtk_tree_model_get_iter_first( model, &iter );
- if (!gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter ))
- return 0;
- unsigned int ret = 1;
- while (gtk_tree_model_iter_next( model, &iter ))
- ret++;
- return ret;
- }
- else
-#endif
- {
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GList *child = GTK_LIST(list)->children;
- unsigned int count = 0;
- while (child)
- {
- count++;
- child = child->next;
- }
- return count;
- }
+ GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
+ GtkTreeModel* model = gtk_combo_box_get_model( combobox );
+ GtkTreeIter iter;
+ gtk_tree_model_get_iter_first( model, &iter );
+ if (!gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter ))
+ return 0;
+ unsigned int ret = 1;
+ while (gtk_tree_model_iter_next( model, &iter ))
+ ret++;
+ return ret;
}
void wxComboBox::SetSelection( int n )
DisableEvents();
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- gtk_combo_box_set_active( combobox, n );
- }
- else
-#endif
- {
- GtkWidget *list = GTK_COMBO(m_widget)->list;
- gtk_list_unselect_item( GTK_LIST(list), m_prevSelection );
- gtk_list_select_item( GTK_LIST(list), n );
- m_prevSelection = n;
- }
+ GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
+ gtk_combo_box_set_active( combobox, n );
EnableEvents();
}
void wxComboBox::DisableEvents()
{
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- g_signal_handlers_block_by_func(GTK_BIN(m_widget)->child,
- (gpointer)gtkcombobox_text_changed_callback, this);
-
- g_signal_handlers_block_by_func(m_widget,
- (gpointer)gtkcombobox_changed_callback, this);
- }
- else
-#endif
- {
- g_signal_handlers_block_by_func(GTK_COMBO(m_widget)->list,
- (gpointer) gtkcombo_combo_select_child_callback, this);
+ g_signal_handlers_block_by_func(GTK_BIN(m_widget)->child,
+ (gpointer)gtkcombobox_text_changed_callback, this);
- g_signal_handlers_block_by_func(GTK_COMBO(m_widget)->entry,
- (gpointer) gtkcombo_text_changed_callback, this);
- }
+ g_signal_handlers_block_by_func(m_widget,
+ (gpointer)gtkcombobox_changed_callback, this);
}
void wxComboBox::EnableEvents()
{
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child,
- (gpointer)gtkcombobox_text_changed_callback, this);
-
- g_signal_handlers_unblock_by_func(m_widget,
- (gpointer)gtkcombobox_changed_callback, this);
- }
- else
-#endif
- {
- g_signal_handlers_unblock_by_func(GTK_COMBO(m_widget)->list,
- (gpointer) gtkcombo_combo_select_child_callback, this);
-
- g_signal_handlers_unblock_by_func(GTK_COMBO(m_widget)->entry,
- (gpointer) gtkcombo_text_changed_callback, this);
- }
-}
-
-void wxComboBox::OnSize( wxSizeEvent &event )
-{
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- // Do nothing
- }
- else
-#endif
- {
- // NB: In some situations (e.g. on non-first page of a wizard, if the
- // size used is default size), GtkCombo widget is resized correctly,
- // but it's look is not updated, it's rendered as if it was much wider.
- // No other widgets are affected, so it looks like a bug in GTK+.
- // Manually requesting resize calculation (as gtk_pizza_set_size does)
- // fixes it.
- if (GTK_WIDGET_VISIBLE(m_widget))
- gtk_widget_queue_resize(m_widget);
- }
-
- event.Skip();
-}
-
-void wxComboBox::DoApplyWidgetStyle(GtkRcStyle *style)
-{
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- // Do nothing
- }
- else
-#endif
- {
-// gtk_widget_modify_style( GTK_COMBO(m_widget)->button, syle );
+ g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child,
+ (gpointer)gtkcombobox_text_changed_callback, this);
- gtk_widget_modify_style( GTK_COMBO(m_widget)->entry, style );
- gtk_widget_modify_style( GTK_COMBO(m_widget)->list, style );
-
- GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
- GList *child = list->children;
- while (child)
- {
- gtk_widget_modify_style( GTK_WIDGET(child->data), style );
-
- GtkBin *bin = GTK_BIN(child->data);
- gtk_widget_modify_style( bin->child, style );
-
- child = child->next;
- }
- }
+ g_signal_handlers_unblock_by_func(m_widget,
+ (gpointer)gtkcombobox_changed_callback, this);
}
GtkWidget* wxComboBox::GetConnectWidget()
{
- GtkEntry *entry = NULL;
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
- else
-#endif
- entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
- return GTK_WIDGET( entry );
+ return GTK_WIDGET( GetEntry() );
}
GdkWindow *wxComboBox::GTKGetWindow(wxArrayGdkWindows& windows) const
{
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- wxUnusedVar(windows);
+ wxUnusedVar(windows);
- return GTK_ENTRY(GTK_BIN(m_widget)->child)->text_area;
- }
- else
-#endif // GTK+ 2.4
- {
- windows.push_back(GTK_ENTRY(GTK_COMBO(m_widget)->entry)->text_area);
- windows.push_back(GTK_COMBO(m_widget)->button->window);
-
- // indicate that we return multiple windows in the windows array
- return NULL;
- }
+ return GetEntry()->text_area;
}
wxSize wxComboBox::DoGetBestSize() const
wxVisualAttributes
wxComboBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
{
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- return GetDefaultAttributesFromGTKWidget(gtk_combo_box_entry_new, true);
- else
-#endif
- return GetDefaultAttributesFromGTKWidget(gtk_combo_new, true);
+ return GetDefaultAttributesFromGTKWidget(gtk_combo_box_entry_new, true);
}
// ----------------------------------------------------------------------------
bool bHasMask = image.HasMask();
int imagebitcount = (w*h)/8;
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
+ if ( gdk_display_supports_cursor_color(gdk_display_get_default()) )
{
- if ( gdk_display_supports_cursor_color(gdk_display_get_default()) )
+ unsigned char rMask = 0,
+ gMask = 0,
+ bMask = 0;
+ if (bHasMask)
{
- unsigned char rMask = 0,
- gMask = 0,
- bMask = 0;
- if (bHasMask)
- {
- rMask = image.GetMaskRed();
- gMask = image.GetMaskGreen();
- bMask = image.GetMaskBlue();
- }
+ rMask = image.GetMaskRed();
+ gMask = image.GetMaskGreen();
+ bMask = image.GetMaskBlue();
+ }
- GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, w, h);
- unsigned char *alpha = image.HasAlpha() ? image.GetAlpha() : NULL;
- unsigned char *out = gdk_pixbuf_get_pixels(pixbuf);
- int rowpad = gdk_pixbuf_get_rowstride(pixbuf) - 4 * w;
- for ( int y = 0; y < h; y++, out += rowpad )
+ GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, w, h);
+ unsigned char *alpha = image.HasAlpha() ? image.GetAlpha() : NULL;
+ unsigned char *out = gdk_pixbuf_get_pixels(pixbuf);
+ int rowpad = gdk_pixbuf_get_rowstride(pixbuf) - 4 * w;
+ for ( int y = 0; y < h; y++, out += rowpad )
+ {
+ for ( int x = 0; x < w; x++, out += 4, rgbBits += 3 )
{
- for ( int x = 0; x < w; x++, out += 4, rgbBits += 3 )
- {
- out[0] = rgbBits[0];
- out[1] = rgbBits[1];
- out[2] = rgbBits[2];
- if (bHasMask &&
- out[0] == rMask && out[1] == gMask && out[2] == bMask)
- out[3] = 0;
- else
- out[3] = alpha ? *alpha : 255;
- if ( alpha )
- ++alpha;
- }
+ out[0] = rgbBits[0];
+ out[1] = rgbBits[1];
+ out[2] = rgbBits[2];
+ if (bHasMask &&
+ out[0] == rMask && out[1] == gMask && out[2] == bMask)
+ out[3] = 0;
+ else
+ out[3] = alpha ? *alpha : 255;
+ if ( alpha )
+ ++alpha;
}
-
- int hotSpotX, hotSpotY;
- GetHotSpot(image, hotSpotX, hotSpotY);
-
- m_refData = new wxCursorRefData;
- M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixbuf
- (
- gdk_display_get_default(),
- pixbuf,
- hotSpotX, hotSpotY
- );
- g_object_unref (pixbuf);
- return;
}
+
+ int hotSpotX, hotSpotY;
+ GetHotSpot(image, hotSpotX, hotSpotY);
+
+ m_refData = new wxCursorRefData;
+ M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixbuf
+ (
+ gdk_display_get_default(),
+ pixbuf,
+ hotSpotX, hotSpotY
+ );
+ g_object_unref (pixbuf);
+ return;
}
-#endif // GTK+ 2.4+
unsigned char * bits = new unsigned char [imagebitcount];
unsigned char * maskBits = new unsigned char [imagebitcount];
// wxTextDataObject
// ----------------------------------------------------------------------------
-#if defined(__WXGTK20__) && wxUSE_UNICODE
+#if wxUSE_UNICODE
+
void
wxTextDataObject::GetAllFormats(wxDataFormat *formats,
wxDataObjectBase::Direction WXUNUSED(dir)) const
*formats++ = GetPreferredFormat();
*formats = g_altTextAtom;
}
-#endif
+
+#endif // wxUSE_UNICODE
// ----------------------------------------------------------------------------
// wxFileDataObject
/* background colour */
m_backgroundBrush = *wxWHITE_BRUSH;
m_backgroundBrush.GetColour().CalcPixel( m_cmap );
-#ifdef __WXGTK24__
const GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor();
-#else
- GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor();
-#endif
/* m_textGC */
m_textForegroundColour.CalcPixel( m_cmap );
if ((w != ww) || (h != hh))
use_bitmap = use_bitmap.Rescale( 0, 0, ww, hh, ww, hh );
- // NB: We can't render pixbufs with GTK+ < 2.2, we need to use pixmaps code.
- // Pixbufs-based bitmaps with alpha channel don't have a mask, so we
- // have to call GetPixmap() here -- it converts the pixbuf into pixmap
- // and also creates the mask as a side-effect:
- if (gtk_check_version(2,2,0))
- use_bitmap.GetPixmap();
-
// apply mask if any
GdkBitmap *mask = (GdkBitmap *) NULL;
if (useMask && use_bitmap.GetMask())
}
else
{
-#if GTK_CHECK_VERSION(2,2,0)
- if (!gtk_check_version(2,2,0) && use_bitmap.HasPixbuf())
+ if (use_bitmap.HasPixbuf())
{
gdk_draw_pixbuf(m_window, use_gc,
use_bitmap.GetPixbuf(),
GDK_RGB_DITHER_NORMAL, xx, yy);
}
else
-#endif
{
gdk_draw_drawable(m_window, use_gc,
use_bitmap.GetPixmap(),
-#if wxUSE_DIRDLG && defined( __WXGTK24__ )
+#if wxUSE_DIRDLG
#include "wx/dirdlg.h"
// wxDirDialog
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxDirDialog,wxGenericDirDialog)
+IMPLEMENT_DYNAMIC_CLASS(wxDirDialog, wxDialog)
-BEGIN_EVENT_TABLE(wxDirDialog,wxGenericDirDialog)
+BEGIN_EVENT_TABLE(wxDirDialog, wxDirDialogBase)
EVT_BUTTON(wxID_OK, wxDirDialog::OnFakeOk)
END_EVENT_TABLE()
-wxDirDialog::wxDirDialog(wxWindow* parent, const wxString& title,
- const wxString& defaultPath, long style,
- const wxPoint& pos, const wxSize& sz,
- const wxString& name)
+wxDirDialog::wxDirDialog(wxWindow* parent,
+ const wxString& title,
+ const wxString& defaultPath,
+ long style,
+ const wxPoint& pos,
+ const wxSize& WXUNUSED(sz),
+ const wxString& WXUNUSED(name))
{
- if (!gtk_check_version(2,4,0))
+ m_message = title;
+
+ parent = GetParentForModalDialog(parent);
+
+ if (!PreCreation(parent, pos, wxDefaultSize) ||
+ !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
+ wxDefaultValidator, wxT("dirdialog")))
{
- m_message = title;
-
- parent = GetParentForModalDialog(parent);
-
- if (!PreCreation(parent, pos, wxDefaultSize) ||
- !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
- wxDefaultValidator, wxT("dirdialog")))
- {
- wxFAIL_MSG( wxT("wxDirDialog creation failed") );
- return;
- }
-
- GtkWindow* gtk_parent = NULL;
- if (parent)
- gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) );
-
- m_widget = gtk_file_chooser_dialog_new(
- wxGTK_CONV(m_message),
- gtk_parent,
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT);
-
- // gtk_widget_hide_on_delete is used here to avoid that Gtk automatically destroys
- // the dialog when the user press ESC on the dialog: in that case a second call to
- // ShowModal() would result in a bunch of Gtk-CRITICAL errors...
- g_signal_connect (G_OBJECT(m_widget),
- "delete_event",
- G_CALLBACK (gtk_widget_hide_on_delete),
- (gpointer)this);
-
- // local-only property could be set to false to allow non-local files to be loaded.
- // In that case get/set_uri(s) should be used instead of get/set_filename(s) everywhere
- // and the GtkFileChooserDialog should probably also be created with a backend,
- // e.g "gnome-vfs", "default", ... (gtk_file_chooser_dialog_new_with_backend).
- // Currently local-only is kept as the default - true:
- // gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(m_widget), true);
-
- g_signal_connect (m_widget, "response",
- G_CALLBACK (gtk_dirdialog_response_callback), this);
-
- if ( !defaultPath.empty() )
- gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget),
- defaultPath.fn_str() );
+ wxFAIL_MSG( wxT("wxDirDialog creation failed") );
+ return;
}
- else
- wxGenericDirDialog::Create(parent, title, defaultPath, style, pos, sz, name);
-}
-
-void wxDirDialog::OnFakeOk( wxCommandEvent &event )
-{
- if (!gtk_check_version(2,4,0))
- EndDialog(wxID_OK);
- else
- wxGenericDirDialog::OnOK( event );
-}
-int wxDirDialog::ShowModal()
-{
- if (!gtk_check_version(2,4,0))
- return wxDialog::ShowModal();
- else
- return wxGenericDirDialog::ShowModal();
+ GtkWindow* gtk_parent = NULL;
+ if (parent)
+ gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) );
+
+ m_widget = gtk_file_chooser_dialog_new(
+ wxGTK_CONV(m_message),
+ gtk_parent,
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT);
+
+ // gtk_widget_hide_on_delete is used here to avoid that Gtk automatically destroys
+ // the dialog when the user press ESC on the dialog: in that case a second call to
+ // ShowModal() would result in a bunch of Gtk-CRITICAL errors...
+ g_signal_connect (G_OBJECT(m_widget),
+ "delete_event",
+ G_CALLBACK (gtk_widget_hide_on_delete),
+ (gpointer)this);
+
+ // local-only property could be set to false to allow non-local files to be loaded.
+ // In that case get/set_uri(s) should be used instead of get/set_filename(s) everywhere
+ // and the GtkFileChooserDialog should probably also be created with a backend,
+ // e.g "gnome-vfs", "default", ... (gtk_file_chooser_dialog_new_with_backend).
+ // Currently local-only is kept as the default - true:
+ // gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(m_widget), true);
+
+ g_signal_connect (m_widget, "response",
+ G_CALLBACK (gtk_dirdialog_response_callback), this);
+
+ if ( !defaultPath.empty() )
+ gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget),
+ defaultPath.fn_str() );
}
-bool wxDirDialog::Show( bool show )
+void wxDirDialog::OnFakeOk(wxCommandEvent& WXUNUSED(event))
{
- if (!gtk_check_version(2,4,0))
- return wxDialog::Show( show );
- else
- return wxGenericDirDialog::Show( show );
+ EndDialog(wxID_OK);
}
void wxDirDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
if (!m_wxwindow)
return;
- else
- wxGenericDirDialog::DoSetSize( x, y, width, height, sizeFlags );
+
+ wxDirDialogBase::DoSetSize( x, y, width, height, sizeFlags );
}
void wxDirDialog::SetPath(const wxString& dir)
{
- if (!gtk_check_version(2,4,0))
+ if (wxDirExists(dir))
{
- if (wxDirExists(dir))
- {
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
- dir.fn_str());
- }
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+ dir.fn_str());
}
- else
- wxGenericDirDialog::SetPath( dir );
}
wxString wxDirDialog::GetPath() const
{
- if (!gtk_check_version(2,4,0))
- {
- wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
- return wxString(str, *wxConvFileName);
- }
-
- return wxGenericDirDialog::GetPath();
+ wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
+ return wxString(str, *wxConvFileName);
}
#endif // wxUSE_DIRDLG
#include "wx/filectrl.h"
-#if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
+#if !defined(__WXUNIVERSAL__)
#ifndef WX_PRECOMP
# include "wx/sizer.h"
g_object_set (G_OBJECT (m_fcWidget), "show-hidden", show, NULL);
}
-#endif
- // wxUSE_FILECTRL
+#endif // wxUSE_FILECTRL
-#endif
- // if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
+#endif // !defined(__WXUNIVERSAL__)
}
}
-void wxFileDialog::OnFakeOk( wxCommandEvent &event )
+void wxFileDialog::OnFakeOk(wxCommandEvent& WXUNUSED(event))
{
EndDialog(wxID_OK);
}
// wxFontButton
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxFontButton, wxGenericFontButton)
+IMPLEMENT_DYNAMIC_CLASS(wxFontButton, wxButton)
bool wxFontButton::Create( wxWindow *parent, wxWindowID id,
const wxFont &initial,
long style, const wxValidator& validator,
const wxString &name )
{
- if (!gtk_check_version(2,4,0))
+ if (!PreCreation( parent, pos, size ) ||
+ !wxControl::CreateBase(parent, id, pos, size, style, validator, name))
{
- if (!PreCreation( parent, pos, size ) ||
- !wxControl::CreateBase(parent, id, pos, size, style, validator, name))
- {
- wxFAIL_MSG( wxT("wxFontButton creation failed") );
- return false;
- }
+ wxFAIL_MSG( wxT("wxFontButton creation failed") );
+ return false;
+ }
- m_widget = gtk_font_button_new();
+ m_widget = gtk_font_button_new();
- // set initial font
- m_selectedFont = initial.IsOk() ? initial : *wxNORMAL_FONT;
- UpdateFont();
+ // set initial font
+ m_selectedFont = initial.IsOk() ? initial : *wxNORMAL_FONT;
+ UpdateFont();
- // honour the fontbutton styles
- bool showall = (style & wxFNTP_FONTDESC_AS_LABEL) != 0,
- usefont = (style & wxFNTP_USEFONT_FOR_LABEL) != 0;
- gtk_font_button_set_show_style(GTK_FONT_BUTTON(m_widget), showall);
- gtk_font_button_set_show_size(GTK_FONT_BUTTON(m_widget), showall);
+ // honour the fontbutton styles
+ bool showall = (style & wxFNTP_FONTDESC_AS_LABEL) != 0,
+ usefont = (style & wxFNTP_USEFONT_FOR_LABEL) != 0;
+ gtk_font_button_set_show_style(GTK_FONT_BUTTON(m_widget), showall);
+ gtk_font_button_set_show_size(GTK_FONT_BUTTON(m_widget), showall);
- gtk_font_button_set_use_size(GTK_FONT_BUTTON(m_widget), usefont);
- gtk_font_button_set_use_font(GTK_FONT_BUTTON(m_widget), usefont);
+ gtk_font_button_set_use_size(GTK_FONT_BUTTON(m_widget), usefont);
+ gtk_font_button_set_use_font(GTK_FONT_BUTTON(m_widget), usefont);
- gtk_widget_show(m_widget);
+ gtk_widget_show(m_widget);
- // GtkFontButton signals
- g_signal_connect(m_widget, "font-set",
- G_CALLBACK(gtk_fontbutton_setfont_callback), this);
+ // GtkFontButton signals
+ g_signal_connect(m_widget, "font-set",
+ G_CALLBACK(gtk_fontbutton_setfont_callback), this);
- m_parent->DoAddChild( this );
+ m_parent->DoAddChild( this );
+
+ PostCreation(size);
+ SetInitialSize(size);
- PostCreation(size);
- SetInitialSize(size);
- }
- else
- return wxGenericFontButton::Create(parent, id, initial, pos, size,
- style, validator, name);
return true;
}
void wxFontButton::UpdateFont()
{
- if (!gtk_check_version(2,4,0))
- {
- const wxNativeFontInfo *info = m_selectedFont.GetNativeFontInfo();
- wxASSERT_MSG( info, wxT("The fontbutton's internal font is not valid ?") );
+ const wxNativeFontInfo *info = m_selectedFont.GetNativeFontInfo();
+ wxASSERT_MSG( info, wxT("The fontbutton's internal font is not valid ?") );
- const wxString& fontname = info->ToString();
- gtk_font_button_set_font_name(GTK_FONT_BUTTON(m_widget), wxGTK_CONV(fontname));
- }
- else
- wxGenericFontButton::UpdateFont();
+ const wxString& fontname = info->ToString();
+ gtk_font_button_set_font_name(GTK_FONT_BUTTON(m_widget), wxGTK_CONV(fontname));
}
-#endif // wxUSE_FONTPICKERCTRL
+#endif // wxUSE_FONTPICKERCTRL
GdkVisual *visual;
GdkColormap *colormap;
- // MR: This needs a fix for lower gtk+ versions too. Might need to rethink logic (FIXME)
-#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,2,0)
- if (!gtk_check_version(2,2,0))
- {
- wxWindow::Create( parent, id, pos, size, style, name );
-
- m_glWidget = m_wxwindow;
+ wxWindow::Create( parent, id, pos, size, style, name );
- GdkScreen *screen = gtk_widget_get_screen( m_glWidget );
- colormap = gdk_screen_get_default_colormap(screen);
- visual = gdk_colormap_get_visual(colormap);
+ m_glWidget = m_wxwindow;
- if (GDK_VISUAL_XVISUAL(visual)->visualid != xvi->visualid)
- {
- visual = gdk_x11_screen_lookup_visual( screen, xvi->visualid );
- colormap = gdk_colormap_new(visual, FALSE);
- }
+ GdkScreen *screen = gtk_widget_get_screen( m_glWidget );
+ colormap = gdk_screen_get_default_colormap(screen);
+ visual = gdk_colormap_get_visual(colormap);
- gtk_widget_set_colormap( m_glWidget, colormap );
- }
- else
-#endif // GTK+ >= 2.2
+ if (GDK_VISUAL_XVISUAL(visual)->visualid != xvi->visualid)
{
- visual = gdkx_visual_get( xvi->visualid );
- colormap = gdk_colormap_new( visual, TRUE );
-
- gtk_widget_push_colormap( colormap );
-
- wxWindow::Create( parent, id, pos, size, style, name );
- m_glWidget = m_wxwindow;
+ visual = gdk_x11_screen_lookup_visual( screen, xvi->visualid );
+ colormap = gdk_colormap_new(visual, FALSE);
}
+ gtk_widget_set_colormap( m_glWidget, colormap );
+
gtk_widget_set_double_buffered( m_glWidget, FALSE );
#if WXWIN_COMPATIBILITY_2_8
g_signal_connect(m_wxwindow, "expose_event", G_CALLBACK(gtk_glwindow_expose_callback), this);
g_signal_connect(m_widget, "size_allocate", G_CALLBACK(gtk_glcanvas_size_callback), this);
- if (gtk_check_version(2,2,0) != NULL)
- {
- gtk_widget_pop_colormap();
- }
-
#if WXWIN_COMPATIBILITY_2_8
// if our parent window is already visible, we had been realized before we
// connected to the "realize" signal and hence our m_glContext hasn't been
#endif // wxUSE_MENUS_NATIVE
-#ifdef __WXGTK20__
-
#include <gtk/gtk.h>
const char *wxGetStockGtkID(wxWindowID id)
return false;
}
-#endif // __WXGTK20__
-
#endif // wxUSE_MENUS
#pragma hdrstop
#endif
-#if wxUSE_MSGDLG && defined(__WXGTK20__) && !defined(__WXGPE__)
+#if wxUSE_MSGDLG && !defined(__WXGPE__)
#include "wx/msgdlg.h"
}
-#endif // wxUSE_MSGDLG && defined(__WXGTK20__) && !defined(__WXGPE__)
+#endif // wxUSE_MSGDLG && !defined(__WXGPE__)
{
bool success = false;
Atom property = 0;
-#if GTK_CHECK_VERSION(2, 2, 0)
- if (gtk_check_version(2, 2, 0) == NULL)
+ if (gdk_x11_screen_supports_net_wm_hint(
+ gdk_drawable_get_screen(window),
+ gdk_atom_intern("_NET_FRAME_EXTENTS", false)))
{
- if (gdk_x11_screen_supports_net_wm_hint(
- gdk_drawable_get_screen(window),
- gdk_atom_intern("_NET_FRAME_EXTENTS", false)))
- {
- success = true;
- property = gdk_x11_get_xatom_by_name_for_display(
- gdk_drawable_get_display(window),
- "_NET_FRAME_EXTENTS");
- }
- }
- else
-#endif
- {
- if (gdk_net_wm_supports(gdk_atom_intern("_NET_FRAME_EXTENTS", false)))
- {
- success = true;
- property = gdk_x11_get_xatom_by_name("_NET_FRAME_EXTENTS");
- }
+ success = true;
+ property = gdk_x11_get_xatom_by_name_for_display(
+ gdk_drawable_get_display(window),
+ "_NET_FRAME_EXTENTS");
}
+
if (success)
{
Atom type;
return success;
}
+// helper: return the GtkSettings either for the screen the current window is
+// on or for the default screen if window is NULL
+static GtkSettings *GetSettingsForWindowScreen(GdkWindow *window)
+{
+ return window ? gtk_settings_get_for_screen(gdk_drawable_get_screen(window))
+ : gtk_settings_get_default();
+}
+
int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
{
GdkWindow *window = NULL;
case wxSYS_CURSOR_X:
case wxSYS_CURSOR_Y:
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- if (window)
- return gdk_display_get_default_cursor_size(gdk_drawable_get_display(window));
- else
- return gdk_display_get_default_cursor_size(gdk_display_get_default());
- }
- else
-#endif
- return 16;
+ return gdk_display_get_default_cursor_size(
+ window ? gdk_drawable_get_display(window)
+ : gdk_display_get_default());
case wxSYS_DCLICK_X:
case wxSYS_DCLICK_Y:
gint dclick_distance;
-#if GTK_CHECK_VERSION(2,2,0)
- if (window && !gtk_check_version(2,2,0))
- g_object_get(gtk_settings_get_for_screen(gdk_drawable_get_screen(window)),
- "gtk-double-click-distance", &dclick_distance, NULL);
- else
-#endif
- g_object_get(gtk_settings_get_default(),
- "gtk-double-click-distance", &dclick_distance, NULL);
+ g_object_get(GetSettingsForWindowScreen(window),
+ "gtk-double-click-distance", &dclick_distance, NULL);
return dclick_distance * 2;
case wxSYS_DCLICK_MSEC:
gint dclick;
- g_object_get(gtk_settings_get_default(),
+ g_object_get(GetSettingsForWindowScreen(window),
"gtk-double-click-time", &dclick, NULL);
return dclick;
case wxSYS_DRAG_X:
case wxSYS_DRAG_Y:
gint drag_threshold;
-#if GTK_CHECK_VERSION(2,2,0)
- if (window && !gtk_check_version(2,2,0))
- {
- g_object_get(
- gtk_settings_get_for_screen(gdk_drawable_get_screen(window)),
- "gtk-dnd-drag-threshold",
- &drag_threshold, NULL);
- }
- else
-#endif
- {
- g_object_get(gtk_settings_get_default(),
- "gtk-dnd-drag-threshold", &drag_threshold, NULL);
- }
+ g_object_get(GetSettingsForWindowScreen(window),
+ "gtk-dnd-drag-threshold", &drag_threshold, NULL);
// The correct thing here would be to double the value
// since that is what the API wants. But the values
return drag_threshold;
- // MBN: ditto for icons
- case wxSYS_ICON_X: return 32;
- case wxSYS_ICON_Y: return 32;
+ case wxSYS_ICON_X:
+ case wxSYS_ICON_Y:
+ return 32;
case wxSYS_SCREEN_X:
-#if GTK_CHECK_VERSION(2,2,0)
- if (window && !gtk_check_version(2,2,0))
+ if (window)
return gdk_screen_get_width(gdk_drawable_get_screen(window));
else
-#endif
return gdk_screen_width();
case wxSYS_SCREEN_Y:
-#if GTK_CHECK_VERSION(2,2,0)
- if (window && !gtk_check_version(2,2,0))
+ if (window)
return gdk_screen_get_height(gdk_drawable_get_screen(window));
else
-#endif
return gdk_screen_height();
- case wxSYS_HSCROLL_Y: return 15;
- case wxSYS_VSCROLL_X: return 15;
+ case wxSYS_HSCROLL_Y:
+ case wxSYS_VSCROLL_X:
+ return 15;
case wxSYS_CAPTION_Y:
if (!window)
wxGtkTextRemoveTagsWithPrefix(text_buffer, "WXINDENT", start, end);
// Convert indent from 1/10th of a mm into pixels
- float factor;
-#if GTK_CHECK_VERSION(2,2,0)
- if (!gtk_check_version(2,2,0))
- factor = (float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
+ float factor =
+ (float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
gdk_screen_get_width_mm(gtk_widget_get_screen(text)) / 10;
- else
-#endif
- factor = (float)gdk_screen_width() / gdk_screen_width_mm() / 10;
const int indent = (int)(factor * attr.GetLeftIndent());
const int subIndent = (int)(factor * attr.GetLeftSubIndent());
if (!tag)
{
// Factor to convert from 1/10th of a mm into pixels
- float factor;
-#if GTK_CHECK_VERSION(2,2,0)
- if (!gtk_check_version(2,2,0))
- factor = (float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
+ float factor =
+ (float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
gdk_screen_get_width_mm(gtk_widget_get_screen(text)) / 10;
- else
-#endif
- factor = (float)gdk_screen_width() / gdk_screen_width_mm() / 10;
PangoTabArray* tabArray = pango_tab_array_new(tabs.GetCount(), TRUE);
for (size_t i = 0; i < tabs.GetCount(); i++)
else if ( HasFlag( wxTE_WORDWRAP ) )
wrap = GTK_WRAP_WORD;
else // HasFlag(wxTE_BESTWRAP) always true as wxTE_BESTWRAP == 0
- {
- // GTK_WRAP_WORD_CHAR seems to be new in GTK+ 2.4
-#ifdef __WXGTK24__
- if ( !gtk_check_version(2,4,0) )
- {
- wrap = GTK_WRAP_WORD_CHAR;
- }
- else
-#endif // __WXGTK24__
- wrap = GTK_WRAP_WORD;
- }
+ wrap = GTK_WRAP_WORD_CHAR;
gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), wrap );
}
}
else // single line
{
-#ifdef __WXGTK24__
- // gtk_entry_set_alignment was introduced in gtk+-2.3.5
- if (!gtk_check_version(2,4,0))
- {
- gfloat align;
- if ( HasFlag(wxTE_RIGHT) )
- align = 1.0;
- else if ( HasFlag(wxTE_CENTRE) )
- align = 0.5;
- else // single line
- align = 0.0;
-
- gtk_entry_set_alignment(GTK_ENTRY(m_text), align);
- }
-#endif // __WXGTK24__
- }
+ gfloat align;
+ if ( HasFlag(wxTE_RIGHT) )
+ align = 1.0;
+ else if ( HasFlag(wxTE_CENTRE) )
+ align = 0.5;
+ else // single line
+ align = 0.0;
+ gtk_entry_set_alignment(GTK_ENTRY(m_text), align);
+ }
}
void wxTextCtrl::SetWindowStyleFlag(long style)
if (event->state == GDK_PROPERTY_NEW_VALUE && event->atom == property &&
win->IsDecorCacheable() && !win->IsFullScreen())
{
- Atom xproperty;
-#if GTK_CHECK_VERSION(2, 2, 0)
- if (gtk_check_version(2, 2, 0) == NULL)
- {
- xproperty = gdk_x11_atom_to_xatom_for_display(
- gdk_drawable_get_display(event->window), property);
- }
- else
-#endif
- {
- xproperty = gdk_x11_atom_to_xatom(property);
- }
+ Atom xproperty = gdk_x11_atom_to_xatom_for_display(
+ gdk_drawable_get_display(event->window), property);
Atom type;
int format;
gulong nitems, bytes_after;
}
else
{
-#if GTK_CHECK_VERSION(2,1,0)
- if (!gtk_check_version(2,1,0))
+ if (style & wxFRAME_TOOL_WINDOW)
{
- if (style & wxFRAME_TOOL_WINDOW)
- {
- gtk_window_set_type_hint(GTK_WINDOW(m_widget),
- GDK_WINDOW_TYPE_HINT_UTILITY);
-
- // On some WMs, like KDE, a TOOL_WINDOW will still show
- // on the taskbar, but on Gnome a TOOL_WINDOW will not.
- // For consistency between WMs and with Windows, we
- // should set the NO_TASKBAR flag which will apply
- // the set_skip_taskbar_hint if it is available,
- // ensuring no taskbar entry will appear.
- style |= wxFRAME_NO_TASKBAR;
- }
+ gtk_window_set_type_hint(GTK_WINDOW(m_widget),
+ GDK_WINDOW_TYPE_HINT_UTILITY);
+
+ // On some WMs, like KDE, a TOOL_WINDOW will still show
+ // on the taskbar, but on Gnome a TOOL_WINDOW will not.
+ // For consistency between WMs and with Windows, we
+ // should set the NO_TASKBAR flag which will apply
+ // the set_skip_taskbar_hint if it is available,
+ // ensuring no taskbar entry will appear.
+ style |= wxFRAME_NO_TASKBAR;
}
-#endif
}
}
GTK_WINDOW(topParent->m_widget) );
}
-#if GTK_CHECK_VERSION(2,2,0)
- if (!gtk_check_version(2,2,0))
+ if (style & wxFRAME_NO_TASKBAR)
{
- if (style & wxFRAME_NO_TASKBAR)
- {
- gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), TRUE);
- }
+ gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), TRUE);
}
-#endif
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
+ if (style & wxSTAY_ON_TOP)
{
- if (style & wxSTAY_ON_TOP)
- {
- gtk_window_set_keep_above(GTK_WINDOW(m_widget), TRUE);
- }
+ gtk_window_set_keep_above(GTK_WINDOW(m_widget), TRUE);
}
-#endif
#if 0
if (!name.empty())
wxGetFullScreenMethodX11((WXDisplay*)GDK_DISPLAY(),
(WXWindow)GDK_ROOT_WINDOW());
-#if GTK_CHECK_VERSION(2,2,0)
// NB: gtk_window_fullscreen() uses freedesktop.org's WMspec extensions
// to switch to fullscreen, which is not always available. We must
// check if WM supports the spec and use legacy methods if it
// doesn't.
- if ( (method == wxX11_FS_WMSPEC) && !gtk_check_version(2,2,0) )
+ if ( method == wxX11_FS_WMSPEC )
{
if (show)
gtk_window_fullscreen( GTK_WINDOW( m_widget ) );
gtk_window_unfullscreen( GTK_WINDOW( m_widget ) );
}
else
-#endif // GTK+ >= 2.2.0
{
GdkWindow *window = m_widget->window;
gint client_x, client_y, root_x, root_y;
gint width, height;
- if (method != wxX11_FS_WMSPEC)
- {
- // don't do it always, Metacity hates it
- m_fsSaveGdkFunc = m_gdkFunc;
- m_fsSaveGdkDecor = m_gdkDecor;
- m_gdkFunc = m_gdkDecor = 0;
- gdk_window_set_decorations(window, (GdkWMDecoration)0);
- gdk_window_set_functions(window, (GdkWMFunction)0);
- }
+ m_fsSaveGdkFunc = m_gdkFunc;
+ m_fsSaveGdkDecor = m_gdkDecor;
+ m_gdkFunc = m_gdkDecor = 0;
+ gdk_window_set_decorations(window, (GdkWMDecoration)0);
+ gdk_window_set_functions(window, (GdkWMFunction)0);
gdk_window_get_origin (m_widget->window, &root_x, &root_y);
gdk_window_get_geometry (m_widget->window, &client_x, &client_y,
}
else // hide
{
- if (method != wxX11_FS_WMSPEC)
- {
- // don't do it always, Metacity hates it
- m_gdkFunc = m_fsSaveGdkFunc;
- m_gdkDecor = m_fsSaveGdkDecor;
- gdk_window_set_decorations(window, (GdkWMDecoration)m_gdkDecor);
- gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc);
- }
+ m_gdkFunc = m_fsSaveGdkFunc;
+ m_gdkDecor = m_fsSaveGdkDecor;
+ gdk_window_set_decorations(window, (GdkWMDecoration)m_gdkDecor);
+ gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc);
wxSetFullScreenStateX11((WXDisplay*)GDK_DISPLAY(),
(WXWindow)GDK_ROOT_WINDOW(),
void wxTopLevelWindowGTK::SetWindowStyleFlag( long style )
{
-#if defined(__WXGTK24__) || GTK_CHECK_VERSION(2,2,0)
// Store which styles were changed
long styleChanges = style ^ m_windowStyle;
-#endif
// Process wxWindow styles. This also updates the internal variable
// Therefore m_windowStyle bits carry now the _new_ style values
if (!m_widget)
return;
-#ifdef __WXGTK24__
- if ( (styleChanges & wxSTAY_ON_TOP) && !gtk_check_version(2,4,0) )
- gtk_window_set_keep_above(GTK_WINDOW(m_widget), m_windowStyle & wxSTAY_ON_TOP);
-#endif // GTK+ 2.4
-#if GTK_CHECK_VERSION(2,2,0)
- if ( (styleChanges & wxFRAME_NO_TASKBAR) && !gtk_check_version(2,2,0) )
+ if ( styleChanges & wxSTAY_ON_TOP )
+ {
+ gtk_window_set_keep_above(GTK_WINDOW(m_widget),
+ m_windowStyle & wxSTAY_ON_TOP);
+ }
+
+ if ( styleChanges & wxFRAME_NO_TASKBAR )
{
- gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), m_windowStyle & wxFRAME_NO_TASKBAR);
+ gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget),
+ m_windowStyle & wxFRAME_NO_TASKBAR);
}
-#endif // GTK+ 2.2
}
/* Get the X Window between child and the root window.
wxEventType event_type = wxEVT_NULL;
- // GdkDisplay is a GTK+ 2.2.0 thing
-#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2, 2, 0)
if ( gdk_event->type == GDK_2BUTTON_PRESS &&
- !gtk_check_version(2,2,0) &&
gdk_event->button >= 1 && gdk_event->button <= 3 )
{
// Reset GDK internal timestamp variables in order to disable GDK
display->button_click_time[1] = 0;
display->button_click_time[0] = 0;
}
-#endif // GTK 2+
if (gdk_event->button == 1)
{
return false;
}
-#if defined(__WXGTK20__) || !defined(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE)
- if ( fixedWidthOnly
-#if defined(__WXGTK24__)
- && (gtk_check_version(2,4,0) != NULL)
-#endif
- )
- {
- OnFacename( wxT("monospace") );
- }
- else // !fixedWidthOnly
-#endif // __WXGTK20__ || !HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
- {
- PangoFontFamily **families = NULL;
- gint n_families = 0;
- pango_context_list_families (
+ PangoFontFamily **families = NULL;
+ gint n_families = 0;
+ pango_context_list_families (
#ifdef __WXGTK20__
- gtk_widget_get_pango_context( wxGetRootWindow() ),
+ gtk_widget_get_pango_context( wxGetRootWindow() ),
#else
- wxTheApp->GetPangoContext(),
+ wxTheApp->GetPangoContext(),
#endif
- &families, &n_families );
- qsort (families, n_families, sizeof (PangoFontFamily *), wxCompareFamilies);
+ &families, &n_families );
+ qsort (families, n_families, sizeof (PangoFontFamily *), wxCompareFamilies);
- for (int i=0; i<n_families; i++)
- {
-#if defined(__WXGTK24__) || defined(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE)
- if (!fixedWidthOnly || (
-#ifdef __WXGTK24__
- !gtk_check_version(2,4,0) &&
-#endif
- pango_font_family_is_monospace(families[i])
- ) )
+ for ( int i = 0; i < n_families; i++ )
+ {
+#if defined(__WXGTK20__) || defined(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE)
+ if ( !fixedWidthOnly ||
+ pango_font_family_is_monospace(families[i]) )
#endif
- {
- const gchar *name = pango_font_family_get_name(families[i]);
- OnFacename(wxString(name, wxConvUTF8));
- }
+ {
+ const gchar *name = pango_font_family_get_name(families[i]);
+ OnFacename(wxString(name, wxConvUTF8));
}
- g_free(families);
}
+ g_free(families);
return true;
}
ret = wxFONTFAMILY_TELETYPE; // begins with "Monospace"
else if (strncmp( family_text, "courier", 7 ) == 0)
ret = wxFONTFAMILY_TELETYPE; // begins with "Courier"
-#if defined(__WXGTK24__) || defined(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE)
+#if defined(__WXGTK20__) || defined(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE)
else
-#ifdef __WXGTK24__
+#ifdef __WXGTK20__
if (!gtk_check_version(2,4,0))
#endif
{
if (family != NULL && pango_font_family_is_monospace( family ))
ret = wxFONTFAMILY_TELETYPE; // is deemed a monospace font by pango
}
-#endif // gtk24 || HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
+#endif // GTK+ 2 || HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
if (ret == wxFONTFAMILY_DEFAULT)
{