support for GTK3

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71894 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2012-06-30 20:39:06 +00:00
parent 6f41c10973
commit 9dc44eff02
89 changed files with 6885 additions and 1923 deletions

View File

@@ -10,6 +10,10 @@
#ifndef _WX_GTK_BITMAP_H_
#define _WX_GTK_BITMAP_H_
#ifdef __WXGTK3__
typedef struct _cairo cairo_t;
typedef struct _cairo_surface cairo_surface_t;
#endif
typedef struct _GdkPixbuf GdkPixbuf;
class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
@@ -30,8 +34,13 @@ public:
virtual ~wxMask();
// implementation
#ifdef __WXGTK3__
wxMask(cairo_surface_t*);
cairo_surface_t* GetBitmap() const;
#else
wxMask(GdkPixmap*);
GdkPixmap* GetBitmap() const;
#endif
protected:
virtual void FreeData();
@@ -39,7 +48,11 @@ protected:
virtual bool InitFromMonoBitmap(const wxBitmap& bitmap);
private:
#ifdef __WXGTK3__
cairo_surface_t* m_bitmap;
#else
GdkPixmap* m_bitmap;
#endif
DECLARE_DYNAMIC_CLASS(wxMask)
};
@@ -65,8 +78,7 @@ public:
#endif
wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
#if wxUSE_IMAGE
wxBitmap( const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH )
{ (void)CreateFromImage(image, depth); }
wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH);
#endif // wxUSE_IMAGE
wxBitmap(GdkPixbuf* pixbuf);
virtual ~wxBitmap();
@@ -88,6 +100,7 @@ public:
wxMask *GetMask() const;
void SetMask( wxMask *mask );
wxBitmap GetMaskBitmap() const;
wxBitmap GetSubBitmap( const wxRect& rect ) const;
@@ -110,9 +123,16 @@ public:
void SetWidth( int width );
void SetDepth( int depth );
#ifdef __WXGTK3__
GdkPixbuf* GetPixbufNoMask() const;
cairo_t* CairoCreate() const;
void Draw(cairo_t* cr, int x, int y, bool useMask = true, const wxColour* fg = NULL, const wxColour* bg = NULL) const;
void SetSourceSurface(cairo_t* cr, int x, int y, const wxColour* fg = NULL, const wxColour* bg = NULL) const;
#else
GdkPixmap *GetPixmap() const;
bool HasPixmap() const;
bool HasPixbuf() const;
#endif
GdkPixbuf *GetPixbuf() const;
// raw bitmap access support functions
@@ -122,14 +142,17 @@ public:
bool HasAlpha() const;
protected:
#ifndef __WXGTK3__
#if wxUSE_IMAGE
bool CreateFromImage(const wxImage& image, int depth);
#endif // wxUSE_IMAGE
#endif
virtual wxGDIRefData* CreateGDIRefData() const;
virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
private:
#ifndef __WXGTK3__
void SetPixmap(GdkPixmap* pixmap);
#if wxUSE_IMAGE
// to be called from CreateFromImage only!
@@ -147,6 +170,7 @@ public:
// removes other representations from memory, keeping only 'keep'
// (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
void PurgeOtherRepresentations(Representation keep);
#endif
DECLARE_DYNAMIC_CLASS(wxBitmap)
};

View File

@@ -81,3 +81,14 @@
#endif
#endif /* __WINDOWS__ */
#ifdef __WXGTK3__
#if !wxUSE_GRAPHICS_CONTEXT
#ifdef wxABORT_ON_CONFIG_ERROR
#error "GTK+ 3 support requires wxGraphicsContext"
#else
#undef wxUSE_GRAPHICS_CONTEXT
#define wxUSE_GRAPHICS_CONTEXT 1
#endif
#endif
#endif

View File

@@ -52,8 +52,8 @@ protected:
public: // used by the GTK callback only
void SetGdkColor(const GdkColor& gdkColor)
{ m_colour = wxColor(gdkColor); }
void GTKSetColour(const wxColour& colour)
{ m_colour = colour; }
wxWindow *m_topParent;

View File

