initial commit

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2025-10-31 23:37:30 +01:00
commit bf6b52fd94
9654 changed files with 4035664 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/addremovectrl.h
// Purpose: GTK specific wxAddRemoveImpl implementation
// Author: Vadim Zeitlin
// Created: 2015-02-05
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_ADDREMOVECTRL_H_
#define _WX_GTK_PRIVATE_ADDREMOVECTRL_H_
#include "wx/artprov.h"
#include "wx/bmpbuttn.h"
#include "wx/toolbar.h"
#include "wx/gtk/private/wrapgtk.h"
// ----------------------------------------------------------------------------
// wxAddRemoveImpl
// ----------------------------------------------------------------------------
class wxAddRemoveImpl : public wxAddRemoveImplBase
{
public:
wxAddRemoveImpl(wxAddRemoveAdaptor* adaptor,
wxAddRemoveCtrl* parent,
wxWindow* ctrlItems)
: wxAddRemoveImplBase(adaptor, parent, ctrlItems),
m_tbar(new wxToolBar(parent, wxID_ANY))
{
m_tbar->AddTool(wxID_ADD, wxString(), GetNamedBitmap("list-add"));
m_tbar->AddTool(wxID_REMOVE, wxString(), GetNamedBitmap("list-remove"));
#if defined(__WXGTK3__) && !defined(__WXUNIVERSAL__)
// Tweak the toolbar appearance to correspond to how the toolbars used
// in other GNOME applications for similar purposes look.
GtkToolbar* const toolbar = m_tbar->GTKGetToolbar();
GtkStyleContext* context = gtk_widget_get_style_context(GTK_WIDGET(toolbar));
gtk_style_context_add_class(context, GTK_STYLE_CLASS_INLINE_TOOLBAR);
gtk_style_context_set_junction_sides(context, GTK_JUNCTION_TOP);
#endif // GTK+3
wxSizer* const sizerTop = new wxBoxSizer(wxVERTICAL);
sizerTop->Add(ctrlItems, wxSizerFlags(1).Expand());
sizerTop->Add(m_tbar, wxSizerFlags().Expand());
parent->SetSizer(sizerTop);
m_tbar->Bind(wxEVT_UPDATE_UI,
&wxAddRemoveImplBase::OnUpdateUIAdd, this, wxID_ADD);
m_tbar->Bind(wxEVT_UPDATE_UI,
&wxAddRemoveImplBase::OnUpdateUIRemove, this, wxID_REMOVE);
m_tbar->Bind(wxEVT_TOOL, &wxAddRemoveImplBase::OnAdd, this, wxID_ADD);
m_tbar->Bind(wxEVT_TOOL, &wxAddRemoveImplBase::OnRemove, this, wxID_REMOVE);
}
virtual void SetButtonsToolTips(const wxString& addtip,
const wxString& removetip) override
{
m_tbar->SetToolShortHelp(wxID_ADD, addtip);
m_tbar->SetToolShortHelp(wxID_REMOVE, removetip);
}
private:
static wxBitmapBundle GetNamedBitmap(const wxString& name)
{
// GTK UI guidelines recommend using "symbolic" versions of the icons
// for these buttons, so try them first but fall back to the normal
// ones if symbolic theme is not installed.
wxBitmap bmp = wxArtProvider::GetBitmap(name + wxASCII_STR("-symbolic"), wxART_MENU);
if ( !bmp.IsOk() )
bmp = wxArtProvider::GetBitmap(name, wxART_MENU);
return bmp;
}
wxToolBar* const m_tbar;
};
#endif // _WX_GTK_PRIVATE_ADDREMOVECTRL_H_

View File

@@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/animate.h
// Purpose: Animation classes
// Author: Julian Smart and Guillermo Rodriguez Garcia
// Modified by: Francesco Montorsi
// Created: 13/8/99
// Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_ANIMATEH__
#define _WX_GTK_PRIVATE_ANIMATEH__
#include "wx/private/animate.h"
typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
// ----------------------------------------------------------------------------
// wxAnimationGTKImpl
// Unlike the generic wxAnimation object we won't use directly
// wxAnimationDecoders as gdk-pixbuf already provides the concept of decoder and
// will automatically use the available handlers.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxAnimationGTKImpl : public wxAnimationImpl
{
public:
wxAnimationGTKImpl()
: m_pixbuf(nullptr) {}
~wxAnimationGTKImpl() { UnRef(); }
virtual bool IsOk() const override
{ return m_pixbuf != nullptr; }
virtual bool IsCompatibleWith(wxClassInfo* ci) const override;
// unfortunately GdkPixbufAnimation does not expose these info:
virtual unsigned int GetFrameCount() const override { return 0; }
virtual wxImage GetFrame(unsigned int frame) const override;
// we can retrieve the delay for a frame only after building
// a GdkPixbufAnimationIter...
virtual int GetDelay(unsigned int WXUNUSED(frame)) const override { return 0; }
virtual wxSize GetSize() const override;
virtual bool LoadFile(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY) override;
virtual bool Load(wxInputStream &stream, wxAnimationType type = wxANIMATION_TYPE_ANY) override;
// Implementation
public: // used by GTK callbacks
GdkPixbufAnimation *GetPixbuf() const
{ return m_pixbuf; }
void SetPixbuf(GdkPixbufAnimation* p);
protected:
GdkPixbufAnimation *m_pixbuf;
private:
void UnRef();
typedef wxAnimationImpl base_type;
wxDECLARE_NO_COPY_CLASS(wxAnimationGTKImpl);
};
#endif // _WX_GTK_PRIVATE_ANIMATEH__

View File

@@ -0,0 +1,30 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/appearance.h
// Purpose: Private wxGTK functions for working with appearance settings
// Copyright: (c) 2024 Vadim Zeitlin
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_APPEARANCE_H_
#define _WX_GTK_PRIVATE_APPEARANCE_H_
namespace wxGTKImpl
{
// This enum uses the same values as org.freedesktop.appearance.color-scheme
enum class ColorScheme
{
NoPreference = 0,
PreferDark = 1,
PreferLight = 2
};
// Update GTK color scheme if possible.
//
// Return false if the preference wasn't changed because it is overridden by
// the theme anyhow.
bool UpdateColorScheme(ColorScheme colorScheme);
} // namespace wxGTKImpl
#endif // _WX_GTK_PRIVATE_APPEARANCE_H_

View File

@@ -0,0 +1,14 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/backend.h
// Author: Paul Cornett
// Copyright: (c) 2022 Paul Cornett
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifdef __WXGTK3__
namespace wxGTKImpl
{
WXDLLIMPEXP_CORE bool IsWayland(void* instance);
WXDLLIMPEXP_CORE bool IsX11(void* instance);
}
#endif

View File

@@ -0,0 +1,55 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/cairo.h
// Purpose: Cairo-related helpers
// Author: Vadim Zeitlin
// Created: 2022-09-23
// Copyright: (c) 2022 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_CAIRO_H_
#define _WX_GTK_PRIVATE_CAIRO_H_
// ----------------------------------------------------------------------------
// Redefine GDK function to avoiding deprecation warnings
// ----------------------------------------------------------------------------
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
static inline
cairo_t* wx_gdk_cairo_create(GdkWindow* w) { return gdk_cairo_create(w); }
#define gdk_cairo_create wx_gdk_cairo_create
wxGCC_WARNING_RESTORE(deprecated-declarations)
// ----------------------------------------------------------------------------
// RAII helper creating a Cairo context in ctor and destroying it in dtor
// ----------------------------------------------------------------------------
namespace wxGTKImpl
{
class CairoContext
{
public:
explicit CairoContext(GdkWindow* window)
: m_cr(gdk_cairo_create(window))
{
}
~CairoContext()
{
cairo_destroy(m_cr);
}
operator cairo_t*() const { return m_cr; }
private:
cairo_t* const m_cr;
wxDECLARE_NO_COPY_CLASS(CairoContext);
};
} // namespace wxGTKImpl
#endif // _WX_GTK_PRIVATE_CAIRO_H_

View File

@@ -0,0 +1,64 @@
///////////////////////////////////////////////////////////////////////////////
// Name: gtk/private/error.h
// Purpose: Wrapper around GError.
// Author: Vadim Zeitlin
// Created: 2012-07-25
// Copyright: (c) 2012 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_ERROR_H_
#define _WX_GTK_PRIVATE_ERROR_H_
// ----------------------------------------------------------------------------
// wxGtkError wraps GError and releases it automatically.
// ----------------------------------------------------------------------------
// Create an object of this class and pass the result of its Out() method to a
// function taking "GError**", then use GetMessage() if the function returned
// false.
class wxGtkError
{
public:
wxGtkError() { m_error = nullptr; }
explicit wxGtkError(GError* error) { m_error = error; }
~wxGtkError() { if ( m_error ) g_error_free(m_error); }
GError** Out()
{
// This would result in a GError leak.
wxASSERT_MSG( !m_error, wxS("Can't reuse the same object.") );
return &m_error;
}
// Check if any error actually occurred.
operator bool() const
{
return m_error != nullptr;
}
operator GError*() const
{
return m_error;
}
const gchar* GetMessageStr() const
{
return m_error->message;
}
wxString GetMessage() const
{
wxCHECK( m_error, wxASCII_STR("missing error object") );
return wxString::FromUTF8(m_error->message);
}
private:
GError* m_error;
wxDECLARE_NO_COPY_CLASS(wxGtkError);
};
#endif // _WX_GTK_PRIVATE_ERROR_H_

View File