@@ -10,6 +10,10 @@
#ifndef _WX_GTK_COLOUR_H_
#define _WX_GTK_COLOUR_H_
#ifdef __WXGTK3__
typedef struct _GdkRGBA GdkRGBA;
#endif
//-----------------------------------------------------------------------------
// wxColour
//-----------------------------------------------------------------------------
@@ -21,6 +25,9 @@ public:
// ------------
DEFINE_STD_WXCOLOUR_CONSTRUCTORS
wxColour(const GdkColor& gdkColor);
#ifdef __WXGTK3__
wxColour(const GdkRGBA& gdkRGBA);
#endif
virtual ~wxColour();
@@ -33,8 +40,12 @@ public:
unsigned char Alpha() const;
// Implementation part
#ifdef __WXGTK3__
operator const GdkRGBA*() const;
#else
void CalcPixel( GdkColormap *cmap );
int GetPixel() const;
#endif
const GdkColor *GetColor() const;
protected:
@@ -43,7 +54,6 @@ protected:
virtual bool FromString(const wxString& str);
private:
DECLARE_DYNAMIC_CLASS(wxColour)
};

View File

@@ -26,6 +26,7 @@ extern "C" {
class WXDLLIMPEXP_CORE wxControl : public wxControlBase
{
typedef wxControlBase base_type;
public:
wxControl();
wxControl(wxWindow *parent, wxWindowID id,
@@ -43,8 +44,10 @@ public:
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxControlNameStr);
virtual wxVisualAttributes GetDefaultAttributes() const;
#ifdef __WXGTK3__
virtual bool SetFont(const wxFont& font);
#endif
protected:
virtual wxSize DoGetBestSize() const;

View File

@@ -10,6 +10,105 @@
#ifndef _WX_GTKDC_H_
#define _WX_GTKDC_H_
#ifdef __WXGTK3__
#include "wx/dcgraph.h"
class wxGTKCairoDCImpl: public wxGCDCImpl
{
typedef wxGCDCImpl base_type;
public:
wxGTKCairoDCImpl(wxDC* owner);
wxGTKCairoDCImpl(wxDC* owner, wxWindow* window);
virtual void DoDrawBitmap(const wxBitmap& bitmap, int x, int y, bool useMask);
virtual void DoDrawIcon(const wxIcon& icon, int x, int y);
#if wxUSE_IMAGE
virtual bool DoFloodFill(int x, int y, const wxColour& col, wxFloodFillStyle style);
#endif
virtual wxBitmap DoGetAsBitmap(const wxRect* subrect) const;
virtual bool DoGetPixel(int x, int y, wxColour* col) const;
virtual void DoGetSize(int* width, int* height) const;
virtual bool DoStretchBlit(int xdest, int ydest, int dstWidth, int dstHeight, wxDC* source, int xsrc, int ysrc, int srcWidth, int srcHeight, wxRasterOperationMode rop, bool useMask, int xsrcMask, int ysrcMask);
virtual void* GetCairoContext() const;
protected:
int m_width, m_height;
wxDECLARE_NO_COPY_CLASS(wxGTKCairoDCImpl);
};
//-----------------------------------------------------------------------------
class wxWindowDCImpl: public wxGTKCairoDCImpl
{
typedef wxGTKCairoDCImpl base_type;
public:
wxWindowDCImpl(wxWindowDC* owner, wxWindow* window);
wxDECLARE_NO_COPY_CLASS(wxWindowDCImpl);
};
//-----------------------------------------------------------------------------
class wxClientDCImpl: public wxGTKCairoDCImpl
{
typedef wxGTKCairoDCImpl base_type;
public:
wxClientDCImpl(wxClientDC* owner, wxWindow* window);
wxDECLARE_NO_COPY_CLASS(wxClientDCImpl);
};
//-----------------------------------------------------------------------------
class wxPaintDCImpl: public wxGTKCairoDCImpl
{
typedef wxGTKCairoDCImpl base_type;
public:
wxPaintDCImpl(wxPaintDC* owner, wxWindow* window);
wxDECLARE_NO_COPY_CLASS(wxPaintDCImpl);
};
//-----------------------------------------------------------------------------
class wxScreenDCImpl: public wxGTKCairoDCImpl
{
typedef wxGTKCairoDCImpl base_type;
public:
wxScreenDCImpl(wxScreenDC* owner);
wxDECLARE_NO_COPY_CLASS(wxScreenDCImpl);
};
//-----------------------------------------------------------------------------
class wxMemoryDCImpl: public wxGTKCairoDCImpl
{
typedef wxGTKCairoDCImpl base_type;
public:
wxMemoryDCImpl(wxMemoryDC* owner);
wxMemoryDCImpl(wxMemoryDC* owner, wxBitmap& bitmap);
wxMemoryDCImpl(wxMemoryDC* owner, wxDC* dc);
virtual wxBitmap DoGetAsBitmap(const wxRect* subrect) const;
virtual void DoSelect(const wxBitmap& bitmap);
virtual const wxBitmap& GetSelectedBitmap() const;
virtual wxBitmap& GetSelectedBitmap();
private:
void Setup();
wxBitmap m_bitmap;
wxDECLARE_NO_COPY_CLASS(wxMemoryDCImpl);
};
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGTKCairoDC: public wxDC
{
typedef wxDC base_type;
public:
wxGTKCairoDC(cairo_t* cr);
wxDECLARE_NO_COPY_CLASS(wxGTKCairoDC);
};
#else
#include "wx/dc.h"
//-----------------------------------------------------------------------------
@@ -50,4 +149,5 @@ public:
#define wxHAS_WORKING_GTK_DC_BLIT
#endif
#endif
#endif // _WX_GTKDC_H_

View File

@@ -12,7 +12,12 @@
#ifndef _WX_GTK_DVRENDERERS_H_
#define _WX_GTK_DVRENDERERS_H_
typedef struct _GdkRectangle GdkRectangle;
#ifdef __WXGTK3__
typedef struct _cairo_rectangle_int cairo_rectangle_int_t;
typedef cairo_rectangle_int_t GdkRectangle;
#else
typedef struct _GdkRectangle GdkRectangle;
#endif
// ---------------------------------------------------------
// wxDataViewTextRenderer

View File

@@ -39,6 +39,7 @@ public:
const int *attribList = NULL,
const wxPalette& palette = wxNullPalette);
virtual bool SetBackgroundStyle(wxBackgroundStyle style);
// implement wxGLCanvasX11 methods
// --------------------------------
@@ -93,6 +94,9 @@ public:
void OnInternalIdle();
bool m_exposed;
#ifdef __WXGTK3__
cairo_t* m_cairoPaintContext;
#endif
#if WXWIN_COMPATIBILITY_2_8
wxGLContext *m_sharedContext;

View File

@@ -119,7 +119,7 @@ WXDLLIMPEXP_CORE GtkWidget *GetHeaderButtonWidgetLast();
WXDLLIMPEXP_CORE GtkWidget *GetHeaderButtonWidget();
WXDLLIMPEXP_CORE GtkWidget *GetNotebookWidget();
WXDLLIMPEXP_CORE GtkWidget *GetRadioButtonWidget();
WXDLLIMPEXP_CORE GtkWidget *GetSplitterWidget();
WXDLLIMPEXP_CORE GtkWidget *GetSplitterWidget(wxOrientation orient = wxHORIZONTAL);
WXDLLIMPEXP_CORE GtkWidget *GetTextEntryWidget();
WXDLLIMPEXP_CORE GtkWidget *GetTreeWidget();

View File

@@ -26,7 +26,7 @@
// functions even if GTK_CHECK_VERSION would indicate the function is
// already available in GTK+.
#if !GTK_CHECK_VERSION(3,0,0) && !(defined(GTK_DISABLE_DEPRECATED) || defined(GSEAL_ENABLE))
#ifndef __WXGTK3__
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.8
@@ -342,9 +342,60 @@ static inline GdkWindow* wx_gtk_entry_get_text_window(GtkEntry* entry)
}
#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
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.24
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;
@@ -369,8 +420,20 @@ static inline void wx_gdk_cairo_set_source_window(cairo_t* cr, GdkWindow* window
#define gdk_cairo_set_source_window wx_gdk_cairo_set_source_window
#endif
#endif // !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
// ----------------------------------------------------------------------------
// 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, NULL);
}
#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
#endif // !__WXGTK3__
#endif // _WX_GTK_PRIVATE_COMPAT_H_

View File

@@ -10,8 +10,6 @@
#ifndef _WX_GTK_PIZZA_H_
#define _WX_GTK_PIZZA_H_
#include <gtk/gtk.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())
@@ -26,14 +24,13 @@ struct WXDLLIMPEXP_CORE wxPizza
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_widths(int& x, int& y);
void get_border(GtkBorder& border);
GtkFixed m_fixed;
GList* m_children;
int m_scroll_x;
int m_scroll_y;
int m_border_style;
bool m_is_scrollable;
int m_windowStyle;
};
#endif // _WX_GTK_PIZZA_H_

View File

@@ -10,6 +10,10 @@
#ifndef _WX_GTK_REGION_H_
#define _WX_GTK_REGION_H_
#ifdef __WXGTK3__
typedef struct _cairo_region cairo_region_t;
#endif
// ----------------------------------------------------------------------------
// wxRegion
// ----------------------------------------------------------------------------
@@ -56,12 +60,12 @@ public:
virtual void Clear();
virtual bool IsEmpty() const;
public:
// Init with GdkRegion, set ref count to 2 so that
// the C++ class will not destroy the region!
wxRegion( GdkRegion *region );
#ifdef __WXGTK3__
cairo_region_t* GetRegion() const;
#else
wxRegion(const GdkRegion* region);
GdkRegion *GetRegion() const;
#endif
protected:
virtual wxGDIRefData *CreateGDIRefData() const;