@@ -0,0 +1,129 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/event.h
// Purpose: Helper functions for working with GDK and wx events
// Author: Vaclav Slavik
// Created: 2011-10-14
// Copyright: (c) 2011 Vaclav Slavik
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _GTK_PRIVATE_EVENT_H_
#define _GTK_PRIVATE_EVENT_H_
#if !GTK_CHECK_VERSION(2,10,0)
// GTK+ can reliably detect Meta key state only since 2.10 when
// GDK_META_MASK was introduced -- there wasn't any way to detect it
// in older versions. wxGTK used GDK_MOD2_MASK for this purpose, but
// GDK_MOD2_MASK is documented as:
//
// the fifth modifier key (it depends on the modifier mapping of the X
// server which key is interpreted as this modifier)
//
// In other words, it isn't guaranteed to map to Meta. This is a real
// problem: it is common to map NumLock to it (in fact, it's an exception
// if the X server _doesn't_ use it for NumLock). So the old code caused
// wxKeyEvent::MetaDown() to always return true as long as NumLock was
// on many systems, which broke all applications using
// wxKeyEvent::GetModifiers() to check modifiers state (see e.g. here:
// http://tinyurl.com/56lsk2).
//
// Because of this, it's better to not detect Meta key state at all than
// to detect it incorrectly. Hence the following #define, which causes
// m_metaDown to be always set to false.
#define GDK_META_MASK 0
#endif
namespace wxGTKImpl
{
// init wxMouseEvent with the info from GdkEventXXX struct
template<typename T> void InitMouseEvent(wxWindowGTK *win,
wxMouseEvent& event,
T *gdk_event)
{
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK) != 0;
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK) != 0;
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK) != 0;
event.m_metaDown = (gdk_event->state & GDK_META_MASK) != 0;
event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK) != 0;
event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK) != 0;
event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK) != 0;
// In gdk/win32 VK_XBUTTON1 is translated to GDK_BUTTON4_MASK
// and VK_XBUTTON2 to GDK_BUTTON5_MASK. In x11/gdk buttons 4/5
// are wheel rotation and buttons 8/9 don't change the state.
event.m_aux1Down = (gdk_event->state & GDK_BUTTON4_MASK) != 0;
event.m_aux2Down = (gdk_event->state & GDK_BUTTON5_MASK) != 0;
wxPoint pt = win->GetClientAreaOrigin();
event.m_x = (wxCoord)gdk_event->x - pt.x;
event.m_y = (wxCoord)gdk_event->y - pt.y;
// Some no-window widgets, notably GtkEntry on GTK3, have a GdkWindow
// covering part of their area. Event coordinates from that window are
// not relative to the widget, so do the conversion here.
if (win->m_wxwindow == nullptr && !gtk_widget_get_has_window(win->m_widget) &&
gtk_widget_get_window(win->m_widget) == gdk_window_get_parent(gdk_event->window))
{
GtkAllocation a;
gtk_widget_get_allocation(win->m_widget, &a);
int posX, posY;
gdk_window_get_position(gdk_event->window, &posX, &posY);
event.m_x += posX - a.x;
event.m_y += posY - a.y;
}
if ((win->m_wxwindow) && (win->GetLayoutDirection() == wxLayout_RightToLeft))
{
// origin in the upper right corner
GtkAllocation a;
gtk_widget_get_allocation(win->m_wxwindow, &a);
int window_width = a.width;
event.m_x = window_width - event.m_x;
}
event.SetEventObject( win );
event.SetId( win->GetId() );
event.SetTimestamp( gdk_event->time );
}
// Update the window currently known to be under the mouse pointer.
//
// Returns true if it was updated, false if this window was already known to
// contain the mouse pointer.
bool SetWindowUnderMouse(wxWindowGTK* win);
// Implementation of enter/leave window callbacks.
gboolean
WindowEnterCallback(GtkWidget* widget,
GdkEventCrossing* event,
wxWindowGTK* win);
gboolean
WindowLeaveCallback(GtkWidget* widget,
GdkEventCrossing* event,
wxWindowGTK* win);
gboolean
WindowMotionCallback(GtkWidget* widget,
GdkEventMotion* event,
wxWindowGTK* win,
bool synthesized = false);
gboolean
WindowButtonPressCallback(GtkWidget* widget,
GdkEventButton* event,
wxWindowGTK* win,
bool synthesized = false);
gboolean
WindowButtonReleaseCallback(GtkWidget* widget,
GdkEventButton* event,
wxWindowGTK* win,
bool synthesized = false);
} // namespace wxGTKImpl
#endif // _GTK_PRIVATE_EVENT_H_

View File

@@ -0,0 +1,41 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/eventsdisabler.h
// Purpose: Helper for temporarily disabling events.
// Author: Vadim Zeitlin
// Created: 2016-02-06
// Copyright: (c) 2016 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _GTK_PRIVATE_EVENTSDISABLER_H_
#define _GTK_PRIVATE_EVENTSDISABLER_H_
// ----------------------------------------------------------------------------
// wxGtkEventsDisabler: calls GTKDisableEvents() and GTKEnableEvents() in dtor.
// ----------------------------------------------------------------------------
// Template parameter T must be a wxGTK class providing the required methods,
// e.g. wxCheckBox, wxChoice, ...
template <typename T>
class wxGtkEventsDisabler
{
public:
// Disable the events for the specified (non-null, having lifetime greater
// than ours) window for the lifetime of this object.
explicit wxGtkEventsDisabler(T* win) : m_win(win)
{
m_win->GTKDisableEvents();
}
~wxGtkEventsDisabler()
{
m_win->GTKEnableEvents();
}
private:
T* const m_win;
wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxGtkEventsDisabler, T);
};
#endif // _GTK_PRIVATE_EVENTSDISABLER_H_

View File

@@ -0,0 +1,32 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/gdkconv.h
// Purpose: Helper functions for converting between GDK and wx types
// Author: Vadim Zeitlin
// Created: 2009-11-10
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _GTK_PRIVATE_GDKCONV_H_
#define _GTK_PRIVATE_GDKCONV_H_
namespace wxGTKImpl
{
inline wxRect wxRectFromGDKRect(const GdkRectangle *r)
{
return wxRect(r->x, r->y, r->width, r->height);
}
inline void wxRectToGDKRect(const wxRect& rect, GdkRectangle& r)
{
r.x = rect.x;
r.y = rect.y;
r.width = rect.width;
r.height = rect.height;
}
} // namespace wxGTKImpl
#endif // _GTK_PRIVATE_GDKCONV_H_

View File

@@ -0,0 +1,57 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/glibptr.h
// Purpose: Simple RAII helper for calling g_free() automatically
// Author: Vadim Zeitlin
// Created: 2024-12-28
// Copyright: (c) 2024 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_OWNEDPTR_H_
#define _WX_GTK_PRIVATE_OWNEDPTR_H_
// ----------------------------------------------------------------------------
// Convenience class for calling g_free() automatically
// ----------------------------------------------------------------------------
template <typename T>
class wxGlibPtr
{
public:
wxGlibPtr() = default;
explicit wxGlibPtr(const T *p) : m_ptr(const_cast<T*>(p)) { }
wxGlibPtr(wxGlibPtr&& other) : m_ptr(other.m_ptr) { other.m_ptr = nullptr; }
~wxGlibPtr() { g_free(m_ptr); }
wxGlibPtr& operator=(wxGlibPtr&& other)
{
if ( &other != this )
{
g_free(m_ptr);
m_ptr = other.m_ptr;
other.m_ptr = nullptr;
}
return *this;
}
const T* get() const { return m_ptr; }
operator const T*() const { return m_ptr; }
T** Out()
{
wxASSERT_MSG( !m_ptr, wxS("Can't reuse the same object.") );
return &m_ptr;
}
private:
// We store the pointer as non-const because it avoids casts in the dtor
// and Out(), but it's actually always handled as a const one.
T* m_ptr = nullptr;
wxDECLARE_NO_COPY_CLASS(wxGlibPtr);
};
#endif // _WX_GTK_PRIVATE_OWNEDPTR_H_

View File

@@ -0,0 +1,705 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/compat.h
// Purpose: Compatibility code for older GTK+ versions
// Author: Vaclav Slavik
// Created: 2011-03-25
// Copyright: (c) 2011 Vaclav Slavik <vslavik@fastmail.fm>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_COMPAT_H_
#define _WX_GTK_PRIVATE_COMPAT_H_
// ----------------------------------------------------------------------------
// Implementations of new accessors for older GTK+ versions
// ----------------------------------------------------------------------------
// GTK+ deprecated direct access to struct members and some other stuff,
// replacing them with simple accessor functions. These aren't available in
// older versions, though, so we have to provide them for compatibility.
//
// Note: wx_ prefix is used to avoid symbol conflicts at runtime
//
// Note 2: We support building against newer GTK+ version and using an older
// one at runtime, so we must provide our implementations of these
// functions even if GTK_CHECK_VERSION would indicate the function is
// already available in GTK+.
#ifndef __WXGTK3__
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.8
static inline GtkWidget* wx_gtk_scrolled_window_get_hscrollbar(GtkScrolledWindow* scrolled_window)
{
return scrolled_window->hscrollbar;
}
#define gtk_scrolled_window_get_hscrollbar wx_gtk_scrolled_window_get_hscrollbar
static inline GtkWidget* wx_gtk_scrolled_window_get_vscrollbar(GtkScrolledWindow* scrolled_window)
{
return scrolled_window->vscrollbar;
}
#define gtk_scrolled_window_get_vscrollbar wx_gtk_scrolled_window_get_vscrollbar
// ----------------------------------------------------------------------------
// the following were introduced in GLib 2.10
static inline gpointer wx_g_object_ref_sink(gpointer object)
{
g_object_ref(object);
gtk_object_sink(GTK_OBJECT(object));
return object;
}
#undef g_object_ref_sink
#define g_object_ref_sink wx_g_object_ref_sink
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.12
static inline void wx_gtk_about_dialog_set_program_name(GtkAboutDialog* about, const gchar* name)
{
gtk_about_dialog_set_name(about, name);
}
#define gtk_about_dialog_set_program_name wx_gtk_about_dialog_set_program_name
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.14
static inline gdouble wx_gtk_adjustment_get_lower(GtkAdjustment* adjustment)
{
return adjustment->lower;
}
#define gtk_adjustment_get_lower wx_gtk_adjustment_get_lower
static inline gdouble wx_gtk_adjustment_get_page_increment(GtkAdjustment* adjustment)
{
return adjustment->page_increment;
}
#define gtk_adjustment_get_page_increment wx_gtk_adjustment_get_page_increment
static inline gdouble wx_gtk_adjustment_get_page_size(GtkAdjustment* adjustment)
{
return adjustment->page_size;
}
#define gtk_adjustment_get_page_size wx_gtk_adjustment_get_page_size
static inline gdouble wx_gtk_adjustment_get_step_increment(GtkAdjustment* adjustment)
{
return adjustment->step_increment;
}
#define gtk_adjustment_get_step_increment wx_gtk_adjustment_get_step_increment
static inline gdouble wx_gtk_adjustment_get_upper(GtkAdjustment* adjustment)
{
return adjustment->upper;
}
#define gtk_adjustment_get_upper wx_gtk_adjustment_get_upper
static inline void wx_gtk_adjustment_set_step_increment(GtkAdjustment* adjustment, gdouble step_increment)
{
adjustment->step_increment = step_increment;
gtk_adjustment_changed(adjustment);
}
#define gtk_adjustment_set_step_increment wx_gtk_adjustment_set_step_increment
static inline void wx_gtk_adjustment_set_page_increment(GtkAdjustment* adjustment, gdouble page_increment)
{
adjustment->page_increment = page_increment;
gtk_adjustment_changed(adjustment);
}
#define gtk_adjustment_set_page_increment wx_gtk_adjustment_set_page_increment
static inline void wx_gtk_adjustment_set_page_size(GtkAdjustment* adjustment, gdouble page_size)
{
adjustment->page_size = page_size;
}
#define gtk_adjustment_set_page_size wx_gtk_adjustment_set_page_size
static inline GtkWidget* wx_gtk_color_selection_dialog_get_color_selection(GtkColorSelectionDialog* csd)
{
return csd->colorsel;
}
#define gtk_color_selection_dialog_get_color_selection wx_gtk_color_selection_dialog_get_color_selection
static inline GtkWidget* wx_gtk_dialog_get_content_area(GtkDialog* dialog)
{
return dialog->vbox;
}
#define gtk_dialog_get_content_area wx_gtk_dialog_get_content_area
static inline GtkWidget* wx_gtk_dialog_get_action_area(GtkDialog* dialog)
{
return dialog->action_area;
}
#define gtk_dialog_get_action_area wx_gtk_dialog_get_action_area
static inline guint16 wx_gtk_entry_get_text_length(GtkEntry* entry)
{
return entry->text_length;
}
#define gtk_entry_get_text_length wx_gtk_entry_get_text_length
static inline const guchar* wx_gtk_selection_data_get_data(GtkSelectionData* selection_data)
{
return selection_data->data;
}
#define gtk_selection_data_get_data wx_gtk_selection_data_get_data
static inline GdkAtom wx_gtk_selection_data_get_data_type(GtkSelectionData* selection_data)
{
return selection_data->type;
}
#define gtk_selection_data_get_data_type wx_gtk_selection_data_get_data_type
static inline gint wx_gtk_selection_data_get_format(GtkSelectionData* selection_data)
{
return selection_data->format;
}
#define gtk_selection_data_get_format wx_gtk_selection_data_get_format
static inline gint wx_gtk_selection_data_get_length(GtkSelectionData* selection_data)
{
return selection_data->length;
}
#define gtk_selection_data_get_length wx_gtk_selection_data_get_length
static inline GdkAtom wx_gtk_selection_data_get_target(GtkSelectionData* selection_data)
{
return selection_data->target;
}
#define gtk_selection_data_get_target wx_gtk_selection_data_get_target
static inline GdkWindow* wx_gtk_widget_get_window(GtkWidget* widget)
{
return widget->window;
}
#define gtk_widget_get_window wx_gtk_widget_get_window
static inline GtkWidget* wx_gtk_window_get_default_widget(GtkWindow* window)
{
return window->default_widget;
}
#define gtk_window_get_default_widget wx_gtk_window_get_default_widget
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.16
static inline GdkAtom wx_gtk_selection_data_get_selection(GtkSelectionData* selection_data)
{
return selection_data->selection;
}
#define gtk_selection_data_get_selection wx_gtk_selection_data_get_selection
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.18
static inline void wx_gtk_cell_renderer_get_alignment(GtkCellRenderer* cell, gfloat* xalign, gfloat* yalign)
{
*xalign = cell->xalign;
*yalign = cell->yalign;
}
#define gtk_cell_renderer_get_alignment wx_gtk_cell_renderer_get_alignment
static inline void wx_gtk_cell_renderer_get_padding(GtkCellRenderer* cell, gint* xpad, gint* ypad)
{
*xpad = cell->xpad;
*ypad = cell->ypad;
}
#define gtk_cell_renderer_get_padding wx_gtk_cell_renderer_get_padding
static inline void wx_gtk_cell_renderer_set_padding(GtkCellRenderer* cell, gint xpad, gint ypad)
{
cell->xpad = xpad;
cell->ypad = ypad;
}
#define gtk_cell_renderer_set_padding wx_gtk_cell_renderer_set_padding
static inline void wx_gtk_widget_get_allocation(GtkWidget* widget, GtkAllocation* allocation)
{
*allocation = widget->allocation;
}
#define gtk_widget_get_allocation wx_gtk_widget_get_allocation
inline gboolean wx_gtk_widget_get_has_window(GtkWidget *widget)
{
return !GTK_WIDGET_NO_WINDOW(widget);
}
#define gtk_widget_get_has_window wx_gtk_widget_get_has_window
inline gboolean wx_gtk_widget_get_has_grab(GtkWidget *widget)
{
return GTK_WIDGET_HAS_GRAB(widget);
}
#define gtk_widget_get_has_grab wx_gtk_widget_get_has_grab
inline gboolean wx_gtk_widget_get_visible(GtkWidget *widget)
{
return GTK_WIDGET_VISIBLE(widget);
}
#define gtk_widget_get_visible wx_gtk_widget_get_visible
inline gboolean wx_gtk_widget_get_sensitive(GtkWidget *widget)
{
return GTK_WIDGET_SENSITIVE(widget);
}
#define gtk_widget_get_sensitive wx_gtk_widget_get_sensitive
inline gboolean wx_gtk_widget_is_drawable(GtkWidget *widget)
{
return GTK_WIDGET_DRAWABLE(widget);
}
#define gtk_widget_is_drawable wx_gtk_widget_is_drawable
inline gboolean wx_gtk_widget_get_can_focus(GtkWidget *widget)
{
return GTK_WIDGET_CAN_FOCUS(widget);
}
#define gtk_widget_get_can_focus wx_gtk_widget_get_can_focus
inline void wx_gtk_widget_set_can_focus(GtkWidget *widget, gboolean can)
{
if ( can )
GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS);
else
GTK_WIDGET_UNSET_FLAGS(widget, GTK_CAN_FOCUS);
}
#define gtk_widget_set_can_focus wx_gtk_widget_set_can_focus
static inline gboolean wx_gtk_widget_has_focus(GtkWidget* widget)
{
return GTK_WIDGET_HAS_FOCUS(widget);
}
#define gtk_widget_has_focus wx_gtk_widget_has_focus
inline gboolean wx_gtk_widget_get_can_default(GtkWidget *widget)
{
return GTK_WIDGET_CAN_DEFAULT(widget);
}
#define gtk_widget_get_can_default wx_gtk_widget_get_can_default
inline void wx_gtk_widget_set_can_default(GtkWidget *widget, gboolean can)
{
if ( can )
GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_DEFAULT);
else
GTK_WIDGET_UNSET_FLAGS(widget, GTK_CAN_DEFAULT);
}
#define gtk_widget_set_can_default wx_gtk_widget_set_can_default
inline gboolean wx_gtk_widget_has_default(GtkWidget *widget)
{
return GTK_WIDGET_HAS_DEFAULT(widget);
}
#define gtk_widget_has_default wx_gtk_widget_has_default
inline GtkStateType wx_gtk_widget_get_state(GtkWidget *widget)
{
return (GtkStateType)GTK_WIDGET_STATE(widget);
}
#define gtk_widget_get_state wx_gtk_widget_get_state
inline gboolean wx_gtk_widget_get_double_buffered(GtkWidget *widget)
{
return GTK_WIDGET_DOUBLE_BUFFERED(widget);
}
#define gtk_widget_get_double_buffered wx_gtk_widget_get_double_buffered
static inline gboolean wx_gtk_widget_has_grab(GtkWidget* widget)
{
return GTK_WIDGET_HAS_GRAB(widget);
}
#define gtk_widget_has_grab wx_gtk_widget_has_grab
static inline void wx_gtk_widget_set_allocation(GtkWidget* widget, const GtkAllocation* allocation)
{
widget->allocation = *allocation;
}
#define gtk_widget_set_allocation wx_gtk_widget_set_allocation
static inline gboolean wx_gtk_widget_is_toplevel(GtkWidget* widget)
{
return GTK_WIDGET_TOPLEVEL(widget);
}
#define gtk_widget_is_toplevel wx_gtk_widget_is_toplevel
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.20
inline gboolean wx_gtk_widget_get_realized(GtkWidget *widget)
{
return GTK_WIDGET_REALIZED(widget);
}
#define gtk_widget_get_realized wx_gtk_widget_get_realized
inline gboolean wx_gtk_widget_get_mapped(GtkWidget *widget)
{
return GTK_WIDGET_MAPPED(widget);
}
#define gtk_widget_get_mapped wx_gtk_widget_get_mapped
static inline void wx_gtk_widget_get_requisition(GtkWidget* widget, GtkRequisition* requisition)
{
*requisition = widget->requisition;
}
#define gtk_widget_get_requisition wx_gtk_widget_get_requisition
static inline GdkWindow* wx_gtk_entry_get_text_window(GtkEntry* entry)
{
return entry->text_area;
}
#define gtk_entry_get_text_window wx_gtk_entry_get_text_window
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.22
static inline GdkWindow* wx_gtk_button_get_event_window(GtkButton* button)
{
return button->event_window;
}
#define gtk_button_get_event_window wx_gtk_button_get_event_window
static inline GdkDragAction wx_gdk_drag_context_get_actions(GdkDragContext* context)
{
return context->actions;
}
#define gdk_drag_context_get_actions wx_gdk_drag_context_get_actions
static inline GdkDragAction wx_gdk_drag_context_get_selected_action(GdkDragContext* context)
{
return context->action;
}
#define gdk_drag_context_get_selected_action wx_gdk_drag_context_get_selected_action
static inline GdkDragAction wx_gdk_drag_context_get_suggested_action(GdkDragContext* context)
{
return context->suggested_action;
}
#define gdk_drag_context_get_suggested_action wx_gdk_drag_context_get_suggested_action
static inline GList* wx_gdk_drag_context_list_targets(GdkDragContext* context)
{
return context->targets;
}
#define gdk_drag_context_list_targets wx_gdk_drag_context_list_targets
static inline gint wx_gdk_visual_get_depth(GdkVisual* visual)
{
return visual->depth;
}
#define gdk_visual_get_depth wx_gdk_visual_get_depth
static inline gboolean wx_gtk_window_has_group(GtkWindow* window)
{
return window->group != nullptr;
}
#define gtk_window_has_group wx_gtk_window_has_group
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.24
#define gdk_window_get_visual gdk_drawable_get_visual
static inline GdkDisplay* wx_gdk_window_get_display(GdkWindow* window)
{
return gdk_drawable_get_display(window);
}
#define gdk_window_get_display wx_gdk_window_get_display
static inline GdkScreen* wx_gdk_window_get_screen(GdkWindow* window)
{
return gdk_drawable_get_screen(window);
}
#define gdk_window_get_screen wx_gdk_window_get_screen
static inline gint wx_gdk_window_get_height(GdkWindow* window)
{
int h;
gdk_drawable_get_size(window, nullptr, &h);
return h;
}
#define gdk_window_get_height wx_gdk_window_get_height
static inline gint wx_gdk_window_get_width(GdkWindow* window)
{
int w;
gdk_drawable_get_size(window, &w, nullptr);
return w;
}
#define gdk_window_get_width wx_gdk_window_get_width
#if GTK_CHECK_VERSION(2,10,0)
static inline void wx_gdk_cairo_set_source_window(cairo_t* cr, GdkWindow* window, gdouble x, gdouble y)
{
gdk_cairo_set_source_pixmap(cr, window, x, y);
}
#define gdk_cairo_set_source_window wx_gdk_cairo_set_source_window
#endif
// ----------------------------------------------------------------------------
// the following were introduced in Glib 2.32
#ifndef g_signal_handlers_disconnect_by_data
#define g_signal_handlers_disconnect_by_data(instance, data) \
g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, (data))
#endif
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 3.0
static inline void wx_gdk_window_get_geometry(GdkWindow* window, gint* x, gint* y, gint* width, gint* height)
{
gdk_window_get_geometry(window, x, y, width, height, nullptr);
}
#define gdk_window_get_geometry wx_gdk_window_get_geometry
static inline GtkWidget* wx_gtk_tree_view_column_get_button(GtkTreeViewColumn* tree_column)
{
return tree_column->button;
}
#define gtk_tree_view_column_get_button wx_gtk_tree_view_column_get_button
static inline GtkWidget* wx_gtk_box_new(GtkOrientation orientation, gint spacing)
{
GtkWidget* widget;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
widget = gtk_hbox_new(false, spacing);
else
widget = gtk_vbox_new(false, spacing);
return widget;
}
#define gtk_box_new wx_gtk_box_new
static inline GtkWidget* wx_gtk_button_box_new(GtkOrientation orientation)
{
GtkWidget* widget;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
widget = gtk_hbutton_box_new();
else
widget = gtk_vbutton_box_new();
return widget;
}
#define gtk_button_box_new wx_gtk_button_box_new
static inline GtkWidget* wx_gtk_scale_new(GtkOrientation orientation, GtkAdjustment* adjustment)
{
GtkWidget* widget;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
widget = gtk_hscale_new(adjustment);
else
widget = gtk_vscale_new(adjustment);
return widget;
}
#define gtk_scale_new wx_gtk_scale_new
static inline GtkWidget* wx_gtk_scrollbar_new(GtkOrientation orientation, GtkAdjustment* adjustment)
{
GtkWidget* widget;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
widget = gtk_hscrollbar_new(adjustment);
else
widget = gtk_vscrollbar_new(adjustment);
return widget;
}
#define gtk_scrollbar_new wx_gtk_scrollbar_new
static inline GtkWidget* wx_gtk_separator_new(GtkOrientation orientation)
{
GtkWidget* widget;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
widget = gtk_hseparator_new();
else
widget = gtk_vseparator_new();
return widget;
}
#define gtk_separator_new wx_gtk_separator_new
static inline void wx_gtk_widget_get_preferred_height(GtkWidget* widget, gint* minimum, gint* natural)
{
GtkRequisition req;
gtk_widget_size_request(widget, &req);
if (minimum)
*minimum = req.height;
if (natural)
*natural = req.height;
}
#define gtk_widget_get_preferred_height wx_gtk_widget_get_preferred_height
static inline void wx_gtk_widget_get_preferred_width(GtkWidget* widget, gint* minimum, gint* natural)
{
GtkRequisition req;
gtk_widget_size_request(widget, &req);
if (minimum)
*minimum = req.width;
if (natural)
*natural = req.width;
}
#define gtk_widget_get_preferred_width wx_gtk_widget_get_preferred_width
static inline void wx_gtk_widget_get_preferred_size(GtkWidget* widget, GtkRequisition* minimum, GtkRequisition* natural)
{
GtkRequisition* req = minimum;
if (req == nullptr)
req = natural;
gtk_widget_size_request(widget, req);
}
#define gtk_widget_get_preferred_size wx_gtk_widget_get_preferred_size
#define wx_gdk_device_get_window_at_position(unused, win_x, win_y) \
gdk_window_at_pointer(win_x, win_y)
#include <gdk/gdkkeysyms.h>
#if defined(GDK_Alt_L) && !defined(GDK_KEY_Alt_L)
#define GDK_KEY_Alt_L GDK_Alt_L
#define GDK_KEY_Alt_R GDK_Alt_R
#define GDK_KEY_AudioLowerVolume GDK_AudioLowerVolume
#define GDK_KEY_AudioMute GDK_AudioMute
#define GDK_KEY_AudioNext GDK_AudioNext
#define GDK_KEY_AudioPlay GDK_AudioPlay
#define GDK_KEY_AudioPrev GDK_AudioPrev
#define GDK_KEY_AudioRaiseVolume GDK_AudioRaiseVolume
#define GDK_KEY_AudioStop GDK_AudioStop
#define GDK_KEY_Back GDK_Back
#define GDK_KEY_BackSpace GDK_BackSpace
#define GDK_KEY_Begin GDK_Begin
#define GDK_KEY_Caps_Lock GDK_Caps_Lock
#define GDK_KEY_Clear GDK_Clear
#define GDK_KEY_Control_L GDK_Control_L
#define GDK_KEY_Control_R GDK_Control_R
#define GDK_KEY_Delete GDK_Delete
#define GDK_KEY_Down GDK_Down
#define GDK_KEY_End GDK_End
#define GDK_KEY_Escape GDK_Escape
#define GDK_KEY_Execute GDK_Execute
#define GDK_KEY_F10 GDK_F10
#define GDK_KEY_F11 GDK_F11
#define GDK_KEY_F12 GDK_F12
#define GDK_KEY_F1 GDK_F1
#define GDK_KEY_F2 GDK_F2
#define GDK_KEY_F3 GDK_F3
#define GDK_KEY_F4 GDK_F4
#define GDK_KEY_F5 GDK_F5
#define GDK_KEY_F6 GDK_F6
#define GDK_KEY_F7 GDK_F7
#define GDK_KEY_F8 GDK_F8
#define GDK_KEY_F9 GDK_F9
#define GDK_KEY_Favorites GDK_Favorites
#define GDK_KEY_Forward GDK_Forward
#define GDK_KEY_Help GDK_Help
#define GDK_KEY_Home GDK_Home
#define GDK_KEY_HomePage GDK_HomePage
#define GDK_KEY_Insert GDK_Insert
#define GDK_KEY_ISO_Enter GDK_ISO_Enter
#define GDK_KEY_ISO_Left_Tab GDK_ISO_Left_Tab
#define GDK_KEY_KP_0 GDK_KP_0
#define GDK_KEY_KP_1 GDK_KP_1
#define GDK_KEY_KP_2 GDK_KP_2
#define GDK_KEY_KP_3 GDK_KP_3
#define GDK_KEY_KP_4 GDK_KP_4
#define GDK_KEY_KP_5 GDK_KP_5
#define GDK_KEY_KP_6 GDK_KP_6
#define GDK_KEY_KP_7 GDK_KP_7
#define GDK_KEY_KP_8 GDK_KP_8
#define GDK_KEY_KP_9 GDK_KP_9
#define GDK_KEY_KP_Add GDK_KP_Add
#define GDK_KEY_KP_Begin GDK_KP_Begin
#define GDK_KEY_KP_Decimal GDK_KP_Decimal
#define GDK_KEY_KP_Delete GDK_KP_Delete
#define GDK_KEY_KP_Divide GDK_KP_Divide
#define GDK_KEY_KP_Down GDK_KP_Down
#define GDK_KEY_KP_End GDK_KP_End
#define GDK_KEY_KP_Enter GDK_KP_Enter
#define GDK_KEY_KP_Equal GDK_KP_Equal
#define GDK_KEY_KP_F1 GDK_KP_F1
#define GDK_KEY_KP_F2 GDK_KP_F2
#define GDK_KEY_KP_F3 GDK_KP_F3
#define GDK_KEY_KP_F4 GDK_KP_F4
#define GDK_KEY_KP_Home GDK_KP_Home
#define GDK_KEY_KP_Insert GDK_KP_Insert
#define GDK_KEY_KP_Left GDK_KP_Left
#define GDK_KEY_KP_Multiply GDK_KP_Multiply
#define GDK_KEY_KP_Next GDK_KP_Next
#define GDK_KEY_KP_Prior GDK_KP_Prior
#define GDK_KEY_KP_Right GDK_KP_Right
#define GDK_KEY_KP_Separator GDK_KP_Separator
#define GDK_KEY_KP_Space GDK_KP_Space
#define GDK_KEY_KP_Subtract GDK_KP_Subtract
#define GDK_KEY_KP_Tab GDK_KP_Tab
#define GDK_KEY_KP_Up GDK_KP_Up
#define GDK_KEY_Launch0 GDK_Launch0
#define GDK_KEY_Launch1 GDK_Launch1
#define GDK_KEY_Launch2 GDK_Launch2
#define GDK_KEY_Launch3 GDK_Launch3
#define GDK_KEY_Launch4 GDK_Launch4
#define GDK_KEY_Launch5 GDK_Launch5
#define GDK_KEY_Launch6 GDK_Launch6
#define GDK_KEY_Launch7 GDK_Launch7
#define GDK_KEY_Launch8 GDK_Launch8
#define GDK_KEY_Launch9 GDK_Launch9
#define GDK_KEY_LaunchA GDK_LaunchA
#define GDK_KEY_LaunchB GDK_LaunchB
#define GDK_KEY_LaunchC GDK_LaunchC
#define GDK_KEY_LaunchD GDK_LaunchD
#define GDK_KEY_LaunchE GDK_LaunchE
#define GDK_KEY_LaunchF GDK_LaunchF
#define GDK_KEY_Left GDK_Left
#define GDK_KEY_Linefeed GDK_Linefeed
#define GDK_KEY_Mail GDK_Mail
#define GDK_KEY_Menu GDK_Menu
#define GDK_KEY_Meta_L GDK_Meta_L
#define GDK_KEY_Meta_R GDK_Meta_R
#define GDK_KEY_Next GDK_Next
#define GDK_KEY_Num_Lock GDK_Num_Lock
#define GDK_KEY_Page_Down GDK_Page_Down
#define GDK_KEY_Page_Up GDK_Page_Up
#define GDK_KEY_Pause GDK_Pause
#define GDK_KEY_Print GDK_Print
#define GDK_KEY_Prior GDK_Prior
#define GDK_KEY_Refresh GDK_Refresh
#define GDK_KEY_Return GDK_Return
#define GDK_KEY_Right GDK_Right
#define GDK_KEY_Scroll_Lock GDK_Scroll_Lock
#define GDK_KEY_Search GDK_Search
#define GDK_KEY_Select GDK_Select
#define GDK_KEY_Shift_L GDK_Shift_L
#define GDK_KEY_Shift_R GDK_Shift_R
#define GDK_KEY_Stop GDK_Stop
#define GDK_KEY_Super_L GDK_Super_L
#define GDK_KEY_Super_R GDK_Super_R
#define GDK_KEY_Tab GDK_Tab
#define GDK_KEY_Up GDK_Up
#endif
// Do perform runtime checks for GTK+ 2 version: we only take the minor version
// component here, major must be 2 and we never need to test for the micro one
// anyhow.
inline bool wx_is_at_least_gtk2(int minor)
{
return gtk_check_version(2, minor, 0) == nullptr;
}
#else // __WXGTK3__
#define wx_gdk_device_get_window_at_position(device, win_x, win_y) \
gdk_device_get_window_at_position(device, win_x, win_y)
// With GTK+ 3 we don't need to check for GTK+ 2 version and
// gtk_check_version() would fail due to major version mismatch.
inline bool wx_is_at_least_gtk2(int WXUNUSED(minor))
{
return true;
}
#endif // !__WXGTK3__/__WXGTK3__
#endif // _WX_GTK_PRIVATE_COMPAT_H_