View File

@@ -1652,9 +1652,6 @@
#define __WXGTK26__
#define __WXGTK210__
#define __WXGTK218__
// Alternatively, all the above symbols could be commented and this one
// uncommented if using GTK+ 3.
//#define __WXGTK30__
//#define __WXGTK3__
#endif // _WX_SETUP_H_

View File

@@ -12,6 +12,13 @@
#include "wx/dynarray.h"
#ifdef __WXGTK3__
typedef struct _cairo cairo_t;
#define WXUNUSED_IN_GTK3(x)
#else
#define WXUNUSED_IN_GTK3(x) x
#endif
// helper structure that holds class that holds GtkIMContext object and
// some additional data needed for key events processing
struct wxGtkIMData;
@@ -140,12 +147,13 @@ public:
// Internal addition of child windows
void DoAddChild(wxWindowGTK *child);
// This methods sends wxPaintEvents to the window. It reads the
// update region, breaks it up into rects and sends an event
// for each rect. It is also responsible for background erase
// events and NC paint events. It is called from "draw" and
// "expose" handlers as well as from ::Update()
void GtkSendPaintEvents();
// This method sends wxPaintEvents to the window.
// It is also responsible for background erase events.
#ifdef __WXGTK3__
void GTKSendPaintEvents(cairo_t* cr);
#else
void GTKSendPaintEvents(const GdkRegion* region);
#endif
// The methods below are required because many native widgets
// are composed of several subwidgets and setting a style for
@@ -267,7 +275,6 @@ public:
wxGtkIMData *m_imData;
// indices for the arrays below
enum ScrollDir { ScrollDir_Horz, ScrollDir_Vert, ScrollDir_Max };
@@ -359,20 +366,23 @@ protected:
// Copies m_children tab order to GTK focus chain:
void RealizeTabOrder();
#ifndef __WXGTK3__
// Called by ApplyWidgetStyle (which is called by SetFont() and
// SetXXXColour etc to apply style changed to native widgets) to create
// modified GTK style with non-standard attributes. If forceStyle=true,
// creates empty GtkRcStyle if there are no modifications, otherwise
// returns NULL in such case.
GtkRcStyle *GTKCreateWidgetStyle(bool forceStyle = false);
#endif
// Overridden in many GTK widgets who have to handle subwidgets
virtual void GTKApplyWidgetStyle(bool forceStyle = false);
void GTKApplyWidgetStyle(bool forceStyle = false);
// helper function to ease native widgets wrapping, called by
// ApplyWidgetStyle -- override this, not ApplyWidgetStyle
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
void GTKApplyStyle(GtkWidget* widget, GtkRcStyle* style);
// sets the border of a given GtkScrolledWindow from a wx style
static void GTKScrolledWindowSetBorder(GtkWidget* w, int style);
@@ -395,6 +405,17 @@ private:
bool DoScrollByUnits(ScrollDir dir, ScrollUnit unit, int units);
virtual void AddChildGTK(wxWindowGTK* child);
#ifdef __WXGTK3__
// paint context is stashed here so wxPaintDC can use it
cairo_t* m_paintContext;
public:
cairo_t* GTKPaintContext() const
{
return m_paintContext;
}
#endif
DECLARE_DYNAMIC_CLASS(wxWindowGTK)
wxDECLARE_NO_COPY_CLASS(wxWindowGTK);
};