View File

@@ -0,0 +1,79 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/gtk3-compat.h
// Purpose: Compatibility code for older GTK+ 3 versions
// Author: Paul Cornett
// Created: 2015-10-10
// Copyright: (c) 2015 Paul Cornett
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_COMPAT3_H_
#define _WX_GTK_PRIVATE_COMPAT3_H_
#ifdef __WXGTK4__
inline GdkDevice* wx_get_gdk_device_from_display(GdkDisplay* display)
{
GdkSeat* seat = gdk_display_get_default_seat(display);
return gdk_seat_get_pointer(seat);
}
#else // !__WXGTK4__
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 3.20
static inline gboolean wx_gtk_text_iter_starts_tag(const GtkTextIter* iter, GtkTextTag* tag)
{
return gtk_text_iter_begins_tag(iter, tag);
}
#define gtk_text_iter_starts_tag wx_gtk_text_iter_starts_tag
#ifdef __WXGTK3__
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 3.12
static inline void wx_gtk_widget_set_margin_start(GtkWidget* widget, gint margin)
{
gtk_widget_set_margin_left(widget, margin);
}
#define gtk_widget_set_margin_start wx_gtk_widget_set_margin_start
static inline void wx_gtk_widget_set_margin_end(GtkWidget* widget, gint margin)
{
gtk_widget_set_margin_right(widget, margin);
}
#define gtk_widget_set_margin_end wx_gtk_widget_set_margin_end
inline GdkDevice* wx_get_gdk_device_from_display(GdkDisplay* display)
{
GdkDeviceManager* manager = gdk_display_get_device_manager(display);
return gdk_device_manager_get_client_pointer(manager);
}
#endif // __WXGTK3__
wxGCC_WARNING_RESTORE()
#endif // __WXGTK4__/!__WXGTK4__
#if defined(__WXGTK4__) || !defined(__WXGTK3__)
static inline bool wx_is_at_least_gtk3(int /* minor */)
{
#ifdef __WXGTK4__
return true;
#else
return false;
#endif
}
#else
static inline bool wx_is_at_least_gtk3(int minor)
{
return gtk_check_version(3, minor, 0) == nullptr;
}
#endif
#endif // _WX_GTK_PRIVATE_COMPAT3_H_

View File

@@ -0,0 +1,48 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/image.h
// Author: Paul Cornett
// Copyright: (c) 2020 Paul Cornett
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// Class that can be used in place of GtkImage, to allow drawing of alternate
// bitmaps, such as HiDPI or disabled.
class wxGtkImage: GtkImage
{
public:
struct BitmapProvider
{
virtual ~BitmapProvider() = default;
virtual wxBitmap Get(int scale) const = 0;
virtual void Set(const wxBitmapBundle&) { }
// Simple helpers used in implementation.
static wxBitmap GetAtScale(const wxBitmapBundle& b, int scale)
{
return b.GetBitmap(b.GetDefaultSize() * scale);
}
};
static GType Type();
static GtkWidget* New(BitmapProvider* provider);
static GtkWidget* New(wxWindow* win = nullptr);
// Use bitmaps from the given bundle, the logical bitmap size is the
// default size of the bundle.
void Set(const wxBitmapBundle& bitmapBundle);
// This pointer is never null and is owned by this class.
BitmapProvider* m_provider;
wxDECLARE_NO_COPY_CLASS(wxGtkImage);
// This class is constructed by New() and destroyed by its GObject
// finalizer, so neither its ctor nor dtor can ever be used.
wxGtkImage() wxMEMBER_DELETE;
~wxGtkImage() wxMEMBER_DELETE;
};
#define WX_GTK_IMAGE(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, wxGtkImage::Type(), wxGtkImage)
#define WX_GTK_IS_IMAGE(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, wxGtkImage::Type())

View File

@@ -0,0 +1,32 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/list.h
// Purpose: wxGtkList class.
// Author: Vadim Zeitlin
// Created: 2011-08-21
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_LIST_H_
#define _WX_GTK_PRIVATE_LIST_H_
// ----------------------------------------------------------------------------
// Convenience class for calling g_list_free() automatically
// ----------------------------------------------------------------------------
class wxGtkList
{
public:
explicit wxGtkList(GList* list) : m_list(list) { }
~wxGtkList() { g_list_free(m_list); }
operator GList *() const { return m_list; }
GList * operator->() const { return m_list; }
protected:
GList* const m_list;
wxDECLARE_NO_COPY_CLASS(wxGtkList);
};
#endif // _WX_GTK_PRIVATE_LIST_H_

View File

@@ -0,0 +1,156 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/log.h
// Purpose: Support for filtering GTK log messages.
// Author: Vadim Zeitlin
// Created: 2022-05-11
// Copyright: (c) 2022 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_LOG_H_
#define _WX_GTK_PRIVATE_LOG_H_
#include <glib.h>
// Support for custom log writers is only available in glib 2.50 or later.
#if GLIB_CHECK_VERSION(2, 50, 0)
#define wxHAS_GLIB_LOG_WRITER
#endif
namespace wxGTKImpl
{
#ifdef wxHAS_GLIB_LOG_WRITER
// LogFilter is the base class for filtering GTK log messages
//
// Note that all members of this class are defined in src/gtk/app.cpp.
class LogFilter
{
public:
LogFilter()
{
m_next = nullptr;
}
// Allow installing our own log writer function, we don't do it by default
// because this results in a fatal error if the application had already
// called g_log_set_writer_func() on its own.
static void Allow() { ms_allowed = true; }
// Function to call to install this filter as the active one if we're
// allowed to do this, i.e. if Allow() had been called before.
//
// Does nothing and just returns false if run-time glib version is too old.
bool Install();
protected:
// Function to override in the derived class to actually filter: return
// true if the message should be suppressed or false if it should be passed
// through to the default writer (which may, or not, show it).
virtual bool Filter(GLogLevelFlags log_level,
const GLogField* fields,
gsize n_fields) const = 0;
// Typically called from the derived class dtor to stop using this filter.
void Uninstall();
private:
// The function used as glib log writer.
static GLogWriterOutput
wx_log_writer(GLogLevelFlags log_level,
const GLogField *fields,
gsize n_fields,
gpointer user_data);
// False initially, indicating that we're not allowed to install our own
// logging function.
static bool ms_allowed;
// False initially, set to true when we install wx_log_writer() as the log
// writer. Once we do it, we never change it any more.
static bool ms_installed;
// We maintain a simple linked list of log filters and this is the head of
// this list.
static LogFilter* ms_first;
// Next entry in the linked list, may be null.
LogFilter* m_next;
wxDECLARE_NO_COPY_CLASS(LogFilter);
};
// LogFilterByLevel filters out all the messages at the specified level.
class LogFilterByLevel : public LogFilter
{
public:
LogFilterByLevel() = default;
void SetLevelToIgnore(int flags)
{
m_logLevelToIgnore = flags;
}
protected:
bool Filter(GLogLevelFlags log_level,
const GLogField* WXUNUSED(fields),
gsize WXUNUSED(n_fields)) const override
{
return log_level & m_logLevelToIgnore;
}
private:
int m_logLevelToIgnore;
wxDECLARE_NO_COPY_CLASS(LogFilterByLevel);
};
// LogFilterByMessage filters out all the messages with the specified content.
class LogFilterByMessage : public LogFilter
{
public:
// Objects of this class are supposed to be created with literal strings as
// argument, so don't bother copying the string but just use the pointer.
explicit LogFilterByMessage(const char* message)
: m_message(message)
{
// We shouldn't warn about anything if Install() failed.
m_warnNotFiltered = Install();
}
// Remove this filter when the object goes out of scope.
//
// The dtor also checks if we actually filtered the message and logs a
// trace message with the "gtklog" mask if we didn't: this allows checking
// if the filter is actually being used.
~LogFilterByMessage();
protected:
bool Filter(GLogLevelFlags WXUNUSED(log_level),
const GLogField* fields,
gsize n_fields) const override;
private:
const char* const m_message;
mutable bool m_warnNotFiltered;
wxDECLARE_NO_COPY_CLASS(LogFilterByMessage);
};
#else // !wxHAS_GLIB_LOG_WRITER
// Provide stubs to avoid having to use preprocessor checks in the code using
// these classes.
class LogFilterByMessage
{
public:
explicit LogFilterByMessage(const char* WXUNUSED(message)) { }
};
#endif // wxHAS_GLIB_LOG_WRITER/!wxHAS_GLIB_LOG_WRITER
} // namespace wxGTKImpl
#endif // _WX_GTK_PRIVATE_LOG_H_

View File

@@ -0,0 +1,51 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/mediactrl.h
// Purpose: Wrap runtime checks to manage GTK windows with Wayland and X11
// Author: Pierluigi Passaro
// Created: 2021-03-18
// Copyright: (c) 2021 Pierluigi Passaro <pierluigi.p@variscite.com>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_MEDIACTRL_H_
#define _WX_GTK_PRIVATE_MEDIACTRL_H_
#include "wx/gtk/private/wrapgdk.h"
#include "wx/gtk/private/backend.h"
//-----------------------------------------------------------------------------
// "wxGtkGetIdFromWidget" from widget
//
// Get the windows_id performing run-time checks If the window wasn't realized
// when Load was called, this is the callback for when it is - the purpose of
// which is to tell GStreamer to play the video in our control
//-----------------------------------------------------------------------------
extern "C" {
inline gpointer wxGtkGetIdFromWidget(GtkWidget* widget)
{
GdkDisplay* display = gtk_widget_get_display(widget);
gdk_display_flush(display);
GdkWindow* window = gtk_widget_get_window(widget);
wxASSERT(window);
#ifdef GDK_WINDOWING_X11
#ifdef __WXGTK3__
if (wxGTKImpl::IsX11(window))
#endif
{
return (gpointer)GDK_WINDOW_XID(window);
}
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (wxGTKImpl::IsWayland(window))
{
return (gpointer)gdk_wayland_window_get_wl_surface(window);
}
#endif
return (gpointer)nullptr;
}
}
#endif // _WX_GTK_PRIVATE_MEDIACTRL_H_

View File

@@ -0,0 +1,46 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/messagetype.h
// Purpose: translate between wx and GtkMessageType
// Author: Vadim Zeitlin
// Created: 2009-09-27
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _GTK_PRIVATE_MSGTYPE_H_
#define _GTK_PRIVATE_MSGTYPE_H_
#include <gtk/gtk.h>
#include "wx/gtk/private/gtk2-compat.h"
namespace wxGTKImpl
{
// Convert the given wx style to GtkMessageType, return true if succeeded or
// false if failed.
inline bool ConvertMessageTypeFromWX(int style, GtkMessageType *type)
{
#ifdef __WXGTK210__
if ( wx_is_at_least_gtk2(10) && (style & wxICON_NONE))
*type = GTK_MESSAGE_OTHER;
else
#endif // __WXGTK210__
if (style & wxICON_EXCLAMATION)
*type = GTK_MESSAGE_WARNING;
else if (style & wxICON_ERROR)
*type = GTK_MESSAGE_ERROR;
else if (style & wxICON_INFORMATION)
*type = GTK_MESSAGE_INFO;
else if (style & wxICON_QUESTION)
*type = GTK_MESSAGE_QUESTION;
else
return false;
return true;
}
} // namespace wxGTKImpl
#endif // _GTK_PRIVATE_MSGTYPE_H_

View File

@@ -0,0 +1,38 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/mnemonics.h
// Purpose: helper functions for dealing with GTK+ mnemonics
// Author: Vadim Zeitlin
// Created: 2007-11-12
// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _GTK_PRIVATE_MNEMONICS_H_
#define _GTK_PRIVATE_MNEMONICS_H_
#if wxUSE_CONTROLS || wxUSE_MENUS
#include "wx/string.h"
// ----------------------------------------------------------------------------
// functions to convert between wxWidgets and GTK+ string containing mnemonics
// ----------------------------------------------------------------------------
// remove all mnemonics from a string
wxString wxGTKRemoveMnemonics(const wxString& label);
// convert a wx string with '&' to GTK+ string with '_'s
wxString wxConvertMnemonicsToGTK(const wxString& label);
// convert a wx string with '&' to indicate mnemonics as well as HTML entities
// to a GTK+ string with "&amp;" used instead of '&', i.e. suitable for use
// with GTK+ functions using markup strings
wxString wxConvertMnemonicsToGTKMarkup(const wxString& label);
// convert GTK+ string with '_'s to wx string with '&'s
wxString wxConvertMnemonicsFromGTK(const wxString& label);
#endif // wxUSE_CONTROLS || wxUSE_MENUS
#endif // _GTK_PRIVATE_MNEMONICS_H_

View File

@@ -0,0 +1,43 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/object.h
// Purpose: wxGtkObject class declaration
// Author: Vadim Zeitlin
// Created: 2008-08-27
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_OBJECT_H_
#define _WX_GTK_PRIVATE_OBJECT_H_
// ----------------------------------------------------------------------------
// Convenience class for calling g_object_unref() automatically
// ----------------------------------------------------------------------------
template <typename T>
class wxGtkObject
{
public:
wxGtkObject() = default;
explicit wxGtkObject(T *p) : m_ptr(p) { }
~wxGtkObject() { if ( m_ptr ) g_object_unref(m_ptr); }
operator T *() const { return m_ptr; }
T** Out()
{
wxASSERT_MSG( !m_ptr, wxS("Can't reuse the same object.") );
return &m_ptr;
}
private:
T* m_ptr = nullptr;
// copying could be implemented by using g_object_ref() but for now there
// is no need for it so don't implement it
wxDECLARE_NO_COPY_CLASS(wxGtkObject);
};
#endif // _WX_GTK_PRIVATE_OBJECT_H_

View File

@@ -0,0 +1,22 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/power.h
// Purpose: Private GTK-specific power management-related declarations.
// Author: Vadim Zeitlin
// Created: 2025-02-06
// Copyright: (c) 2025 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_POWER_H_
#define _WX_GTK_PRIVATE_POWER_H_
#include <glib.h>
// Power events are only supported under Unix with glib >= 2.26 as this is when
// GDBus support was added and GUnixFDList is only available in 2.30, so just
// test for it to keep things simple.
#if defined(__UNIX__) && GLIB_CHECK_VERSION(2, 30, 0)
#define wxHAS_GLIB_POWER_SUPPORT
#endif
#endif // _WX_GTK_PRIVATE_POWER_H_

View File

@@ -0,0 +1,113 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/string.h
// Purpose: wxGtkString class declaration
// Author: Vadim Zeitlin
// Created: 2006-10-19
// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_STRING_H_
#define _WX_GTK_PRIVATE_STRING_H_
#include "wx/gtk/private/glibptr.h"
#include <utility>
#include <vector>
// ----------------------------------------------------------------------------
// Convenience class for g_freeing a gchar* on scope exit automatically
// ----------------------------------------------------------------------------
class wxGtkString : public wxGlibPtr<gchar>
{
public:
using Base = wxGlibPtr<gchar>;
explicit wxGtkString(const gchar *s) : Base(s) { }
wxGtkString(wxGtkString&& other) : Base(std::move(other)) { }
wxGtkString& operator=(wxGtkString&& other)
{
Base::operator=(std::move(other));
return *this;
}
// More string-like accessor.
const gchar *c_str() const { return get(); }
};
// ----------------------------------------------------------------------------
// list for sorting collated strings
// ----------------------------------------------------------------------------
#include "wx/string.h"
class wxGtkCollatableString
{
public:
wxGtkCollatableString( const wxString &label, const gchar *key )
: m_label(label), m_key(key)
{
}
wxString m_label;
wxGtkString m_key;
};
class wxGtkCollatedArrayString
{
public:
wxGtkCollatedArrayString() = default;
int Add( const wxString &new_label )
{
int index = 0;
wxGtkString new_key_lower(g_utf8_casefold( new_label.utf8_str(), -1));
gchar *new_key = g_utf8_collate_key( new_key_lower, -1);
wxGtkCollatableString new_str( new_label, new_key );
for (auto iter = m_list.begin(); iter != m_list.end(); ++iter)
{
const gchar* key = iter->m_key;
if (strcmp(key,new_key) >= 0)
{
m_list.insert( iter, std::move(new_str) );
return index;
}
index ++;
}
m_list.push_back( std::move(new_str) );
return index;
}
size_t GetCount()
{
return m_list.size();
}
wxString At( size_t index )
{
return m_list.at(index).m_label;
}
void Clear()
{
m_list.clear();
}
void RemoveAt( size_t index )
{
m_list.erase( m_list.begin() + index );
}
private:
std::vector<wxGtkCollatableString> m_list;
};
#endif // _WX_GTK_PRIVATE_STRING_H_

View File

@@ -0,0 +1,49 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/stylecontext.h
// Purpose: GtkStyleContext helper class
// Author: Paul Cornett
// Created: 2018-06-04
// Copyright: (c) 2018 Paul Cornett
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_STYLECONTEXT_H_
#define _WX_GTK_PRIVATE_STYLECONTEXT_H_
#ifdef __WXGTK3__
class wxGtkStyleContext
{
public:
explicit wxGtkStyleContext(double scale = 1);
~wxGtkStyleContext();
wxGtkStyleContext& Add(GType type, const char* objectName, ...) G_GNUC_NULL_TERMINATED;
wxGtkStyleContext& Add(const char* objectName);
wxGtkStyleContext& AddButton();
wxGtkStyleContext& AddCheckButton();
wxGtkStyleContext& AddHeaderbar();
wxGtkStyleContext& AddLabel();
wxGtkStyleContext& AddMenu();
wxGtkStyleContext& AddMenuItem();
wxGtkStyleContext& AddTextview(const char* child1 = nullptr, const char* child2 = nullptr);
wxGtkStyleContext& AddTooltip();
wxGtkStyleContext& AddTreeview();
#if GTK_CHECK_VERSION(3,20,0)
wxGtkStyleContext& AddTreeviewHeaderButton(int pos);
#endif // GTK >= 3.20
wxGtkStyleContext& AddWindow(const char* className2 = nullptr);
void Bg(wxColour& color, int state = GTK_STATE_FLAG_NORMAL) const;
void Fg(wxColour& color, int state = GTK_STATE_FLAG_NORMAL) const;
void Border(wxColour& color) const;
operator GtkStyleContext*() { return m_context; }
private:
GtkStyleContext* m_context;
GtkWidgetPath* const m_path;
const int m_scale;
wxDECLARE_NO_COPY_CLASS(wxGtkStyleContext);
};
#endif // __WXGTK3__
#endif // _WX_GTK_PRIVATE_STYLECONTEXT_H_

View File

@@ -0,0 +1,64 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/textmeasure.h
// Purpose: wxGTK-specific declaration of wxTextMeasure class
// Author: Manuel Martin
// Created: 2012-10-05
// Copyright: (c) 1997-2012 wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_TEXTMEASURE_H_
#define _WX_GTK_PRIVATE_TEXTMEASURE_H_
// ----------------------------------------------------------------------------
// wxTextMeasure
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxWindowDCImpl;
class wxTextMeasure : public wxTextMeasureBase
{
public:
explicit wxTextMeasure(const wxDC *dc, const wxFont *font = nullptr)
: wxTextMeasureBase(dc, font)
{
Init();
}
explicit wxTextMeasure(const wxWindow *win, const wxFont *font = nullptr)
: wxTextMeasureBase(win, font)
{
Init();
}
protected:
// Common part of both ctors.
void Init();
virtual void BeginMeasuring() override;
virtual void EndMeasuring() override;
virtual void DoGetTextExtent(const wxString& string,
wxCoord *width,
wxCoord *height,
wxCoord *descent = nullptr,
wxCoord *externalLeading = nullptr) override;
virtual bool DoGetPartialTextExtents(const wxString& text,
wxArrayInt& widths,
double scaleX) override;
// This class is only used for DC text measuring with GTK+ 2 as GTK+ 3 uses
// Cairo and not Pango for this. However it's still used even with GTK+ 3
// for window text measuring, so the context and the layout are still
// needed.
#ifndef __WXGTK3__
wxWindowDCImpl *m_wdc;
#endif // GTK+ < 3
PangoContext *m_context;
PangoLayout *m_layout;
wxDECLARE_NO_COPY_CLASS(wxTextMeasure);
};
#endif // _WX_GTK_PRIVATE_TEXTMEASURE_H_

View File

@@ -0,0 +1,40 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/threads.h
// Purpose: Wrappers for GDK threads support.
// Author: Vadim Zeitlin
// Created: 2022-09-23
// Copyright: (c) 2022 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_THREADS_H_
#define _WX_GTK_PRIVATE_THREADS_H_
// ----------------------------------------------------------------------------
// Redefine GDK functions to avoiding deprecation warnings
// ----------------------------------------------------------------------------
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
static inline void wx_gdk_threads_enter() { gdk_threads_enter(); }
#define gdk_threads_enter wx_gdk_threads_enter
static inline void wx_gdk_threads_leave() { gdk_threads_leave(); }
#define gdk_threads_leave wx_gdk_threads_leave
wxGCC_WARNING_RESTORE(deprecated-declarations)
// ----------------------------------------------------------------------------
// RAII wrapper for acquiring/leaving GDK lock in ctor/dtor
// ----------------------------------------------------------------------------
class wxGDKThreadsLock
{
public:
wxGDKThreadsLock() { gdk_threads_enter(); }
~wxGDKThreadsLock() { gdk_threads_leave(); }
wxDECLARE_NO_COPY_CLASS(wxGDKThreadsLock);
};
#endif // _WX_GTK_PRIVATE_THREADS_H_

View File

@@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/timer.h
// Purpose: wxTimerImpl for wxGTK
// Author: Robert Roebling
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_TIMER_H_
#define _WX_GTK_PRIVATE_TIMER_H_
#if wxUSE_TIMER
#include "wx/private/timer.h"
//-----------------------------------------------------------------------------
// wxTimer
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGTKTimerImpl : public wxTimerImpl
{
public:
wxGTKTimerImpl(wxTimer* timer) : wxTimerImpl(timer) { m_sourceId = 0; }
virtual bool Start( int millisecs = -1, bool oneShot = false ) override;
virtual void Stop() override;
virtual bool IsRunning() const override { return m_sourceId != 0; }
protected:
int m_sourceId;
};
#endif // wxUSE_TIMER
#endif // _WX_GTK_PRIVATE_TIMER_H_

View File

@@ -0,0 +1,75 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/tlwgeom.h
// Purpose: wxGTK-specific wxTLWGeometry class.
// Author: Vadim Zeitlin
// Created: 2018-04-29
// Copyright: (c) 2018 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_TLWGEOM_H_
#define _WX_GTK_PRIVATE_TLWGEOM_H_
class wxTLWGeometry : public wxTLWGeometryGeneric
{
typedef wxTLWGeometryGeneric BaseType;
public:
virtual bool Save(const Serializer& ser) const override
{
if ( !wxTLWGeometryGeneric::Save(ser) )
return false;
// Don't save the decoration sizes if we don't really have any values
// for them.
if ( m_decorSize.left || m_decorSize.right ||
m_decorSize.top || m_decorSize.bottom )
{
ser.SaveField("decor_l", m_decorSize.left);
ser.SaveField("decor_r", m_decorSize.right);
ser.SaveField("decor_t", m_decorSize.top);
ser.SaveField("decor_b", m_decorSize.bottom);
}
return true;
}
virtual bool Restore(Serializer& ser) override
{
if ( !wxTLWGeometryGeneric::Restore(ser) )
return false;
ser.RestoreField("decor_l", &m_decorSize.left);
ser.RestoreField("decor_r", &m_decorSize.right);
ser.RestoreField("decor_t", &m_decorSize.top);
ser.RestoreField("decor_b", &m_decorSize.bottom);
return true;
}
virtual bool GetFrom(const wxTopLevelWindow* tlw) override
{
if ( !wxTLWGeometryGeneric::GetFrom(tlw) )
return false;
m_decorSize = tlw->m_decorSize;
return true;
}
virtual bool ApplyTo(wxTopLevelWindow* tlw) override
{
// Don't overwrite the current decoration size if we already have it.
if ( !tlw->m_decorSize.left && !tlw->m_decorSize.right &&
!tlw->m_decorSize.top && !tlw->m_decorSize.bottom )
{
tlw->m_decorSize = m_decorSize;
}
return BaseType::ApplyTo(tlw);
}
private:
wxTopLevelWindow::DecorSize m_decorSize;
};
#endif // _WX_GTK_PRIVATE_TLWGEOM_H_

View File

@@ -0,0 +1,58 @@
/* ///////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/treeentry_gtk.h
// Purpose: GtkTreeEntry - a string/userdata combo for use with treeview
// Author: Ryan Norton
// Copyright: (c) 2006 Ryan Norton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////// */
#ifndef _WX_GTK_TREE_ENTRY_H_
#define _WX_GTK_TREE_ENTRY_H_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <gtk/gtk.h> /* for gpointer and gchar* etc. */
#define WX_TYPE_TREE_ENTRY wx_tree_entry_get_type()
#define WX_TREE_ENTRY(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, wx_tree_entry_get_type(), wxTreeEntry)
#define WX_IS_TREE_ENTRY(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, wx_tree_entry_get_type())
typedef struct _wxTreeEntry wxTreeEntry;
typedef void (*wxTreeEntryDestroy)(wxTreeEntry* entry, void* context);
struct _wxTreeEntry
{
GObject parent; /* object instance */
gchar* label; /* label - always copied by this object except on get */
gchar* collate_key; /* collate key used for string comparisons/sorting */
gpointer userdata; /* untouched userdata */
wxTreeEntryDestroy destroy_func; /* called upon destruction - use for freeing userdata etc. */
gpointer destroy_func_data; /* context passed to destroy_func */
};
wxTreeEntry* wx_tree_entry_new(void);
GType wx_tree_entry_get_type(void);
char* wx_tree_entry_get_collate_key(wxTreeEntry* entry);
char* wx_tree_entry_get_label(wxTreeEntry* entry);
void* wx_tree_entry_get_userdata(wxTreeEntry* entry);
void wx_tree_entry_set_label(wxTreeEntry* entry, const char* label);
void wx_tree_entry_set_userdata(wxTreeEntry* entry, void* userdata);
void wx_tree_entry_set_destroy_func(wxTreeEntry* entry,
wxTreeEntryDestroy destroy_func,
gpointer destroy_func_data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _WX_GTK_TREE_ENTRY_H_ */

View File

@@ -0,0 +1,62 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/treeview.h
// Purpose: Private helpers for wxGTK controls using GtkTreeView
// Author: Vadim Zeitlin
// Created: 2016-02-06 (extracted from src/gtk/dataview.cpp)
// Copyright: (c) 2016 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _GTK_PRIVATE_TREEVIEW_H_
#define _GTK_PRIVATE_TREEVIEW_H_
// ----------------------------------------------------------------------------
// wxGtkTreePath: RAII wrapper for GtkTreePath
// ----------------------------------------------------------------------------
// Usually this object is initialized with the associated GtkTreePath
// immediately when it's constructed but it can also be changed later either by
// using Assign() or by getting the pointer to the internally stored pointer
// value using ByRef(). The latter should be avoided but is very convenient
// when using GTK functions with GtkTreePath output parameters.
class wxGtkTreePath
{
public:
// Ctor takes ownership of the given path and will free it if non-null.
wxGtkTreePath(GtkTreePath *path = nullptr) : m_path(path) { }
// Creates a tree path for the given string path.
wxGtkTreePath(const gchar *strpath)
: m_path(gtk_tree_path_new_from_string(strpath))
{
}
// Set the stored pointer if not done by ctor.
void Assign(GtkTreePath *path)
{
wxASSERT_MSG( !m_path, "shouldn't be already initialized" );
m_path = path;
}
// Return the pointer to the internally stored pointer. This should only be
// used to initialize the object by passing it to some GTK function.
GtkTreePath **ByRef()
{
wxASSERT_MSG( !m_path, "shouldn't be already initialized" );
return &m_path;
}
operator GtkTreePath *() const { return m_path; }
~wxGtkTreePath() { if ( m_path ) gtk_tree_path_free(m_path); }
private:
GtkTreePath *m_path;
wxDECLARE_NO_COPY_CLASS(wxGtkTreePath);
};
#endif // _GTK_PRIVATE_TREEVIEW_H_

View File

@@ -0,0 +1,48 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/value.h
// Purpose: Helper wrapper for working with GValue.
// Author: Vadim Zeitlin
// Created: 2015-03-05
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_VALUE_H_
#define _WX_GTK_PRIVATE_VALUE_H_
// ----------------------------------------------------------------------------
// wxGtkValue: RAII wrapper for GValue
// ----------------------------------------------------------------------------
class wxGtkValue
{
public:
explicit wxGtkValue()
{
memset(&m_val, 0, sizeof(m_val));
}
// Initialize the value of the specified type.
explicit wxGtkValue(GType gtype)
{
memset(&m_val, 0, sizeof(m_val));
g_value_init(&m_val, gtype);
}
~wxGtkValue()
{
g_value_unset(&m_val);
}
// Unsafe but convenient access to the real value for GTK+ functions.
operator GValue*() { return &m_val; }
private:
GValue m_val;
// For now we just don't support copying at all for simplicity, it could be
// implemented later if needed.
wxDECLARE_NO_COPY_CLASS(wxGtkValue);
};
#endif // _WX_GTK_PRIVATE_VALUE_H_

View File

@@ -0,0 +1,87 @@
///////////////////////////////////////////////////////////////////////////////
// Name: gtk/private/variant.h
// Purpose: RAII wrapper for working with GVariant
// Author: Vadim Zeitlin
// Created: 2024-04-11
// Copyright: (c) 2024 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_VARIANT_H_
#define _WX_GTK_PRIVATE_VARIANT_H_
// ----------------------------------------------------------------------------
// wxGtkVariant: RAII wrapper for GVariant
// ----------------------------------------------------------------------------
class wxGtkVariant
{
public:
wxGtkVariant() = default;
explicit wxGtkVariant(GVariant* variant) : m_variant(variant) { }
wxGtkVariant(wxGtkVariant&& other) noexcept
: m_variant(other.m_variant)
{
other.m_variant = nullptr;
}
wxGtkVariant& operator=(wxGtkVariant&& other) noexcept
{
if ( this != &other )
{
m_variant = other.m_variant;
other.m_variant = nullptr;
}
return *this;
}
~wxGtkVariant()
{
if ( m_variant )
g_variant_unref(m_variant);
}
// Check if we have a valid GVariant.
explicit operator bool() const { return m_variant != nullptr; }
// Return the pointer to the internally stored pointer. This should only be
// used to initialize the object by passing it to some GTK function.
GVariant **ByRef()
{
wxASSERT_MSG( !m_variant, "shouldn't be already initialized" );
return &m_variant;
}
// Wrappers for a few functions used in our code.
guint32 GetUint32() const { return g_variant_get_uint32(m_variant); }
wxGtkVariant GetVariant() const { return wxGtkVariant{g_variant_get_variant(m_variant)}; }
// Wrapper for generic g_variant_get(): this is still as type-unsafe as the
// original C function.
template <typename... Args>
void Get(const gchar* format_string, Args*... args) const
{
g_variant_get(m_variant, format_string, args...);
}
// Yield ownership of the GVariant to the caller.
GVariant* Release()
{
GVariant* const variant = m_variant;
m_variant = nullptr;
return variant;
}
private:
GVariant* m_variant = nullptr;
// For now we just don't support copying at all for simplicity, it could be
// implemented later if needed.
wxDECLARE_NO_COPY_CLASS(wxGtkVariant);
};
#endif // _WX_GTK_PRIVATE_VARIANT_H_

View File

@@ -0,0 +1,71 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/webkit.h
// Purpose: wxWebKitGtk RAII wrappers declaration
// Author: Jose Lorenzo
// Created: 2017-08-21
// Copyright: (c) 2017 Jose Lorenzo <josee.loren@gmail.com>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_WEBKIT_H_
#define _WX_GTK_PRIVATE_WEBKIT_H_
#include "wx/buffer.h"
#include <webkit2/webkit2.h>
#include <JavaScriptCore/JSStringRef.h>
// ----------------------------------------------------------------------------
// RAII wrapper of WebKitJavascriptResult taking care of freeing it
// ----------------------------------------------------------------------------
class wxWebKitJavascriptResult
{
public:
explicit wxWebKitJavascriptResult(WebKitJavascriptResult *r)
: m_jsresult(r)
{
}
~wxWebKitJavascriptResult()
{
if ( m_jsresult != nullptr )
webkit_javascript_result_unref(m_jsresult);
}
operator WebKitJavascriptResult *() const { return m_jsresult; }
private:
WebKitJavascriptResult *m_jsresult;
wxDECLARE_NO_COPY_CLASS(wxWebKitJavascriptResult);
};
// ----------------------------------------------------------------------------
// RAII wrapper of JSStringRef, also providing conversion to wxString
// ----------------------------------------------------------------------------
class wxJSStringRef
{
public:
explicit wxJSStringRef(JSStringRef r) : m_jssref(r) { }
~wxJSStringRef() { JSStringRelease(m_jssref); }
wxString ToWxString() const
{
const size_t length = JSStringGetMaximumUTF8CStringSize(m_jssref);
wxCharBuffer str(length);
JSStringGetUTF8CString(m_jssref, str.data(), length);
return wxString::FromUTF8(str);
}
private:
JSStringRef m_jssref;
wxDECLARE_NO_COPY_CLASS(wxJSStringRef);
};
#endif // _WX_GTK_PRIVATE_WEBKIT_H_

View File

@@ -0,0 +1,15 @@
/////////////////////////////////////////////////////////////////////////////
// Name: include/wx/gtk/private/webview_webkit2_extension.h
// Purpose: Common elements for webview webkit2 extension
// Author: Scott Talbert
// Copyright: (c) 2017 Scott Talbert
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_WEBVIEW_WEBKIT2_EXTENSION_H_
#define _WX_GTK_PRIVATE_WEBVIEW_WEBKIT2_EXTENSION_H_
#define WXGTK_WEB_EXTENSION_OBJECT_PATH "/org/wxwidgets/wxGTK/WebExtension"
#define WXGTK_WEB_EXTENSION_INTERFACE "org.wxwidgets.wxGTK.WebExtension"
#endif // _WX_GTK_PRIVATE_WEBVIEW_WEBKIT2_EXTENSION_H_

View File

@@ -0,0 +1,37 @@
/* ///////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/win_gtk.h
// Purpose: native GTK+ widget for wxWindow
// Author: Robert Roebling
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////// */
#ifndef _WX_GTK_PIZZA_H_
#define _WX_GTK_PIZZA_H_
#define WX_PIZZA(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, wxPizza::type(), wxPizza)
#define WX_IS_PIZZA(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, wxPizza::type())
struct WXDLLIMPEXP_CORE wxPizza
{
// borders styles which can be used with wxPizza
enum { BORDER_STYLES =
wxBORDER_SIMPLE | wxBORDER_RAISED | wxBORDER_SUNKEN | wxBORDER_THEME };
static GtkWidget* New(long windowStyle = 0);
static GType type();
void move(GtkWidget* widget, int x, int y, int width, int height);
void put(GtkWidget* widget, int x, int y, int width, int height);
void scroll(int dx, int dy);
void get_border(GtkBorder& border);
void size_allocate_child(
GtkWidget* child, int x, int y, int width, int height, int parent_width = -1);
GtkFixed m_fixed;
GList* m_children;
int m_scroll_x;
int m_scroll_y;
int m_windowStyle;
};
#endif // _WX_GTK_PIZZA_H_

View File

@@ -0,0 +1,33 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/wrapgdk.h
// Purpose: Include GDK header for the appropriate window system
// Author: Vadim Zeitlin
// Created: 2024-07-17
// Copyright: (c) 2024 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_WRAPGDK_H_
#define _WX_GTK_PRIVATE_WRAPGDK_H_
#include "wx/gtk/private/wrapgtk.h"
#ifdef GDK_WINDOWING_WAYLAND
// Wayland headers included from gdkwayland.h may result in -Wundef due to
// __STDC_VERSION__ used there being undefined, suppress this.
wxGCC_WARNING_SUPPRESS(undef)
#include <gdk/gdkwayland.h>
wxGCC_WARNING_RESTORE(undef)
#endif // GDK_WINDOWING_WAYLAND
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#ifdef GDK_WINDOWING_WIN32
#include <gdk/gdkwin32.h>
#endif
#endif // _WX_GTK_PRIVATE_WRAPGDK_H_

View File

@@ -0,0 +1,21 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/wrapgtk.h
// Purpose: Include gtk/gtk.h without warnings and with compatibility
// Author: Vadim Zeitlin
// Created: 2018-05-20
// Copyright: (c) 2018 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_WRAPGTK_H_
#define _WX_GTK_PRIVATE_WRAPGTK_H_
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
wxGCC_WARNING_SUPPRESS(parentheses)
#include <gtk/gtk.h>
wxGCC_WARNING_RESTORE(parentheses)
wxGCC_WARNING_RESTORE(deprecated-declarations)
#include "wx/gtk/private/gtk2-compat.h"
#endif // _WX_GTK_PRIVATE_WRAPGTK_H_