From 3cbab64109b007fa1d939fe588f5e79f9105b915 Mon Sep 17 00:00:00 2001 From: Mart Raudsepp Date: Mon, 23 Jan 2006 01:14:32 +0000 Subject: [PATCH] Remove GTK2 stuff from src/gtk1. Rename wx/gtk includes to wx/gtk1. 57 files changed, 394 insertions(+), 6767 deletions(-) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37063 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk1/app.cpp | 60 +- src/gtk1/artgtk.cpp | 293 ------ src/gtk1/bitmap.cpp | 782 ++++++---------- src/gtk1/bmpbuttn.cpp | 17 +- src/gtk1/brush.cpp | 2 +- src/gtk1/button.cpp | 91 +- src/gtk1/checkbox.cpp | 79 +- src/gtk1/checklst.cpp | 2 +- src/gtk1/choice.cpp | 24 +- src/gtk1/clipbrd.cpp | 32 +- src/gtk1/colordlg.cpp | 130 --- src/gtk1/colour.cpp | 15 +- src/gtk1/combobox.cpp | 30 +- src/gtk1/control.cpp | 37 +- src/gtk1/dataobj.cpp | 12 - src/gtk1/dcclient.cpp | 274 +----- src/gtk1/dcmemory.cpp | 22 - src/gtk1/dcscreen.cpp | 9 - src/gtk1/dialog.cpp | 2 +- src/gtk1/dnd.cpp | 14 +- src/gtk1/filedlg.cpp | 423 +-------- src/gtk1/font.cpp | 127 +-- src/gtk1/fontdlg.cpp | 13 +- src/gtk1/frame.cpp | 4 +- src/gtk1/glcanvas.cpp | 21 +- src/gtk1/gnome/gprint.cpp | 1790 ------------------------------------- src/gtk1/listbox.cpp | 10 +- src/gtk1/mdi.cpp | 6 +- src/gtk1/menu.cpp | 106 +-- src/gtk1/minifram.cpp | 14 +- src/gtk1/msgdlg.cpp | 115 +-- src/gtk1/notebook.cpp | 12 +- src/gtk1/pen.cpp | 2 +- src/gtk1/popupwin.cpp | 2 +- src/gtk1/radiobox.cpp | 14 +- src/gtk1/radiobut.cpp | 2 +- src/gtk1/region.cpp | 61 +- src/gtk1/renderer.cpp | 127 +-- src/gtk1/scrolbar.cpp | 8 +- src/gtk1/scrolwin.cpp | 2 +- src/gtk1/settings.cpp | 194 +--- src/gtk1/slider.cpp | 29 +- src/gtk1/spinbutt.cpp | 2 +- src/gtk1/spinctrl.cpp | 2 +- src/gtk1/statbmp.cpp | 10 - src/gtk1/statbox.cpp | 5 +- src/gtk1/stattext.cpp | 45 +- src/gtk1/taskbar.cpp | 131 --- src/gtk1/tbargtk.cpp | 70 +- src/gtk1/textctrl.cpp | 981 +------------------- src/gtk1/tglbtn.cpp | 4 +- src/gtk1/tooltip.cpp | 2 +- src/gtk1/toplevel.cpp | 137 +-- src/gtk1/treegtk.cpp | 2 +- src/gtk1/utilsgtk.cpp | 45 +- src/gtk1/win_gtk.c | 136 +-- src/gtk1/window.cpp | 579 +----------- 57 files changed, 393 insertions(+), 6767 deletions(-) diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index aaf7989b30..8255d6178c 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -73,7 +73,7 @@ #endif // HAVE_POLL/!HAVE_POLL #include "wx/unix/private.h" -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/win_gtk.h" #include @@ -173,21 +173,17 @@ bool wxApp::Yield(bool onlyIfNeeded) void wxApp::WakeUpIdle() { -#ifndef __WXGTK20__ #if wxUSE_THREADS if (!wxThread::IsMain()) wxMutexGuiEnter(); #endif // wxUSE_THREADS_ -#endif // __WXGTK2__ wxapp_install_idle_handler(); -#ifndef __WXGTK20__ #if wxUSE_THREADS if (!wxThread::IsMain()) wxMutexGuiLeave(); #endif // wxUSE_THREADS_ -#endif // __WXGTK2__ } //----------------------------------------------------------------------------- @@ -245,11 +241,7 @@ static gint wxapp_idle_callback( gpointer WXUNUSED(data) ) if (wxTopLevelWindows.GetCount() > 0) { wxWindow* win = (wxWindow*) wxTopLevelWindows.GetLast()->GetData(); -#ifdef __WXGTK20__ - if (win->IsKindOf(CLASSINFO(wxMessageDialog))) -#else if (win->IsKindOf(CLASSINFO(wxGenericMessageDialog))) -#endif win->OnInternalIdle(); } return TRUE; @@ -469,14 +461,9 @@ bool wxApp::OnInitGui() // chosen a specific visual, then derive the GdkVisual from that if (m_glVisualInfo != NULL) { -#ifdef __WXGTK20__ - // seems gtk_widget_set_default_visual no longer exists? - GdkVisual* vis = gtk_widget_get_default_visual(); -#else GdkVisual* vis = gdkx_visual_get( ((XVisualInfo *) m_glVisualInfo) ->visualid ); gtk_widget_set_default_visual( vis ); -#endif GdkColormap *colormap = gdk_colormap_new( vis, FALSE ); gtk_widget_set_default_colormap( colormap ); @@ -490,13 +477,8 @@ bool wxApp::OnInitGui() else if ((gdk_visual_get_best() != gdk_visual_get_system()) && (m_useBestVisual)) { -#ifdef __WXGTK20__ - /* seems gtk_widget_set_default_visual no longer exists? */ - GdkVisual* vis = gtk_widget_get_default_visual(); -#else GdkVisual* vis = gdk_visual_get_best(); gtk_widget_set_default_visual( vis ); -#endif GdkColormap *colormap = gdk_colormap_new( vis, FALSE ); gtk_widget_set_default_colormap( colormap ); @@ -575,7 +557,7 @@ GdkVisual *wxApp::GetGdkVisual() bool wxApp::Initialize(int& argc, wxChar **argv) { bool init_result; - + #if wxUSE_THREADS // GTK 1.2 up to version 1.2.3 has broken threads if ((gtk_major_version == 1) && @@ -595,47 +577,13 @@ bool wxApp::Initialize(int& argc, wxChar **argv) // We should have the wxUSE_WCHAR_T test on the _outside_ #if wxUSE_WCHAR_T - #if defined(__WXGTK20__) - // gtk+ 2.0 supports Unicode through UTF-8 strings - wxConvCurrent = &wxConvUTF8; - #else // GTK 1.x if (!wxOKlibc()) wxConvCurrent = &wxConvLocal; - #endif #else // !wxUSE_WCHAR_T if (!wxOKlibc()) wxConvCurrent = (wxMBConv*) NULL; #endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T -#ifdef __WXGTK20__ - // decide which conversion to use for the file names - - // (1) this variable exists for the sole purpose of specifying the encoding - // of the filenames for GTK+ programs, so use it if it is set - wxString encName(wxGetenv(_T("G_FILENAME_ENCODING"))); - encName = encName.BeforeFirst(_T(',')); - if (encName == _T("@locale")) - encName.clear(); - encName.MakeUpper(); -#if wxUSE_INTL - if (encName.empty()) - { - // (2) if a non default locale is set, assume that the user wants his - // filenames in this locale too - encName = wxLocale::GetSystemEncodingName().Upper(); - // (3) finally use UTF-8 by default - if (encName.empty() || encName == _T("US-ASCII")) - encName = _T("UTF-8"); - wxSetEnv(_T("G_FILENAME_ENCODING"), encName); - } -#else - if (encName.empty()) - encName = _T("UTF-8"); -#endif // wxUSE_INTL - static wxConvBrokenFileNames fileconv(encName); - wxConvFileName = &fileconv; -#endif // __WXGTK20__ - #if wxUSE_UNICODE // gtk_init() wants UTF-8, not wchar_t, so convert int i; @@ -648,7 +596,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv) argvGTK[argc] = NULL; int argcGTK = argc; - + #ifdef __WXGPE__ init_result = true; // is there a _check() version of this? gpe_application_init( &argcGTK, &argvGTK ); @@ -688,7 +636,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv) wxLogError(wxT("Unable to initialize gtk, is DISPLAY set properly?")); return false; } - + // we can not enter threads before gtk_init is done gdk_threads_enter(); diff --git a/src/gtk1/artgtk.cpp b/src/gtk1/artgtk.cpp index 8cdcb39bf7..959b3a455d 100644 --- a/src/gtk1/artgtk.cpp +++ b/src/gtk1/artgtk.cpp @@ -19,296 +19,3 @@ #if defined(__BORLANDC__) #pragma hdrstop #endif - -#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) - -#include "wx/artprov.h" -#include "wx/module.h" -#include "wx/gtk/private.h" - -#include - -// compatibility with older GTK+ versions: -#ifndef GTK_STOCK_FILE - #define GTK_STOCK_FILE "gtk-file" -#endif -#ifndef GTK_STOCK_DIRECTORY - #define GTK_STOCK_DIRECTORY "gtk-directory" -#endif - - -// ---------------------------------------------------------------------------- -// wxGTK2ArtProvider -// ---------------------------------------------------------------------------- - -class wxGTK2ArtProvider : public wxArtProvider -{ -protected: - virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, - const wxSize& size); -}; - -/*static*/ void wxArtProvider::InitNativeProvider() -{ - wxArtProvider::PushProvider(new wxGTK2ArtProvider); -} - -// ---------------------------------------------------------------------------- -// CreateBitmap routine -// ---------------------------------------------------------------------------- - -static const char *wxArtIDToStock(const wxArtID& id) -{ - #define ART(wxid, gtkid) \ - if (id == wxid) return gtkid; - - ART(wxART_ERROR, GTK_STOCK_DIALOG_ERROR) - ART(wxART_INFORMATION, GTK_STOCK_DIALOG_INFO) - ART(wxART_WARNING, GTK_STOCK_DIALOG_WARNING) - ART(wxART_QUESTION, GTK_STOCK_DIALOG_QUESTION) - - //ART(wxART_HELP_SIDE_PANEL, ) - ART(wxART_HELP_SETTINGS, GTK_STOCK_SELECT_FONT) - //ART(wxART_HELP_BOOK, ) - ART(wxART_HELP_FOLDER, GTK_STOCK_DIRECTORY) - ART(wxART_HELP_PAGE, GTK_STOCK_FILE) - ART(wxART_MISSING_IMAGE, GTK_STOCK_MISSING_IMAGE) - ART(wxART_ADD_BOOKMARK, GTK_STOCK_ADD) - ART(wxART_DEL_BOOKMARK, GTK_STOCK_REMOVE) - ART(wxART_GO_BACK, GTK_STOCK_GO_BACK) - ART(wxART_GO_FORWARD, GTK_STOCK_GO_FORWARD) - ART(wxART_GO_UP, GTK_STOCK_GO_UP) - ART(wxART_GO_DOWN, GTK_STOCK_GO_DOWN) - ART(wxART_GO_TO_PARENT, GTK_STOCK_GO_UP) - ART(wxART_GO_HOME, GTK_STOCK_HOME) - ART(wxART_FILE_OPEN, GTK_STOCK_OPEN) - ART(wxART_PRINT, GTK_STOCK_PRINT) - ART(wxART_HELP, GTK_STOCK_HELP) - ART(wxART_TIP, GTK_STOCK_DIALOG_INFO) - //ART(wxART_REPORT_VIEW, ) - //ART(wxART_LIST_VIEW, ) - //ART(wxART_NEW_DIR, ) -#ifdef __WXGTK24__ - ART(wxART_FOLDER, GTK_STOCK_DIRECTORY) - ART(wxART_FOLDER_OPEN, GTK_STOCK_DIRECTORY) -#endif - //ART(wxART_GO_DIR_UP, ) - ART(wxART_EXECUTABLE_FILE, GTK_STOCK_EXECUTE) - ART(wxART_NORMAL_FILE, GTK_STOCK_FILE) - ART(wxART_TICK_MARK, GTK_STOCK_APPLY) - ART(wxART_CROSS_MARK, GTK_STOCK_CANCEL) - -#ifdef __WXGTK24__ - ART(wxART_FLOPPY, GTK_STOCK_FLOPPY) - ART(wxART_CDROM, GTK_STOCK_CDROM) - ART(wxART_HARDDISK, GTK_STOCK_HARDDISK) - ART(wxART_REMOVABLE, GTK_STOCK_HARDDISK) - - ART(wxART_FILE_SAVE, GTK_STOCK_SAVE) - ART(wxART_FILE_SAVE_AS, GTK_STOCK_SAVE_AS) - - ART(wxART_COPY, GTK_STOCK_COPY) - ART(wxART_CUT, GTK_STOCK_CUT) - ART(wxART_PASTE, GTK_STOCK_PASTE) - ART(wxART_DELETE, GTK_STOCK_DELETE) - ART(wxART_NEW, GTK_STOCK_NEW) - - ART(wxART_UNDO, GTK_STOCK_UNDO) - ART(wxART_REDO, GTK_STOCK_REDO) - - ART(wxART_QUIT, GTK_STOCK_QUIT) - - ART(wxART_FIND, GTK_STOCK_FIND) - ART(wxART_FIND_AND_REPLACE, GTK_STOCK_FIND_AND_REPLACE) -#endif - - return NULL; - - #undef ART -} - -GtkIconSize wxArtClientToIconSize(const wxArtClient& client) -{ - if (client == wxART_TOOLBAR) - return GTK_ICON_SIZE_LARGE_TOOLBAR; - else if (client == wxART_MENU) - return GTK_ICON_SIZE_MENU; - else if (client == wxART_CMN_DIALOG || client == wxART_MESSAGE_BOX) - return GTK_ICON_SIZE_DIALOG; - else if (client == wxART_BUTTON) - return GTK_ICON_SIZE_BUTTON; - else - return GTK_ICON_SIZE_INVALID; // this is arbitrary -} - -static GtkIconSize FindClosestIconSize(const wxSize& size) -{ - #define NUM_SIZES 6 - static struct - { - GtkIconSize icon; - gint x, y; - } s_sizes[NUM_SIZES]; - static bool s_sizesInitialized = false; - - if (!s_sizesInitialized) - { - s_sizes[0].icon = GTK_ICON_SIZE_MENU; - s_sizes[1].icon = GTK_ICON_SIZE_SMALL_TOOLBAR; - s_sizes[2].icon = GTK_ICON_SIZE_LARGE_TOOLBAR; - s_sizes[3].icon = GTK_ICON_SIZE_BUTTON; - s_sizes[4].icon = GTK_ICON_SIZE_DND; - s_sizes[5].icon = GTK_ICON_SIZE_DIALOG; - for (size_t i = 0; i < NUM_SIZES; i++) - { - gtk_icon_size_lookup(s_sizes[i].icon, - &s_sizes[i].x, &s_sizes[i].y); - } - s_sizesInitialized = true; - } - - GtkIconSize best = GTK_ICON_SIZE_DIALOG; // presumably largest - unsigned distance = INT_MAX; - for (size_t i = 0; i < NUM_SIZES; i++) - { - // only use larger bitmaps, scaling down looks better than scaling up: - if (size.x > s_sizes[i].x || size.y > s_sizes[i].y) - continue; - - unsigned dist = (size.x - s_sizes[i].x) * (size.x - s_sizes[i].x) + - (size.y - s_sizes[i].y) * (size.y - s_sizes[i].y); - if (dist == 0) - return s_sizes[i].icon; - else if (dist < distance) - { - distance = dist; - best = s_sizes[i].icon; - } - } - return best; -} - - -static GtkStyle *gs_gtkStyle = NULL; - -static GdkPixbuf *CreateStockIcon(const char *stockid, GtkIconSize size) -{ - // FIXME: This code is not 100% correct, because stock pixmap are - // context-dependent and may be affected by theme engine, the - // correct value can only be obtained for given GtkWidget object. - // - // Fool-proof implementation of stock bitmaps would extend wxBitmap - // with "stock-id" representation (in addition to pixmap and pixbuf - // ones) and would convert it to pixbuf when rendered. - - if (gs_gtkStyle == NULL) - { - GtkWidget *widget = gtk_button_new(); - gs_gtkStyle = gtk_rc_get_style(widget); - wxASSERT( gs_gtkStyle != NULL ); - g_object_ref(G_OBJECT(gs_gtkStyle)); - gtk_widget_destroy(widget); - } - - GtkIconSet *iconset = gtk_style_lookup_icon_set(gs_gtkStyle, stockid); - - if (!iconset) - return NULL; - - return gtk_icon_set_render_icon(iconset, gs_gtkStyle, - gtk_widget_get_default_direction(), - GTK_STATE_NORMAL, size, NULL, NULL); -} - -#ifdef __WXGTK24__ -static GdkPixbuf *CreateThemeIcon(const char *iconname, - GtkIconSize iconsize, const wxSize& sz) -{ - wxSize size(sz); - if (size == wxDefaultSize) - { - gtk_icon_size_lookup(iconsize, &size.x, &size.y); - } - - return gtk_icon_theme_load_icon( - gtk_icon_theme_get_default(), - iconname, - size.x, - (GtkIconLookupFlags)0, NULL); -} -#endif - -wxBitmap wxGTK2ArtProvider::CreateBitmap(const wxArtID& id, - const wxArtClient& client, - const wxSize& size) -{ - wxCharBuffer stockid = wxArtIDToStock(id); - GtkIconSize stocksize = (size == wxDefaultSize) ? - wxArtClientToIconSize(client) : - FindClosestIconSize(size); - - // we must have some size, this is arbitrary - if (stocksize == GTK_ICON_SIZE_INVALID) - stocksize = GTK_ICON_SIZE_BUTTON; - - // allow passing GTK+ stock IDs to wxArtProvider: - if (!stockid) - stockid = id.ToAscii(); - - GdkPixbuf *pixbuf = CreateStockIcon(stockid, stocksize); - -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - if (!pixbuf) - pixbuf = CreateThemeIcon(stockid, stocksize, size); - } -#endif - - if (pixbuf && size != wxDefaultSize && - (size.x != gdk_pixbuf_get_width(pixbuf) || - size.y != gdk_pixbuf_get_height(pixbuf))) - { - GdkPixbuf *p2 = gdk_pixbuf_scale_simple(pixbuf, size.x, size.y, - GDK_INTERP_BILINEAR); - if (p2) - { - gdk_pixbuf_unref(pixbuf); - pixbuf = p2; - } - } - - if (!pixbuf) - return wxNullBitmap; - - wxBitmap bmp; - bmp.SetWidth(gdk_pixbuf_get_width(pixbuf)); - bmp.SetHeight(gdk_pixbuf_get_height(pixbuf)); - bmp.SetPixbuf(pixbuf); - - return bmp; -} - -// ---------------------------------------------------------------------------- -// Cleanup -// ---------------------------------------------------------------------------- - -class wxArtGtkModule: public wxModule -{ -public: - bool OnInit() { return true; } - void OnExit() - { - if (gs_gtkStyle) - { - g_object_unref(G_OBJECT(gs_gtkStyle)); - gs_gtkStyle = NULL; - } - } - - DECLARE_DYNAMIC_CLASS(wxArtGtkModule) -}; - -IMPLEMENT_DYNAMIC_CLASS(wxArtGtkModule, wxModule) - -#endif // defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) diff --git a/src/gtk1/bitmap.cpp b/src/gtk1/bitmap.cpp index 46ffd4b0ca..f8e9bd35ee 100644 --- a/src/gtk1/bitmap.cpp +++ b/src/gtk1/bitmap.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/bitmap.cpp +// Name: src/gtk1/bitmap.cpp // Purpose: // Author: Robert Roebling // RCS-ID: $Id$ @@ -20,33 +20,24 @@ #include "wx/dcmemory.h" #include "wx/app.h" -#ifdef __WXGTK20__ -#include "wx/rawbmp.h" - // need this to get gdk_image_new_bitmap() - #define GDK_ENABLE_BROKEN -#endif - #include #include #include -#ifdef __WXGTK20__ - #include -#else // GTK+ 1.2 - #include -#endif // GTK+ 2.0/1.2 +#include #include "wx/math.h" -extern void gdk_wx_draw_bitmap (GdkDrawable *drawable, - GdkGC *gc, - GdkDrawable *src, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height); +extern +void gdk_wx_draw_bitmap (GdkDrawable *drawable, + GdkGC *gc, + GdkDrawable *src, + gint xsrc, + gint ysrc, + gint xdest, + gint ydest, + gint width, + gint height); //----------------------------------------------------------------------------- // data @@ -240,9 +231,6 @@ public: GdkPixmap *m_pixmap; GdkBitmap *m_bitmap; -#ifdef __WXGTK20__ - GdkPixbuf *m_pixbuf; -#endif wxMask *m_mask; int m_width; int m_height; @@ -254,9 +242,6 @@ wxBitmapRefData::wxBitmapRefData() { m_pixmap = (GdkPixmap *) NULL; m_bitmap = (GdkBitmap *) NULL; -#ifdef __WXGTK20__ - m_pixbuf = (GdkPixbuf *) NULL; -#endif m_mask = (wxMask *) NULL; m_width = 0; m_height = 0; @@ -270,10 +255,6 @@ wxBitmapRefData::~wxBitmapRefData() gdk_pixmap_unref( m_pixmap ); if (m_bitmap) gdk_bitmap_unref( m_bitmap ); -#ifdef __WXGTK20__ - if (m_pixbuf) - gdk_pixbuf_unref( m_pixbuf ); -#endif delete m_mask; #if wxUSE_PALETTE delete m_palette; @@ -321,14 +302,6 @@ bool wxBitmap::Create( int width, int height, int depth ) M_BMPDATA->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ); M_BMPDATA->m_bpp = 1; } -#ifdef __WXGTK20__ - else if (depth == 32) - { - M_BMPDATA->m_pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, true, - 8, width, height); - M_BMPDATA->m_bpp = 32; - } -#endif else { M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth ); @@ -381,77 +354,124 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, wxBitmap bmp; -#ifdef __WXGTK20__ - if (HasPixbuf()) + GdkImage *img = (GdkImage*) NULL; + if (GetPixmap()) + img = gdk_image_get( GetPixmap(), 0, 0, GetWidth(), GetHeight() ); + else if (GetBitmap()) + img = gdk_image_get( GetBitmap(), 0, 0, GetWidth(), GetHeight() ); + else + wxFAIL_MSG( wxT("Ill-formed bitmap") ); + + wxCHECK_MSG( img, wxNullBitmap, wxT("couldn't create image") ); + + int bpp = -1; + + + GdkGC *gc = NULL; + GdkPixmap *dstpix = NULL; + if (GetPixmap()) { - bmp.SetWidth(width); - bmp.SetHeight(height); - bmp.SetDepth(GetDepth()); - bmp.SetPixbuf(gdk_pixbuf_new(GDK_COLORSPACE_RGB, - gdk_pixbuf_get_has_alpha(GetPixbuf()), - 8, width, height)); - gdk_pixbuf_scale(GetPixbuf(), bmp.GetPixbuf(), - 0, 0, width, height, - clipx, clipy, - (double)newx/GetWidth(), (double)newy/GetHeight(), - GDK_INTERP_BILINEAR); + GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); + if (visual == NULL) + visual = wxTheApp->GetGdkVisual(); + + bpp = visual->depth; + bmp = wxBitmap(width,height,bpp); + dstpix = bmp.GetPixmap(); + gc = gdk_gc_new( dstpix ); } - else -#endif // __WXGTK20__ + + char *dst = NULL; + long dstbyteperline = 0; + + if (GetBitmap()) { - GdkImage *img = (GdkImage*) NULL; - if (GetPixmap()) - img = gdk_image_get( GetPixmap(), 0, 0, GetWidth(), GetHeight() ); - else if (GetBitmap()) - img = gdk_image_get( GetBitmap(), 0, 0, GetWidth(), GetHeight() ); - else - wxFAIL_MSG( wxT("Ill-formed bitmap") ); + bpp = 1; + dstbyteperline = width/8*M_BMPDATA->m_bpp; + if (width*M_BMPDATA->m_bpp % 8 != 0) + dstbyteperline++; + dst = (char*) malloc(dstbyteperline*height); + } - wxCHECK_MSG( img, wxNullBitmap, wxT("couldn't create image") ); + // be careful to use the right scaling factor + float scx = (float)M_BMPDATA->m_width/(float)newx; + float scy = (float)M_BMPDATA->m_height/(float)newy; + // prepare accel-tables + int *tablex = (int *)calloc(width,sizeof(int)); + int *tabley = (int *)calloc(height,sizeof(int)); - int bpp = -1; + // accel table filled with clipped values + for (int x = 0; x < width; x++) + tablex[x] = (int) (scx * (x+clipx)); + for (int y = 0; y < height; y++) + tabley[y] = (int) (scy * (y+clipy)); + // Main rescaling routine starts here + for (int h = 0; h < height; h++) + { + char outbyte = 0; + int old_x = -1; + guint32 old_pixval = 0; - GdkGC *gc = NULL; - GdkPixmap *dstpix = NULL; - if (GetPixmap()) + for (int w = 0; w < width; w++) { - GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); - if (visual == NULL) - visual = wxTheApp->GetGdkVisual(); - - bpp = visual->depth; - bmp = wxBitmap(width,height,bpp); - dstpix = bmp.GetPixmap(); - gc = gdk_gc_new( dstpix ); - } + guint32 pixval; + int x = tablex[w]; + if (x == old_x) + pixval = old_pixval; + else + { + pixval = gdk_image_get_pixel( img, x, tabley[h] ); + old_pixval = pixval; + old_x = x; + } - char *dst = NULL; - long dstbyteperline = 0; + if (bpp == 1) + { + if (!pixval) + { + char bit=1; + char shift = bit << (w % 8); + outbyte |= shift; + } - if (GetBitmap()) - { - bpp = 1; - dstbyteperline = width/8*M_BMPDATA->m_bpp; - if (width*M_BMPDATA->m_bpp % 8 != 0) - dstbyteperline++; - dst = (char*) malloc(dstbyteperline*height); + if ((w+1)%8==0) + { + dst[h*dstbyteperline+w/8] = outbyte; + outbyte = 0; + } + } + else + { + GdkColor col; + col.pixel = pixval; + gdk_gc_set_foreground( gc, &col ); + gdk_draw_point( dstpix, gc, w, h); + } } - // be careful to use the right scaling factor - float scx = (float)M_BMPDATA->m_width/(float)newx; - float scy = (float)M_BMPDATA->m_height/(float)newy; - // prepare accel-tables - int *tablex = (int *)calloc(width,sizeof(int)); - int *tabley = (int *)calloc(height,sizeof(int)); + // do not forget the last byte + if ((bpp == 1) && (width % 8 != 0)) + dst[h*dstbyteperline+width/8] = outbyte; + } - // accel table filled with clipped values - for (int x = 0; x < width; x++) - tablex[x] = (int) (scx * (x+clipx)); - for (int y = 0; y < height; y++) - tabley[y] = (int) (scy * (y+clipy)); + gdk_image_destroy( img ); + if (gc) gdk_gc_unref( gc ); + + if (bpp == 1) + { + bmp = wxBitmap( (const char *)dst, width, height, 1 ); + free( dst ); + } + + if (GetMask()) + { + dstbyteperline = width/8; + if (width % 8 != 0) + dstbyteperline++; + dst = (char*) malloc(dstbyteperline*height); + img = gdk_image_get( GetMask()->GetBitmap(), 0, 0, GetWidth(), GetHeight() ); - // Main rescaling routine starts here for (int h = 0; h < height; h++) { char outbyte = 0; @@ -471,101 +491,35 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, old_x = x; } - if (bpp == 1) + if (pixval) { - if (!pixval) - { - char bit=1; - char shift = bit << (w % 8); - outbyte |= shift; - } - - if ((w+1)%8==0) - { - dst[h*dstbyteperline+w/8] = outbyte; - outbyte = 0; - } + char bit=1; + char shift = bit << (w % 8); + outbyte |= shift; } - else + + if ((w+1)%8 == 0) { - GdkColor col; - col.pixel = pixval; - gdk_gc_set_foreground( gc, &col ); - gdk_draw_point( dstpix, gc, w, h); + dst[h*dstbyteperline+w/8] = outbyte; + outbyte = 0; } } // do not forget the last byte - if ((bpp == 1) && (width % 8 != 0)) + if (width % 8 != 0) dst[h*dstbyteperline+width/8] = outbyte; } + wxMask* mask = new wxMask; + mask->m_bitmap = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) dst, width, height ); + bmp.SetMask(mask); + free( dst ); gdk_image_destroy( img ); - if (gc) gdk_gc_unref( gc ); - - if (bpp == 1) - { - bmp = wxBitmap( (const char *)dst, width, height, 1 ); - free( dst ); - } - - if (GetMask()) - { - dstbyteperline = width/8; - if (width % 8 != 0) - dstbyteperline++; - dst = (char*) malloc(dstbyteperline*height); - img = gdk_image_get( GetMask()->GetBitmap(), 0, 0, GetWidth(), GetHeight() ); - - for (int h = 0; h < height; h++) - { - char outbyte = 0; - int old_x = -1; - guint32 old_pixval = 0; - - for (int w = 0; w < width; w++) - { - guint32 pixval; - int x = tablex[w]; - if (x == old_x) - pixval = old_pixval; - else - { - pixval = gdk_image_get_pixel( img, x, tabley[h] ); - old_pixval = pixval; - old_x = x; - } - - if (pixval) - { - char bit=1; - char shift = bit << (w % 8); - outbyte |= shift; - } - - if ((w+1)%8 == 0) - { - dst[h*dstbyteperline+w/8] = outbyte; - outbyte = 0; - } - } - - // do not forget the last byte - if (width % 8 != 0) - dst[h*dstbyteperline+width/8] = outbyte; - } - wxMask* mask = new wxMask; - mask->m_bitmap = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) dst, width, height ); - bmp.SetMask(mask); - - free( dst ); - gdk_image_destroy( img ); - } - - free( tablex ); - free( tabley ); } + free( tablex ); + free( tabley ); + return bmp; } @@ -587,10 +541,6 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth) } else { -#ifdef __WXGTK20__ - if (image.HasAlpha()) - return CreateFromImageAsPixbuf(image); -#endif return CreateFromImageAsPixmap(image); } } @@ -935,51 +885,6 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img) return true; } -#ifdef __WXGTK20__ -bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image) -{ - int width = image.GetWidth(); - int height = image.GetHeight(); - - GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, - image.HasAlpha(), - 8 /* bits per sample */, - width, height); - if (!pixbuf) - return false; - - wxASSERT( image.HasAlpha() ); // for now - wxASSERT( gdk_pixbuf_get_n_channels(pixbuf) == 4 ); - wxASSERT( gdk_pixbuf_get_width(pixbuf) == width ); - wxASSERT( gdk_pixbuf_get_height(pixbuf) == height ); - - M_BMPDATA->m_pixbuf = pixbuf; - SetHeight(height); - SetWidth(width); - SetDepth(wxTheApp->GetGdkVisual()->depth); - - // Copy the data: - unsigned char *in = image.GetData(); - unsigned char *out = gdk_pixbuf_get_pixels(pixbuf); - unsigned char *alpha = image.GetAlpha(); - - int rowinc = gdk_pixbuf_get_rowstride(pixbuf) - 4 * width; - - for (int y = 0; y < height; y++, out += rowinc) - { - for (int x = 0; x < width; x++, alpha++, out += 4, in += 3) - { - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - out[3] = *alpha; - } - } - - return true; -} -#endif // __WXGTK20__ - wxImage wxBitmap::ConvertToImage() const { wxImage image; @@ -995,172 +900,141 @@ wxImage wxBitmap::ConvertToImage() const return wxNullImage; } -#ifdef __WXGTK20__ - if (HasPixbuf()) - { - GdkPixbuf *pixbuf = GetPixbuf(); - wxASSERT( gdk_pixbuf_get_has_alpha(pixbuf) ); - - int w = GetWidth(); - int h = GetHeight(); - - image.SetAlpha(); + // the colour used as transparent one in wxImage and the one it is + // replaced with when it really occurs in the bitmap + static const int MASK_RED = 1; + static const int MASK_GREEN = 2; + static const int MASK_BLUE = 3; + static const int MASK_BLUE_REPLACEMENT = 2; - unsigned char *alpha = image.GetAlpha(); - unsigned char *in = gdk_pixbuf_get_pixels(pixbuf); - unsigned char *out = data; - int rowinc = gdk_pixbuf_get_rowstride(pixbuf) - 4 * w; + GdkImage *gdk_image = (GdkImage*) NULL; - for (int y = 0; y < h; y++, in += rowinc) - { - for (int x = 0; x < w; x++, in += 4, out += 3, alpha++) - { - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - *alpha = in[3]; - } - } + if (HasPixmap()) + { + gdk_image = gdk_image_get( GetPixmap(), + 0, 0, + GetWidth(), GetHeight() ); + } + else if (GetBitmap()) + { + gdk_image = gdk_image_get( GetBitmap(), + 0, 0, + GetWidth(), GetHeight() ); } else -#endif // __WXGTK20__ { - // the colour used as transparent one in wxImage and the one it is - // replaced with when it really occurs in the bitmap - static const int MASK_RED = 1; - static const int MASK_GREEN = 2; - static const int MASK_BLUE = 3; - static const int MASK_BLUE_REPLACEMENT = 2; - - GdkImage *gdk_image = (GdkImage*) NULL; - - if (HasPixmap()) - { - gdk_image = gdk_image_get( GetPixmap(), - 0, 0, - GetWidth(), GetHeight() ); - } - else if (GetBitmap()) - { - gdk_image = gdk_image_get( GetBitmap(), - 0, 0, - GetWidth(), GetHeight() ); - } - else - { - wxFAIL_MSG( wxT("Ill-formed bitmap") ); - } + wxFAIL_MSG( wxT("Ill-formed bitmap") ); + } - wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") ); + wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") ); - GdkImage *gdk_image_mask = (GdkImage*) NULL; - if (GetMask()) - { - gdk_image_mask = gdk_image_get( GetMask()->GetBitmap(), - 0, 0, - GetWidth(), GetHeight() ); + GdkImage *gdk_image_mask = (GdkImage*) NULL; + if (GetMask()) + { + gdk_image_mask = gdk_image_get( GetMask()->GetBitmap(), + 0, 0, + GetWidth(), GetHeight() ); - image.SetMaskColour( MASK_RED, MASK_GREEN, MASK_BLUE ); - } + image.SetMaskColour( MASK_RED, MASK_GREEN, MASK_BLUE ); + } - int bpp = -1; - int red_shift_right = 0; - int green_shift_right = 0; - int blue_shift_right = 0; - int red_shift_left = 0; - int green_shift_left = 0; - int blue_shift_left = 0; - bool use_shift = false; + int bpp = -1; + int red_shift_right = 0; + int green_shift_right = 0; + int blue_shift_right = 0; + int red_shift_left = 0; + int green_shift_left = 0; + int blue_shift_left = 0; + bool use_shift = false; - if (GetPixmap()) - { - GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); - if (visual == NULL) - visual = wxTheApp->GetGdkVisual(); - - bpp = visual->depth; - if (bpp == 16) - bpp = visual->red_prec + visual->green_prec + visual->blue_prec; - red_shift_right = visual->red_shift; - red_shift_left = 8-visual->red_prec; - green_shift_right = visual->green_shift; - green_shift_left = 8-visual->green_prec; - blue_shift_right = visual->blue_shift; - blue_shift_left = 8-visual->blue_prec; - - use_shift = (visual->type == GDK_VISUAL_TRUE_COLOR) || (visual->type == GDK_VISUAL_DIRECT_COLOR); - } - if (GetBitmap()) - { - bpp = 1; - } + if (GetPixmap()) + { + GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); + if (visual == NULL) + visual = wxTheApp->GetGdkVisual(); + + bpp = visual->depth; + if (bpp == 16) + bpp = visual->red_prec + visual->green_prec + visual->blue_prec; + red_shift_right = visual->red_shift; + red_shift_left = 8-visual->red_prec; + green_shift_right = visual->green_shift; + green_shift_left = 8-visual->green_prec; + blue_shift_right = visual->blue_shift; + blue_shift_left = 8-visual->blue_prec; + + use_shift = (visual->type == GDK_VISUAL_TRUE_COLOR) || (visual->type == GDK_VISUAL_DIRECT_COLOR); + } + if (GetBitmap()) + { + bpp = 1; + } - GdkColormap *cmap = gtk_widget_get_default_colormap(); + GdkColormap *cmap = gtk_widget_get_default_colormap(); - long pos = 0; - for (int j = 0; j < GetHeight(); j++) + long pos = 0; + for (int j = 0; j < GetHeight(); j++) + { + for (int i = 0; i < GetWidth(); i++) { - for (int i = 0; i < GetWidth(); i++) + wxUint32 pixel = gdk_image_get_pixel( gdk_image, i, j ); + if (bpp == 1) { - wxUint32 pixel = gdk_image_get_pixel( gdk_image, i, j ); - if (bpp == 1) - { - if (pixel == 0) - { - data[pos] = 0; - data[pos+1] = 0; - data[pos+2] = 0; - } - else - { - data[pos] = 255; - data[pos+1] = 255; - data[pos+2] = 255; - } - } - else if (use_shift) + if (pixel == 0) { - data[pos] = (pixel >> red_shift_right) << red_shift_left; - data[pos+1] = (pixel >> green_shift_right) << green_shift_left; - data[pos+2] = (pixel >> blue_shift_right) << blue_shift_left; - } - else if (cmap->colors) - { - data[pos] = cmap->colors[pixel].red >> 8; - data[pos+1] = cmap->colors[pixel].green >> 8; - data[pos+2] = cmap->colors[pixel].blue >> 8; + data[pos] = 0; + data[pos+1] = 0; + data[pos+2] = 0; } else { - wxFAIL_MSG( wxT("Image conversion failed. Unknown visual type.") ); + data[pos] = 255; + data[pos+1] = 255; + data[pos+2] = 255; } + } + else if (use_shift) + { + data[pos] = (pixel >> red_shift_right) << red_shift_left; + data[pos+1] = (pixel >> green_shift_right) << green_shift_left; + data[pos+2] = (pixel >> blue_shift_right) << blue_shift_left; + } + else if (cmap->colors) + { + data[pos] = cmap->colors[pixel].red >> 8; + data[pos+1] = cmap->colors[pixel].green >> 8; + data[pos+2] = cmap->colors[pixel].blue >> 8; + } + else + { + wxFAIL_MSG( wxT("Image conversion failed. Unknown visual type.") ); + } - if (gdk_image_mask) + if (gdk_image_mask) + { + int mask_pixel = gdk_image_get_pixel( gdk_image_mask, i, j ); + if (mask_pixel == 0) { - int mask_pixel = gdk_image_get_pixel( gdk_image_mask, i, j ); - if (mask_pixel == 0) - { - data[pos] = MASK_RED; - data[pos+1] = MASK_GREEN; - data[pos+2] = MASK_BLUE; - } - else if ( data[pos] == MASK_RED && - data[pos+1] == MASK_GREEN && - data[pos+2] == MASK_BLUE ) - { - data[pos+2] = MASK_BLUE_REPLACEMENT; - } + data[pos] = MASK_RED; + data[pos+1] = MASK_GREEN; + data[pos+2] = MASK_BLUE; + } + else if ( data[pos] == MASK_RED && + data[pos+1] == MASK_GREEN && + data[pos+2] == MASK_BLUE ) + { + data[pos+2] = MASK_BLUE_REPLACEMENT; } - - pos += 3; } - } - gdk_image_destroy( gdk_image ); - if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); + pos += 3; + } } + gdk_image_destroy( gdk_image ); + if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); + return image; } @@ -1222,12 +1096,7 @@ bool wxBitmap::operator != ( const wxBitmap& bmp ) const bool wxBitmap::Ok() const { return (m_refData != NULL) && - ( -#ifdef __WXGTK20__ - M_BMPDATA->m_pixbuf || -#endif - M_BMPDATA->m_bitmap || M_BMPDATA->m_pixmap - ); + (M_BMPDATA->m_bitmap || M_BMPDATA->m_pixmap); } int wxBitmap::GetHeight() const @@ -1283,37 +1152,22 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const wxBitmap ret( rect.width, rect.height, M_BMPDATA->m_bpp ); wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") ); -#ifdef __WXGTK20__ - if (HasPixbuf()) + if (ret.GetPixmap()) { - GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, - gdk_pixbuf_get_has_alpha(GetPixbuf()), - 8, rect.width, rect.height); - ret.SetPixbuf(pixbuf); - gdk_pixbuf_copy_area(GetPixbuf(), - rect.x, rect.y, rect.width, rect.height, - pixbuf, 0, 0); + GdkGC *gc = gdk_gc_new( ret.GetPixmap() ); + gdk_draw_pixmap( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); + gdk_gc_destroy( gc ); } else -#endif // __WXGTK20__ { - if (ret.GetPixmap()) - { - GdkGC *gc = gdk_gc_new( ret.GetPixmap() ); - gdk_draw_pixmap( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); - gdk_gc_destroy( gc ); - } - else - { - GdkGC *gc = gdk_gc_new( ret.GetBitmap() ); - GdkColor col; - col.pixel = 0xFFFFFF; - gdk_gc_set_foreground( gc, &col ); - col.pixel = 0; - gdk_gc_set_background( gc, &col ); - gdk_wx_draw_bitmap( ret.GetBitmap(), gc, GetBitmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); - gdk_gc_destroy( gc ); - } + GdkGC *gc = gdk_gc_new( ret.GetBitmap() ); + GdkColor col; + col.pixel = 0xFFFFFF; + gdk_gc_set_foreground( gc, &col ); + col.pixel = 0; + gdk_gc_set_background( gc, &col ); + gdk_wx_draw_bitmap( ret.GetBitmap(), gc, GetBitmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); + gdk_gc_destroy( gc ); } if (GetMask()) @@ -1439,9 +1293,6 @@ void wxBitmap::SetPixmap( GdkPixmap *pixmap ) m_refData = new wxBitmapRefData(); M_BMPDATA->m_pixmap = pixmap; -#ifdef __WXGTK20__ - PurgeOtherRepresentations(Pixmap); -#endif } void wxBitmap::SetBitmap( GdkPixmap *bitmap ) @@ -1450,28 +1301,12 @@ void wxBitmap::SetBitmap( GdkPixmap *bitmap ) m_refData = new wxBitmapRefData(); M_BMPDATA->m_bitmap = bitmap; -#ifdef __WXGTK20__ - PurgeOtherRepresentations(Pixmap); -#endif } GdkPixmap *wxBitmap::GetPixmap() const { wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, wxT("invalid bitmap") ); -#ifdef __WXGTK20__ - // create the pixmap on the fly if we use Pixbuf representation: - if (HasPixbuf() && !HasPixmap()) - { - delete M_BMPDATA->m_mask; - M_BMPDATA->m_mask = new wxMask(); - gdk_pixbuf_render_pixmap_and_mask(M_BMPDATA->m_pixbuf, - &M_BMPDATA->m_pixmap, - &M_BMPDATA->m_mask->m_bitmap, - 128 /*threshold*/); - } -#endif // __WXGTK20__ - return M_BMPDATA->m_pixmap; } @@ -1489,113 +1324,9 @@ GdkBitmap *wxBitmap::GetBitmap() const return M_BMPDATA->m_bitmap; } -#ifdef __WXGTK20__ -GdkPixbuf *wxBitmap::GetPixbuf() const -{ - wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") ); - - if (HasPixmap() && !HasPixbuf()) - { - int width = GetWidth(); - int height = GetHeight(); - - GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, - GetMask() != NULL, - 8, width, height); - M_BMPDATA->m_pixbuf = - gdk_pixbuf_get_from_drawable(pixbuf, M_BMPDATA->m_pixmap, NULL, - 0, 0, 0, 0, width, height); - - // apply the mask to created pixbuf: - if (M_BMPDATA->m_pixbuf && M_BMPDATA->m_mask) - { - GdkPixbuf *pmask = - gdk_pixbuf_get_from_drawable(NULL, - M_BMPDATA->m_mask->GetBitmap(), - NULL, - 0, 0, 0, 0, width, height); - if (pmask) - { - guchar *bmp = gdk_pixbuf_get_pixels(pixbuf); - guchar *mask = gdk_pixbuf_get_pixels(pmask); - int bmprowinc = gdk_pixbuf_get_rowstride(pixbuf) - 4 * width; - int maskrowinc = gdk_pixbuf_get_rowstride(pmask) - 3 * width; - - for (int y = 0; y < height; - y++, bmp += bmprowinc, mask += maskrowinc) - { - for (int x = 0; x < width; x++, bmp += 4, mask += 3) - { - if (mask[0] == 0 /*black pixel*/) - bmp[3] = 0; - } - } - - gdk_pixbuf_unref(pmask); - } - } - } - - return M_BMPDATA->m_pixbuf; -} - -bool wxBitmap::HasPixbuf() const -{ - wxCHECK_MSG( Ok(), false, wxT("invalid bitmap") ); - - return M_BMPDATA->m_pixbuf != NULL; -} - -void wxBitmap::SetPixbuf( GdkPixbuf *pixbuf ) -{ - if (!m_refData) - m_refData = new wxBitmapRefData(); - - M_BMPDATA->m_pixbuf = pixbuf; - PurgeOtherRepresentations(Pixbuf); -} - -void wxBitmap::PurgeOtherRepresentations(wxBitmap::Representation keep) -{ - if (keep == Pixmap && HasPixbuf()) - { - gdk_pixbuf_unref( M_BMPDATA->m_pixbuf ); - M_BMPDATA->m_pixbuf = NULL; - } - if (keep == Pixbuf && HasPixmap()) - { - gdk_pixmap_unref( M_BMPDATA->m_pixmap ); - M_BMPDATA->m_pixmap = NULL; - } -} - -#endif // __WXGTK20__ - void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) { -#ifdef __WXGTK20__ - if (bpp != 32) - return NULL; - - GdkPixbuf *pixbuf = GetPixbuf(); - if (!pixbuf) - return NULL; - -#if 0 - if (gdk_pixbuf_get_has_alpha( pixbuf )) - wxPrintf( wxT("Has alpha\n") ); - else - wxPrintf( wxT("No alpha.\n") ); -#endif - - data.m_height = gdk_pixbuf_get_height( pixbuf ); - data.m_width = gdk_pixbuf_get_width( pixbuf ); - data.m_stride = gdk_pixbuf_get_rowstride( pixbuf ); - - return gdk_pixbuf_get_pixels( pixbuf ); -#else return NULL; -#endif } void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data)) @@ -1605,18 +1336,11 @@ void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data)) bool wxBitmap::HasAlpha() const { -#ifdef __WXGTK20__ - return HasPixbuf(); -#else return false; -#endif } void wxBitmap::UseAlpha() { -#ifdef __WXGTK20__ - GetPixbuf(); -#endif } //----------------------------------------------------------------------------- diff --git a/src/gtk1/bmpbuttn.cpp b/src/gtk1/bmpbuttn.cpp index 8ab5eaa6cd..1a0d71c032 100644 --- a/src/gtk1/bmpbuttn.cpp +++ b/src/gtk1/bmpbuttn.cpp @@ -16,7 +16,7 @@ #include "wx/bmpbuttn.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" //----------------------------------------------------------------------------- // classes @@ -224,29 +224,14 @@ void wxBitmapButton::OnSetBitmap() { // initial bitmap GtkWidget *pixmap; -#ifdef __WXGTK20__ - if (the_one.HasPixbuf()) - pixmap = gtk_image_new_from_pixbuf(the_one.GetPixbuf()); - else - pixmap = gtk_image_new_from_pixmap(the_one.GetPixmap(), mask); -#else pixmap = gtk_pixmap_new(the_one.GetPixmap(), mask); -#endif gtk_widget_show(pixmap); gtk_container_add(GTK_CONTAINER(m_widget), pixmap); } else { // subsequent bitmaps -#ifdef __WXGTK20__ - GtkImage *pixmap = GTK_IMAGE(child); - if (the_one.HasPixbuf()) - gtk_image_set_from_pixbuf(pixmap, the_one.GetPixbuf()); - else - gtk_image_set_from_pixmap(pixmap, the_one.GetPixmap(), mask); -#else GtkPixmap *pixmap = GTK_PIXMAP(child); gtk_pixmap_set(pixmap, the_one.GetPixmap(), mask); -#endif } } diff --git a/src/gtk1/brush.cpp b/src/gtk1/brush.cpp index 3d4549539f..d07c3ed0f7 100644 --- a/src/gtk1/brush.cpp +++ b/src/gtk1/brush.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/brush.cpp +// Name: src/gtk1/brush.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index ca57fcc514..860efb5a35 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -17,8 +17,8 @@ #include "wx/button.h" #include "wx/stockitem.h" -#include "wx/gtk/private.h" -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/private.h" +#include "wx/gtk1/win_gtk.h" //----------------------------------------------------------------------------- // classes @@ -76,23 +76,10 @@ gtk_button_style_set_callback( GtkWidget *m_widget, GtkStyle *WXUNUSED(style), w /* the default button has a border around it */ if (GTK_WIDGET_CAN_DEFAULT(m_widget)) { -#ifdef __WXGTK20__ - GtkBorder *default_border = NULL; - gtk_widget_style_get( m_widget, "default_border", &default_border, NULL ); - if (default_border) - { - left_border += default_border->left; - right_border += default_border->right; - top_border += default_border->top; - bottom_border += default_border->bottom; - g_free( default_border ); - } -#else left_border = 6; right_border = 6; top_border = 6; bottom_border = 5; -#endif win->DoMoveWindow( win->m_x-top_border, win->m_y-left_border, win->m_width+left_border+right_border, @@ -130,11 +117,7 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, return FALSE; } -#ifdef __WXGTK20__ - m_widget = gtk_button_new_with_mnemonic(""); -#else m_widget = gtk_button_new_with_label(""); -#endif float x_alignment = 0.5; if (HasFlag(wxBU_LEFT)) @@ -148,18 +131,9 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, else if (HasFlag(wxBU_BOTTOM)) y_alignment = 1.0; -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, y_alignment); - } - else -#endif - { - if (GTK_IS_MISC(BUTTON_CHILD(m_widget))) - gtk_misc_set_alignment (GTK_MISC (BUTTON_CHILD (m_widget)), + if (GTK_IS_MISC(BUTTON_CHILD(m_widget))) + gtk_misc_set_alignment (GTK_MISC (BUTTON_CHILD (m_widget)), x_alignment, y_alignment); - } SetLabel(label); @@ -197,40 +171,7 @@ void wxButton::SetDefault() /* static */ wxSize wxButtonBase::GetDefaultSize() { -#ifdef __WXGTK20__ - static wxSize size = wxDefaultSize; - if (size == wxDefaultSize) - { - // NB: Default size of buttons should be same as size of stock - // buttons as used in most GTK+ apps. Unfortunately it's a little - // tricky to obtain this size: stock button's size may be smaller - // than size of button in GtkButtonBox and vice versa, - // GtkButtonBox's minimal button size may be smaller than stock - // button's size. We have to retrieve both values and combine them. - - GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); - GtkWidget *box = gtk_hbutton_box_new(); - GtkWidget *btn = gtk_button_new_from_stock(GTK_STOCK_CANCEL); - gtk_container_add(GTK_CONTAINER(box), btn); - gtk_container_add(GTK_CONTAINER(wnd), box); - GtkRequisition req; - gtk_widget_size_request(btn, &req); - - gint minwidth, minheight; - gtk_widget_style_get(box, - "child-min-width", &minwidth, - "child-min-height", &minheight, - NULL); - - size.x = wxMax(minwidth, req.width); - size.y = wxMax(minheight, req.height); - - gtk_widget_destroy(wnd); - } - return size; -#else return wxSize(80,26); -#endif } void wxButton::SetLabel( const wxString &lbl ) @@ -246,25 +187,7 @@ void wxButton::SetLabel( const wxString &lbl ) const wxString labelGTK = GTKConvertMnemonics(label); -#ifdef __WXGTK20__ - if (wxIsStockID(m_windowId) && wxIsStockLabel(m_windowId, label)) - { - const char *stock = wxGetStockGtkID(m_windowId); - if (stock) - { - gtk_button_set_label(GTK_BUTTON(m_widget), stock); - gtk_button_set_use_stock(GTK_BUTTON(m_widget), TRUE); - return; - } - } - - gtk_button_set_label(GTK_BUTTON(m_widget), wxGTK_CONV(labelGTK)); - gtk_button_set_use_stock(GTK_BUTTON(m_widget), FALSE); - - ApplyWidgetStyle( false ); -#else // GTK+ 1 gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), wxGTK_CONV(labelGTK)); -#endif // GTK+ 2/1 } bool wxButton::Enable( bool enable ) @@ -279,11 +202,7 @@ bool wxButton::Enable( bool enable ) bool wxButton::IsOwnGtkWindow( GdkWindow *window ) { -#ifdef __WXGTK20__ - return GTK_BUTTON(m_widget)->event_window; -#else return (window == m_widget->window); -#endif } void wxButton::DoApplyWidgetStyle(GtkRcStyle *style) @@ -313,9 +232,7 @@ wxSize wxButton::DoGetBestSize() const GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); } -#ifndef __WXGTK20__ ret.x += 10; // add a few pixels for sloppy (but common) themes -#endif if (!HasFlag(wxBU_EXACTFIT)) { diff --git a/src/gtk1/checkbox.cpp b/src/gtk1/checkbox.cpp index 4e6cc8f252..c9d1c422d3 100644 --- a/src/gtk1/checkbox.cpp +++ b/src/gtk1/checkbox.cpp @@ -16,7 +16,7 @@ #include "wx/checkbox.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" //----------------------------------------------------------------------------- // idle system @@ -48,60 +48,8 @@ static void gtk_checkbox_toggled_callback(GtkWidget *widget, wxCheckBox *cb) if (cb->m_blockEvent) return; -#ifdef __WXGTK20__ - // Transitions for 3state checkbox must be done manually, GTK's checkbox - // is 2state with additional "undetermined state" flag which isn't - // changed automatically: - if (cb->Is3State()) - { - GtkToggleButton *toggle = GTK_TOGGLE_BUTTON(widget); - - if (cb->Is3rdStateAllowedForUser()) - { - // The 3 states cycle like this when clicked: - // checked -> undetermined -> unchecked -> checked -> ... - bool active = gtk_toggle_button_get_active(toggle); - bool inconsistent = gtk_toggle_button_get_inconsistent(toggle); - - cb->m_blockEvent = true; - - if (!active && !inconsistent) - { - // checked -> undetermined - gtk_toggle_button_set_active(toggle, true); - gtk_toggle_button_set_inconsistent(toggle, true); - } - else if (!active && inconsistent) - { - // undetermined -> unchecked - gtk_toggle_button_set_inconsistent(toggle, false); - } - else if (active && !inconsistent) - { - // unchecked -> checked - // nothing to do - } - else - { - wxFAIL_MSG(_T("3state wxCheckBox in unexpected state!")); - } - - cb->m_blockEvent = false; - } - else - { - // user's action unsets undetermined state: - gtk_toggle_button_set_inconsistent(toggle, false); - } - } -#endif - wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId()); -#ifdef __WXGTK20__ - event.SetInt(cb->Get3StateValue()); -#else event.SetInt(cb->GetValue()); -#endif event.SetEventObject(cb); cb->GetEventHandler()->ProcessEvent(event); } @@ -197,34 +145,9 @@ bool wxCheckBox::GetValue() const { wxCHECK_MSG( m_widgetCheckbox != NULL, FALSE, wxT("invalid checkbox") ); -#ifdef __WXGTK20__ - return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_widgetCheckbox)); -#else return GTK_TOGGLE_BUTTON(m_widgetCheckbox)->active; -#endif } -#ifdef __WXGTK20__ -void wxCheckBox::DoSet3StateValue(wxCheckBoxState state) -{ - SetValue(state != wxCHK_UNCHECKED); - gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(m_widgetCheckbox), - state == wxCHK_UNDETERMINED); -} - -wxCheckBoxState wxCheckBox::DoGet3StateValue() const -{ - if (gtk_toggle_button_get_inconsistent(GTK_TOGGLE_BUTTON(m_widgetCheckbox))) - { - return wxCHK_UNDETERMINED; - } - else - { - return GetValue() ? wxCHK_CHECKED : wxCHK_UNCHECKED; - } -} -#endif - void wxCheckBox::SetLabel( const wxString& label ) { wxCHECK_RET( m_widgetLabel != NULL, wxT("invalid checkbox") ); diff --git a/src/gtk1/checklst.cpp b/src/gtk1/checklst.cpp index ba70c07e7f..0b1d1fdef0 100644 --- a/src/gtk1/checklst.cpp +++ b/src/gtk1/checklst.cpp @@ -15,7 +15,7 @@ #if wxUSE_CHECKLISTBOX #include "wx/checklst.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include #include diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index f5a9bd5034..8b61e05950 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/choice.cpp +// Name: src/gtk1/choice.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -14,7 +14,7 @@ #include "wx/choice.h" #include "wx/arrstr.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" //----------------------------------------------------------------------------- // idle system @@ -45,9 +45,6 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice * int selection = wxNOT_FOUND; -#ifdef __WXGTK20__ - selection = gtk_option_menu_get_history( GTK_OPTION_MENU(choice->GetHandle()) ); -#else GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(choice->GetHandle()) ) ); int count = 0; @@ -63,7 +60,7 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice * child = child->next; count++; } -#endif + choice->m_selection_hack = selection; wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() ); @@ -355,12 +352,9 @@ int wxChoice::FindString( const wxString &string, bool bCase ) const wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") ); -#ifdef __WXGTK20__ - wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text( label) ) ); -#else wxString tmp( label->label ); -#endif - if (string.IsSameAs( tmp, bCase )) + + if (string.IsSameAs( tmp, bCase )) return count; child = child->next; @@ -427,11 +421,7 @@ wxString wxChoice::GetString( int n ) const wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") ); -#ifdef __WXGTK20__ - return wxString( wxGTK_CONV_BACK( gtk_label_get_text( label) ) ); -#else return wxString( label->label ); -#endif } child = child->next; count++; @@ -622,11 +612,7 @@ wxSize wxChoice::DoGetBestSize() const bool wxChoice::IsOwnGtkWindow( GdkWindow *window ) { -#ifdef __WXGTK20__ - return GTK_BUTTON(m_widget)->event_window; -#else return (window == m_widget->window); -#endif } // static diff --git a/src/gtk1/clipbrd.cpp b/src/gtk1/clipbrd.cpp index 712b6ed9e8..8adca083d2 100644 --- a/src/gtk1/clipbrd.cpp +++ b/src/gtk1/clipbrd.cpp @@ -36,10 +36,6 @@ GdkAtom g_clipboardAtom = 0; GdkAtom g_targetsAtom = 0; -#if defined(__WXGTK20__) && wxUSE_UNICODE -extern GdkAtom g_altTextAtom; -#endif - // the trace mask we use with wxLogTrace() - call // wxLog::AddTraceMask(TRACE_CLIPBOARD) to enable the trace messages from here // (there will be a *lot* of them!) @@ -274,27 +270,12 @@ selection_handler( GtkWidget *WXUNUSED(widget), // Text data will be in UTF8 in Unicode mode. data->GetDataHere( selection_data->target, d ); -#ifdef __WXGTK20__ - // NB: GTK+ requires special treatment of UTF8_STRING data, the text - // would show as UTF-8 data interpreted as latin1 (?) in other - // GTK+ apps if we used gtk_selection_data_set() - if (format == wxDataFormat(wxDF_UNICODETEXT)) - { - gtk_selection_data_set_text( - selection_data, - (const gchar*)d, - size-1 ); - } - else -#endif - { - gtk_selection_data_set( + gtk_selection_data_set( selection_data, GDK_SELECTION_TYPE_STRING, - 8*sizeof(gchar), + 8 * sizeof(gchar), (unsigned char*) d, size-1 ); - } free(d); } @@ -533,15 +514,6 @@ bool wxClipboard::IsSupported( const wxDataFormat& format ) while (m_waiting) gtk_main_iteration(); -#if defined(__WXGTK20__) && wxUSE_UNICODE - if (!m_formatSupported && format == wxDataFormat(wxDF_UNICODETEXT)) - { - // Another try with plain STRING format - extern GdkAtom g_altTextAtom; - return IsSupported(g_altTextAtom); - } -#endif - return m_formatSupported; } diff --git a/src/gtk1/colordlg.cpp b/src/gtk1/colordlg.cpp index 8571dab73e..05aa15ef6a 100644 --- a/src/gtk1/colordlg.cpp +++ b/src/gtk1/colordlg.cpp @@ -15,133 +15,3 @@ #ifdef __BORLANDC__ #pragma hdrstop #endif - -#if wxUSE_COLOURDLG && defined(__WXGTK20__) - -#include "wx/colordlg.h" - -#ifndef WX_PRECOMP - #include "wx/intl.h" -#endif - -#include "wx/gtk/private.h" - -IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog) - -wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data) -{ - Create(parent, data); -} - -bool wxColourDialog::Create(wxWindow *parent, wxColourData *data) -{ - if (data) - m_data = *data; - - wxString title(_("Choose colour")); - m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title)); - - if (parent) - { - GtkWindow* gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) ); - gtk_window_set_transient_for(GTK_WINDOW(m_widget), - gtk_parent); - } - - GtkColorSelection *sel = - GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel); - gtk_color_selection_set_has_palette(sel, true); - - return true; -} - -int wxColourDialog::ShowModal() -{ - ColourDataToDialog(); - - gint result = gtk_dialog_run(GTK_DIALOG(m_widget)); - gtk_widget_hide(m_widget); - - switch (result) - { - default: - wxFAIL_MSG(_T("unexpected GtkColorSelectionDialog return code")); - // fall through - - case GTK_RESPONSE_CANCEL: - case GTK_RESPONSE_DELETE_EVENT: - case GTK_RESPONSE_CLOSE: - return wxID_CANCEL; - - case GTK_RESPONSE_OK: - DialogToColourData(); - return wxID_OK; - } -} - -void wxColourDialog::ColourDataToDialog() -{ - GtkColorSelection *sel = - GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel); - - if (m_data.GetColour().Ok()) - { - gtk_color_selection_set_current_color(sel, - m_data.GetColour().GetColor()); - } - - // setup the palette: - - GdkColor colors[16]; - gint n_colors = 0; - for (unsigned i = 0; i < 16; i++) - { - wxColour c = m_data.GetCustomColour(i); - if (c.Ok()) - { - colors[n_colors] = *c.GetColor(); - n_colors++; - } - } - - gchar *pal = gtk_color_selection_palette_to_string(colors, n_colors); - - GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(sel)); - g_object_set(settings, "gtk-color-palette", pal, NULL); - - g_free(pal); -} - -void wxColourDialog::DialogToColourData() -{ - GtkColorSelection *sel = - GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel); - - GdkColor clr; - gtk_color_selection_get_current_color(sel, &clr); - m_data.SetColour(wxColour(clr.red >> 8, clr.green >> 8, clr.blue >> 8)); - - // Extract custom palette: - - GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(sel)); - gchar *pal; - g_object_get(settings, "gtk-color-palette", &pal, NULL); - - GdkColor *colors; - gint n_colors; - if (gtk_color_selection_palette_from_string(pal, &colors, &n_colors)) - { - for (int i = 0; i < wxMin(n_colors, 16); i++) - { - m_data.SetCustomColour(i, wxColour(colors[i].red >> 8, - colors[i].green >> 8, - colors[i].blue >> 8)); - } - g_free(colors); - } - - g_free(pal); -} - -#endif // wxUSE_COLOURDLG && defined(__WXGTK20__) - diff --git a/src/gtk1/colour.cpp b/src/gtk1/colour.cpp index 2b63a69a0c..9da84b3052 100644 --- a/src/gtk1/colour.cpp +++ b/src/gtk1/colour.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/colour.cpp +// Name: src/gtk1/colour.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -12,7 +12,7 @@ #include "wx/colour.h" #include "wx/gdicmn.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include #include @@ -92,14 +92,9 @@ void wxColourRefData::FreeColour() { if (m_colormap) { -#ifdef __WXGTK20__ - if ((m_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || - (m_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) -#else GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) m_colormap; if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || (private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) -#endif { int idx = m_color.pixel; colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] - 1; @@ -117,14 +112,8 @@ void wxColourRefData::AllocColour( GdkColormap *cmap ) FreeColour(); -#ifdef __WXGTK20__ if ( (cmap->visual->type == GDK_VISUAL_GRAYSCALE) || (cmap->visual->type == GDK_VISUAL_PSEUDO_COLOR) ) -#else - GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) cmap; - if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || - (private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) -#endif { m_hasPixel = gdk_colormap_alloc_color( cmap, &m_color, FALSE, TRUE ); int idx = m_color.pixel; diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 517993327f..5244048804 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/combobox.cpp +// Name: src/gtk1/combobox.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -20,7 +20,7 @@ #include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" //----------------------------------------------------------------------------- // idle system @@ -238,16 +238,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, // and case-sensitive gtk_combo_set_case_sensitive( GTK_COMBO(m_widget), TRUE ); -#ifdef __WXGTK20__ - if (style & wxNO_BORDER) - g_object_set( GTK_ENTRY( combo->entry ), "has-frame", FALSE, NULL ); -#endif - GtkWidget *list = GTK_COMBO(m_widget)->list; -#ifndef __WXGTK20__ // gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE ); -#endif for (int i = 0; i < n; i++) { @@ -550,11 +543,7 @@ int wxComboBox::FindString( const wxString &item, bool bCase ) const { GtkBin *bin = GTK_BIN( child->data ); GtkLabel *label = GTK_LABEL( bin->child ); -#ifdef __WXGTK20__ - wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) ); -#else wxString str( label->label ); -#endif if (item.IsSameAs( str , bCase ) ) return count; @@ -607,11 +596,7 @@ wxString wxComboBox::GetString( int n ) const { GtkBin *bin = GTK_BIN( child->data ); GtkLabel *label = GTK_LABEL( bin->child ); -#ifdef __WXGTK20__ - str = wxGTK_CONV_BACK( gtk_label_get_text(label) ); -#else str = wxString( label->label ); -#endif } else { @@ -632,11 +617,7 @@ wxString wxComboBox::GetStringSelection() const { GtkBin *bin = GTK_BIN( selection->data ); GtkLabel *label = GTK_LABEL( bin->child ); -#ifdef __WXGTK20__ - wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text(label) ) ); -#else wxString tmp( label->label ); -#endif return tmp; } @@ -832,15 +813,8 @@ void wxComboBox::GetSelection( long* from, long* to ) const if (IsEditable()) { GtkEditable *editable = GTK_EDITABLE(GTK_COMBO(m_widget)->entry); -#ifdef __WXGTK20__ - gint start, end; - gtk_editable_get_selection_bounds(editable, & start, & end); - *from = start; - *to = end; -#else *from = (long) editable->selection_start_pos; *to = (long) editable->selection_end_pos; -#endif } } diff --git a/src/gtk1/control.cpp b/src/gtk1/control.cpp index d339e25aeb..eef526875b 100644 --- a/src/gtk1/control.cpp +++ b/src/gtk1/control.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/control.cpp +// Name: src/gtk1/control.cpp // Purpose: wxControl implementation for wxGTK // Author: Robert Roebling // Id: $Id$ @@ -16,7 +16,7 @@ #include "wx/control.h" #include "wx/fontutil.h" #include "wx/settings.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" // ============================================================================ // wxControl implementation @@ -107,11 +107,7 @@ void wxControl::GTKSetLabelForLabel(GtkLabel *w, const wxString& label) const wxString labelGTK = GTKConvertMnemonics(label); -#ifdef __WXGTK20__ - gtk_label_set_text_with_mnemonic(w, wxGTK_CONV(labelGTK)); -#else gtk_label_set(w, wxGTK_CONV(labelGTK)); -#endif } void wxControl::GTKSetLabelForFrame(GtkFrame *w, const wxString& label) @@ -208,11 +204,7 @@ wxString wxControl::GTKRemoveMnemonics(const wxString& label) /* static */ wxString wxControl::GTKConvertMnemonics(const wxString& label) { -#ifdef __WXGTK20__ - return GTKProcessMnemonics(label, MNEMONICS_CONVERT); -#else return GTKRemoveMnemonics(label); -#endif } // ---------------------------------------------------------------------------- @@ -263,33 +255,8 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget, style->bg[state].blue >> SHIFT); // get the style's font -#ifdef __WXGTK20__ - if ( !style->font_desc ) - style = gtk_widget_get_default_style(); - if ( style && style->font_desc ) - { - wxNativeFontInfo info; - info.description = pango_font_description_copy(style->font_desc); - attr.font = wxFont(info); - } - else - { - GtkSettings *settings = gtk_settings_get_default(); - gchar *font_name = NULL; - g_object_get ( settings, - "gtk-font-name", - &font_name, - NULL); - if (!font_name) - attr.font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); - else - attr.font = wxFont(wxString::FromAscii(font_name)); - g_free (font_name); - } -#else // TODO: isn't there a way to get a standard gtk 1.2 font? attr.font = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); -#endif return attr; } diff --git a/src/gtk1/dataobj.cpp b/src/gtk1/dataobj.cpp index e8c5f3d622..1e986e1ce0 100644 --- a/src/gtk1/dataobj.cpp +++ b/src/gtk1/dataobj.cpp @@ -205,18 +205,6 @@ bool wxDataObject::IsSupportedFormat(const wxDataFormat& format, Direction dir) } } -// ---------------------------------------------------------------------------- -// wxTextDataObject -// ---------------------------------------------------------------------------- - -#if defined(__WXGTK20__) && wxUSE_UNICODE -void wxTextDataObject::GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction dir) const -{ - *formats++ = GetPreferredFormat(); - *formats = g_altTextAtom; -} -#endif - // ---------------------------------------------------------------------------- // wxFileDataObject // ---------------------------------------------------------------------------- diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index d97e4ae8de..9e8c3de0e7 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -21,7 +21,7 @@ #include "wx/log.h" #include "wx/fontutil.h" -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/win_gtk.h" #include "wx/math.h" // for floating-point functions @@ -92,21 +92,6 @@ void gdk_wx_draw_bitmap(GdkDrawable *drawable, wxCHECK_RET( src, _T("NULL src in gdk_wx_draw_bitmap") ); wxCHECK_RET( gc, _T("NULL gc in gdk_wx_draw_bitmap") ); -#ifdef __WXGTK20__ - gint src_width, src_height; - gdk_drawable_get_size(src, &src_width, &src_height); - if (width == -1) width = src_width; - if (height == -1) height = src_height; - - XCopyPlane( GDK_WINDOW_XDISPLAY(drawable), - GDK_WINDOW_XID(src), - GDK_WINDOW_XID(drawable), - GDK_GC_XGC(gc), - xsrc, ysrc, - width, height, - 0, 0, - 1 ); -#else GdkWindowPrivate *drawable_private; GdkWindowPrivate *src_private; GdkGCPrivate *gc_private; @@ -132,7 +117,6 @@ void gdk_wx_draw_bitmap(GdkDrawable *drawable, width, height, xdest, ydest, 1 ); -#endif } //----------------------------------------------------------------------------- @@ -288,11 +272,6 @@ wxWindowDC::wxWindowDC() m_isMemDC = false; m_isScreenDC = false; m_owner = (wxWindow *)NULL; -#ifdef __WXGTK20__ - m_context = (PangoContext *)NULL; - m_layout = (PangoLayout *)NULL; - m_fontdesc = (PangoFontDescription *)NULL; -#endif } wxWindowDC::wxWindowDC( wxWindow *window ) @@ -322,12 +301,6 @@ wxWindowDC::wxWindowDC( wxWindow *window ) wxASSERT_MSG( widget, wxT("DC needs a widget") ); -#ifdef __WXGTK20__ - m_context = window->GtkGetPangoDefaultContext(); - m_layout = pango_layout_new( m_context ); - m_fontdesc = pango_font_description_copy( widget->style->font_desc ); -#endif - GtkPizza *pizza = GTK_PIZZA( widget ); m_window = pizza->bin_window; @@ -357,13 +330,6 @@ wxWindowDC::wxWindowDC( wxWindow *window ) wxWindowDC::~wxWindowDC() { Destroy(); - -#ifdef __WXGTK20__ - if (m_layout) - g_object_unref( G_OBJECT( m_layout ) ); - if (m_fontdesc) - pango_font_description_free( m_fontdesc ); -#endif } void wxWindowDC::SetUpDC() @@ -1126,13 +1092,11 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, if ((w != ww) || (h != hh)) use_bitmap = use_bitmap.Rescale( 0, 0, ww, hh, ww, hh ); -#if !GTK_CHECK_VERSION(2,2,0) // NB: We can't render pixbufs with GTK+ < 2.2, we need to use pixmaps code. // Pixbufs-based bitmaps with alpha channel don't have a mask, so we // have to call GetPixmap() here -- it converts the pixbuf into pixmap // and also creates the mask as a side-effect: use_bitmap.GetPixmap(); -#endif // apply mask if any GdkBitmap *mask = (GdkBitmap *) NULL; @@ -1184,38 +1148,13 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, // drawing a mono-bitmap (XBitmap) we use the current text GC if (is_mono) { -#ifdef __WXGTK20__ - GdkPixmap *bitmap2 = gdk_pixmap_new( wxGetRootWindow()->window, ww, hh, -1 ); - GdkGC *gc = gdk_gc_new( bitmap2 ); - gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() ); - gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() ); - gdk_wx_draw_bitmap( bitmap2, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 ); - - gdk_draw_drawable( m_window, m_textGC, bitmap2, 0, 0, xx, yy, -1, -1 ); - - gdk_bitmap_unref( bitmap2 ); - gdk_gc_unref( gc ); -#else gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), 0, 0, xx, yy, -1, -1 ); -#endif } else { -#if GTK_CHECK_VERSION(2,2,0) - if (!gtk_check_version(2,2,0) && use_bitmap.HasPixbuf()) - { - gdk_draw_pixbuf(m_window, m_penGC, - use_bitmap.GetPixbuf(), - 0, 0, xx, yy, -1, -1, - GDK_RGB_DITHER_NORMAL, xx, yy); - } - else -#endif - { - gdk_draw_pixmap(m_window, m_penGC, - use_bitmap.GetPixmap(), - 0, 0, xx, yy, -1, -1); - } + gdk_draw_pixmap(m_window, m_penGC, + use_bitmap.GetPixmap(), + 0, 0, xx, yy, -1, -1); } // remove mask again if any @@ -1442,21 +1381,8 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, if (is_mono) { -#ifdef __WXGTK20__ - GdkPixmap *bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bm_ww, bm_hh, -1 ); - GdkGC *gc = gdk_gc_new( bitmap ); - gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() ); - gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() ); - gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 ); - - gdk_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch ); - - gdk_bitmap_unref( bitmap ); - gdk_gc_unref( gc ); -#else // was: gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, xx, yy, ww, hh ); gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, cx, cy, cw, ch ); -#endif } else { @@ -1529,100 +1455,13 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) if (text.empty()) return; -#ifndef __WXGTK20__ GdkFont *font = m_font.GetInternalFont( m_scaleY ); wxCHECK_RET( font, wxT("invalid font") ); -#endif x = XLOG2DEV(x); y = YLOG2DEV(y); -#ifdef __WXGTK20__ - wxCHECK_RET( m_context, wxT("no Pango context") ); - wxCHECK_RET( m_layout, wxT("no Pango layout") ); - wxCHECK_RET( m_fontdesc, wxT("no Pango font description") ); - - bool underlined = m_font.Ok() && m_font.GetUnderlined(); - -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); - if ( !wdata ) - return; - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); -#endif - size_t datalen = strlen((const char*)data); - pango_layout_set_text( m_layout, (const char*) data, datalen); - - if (underlined) - { - PangoAttrList *attrs = pango_attr_list_new(); - PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE); - a->start_index = 0; - a->end_index = datalen; - pango_attr_list_insert(attrs, a); - pango_layout_set_attributes(m_layout, attrs); - pango_attr_list_unref(attrs); - } - - int w,h; - - if (fabs(m_scaleY - 1.0) > 0.00001) - { - // If there is a user or actually any scale applied to - // the device context, scale the font. - - // scale font description - gint oldSize = pango_font_description_get_size( m_fontdesc ); - double size = oldSize; - size = size * m_scaleY; - pango_font_description_set_size( m_fontdesc, (gint)size ); - - // actually apply scaled font - pango_layout_set_font_description( m_layout, m_fontdesc ); - - pango_layout_get_pixel_size( m_layout, &w, &h ); - if ( m_backgroundMode == wxSOLID ) - { - gdk_gc_set_foreground(m_textGC, m_textBackgroundColour.GetColor()); - gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h); - gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor()); - } - - // Draw layout. - gdk_draw_layout( m_window, m_textGC, x, y, m_layout ); - - // reset unscaled size - pango_font_description_set_size( m_fontdesc, oldSize ); - - // actually apply unscaled font - pango_layout_set_font_description( m_layout, m_fontdesc ); - } - else - { - pango_layout_get_pixel_size( m_layout, &w, &h ); - if ( m_backgroundMode == wxSOLID ) - { - gdk_gc_set_foreground(m_textGC, m_textBackgroundColour.GetColor()); - gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h); - gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor()); - } - // Draw layout. - gdk_draw_layout( m_window, m_textGC, x, y, m_layout ); - } - - if (underlined) - { - // undo underline attributes setting: - pango_layout_set_attributes(m_layout, NULL); - } - - wxCoord width = w; - wxCoord height = h; - -#else // GTK+ 1.x wxCoord width = gdk_string_width( font, text.mbc_str() ); wxCoord height = font->ascent + font->descent; @@ -1643,7 +1482,6 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) if (font->descent > 0) ul_y++; gdk_draw_line( m_window, m_textGC, x, ul_y, x + width, ul_y); } -#endif // GTK+ 2.0/1.x width = wxCoord(width / m_scaleX); height = wxCoord(height / m_scaleY); @@ -1671,11 +1509,6 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, wxCoord w; wxCoord h; -#ifdef __WXGTK20__ - // implement later without GdkFont for GTK 2.0 - GetTextExtent(text, &w, &h, NULL,NULL, &m_font); - -#else GdkFont *font = m_font.GetInternalFont( m_scaleY ); wxCHECK_RET( font, wxT("invalid font") ); @@ -1683,7 +1516,7 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, // the size of the text w = gdk_string_width( font, text.mbc_str() ); h = font->ascent + font->descent; -#endif + // draw the string normally wxBitmap src(w, h); wxMemoryDC dc; @@ -1786,53 +1619,6 @@ void wxWindowDC::DoGetTextExtent(const wxString &string, return; } -#ifdef __WXGTK20__ - // Set new font description - if (theFont) - pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description ); - - // Set layout's text -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); - const char *dataUTF8 = (const char *)data; -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); - if ( !wdata ) - return; - - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - const char *dataUTF8 = (const char *)data; -#endif - - if ( !dataUTF8 ) - { - // hardly ideal, but what else can we do if conversion failed? - return; - } - - pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) ); - - if (descent) - { - int h; - pango_layout_get_pixel_size( m_layout, width, &h ); - PangoLayoutIter *iter = pango_layout_get_iter(m_layout); - int baseline = pango_layout_iter_get_baseline(iter); - pango_layout_iter_free(iter); - *descent = h - PANGO_PIXELS(baseline); - - if (height) - *height = (wxCoord) h; - } - else - { - pango_layout_get_pixel_size( m_layout, width, height ); - } - - // Reset old font description - if (theFont) - pango_layout_set_font_description( m_layout, m_fontdesc ); -#else // GTK+ 1.x wxFont fontToUse = m_font; if (theFont) fontToUse = *theFont; @@ -1847,37 +1633,22 @@ void wxWindowDC::DoGetTextExtent(const wxString &string, *height = wxCoord((font->ascent + font->descent) / m_scaleY); if (descent) *descent = wxCoord(font->descent / m_scaleY); -#endif // GTK+ 2/1 } wxCoord wxWindowDC::GetCharWidth() const { -#ifdef __WXGTK20__ - pango_layout_set_text( m_layout, "H", 1 ); - int w; - pango_layout_get_pixel_size( m_layout, &w, NULL ); - return w; -#else GdkFont *font = m_font.GetInternalFont( m_scaleY ); wxCHECK_MSG( font, -1, wxT("invalid font") ); return wxCoord(gdk_string_width( font, "H" ) / m_scaleX); -#endif } wxCoord wxWindowDC::GetCharHeight() const { -#ifdef __WXGTK20__ - pango_layout_set_text( m_layout, "H", 1 ); - int h; - pango_layout_get_pixel_size( m_layout, NULL, &h ); - return h; -#else GdkFont *font = m_font.GetInternalFont( m_scaleY ); wxCHECK_MSG( font, -1, wxT("invalid font") ); return wxCoord((font->ascent + font->descent) / m_scaleY); -#endif } void wxWindowDC::Clear() @@ -1921,37 +1692,6 @@ void wxWindowDC::Clear() void wxWindowDC::SetFont( const wxFont &font ) { m_font = font; - -#ifdef __WXGTK20__ - if (m_font.Ok()) - { - if (m_fontdesc) - pango_font_description_free( m_fontdesc ); - - m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description ); - - - if (m_owner) - { - PangoContext *oldContext = m_context; - - m_context = m_owner->GtkGetPangoDefaultContext(); - - // If we switch back/forth between different contexts - // we also have to create a new layout. I think so, - // at least, and it doesn't hurt to do it. - if (oldContext != m_context) - { - if (m_layout) - g_object_unref( G_OBJECT( m_layout ) ); - - m_layout = pango_layout_new( m_context ); - } - } - - pango_layout_set_font_description( m_layout, m_fontdesc ); - } -#endif } void wxWindowDC::SetPen( const wxPen &pen ) @@ -2433,13 +2173,9 @@ wxSize wxWindowDC::GetPPI() const int wxWindowDC::GetDepth() const { -#ifdef __WXGTK20__ - return gdk_drawable_get_depth(m_window); -#else wxFAIL_MSG(wxT("not implemented")); return -1; -#endif } diff --git a/src/gtk1/dcmemory.cpp b/src/gtk1/dcmemory.cpp index 5d945a329f..977e3d22fd 100644 --- a/src/gtk1/dcmemory.cpp +++ b/src/gtk1/dcmemory.cpp @@ -26,15 +26,6 @@ wxMemoryDC::wxMemoryDC() : wxWindowDC() m_ok = FALSE; m_cmap = gtk_widget_get_default_colormap(); - -#ifdef __WXGTK20__ - m_context = gdk_pango_context_get(); - // Note: The Sun customised version of Pango shipping with Solaris 10 - // crashes if the language is left NULL (see bug 1374114) - pango_context_set_language( m_context, gtk_get_default_language() ); - m_layout = pango_layout_new( m_context ); - m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) ); -#endif } wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) @@ -44,19 +35,10 @@ wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) m_cmap = gtk_widget_get_default_colormap(); -#ifdef __WXGTK20__ - m_context = gdk_pango_context_get(); - pango_context_set_language( m_context, gtk_get_default_language() ); - m_layout = pango_layout_new( m_context ); - m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) ); -#endif } wxMemoryDC::~wxMemoryDC() { -#ifdef __WXGTK20__ - g_object_unref(m_context); -#endif } void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) @@ -74,10 +56,6 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) m_window = m_selected.GetBitmap(); } -#ifdef __WXGTK20__ - m_selected.PurgeOtherRepresentations(wxBitmap::Pixmap); -#endif - m_isMemDC = TRUE; SetUpDC(); diff --git a/src/gtk1/dcscreen.cpp b/src/gtk1/dcscreen.cpp index bf7d10404d..dbd3a29229 100644 --- a/src/gtk1/dcscreen.cpp +++ b/src/gtk1/dcscreen.cpp @@ -37,15 +37,6 @@ wxScreenDC::wxScreenDC() m_cmap = gdk_colormap_get_system(); m_window = GDK_ROOT_PARENT(); -#ifdef __WXGTK20__ - m_context = gdk_pango_context_get(); - // Note: The Sun customised version of Pango shipping with Solaris 10 - // crashes if the language is left NULL (see bug 1374114) - pango_context_set_language( m_context, gtk_get_default_language() ); - m_layout = pango_layout_new( m_context ); -// m_fontdesc = pango_font_description_copy( widget->style->font_desc ); -#endif - m_isScreenDC = TRUE; SetUpDC(); diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 31df13df6b..f9f34936ff 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -20,7 +20,7 @@ #include #include -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/win_gtk.h" //----------------------------------------------------------------------------- // global data diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index c56c806047..3c4ce2dc54 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -22,7 +22,7 @@ #include "wx/intl.h" #include "wx/utils.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include @@ -506,13 +506,7 @@ GdkAtom wxDropTarget::GetMatchingPair() GList *child = m_dragContext->targets; while (child) { - // in GTK+ 1.x GdkAtom was a gulong, but now it's a pointer - GdkAtom formatAtom = -#ifdef __WXGTK20__ - (GdkAtom)(child->data); -#else - GPOINTER_TO_INT(child->data); -#endif + GdkAtom formatAtom = GPOINTER_TO_INT(child->data); wxDataFormat format( formatAtom ); #ifdef __WXDEBUG__ @@ -823,18 +817,14 @@ void wxDropSource::PrepareIcon( int action, GdkDragContext *context ) gdk_window_get_size (pixmap, &width, &height); GdkColormap *colormap = gtk_widget_get_colormap( m_widget ); -#ifndef __WXGTK20__ gtk_widget_push_visual (gdk_colormap_get_visual (colormap)); -#endif gtk_widget_push_colormap (colormap); m_iconWindow = gtk_window_new (GTK_WINDOW_POPUP); gtk_widget_set_events (m_iconWindow, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); gtk_widget_set_app_paintable (GTK_WIDGET (m_iconWindow), TRUE); -#ifndef __WXGTK20__ gtk_widget_pop_visual (); -#endif gtk_widget_pop_colormap (); gtk_widget_set_usize (m_iconWindow, width, height); diff --git a/src/gtk1/filedlg.cpp b/src/gtk1/filedlg.cpp index ca86050527..e1b7d25cab 100644 --- a/src/gtk1/filedlg.cpp +++ b/src/gtk1/filedlg.cpp @@ -17,107 +17,6 @@ #include "wx/filedlg.h" -#ifdef __WXGTK24__ - -#include -#include "wx/gtk/private.h" - -#include // chdir - -#include "wx/intl.h" -#include "wx/filename.h" // wxFilename -#include "wx/tokenzr.h" // wxStringTokenizer -#include "wx/filefn.h" // ::wxGetCwd -#include "wx/msgdlg.h" // wxMessageDialog - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); - -//----------------------------------------------------------------------------- -// "clicked" for OK-button -//----------------------------------------------------------------------------- - -extern "C" { -static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog) -{ - int style = dialog->GetStyle(); - gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); - - // gtk version numbers must be identical with the one in ctor (that calls set_do_overwrite_confirmation) -#if GTK_CHECK_VERSION(2,7,3) - if(gtk_check_version(2,7,3) != NULL) -#endif - if ((style & wxSAVE) && (style & wxOVERWRITE_PROMPT)) - { - if ( g_file_test(filename, G_FILE_TEST_EXISTS) ) - { - wxString msg; - - msg.Printf( - _("File '%s' already exists, do you really want to overwrite it?"), - wxString(wxConvFileName->cMB2WX(filename)).c_str()); - - wxMessageDialog dlg(dialog, msg, _("Confirm"), - wxYES_NO | wxICON_QUESTION); - if (dlg.ShowModal() != wxID_YES) - return; - } - } - - // change to the directory where the user went if asked - if (style & wxCHANGE_DIR) - { - // Use chdir to not care about filename encodings - gchar* folder = g_path_get_dirname(filename); - chdir(folder); - g_free(folder); - } - - g_free(filename); - - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); - event.SetEventObject(dialog); - dialog->GetEventHandler()->ProcessEvent(event); -} -} - -//----------------------------------------------------------------------------- -// "clicked" for Cancel-button -//----------------------------------------------------------------------------- - -extern "C" { -static void gtk_filedialog_cancel_callback(GtkWidget *WXUNUSED(w), - wxFileDialog *dialog) -{ - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - event.SetEventObject(dialog); - dialog->GetEventHandler()->ProcessEvent(event); -} -} - -extern "C" { -static void gtk_filedialog_response_callback(GtkWidget *w, - gint response, - wxFileDialog *dialog) -{ - wxapp_install_idle_handler(); - - if (response == GTK_RESPONSE_ACCEPT) - gtk_filedialog_ok_callback(w, dialog); - else if (response == GTK_RESPONSE_CANCEL) - gtk_filedialog_cancel_callback(w, dialog); - else // "delete" - { - gtk_filedialog_cancel_callback(w, dialog); - dialog->m_destroyed_by_delete = true; - } -} -} - -#endif // __WXGTK24__ //----------------------------------------------------------------------------- // wxFileDialog @@ -137,138 +36,26 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, : wxGenericFileDialog(parent, message, defaultDir, defaultFileName, wildCard, style, pos, true ) { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - wxASSERT_MSG( !( (style & wxSAVE) && (style & wxMULTIPLE) ), wxT("wxFileDialog - wxMULTIPLE used on a save dialog" ) ); - m_needParent = false; - m_destroyed_by_delete = false; - - if (!PreCreation(parent, pos, wxDefaultSize) || - !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style, - wxDefaultValidator, wxT("filedialog"))) - { - wxFAIL_MSG( wxT("wxFileDialog creation failed") ); - return; - } - - GtkFileChooserAction gtk_action; - GtkWindow* gtk_parent = NULL; - if (parent) - gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) ); - - const gchar* ok_btn_stock; - if ( style & wxSAVE ) - { - gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE; - ok_btn_stock = GTK_STOCK_SAVE; - } - else - { - gtk_action = GTK_FILE_CHOOSER_ACTION_OPEN; - ok_btn_stock = GTK_STOCK_OPEN; - } - - m_widget = gtk_file_chooser_dialog_new( - wxGTK_CONV(m_message), - gtk_parent, - gtk_action, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - ok_btn_stock, GTK_RESPONSE_ACCEPT, - NULL); - - if ( style & wxMULTIPLE ) - gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(m_widget), true); - - // local-only property could be set to false to allow non-local files to be loaded. - // In that case get/set_uri(s) should be used instead of get/set_filename(s) everywhere - // and the GtkFileChooserDialog should probably also be created with a backend, - // e.g "gnome-vfs", "default", ... (gtk_file_chooser_dialog_new_with_backend). - // Currently local-only is kept as the default - true: - // gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(m_widget), true); - - g_signal_connect(G_OBJECT(m_widget), "response", - GTK_SIGNAL_FUNC(gtk_filedialog_response_callback), (gpointer)this); - - SetWildcard(wildCard); - - if ( style & wxSAVE ) - { - if ( !defaultDir.empty() ) - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), - wxConvFileName->cWX2MB(defaultDir)); - - gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget), - wxConvFileName->cWX2MB(defaultFileName)); - -#if GTK_CHECK_VERSION(2,7,3) - if (!gtk_check_version(2,7,3)) - gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(m_widget), TRUE); -#endif - } - else - { - if ( !defaultFileName.empty() ) - { - wxString dir; - if ( defaultDir.empty() ) - dir = ::wxGetCwd(); - else - dir = defaultDir; - - gtk_file_chooser_set_filename( - GTK_FILE_CHOOSER(m_widget), - wxConvFileName->cWX2MB( wxFileName(dir, defaultFileName).GetFullPath() ) ); - } - else if ( !defaultDir.empty() ) - gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget), - wxConvFileName->cWX2MB(defaultDir) ); - } - } - else -#endif wxGenericFileDialog::Create( parent, message, defaultDir, defaultFileName, wildCard, style, pos ); } wxFileDialog::~wxFileDialog() { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - if (m_destroyed_by_delete) - m_widget = NULL; - } -#endif } void wxFileDialog::OnFakeOk( wxCommandEvent &event ) { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - wxDialog::OnOK( event ); - else -#endif - wxGenericFileDialog::OnListOk( event ); + wxGenericFileDialog::OnListOk( event ); } int wxFileDialog::ShowModal() { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - return wxDialog::ShowModal(); - else -#endif - return wxGenericFileDialog::ShowModal(); + return wxGenericFileDialog::ShowModal(); } bool wxFileDialog::Show( bool show ) { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - return wxDialog::Show( show ); - else -#endif - return wxGenericFileDialog::Show( show ); + return wxGenericFileDialog::Show( show ); } void wxFileDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags ) @@ -281,241 +68,63 @@ void wxFileDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags wxString wxFileDialog::GetPath() const { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - return wxConvFileName->cMB2WX(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget))); - else -#endif - return wxGenericFileDialog::GetPath(); + return wxGenericFileDialog::GetPath(); } void wxFileDialog::GetFilenames(wxArrayString& files) const { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - GetPaths(files); - for (size_t n = 0; n < files.GetCount(); ++n ) - { - wxFileName file(files[n]); - files[n] = file.GetFullName(); - } - } - else -#endif - wxGenericFileDialog::GetFilenames( files ); + wxGenericFileDialog::GetFilenames( files ); } void wxFileDialog::GetPaths(wxArrayString& paths) const { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - paths.Empty(); - if (gtk_file_chooser_get_select_multiple(GTK_FILE_CHOOSER(m_widget))) - { - GSList *gpathsi = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(m_widget)); - GSList *gpaths = gpathsi; - while (gpathsi) - { - wxString file(wxConvFileName->cMB2WX((gchar*) gpathsi->data)); - paths.Add(file); - g_free(gpathsi->data); - gpathsi = gpathsi->next; - } - - g_slist_free(gpaths); - } - else - paths.Add(GetPath()); - } - else -#endif - wxGenericFileDialog::GetPaths( paths ); + wxGenericFileDialog::GetPaths( paths ); } void wxFileDialog::SetMessage(const wxString& message) { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - m_message = message; - SetTitle(message); - } - else -#endif - wxGenericFileDialog::SetMessage( message ); + wxGenericFileDialog::SetMessage( message ); } void wxFileDialog::SetPath(const wxString& path) { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - if (path.empty()) return; - - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(path)); - } - else -#endif - wxGenericFileDialog::SetPath( path ); + wxGenericFileDialog::SetPath( path ); } void wxFileDialog::SetDirectory(const wxString& dir) { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - if (wxDirExists(dir)) - { - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(dir)); - } - } - else -#endif - wxGenericFileDialog::SetDirectory( dir ); + wxGenericFileDialog::SetDirectory( dir ); } wxString wxFileDialog::GetDirectory() const { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - return wxConvFileName->cMB2WX( - gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER(m_widget) ) ); - else -#endif - return wxGenericFileDialog::GetDirectory(); + return wxGenericFileDialog::GetDirectory(); } void wxFileDialog::SetFilename(const wxString& name) { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - if (GetStyle() & wxSAVE) - gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(name)); - else - SetPath(wxFileName(GetDirectory(), name).GetFullPath()); - } - else -#endif - wxGenericFileDialog::SetFilename( name ); + + wxGenericFileDialog::SetFilename( name ); } wxString wxFileDialog::GetFilename() const { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - return wxFileName( - wxConvFileName->cMB2WX(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget))) ).GetFullName(); - else -#endif - return wxGenericFileDialog::GetFilename(); + return wxGenericFileDialog::GetFilename(); } void wxFileDialog::SetWildcard(const wxString& wildCard) { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - // parse filters - wxArrayString wildDescriptions, wildFilters; - if (!wxParseCommonDialogsFilter(wildCard, wildDescriptions, wildFilters)) - { - wxFAIL_MSG( wxT("wxFileDialog::SetWildCard - bad wildcard string") ); - } - else - { - // Parsing went fine. Set m_wildCard to be returned by wxFileDialogBase::GetWildcard - m_wildCard = wildCard; - - GtkFileChooser* chooser = GTK_FILE_CHOOSER(m_widget); - - // empty current filter list: - GSList* ifilters = gtk_file_chooser_list_filters(chooser); - GSList* filters = ifilters; - - while (ifilters) - { - gtk_file_chooser_remove_filter(chooser,GTK_FILE_FILTER(ifilters->data)); - ifilters = ifilters->next; - } - g_slist_free(filters); - - // add parsed to GtkChooser - for (size_t n = 0; n < wildFilters.GetCount(); ++n) - { - GtkFileFilter* filter = gtk_file_filter_new(); - gtk_file_filter_set_name(filter, wxGTK_CONV(wildDescriptions[n])); - - wxStringTokenizer exttok(wildFilters[n], wxT(";")); - while (exttok.HasMoreTokens()) - { - wxString token = exttok.GetNextToken(); - gtk_file_filter_add_pattern(filter, wxGTK_CONV(token)); - } - - gtk_file_chooser_add_filter(chooser, filter); - } - - // Reset the filter index - SetFilterIndex(0); - } - } - else -#endif - wxGenericFileDialog::SetWildcard( wildCard ); + wxGenericFileDialog::SetWildcard( wildCard ); } void wxFileDialog::SetFilterIndex(int filterIndex) { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - gpointer filter; - GtkFileChooser *chooser = GTK_FILE_CHOOSER(m_widget); - GSList *filters = gtk_file_chooser_list_filters(chooser); - - filter = g_slist_nth_data(filters, filterIndex); - - if (filter != NULL) - { - gtk_file_chooser_set_filter(chooser, GTK_FILE_FILTER(filter)); - } - else - { - wxFAIL_MSG( wxT("wxFileDialog::SetFilterIndex - bad filter index") ); - } - - g_slist_free(filters); - } - else -#endif - wxGenericFileDialog::SetFilterIndex( filterIndex ); + wxGenericFileDialog::SetFilterIndex( filterIndex ); } int wxFileDialog::GetFilterIndex() const { -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - GtkFileChooser *chooser = GTK_FILE_CHOOSER(m_widget); - GtkFileFilter *filter = gtk_file_chooser_get_filter(chooser); - GSList *filters = gtk_file_chooser_list_filters(chooser); - gint index = g_slist_index(filters, filter); - g_slist_free(filters); - - if (index == -1) - { - wxFAIL_MSG( wxT("wxFileDialog::GetFilterIndex - bad filter index returned by gtk+") ); - return 0; - } - else - return index; - } - else -#endif - return wxGenericFileDialog::GetFilterIndex(); + return wxGenericFileDialog::GetFilterIndex(); } #endif // wxUSE_FILEDLG diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index e174e7c2d0..35a7060ab6 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -29,7 +29,7 @@ #include -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include // ---------------------------------------------------------------------------- @@ -73,13 +73,8 @@ public: // do we have the native font info? bool HasNativeFont() const { -#ifdef __WXGTK20__ - // we always have a Pango font description - return TRUE; -#else // GTK 1.x // only use m_nativeFontInfo if it had been initialized return !m_nativeFontInfo.IsDefault(); -#endif // GTK 2.0/1.x } // setters: all of them also take care to modify m_nativeFontInfo if we @@ -102,7 +97,7 @@ public: // // VZ: I need this as my gdb either shows wildly wrong values or crashes // when I ask it to "p fontRefData" :-( -#if defined(__WXDEBUG__) && !defined(__WXGTK20__) +#if defined(__WXDEBUG__) void Dump() const { wxPrintf(_T("%s-%s-%s-%d-%d\n"), @@ -135,10 +130,8 @@ private: // clear m_scaled_xfonts if any void ClearGdkFonts(); -#ifndef __WXGTK20__ // the map of font sizes to "GdkFont *" wxScaledFontList m_scaled_xfonts; -#endif // GTK 2.0/1.x int m_pointSize; int m_family, @@ -186,84 +179,12 @@ void wxFontRefData::Init(int pointSize, m_encoding = encoding; m_noAA = FALSE; - -#ifdef __WXGTK20__ - // Create native font info - m_nativeFontInfo.description = pango_font_description_new(); - - // And set its values - if (!m_faceName.empty()) - { - pango_font_description_set_family( m_nativeFontInfo.description, wxGTK_CONV(m_faceName) ); - } - else - { - switch (m_family) - { - case wxFONTFAMILY_MODERN: - case wxFONTFAMILY_TELETYPE: - pango_font_description_set_family( m_nativeFontInfo.description, "monospace" ); - break; - case wxFONTFAMILY_ROMAN: - pango_font_description_set_family( m_nativeFontInfo.description, "serif" ); - break; - case wxFONTFAMILY_SWISS: - // SWISS = sans serif - default: - pango_font_description_set_family( m_nativeFontInfo.description, "sans" ); - break; - } - } - - SetStyle( m_style ); - SetPointSize( m_pointSize ); - SetWeight( m_weight ); -#endif // GTK 2.0 } void wxFontRefData::InitFromNative() { m_noAA = FALSE; -#ifdef __WXGTK20__ - // Get native info - PangoFontDescription *desc = m_nativeFontInfo.description; - - // init fields - m_faceName = wxGTK_CONV_BACK( pango_font_description_get_family( desc ) ); - - // Pango sometimes needs to have a size - int pango_size = pango_font_description_get_size( desc ); - if (pango_size == 0) - m_nativeFontInfo.SetPointSize(12); - - m_pointSize = m_nativeFontInfo.GetPointSize(); - m_style = m_nativeFontInfo.GetStyle(); - m_weight = m_nativeFontInfo.GetWeight(); - - if (m_faceName == wxT("monospace")) - { - m_family = wxFONTFAMILY_TELETYPE; - } - else if (m_faceName == wxT("sans")) - { - m_family = wxFONTFAMILY_SWISS; - } - else if (m_faceName == wxT("serif")) - { - m_family = wxFONTFAMILY_ROMAN; - } - else - { - m_family = wxFONTFAMILY_UNKNOWN; - } - - // Pango description are never underlined (?) - m_underlined = FALSE; - - // Cannot we choose that - m_encoding = wxFONTENCODING_SYSTEM; -#else // GTK 1.x // get the font parameters from the XLFD // ------------------------------------- @@ -361,7 +282,6 @@ void wxFontRefData::InitFromNative() // may be give a warning here? or use wxFontMapper? m_encoding = wxFONTENCODING_SYSTEM; } -#endif // GTK 2.0/1.x } wxFontRefData::wxFontRefData( const wxFontRefData& data ) @@ -395,19 +315,14 @@ wxFontRefData::wxFontRefData(int size, int family, int style, wxFontRefData::wxFontRefData(const wxString& fontname) { - // VZ: FromString() should really work in both cases, doesn't it? -#ifdef __WXGTK20__ - m_nativeFontInfo.FromString( fontname ); -#else // GTK 1.x + // FromString() should really work in GTK1 too, doesn't it? m_nativeFontInfo.SetXFontName(fontname); -#endif // GTK 2.0/1.x InitFromNative(); } void wxFontRefData::ClearGdkFonts() { -#ifndef __WXGTK20__ for ( wxScaledFontList::iterator i = m_scaled_xfonts.begin(); i != m_scaled_xfonts.end(); ++i ) @@ -417,7 +332,6 @@ void wxFontRefData::ClearGdkFonts() } m_scaled_xfonts.clear(); -#endif // GTK 1.x } wxFontRefData::~wxFontRefData() @@ -433,9 +347,6 @@ void wxFontRefData::SetPointSize(int pointSize) { m_pointSize = pointSize; -#ifdef __WXGTK20__ - m_nativeFontInfo.SetPointSize(pointSize); -#else if ( HasNativeFont() ) { wxString size; @@ -446,7 +357,6 @@ void wxFontRefData::SetPointSize(int pointSize) m_nativeFontInfo.SetXFontComponent(wxXLFD_POINTSIZE, size); } -#endif } void wxFontRefData::SetFamily(int family) @@ -460,9 +370,6 @@ void wxFontRefData::SetStyle(int style) { m_style = style; -#ifdef __WXGTK20__ - m_nativeFontInfo.SetStyle((wxFontStyle)style); -#else if ( HasNativeFont() ) { wxString slant; @@ -486,16 +393,12 @@ void wxFontRefData::SetStyle(int style) m_nativeFontInfo.SetXFontComponent(wxXLFD_SLANT, slant); } -#endif } void wxFontRefData::SetWeight(int weight) { m_weight = weight; -#ifdef __WXGTK20__ - m_nativeFontInfo.SetWeight((wxFontWeight)weight); -#else //!__WXGTK20__ if ( HasNativeFont() ) { wxString boldness; @@ -520,7 +423,6 @@ void wxFontRefData::SetWeight(int weight) m_nativeFontInfo.SetXFontComponent(wxXLFD_WEIGHT, boldness); } -#endif } void wxFontRefData::SetUnderlined(bool underlined) @@ -534,21 +436,16 @@ void wxFontRefData::SetFaceName(const wxString& facename) { m_faceName = facename; -#ifdef __WXGTK20__ - m_nativeFontInfo.SetFaceName(facename); -#else if ( HasNativeFont() ) { m_nativeFontInfo.SetXFontComponent(wxXLFD_FAMILY, facename); } -#endif } void wxFontRefData::SetEncoding(wxFontEncoding encoding) { m_encoding = encoding; -#ifndef __WXGTK20__ if ( HasNativeFont() ) { wxNativeEncodingInfo info; @@ -558,7 +455,6 @@ void wxFontRefData::SetEncoding(wxFontEncoding encoding) m_nativeFontInfo.SetXFontComponent(wxXLFD_ENCODING, info.xencoding); } } -#endif } void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info) @@ -586,17 +482,7 @@ wxFont::wxFont(const wxNativeFontInfo& info) { Init(); -#ifdef __WXGTK20__ - Create( info.GetPointSize(), - info.GetFamily(), - info.GetStyle(), - info.GetWeight(), - info.GetUnderlined(), - info.GetFaceName(), - info.GetEncoding() ); -#else (void) Create(info.GetXFontName()); -#endif } bool wxFont::Create( int pointSize, @@ -745,7 +631,6 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const { wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") ); -#ifndef __WXGTK20__ if ( !M_FONTDATA->HasNativeFont() ) { // NB: this call has important side-effect: it not only finds @@ -753,7 +638,6 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const // by calling its SetXFontName method GetInternalFont(); } -#endif return &(M_FONTDATA->m_nativeFontInfo); } @@ -762,7 +646,6 @@ bool wxFont::IsFixedWidth() const { wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") ); -#ifndef __WXGTK20__ if ( M_FONTDATA->HasNativeFont() ) { // the monospace fonts are supposed to have "M" in the spacing field @@ -771,7 +654,6 @@ bool wxFont::IsFixedWidth() const return spacing.Upper() == _T('M'); } -#endif return wxFontBase::IsFixedWidth(); } @@ -847,7 +729,6 @@ void wxFont::SetNoAntiAliasing( bool no ) // get internal representation of font // ---------------------------------------------------------------------------- -#ifndef __WXGTK20__ static GdkFont *g_systemDefaultGuiFont = (GdkFont*) NULL; // this is also used from tbargtk.cpp and tooltip.cpp, hence extern @@ -939,5 +820,3 @@ GdkFont *wxFont::GetInternalFont( float scale ) const return font; } -#endif // not GTK 2.0 - diff --git a/src/gtk1/fontdlg.cpp b/src/gtk1/fontdlg.cpp index af709b3825..982850c35e 100644 --- a/src/gtk1/fontdlg.cpp +++ b/src/gtk1/fontdlg.cpp @@ -23,7 +23,7 @@ #include "wx/debug.h" #include "wx/msgdlg.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" //----------------------------------------------------------------------------- // idle system @@ -69,7 +69,6 @@ void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dial GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget); -#ifndef __WXGTK20__ GdkFont *gfont = gtk_font_selection_dialog_get_font(fontdlg); if (!gfont) @@ -78,7 +77,6 @@ void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dial wxOK | wxICON_ERROR); return; } -#endif gchar *fontname = gtk_font_selection_dialog_get_font_name(fontdlg); dialog->SetChosenFont( fontname); @@ -138,18 +136,14 @@ bool wxFontDialog::DoCreate(wxWindow *parent) gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked", GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this ); -#ifndef __WXGTK20__ // strange way to internationalize gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), _("OK") ); -#endif gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked", GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this ); -#ifndef __WXGTK20__ // strange way to internationalize gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), _("Cancel") ); -#endif gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this ); @@ -162,13 +156,10 @@ bool wxFontDialog::DoCreate(wxWindow *parent) if ( info ) { -#ifdef __WXGTK20__ - const wxString& fontname = info->ToString(); -#else const wxString& fontname = info->GetXFontName(); if ( !fontname ) font.GetInternalFont(); -#endif + gtk_font_selection_dialog_set_font_name(sel, wxGTK_CONV(fontname)); } else diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 70136afb42..9b703f28d8 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -34,12 +34,12 @@ #include "wx/dcclient.h" #include -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include #include -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/win_gtk.h" // ---------------------------------------------------------------------------- // constants diff --git a/src/gtk1/glcanvas.cpp b/src/gtk1/glcanvas.cpp index 688402fd99..53f4ce9c2e 100644 --- a/src/gtk1/glcanvas.cpp +++ b/src/gtk1/glcanvas.cpp @@ -30,7 +30,7 @@ extern "C" #include "gdk/gdkx.h" } -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/win_gtk.h" // DLL options compatibility check: #include "wx/build.h" @@ -255,7 +255,6 @@ gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_e // "draw" of m_wxwindow //----------------------------------------------------------------------------- -#ifndef __WXGTK20__ extern "C" { static void gtk_glwindow_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxGLCanvas *win ) @@ -269,7 +268,6 @@ gtk_glwindow_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxG rect->width, rect->height ); } } -#endif //----------------------------------------------------------------------------- // "size_allocate" of m_wxwindow @@ -397,7 +395,7 @@ bool wxGLCanvas::Create( wxWindow *parent, GdkColormap *colormap; // MR: This needs a fix for lower gtk+ versions too. Might need to rethink logic (FIXME) -#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,2,0) +#if 0 if (!gtk_check_version(2,2,0)) { wxWindow::Create( parent, id, pos, size, style, name ); @@ -429,10 +427,6 @@ bool wxGLCanvas::Create( wxWindow *parent, m_glWidget = m_wxwindow; } -#ifdef __WXGTK20__ - gtk_widget_set_double_buffered( m_glWidget, FALSE ); -#endif - gtk_pizza_set_clear( GTK_PIZZA(m_wxwindow), FALSE ); gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize", @@ -444,21 +438,14 @@ bool wxGLCanvas::Create( wxWindow *parent, gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", GTK_SIGNAL_FUNC(gtk_glwindow_expose_callback), (gpointer)this ); -#ifndef __WXGTK20__ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", GTK_SIGNAL_FUNC(gtk_glwindow_draw_callback), (gpointer)this ); -#endif gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_glcanvas_size_callback), (gpointer)this ); -#ifdef __WXGTK20__ - if (gtk_check_version(2,2,0) != NULL) -#endif - { - gtk_widget_pop_visual(); - gtk_widget_pop_colormap(); - } + gtk_widget_pop_visual(); + gtk_widget_pop_colormap(); // if our parent window is already visible, we had been realized before we // connected to the "realize" signal and hence our m_glContext hasn't been diff --git a/src/gtk1/gnome/gprint.cpp b/src/gtk1/gnome/gprint.cpp index c9c378e560..0c6c3f9478 100644 --- a/src/gtk1/gnome/gprint.cpp +++ b/src/gtk1/gnome/gprint.cpp @@ -14,1793 +14,3 @@ #ifdef __BORLANDC__ #pragma hdrstop #endif - -#include "wx/gtk/gnome/gprint.h" - -#if wxUSE_LIBGNOMEPRINT - -#include "wx/math.h" -#include "wx/fontutil.h" -#include "wx/gtk/private.h" -#include "wx/module.h" -#include "wx/dynlib.h" -#include "wx/dcmemory.h" -#include "wx/log.h" -#include "wx/icon.h" - -#include -#include -#include -#include -#include -#include - -static const double RAD2DEG = 180.0 / M_PI; - -#include "wx/html/forcelnk.h" -FORCE_LINK_ME(gnome_print) - -//---------------------------------------------------------------------------- -// wxGnomePrintLibrary -//---------------------------------------------------------------------------- - -#define wxDL_METHOD_DEFINE( rettype, name, args, shortargs, defret ) \ - typedef rettype (* name ## Type) args ; \ - name ## Type pfn_ ## name; \ - rettype name args \ - { if (m_ok) return pfn_ ## name shortargs ; return defret; } - -#define wxDL_METHOD_LOAD( lib, name, success ) \ - pfn_ ## name = (name ## Type) lib->GetSymbol( wxT(#name), &success ); \ - if (!success) return; - -class wxGnomePrintLibrary -{ -public: - wxGnomePrintLibrary(); - ~wxGnomePrintLibrary(); - - bool IsOk(); - void InitializeMethods(); - -private: - bool m_ok; - wxDynamicLibrary *m_gnome_print_lib; - wxDynamicLibrary *m_gnome_printui_lib; - -public: - wxDL_METHOD_DEFINE( gint, gnome_print_newpath, - (GnomePrintContext *pc), (pc), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_moveto, - (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_lineto, - (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_arcto, - (GnomePrintContext *pc, gdouble x, gdouble y, gdouble radius, gdouble angle1, gdouble angle2, gint direction ), (pc, x, y, radius, angle1, angle2, direction), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_curveto, - (GnomePrintContext *pc, gdouble x1, gdouble y1, gdouble x2, gdouble y2, gdouble x3, gdouble y3), (pc, x1, y1, x2, y2, x3, y3), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_closepath, - (GnomePrintContext *pc), (pc), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_stroke, - (GnomePrintContext *pc), (pc), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_fill, - (GnomePrintContext *pc), (pc), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_setrgbcolor, - (GnomePrintContext *pc, gdouble r, gdouble g, gdouble b), (pc, r, g, b), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_setlinewidth, - (GnomePrintContext *pc, gdouble width), (pc, width), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_setdash, - (GnomePrintContext *pc, gint n_values, const gdouble *values, gdouble offset), (pc, n_values, values, offset), 0 ) - - wxDL_METHOD_DEFINE( gint, gnome_print_rgbimage, - (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride), (pc, data, width, height, rowstride ), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_rgbaimage, - (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride), (pc, data, width, height, rowstride ), 0 ) - - wxDL_METHOD_DEFINE( gint, gnome_print_concat, - (GnomePrintContext *pc, const gdouble *matrix), (pc, matrix), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_scale, - (GnomePrintContext *pc, gdouble sx, gdouble sy), (pc, sx, sy), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_rotate, - (GnomePrintContext *pc, gdouble theta), (pc, theta), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_translate, - (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) - - wxDL_METHOD_DEFINE( gint, gnome_print_gsave, - (GnomePrintContext *pc), (pc), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_grestore, - (GnomePrintContext *pc), (pc), 0 ) - - wxDL_METHOD_DEFINE( gint, gnome_print_beginpage, - (GnomePrintContext *pc, const guchar* name), (pc, name), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_showpage, - (GnomePrintContext *pc), (pc), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_end_doc, - (GnomePrintContext *pc), (pc), 0 ) - - wxDL_METHOD_DEFINE( PangoLayout*, gnome_print_pango_create_layout, - (GnomePrintContext *gpc), (gpc), NULL ) - wxDL_METHOD_DEFINE( void, gnome_print_pango_layout, - (GnomePrintContext *gpc, PangoLayout *layout), (gpc, layout), /**/ ) - - wxDL_METHOD_DEFINE( GnomePrintJob*, gnome_print_job_new, - (GnomePrintConfig *config), (config), NULL ) - wxDL_METHOD_DEFINE( GnomePrintContext*, gnome_print_job_get_context, - (GnomePrintJob *job), (job), NULL ) - wxDL_METHOD_DEFINE( gint, gnome_print_job_close, - (GnomePrintJob *job), (job), 0 ) - wxDL_METHOD_DEFINE( gint, gnome_print_job_print, - (GnomePrintJob *job), (job), 0 ) - wxDL_METHOD_DEFINE( gboolean, gnome_print_job_get_page_size, - (GnomePrintJob *job, gdouble *width, gdouble *height), (job, width, height), 0 ) - - wxDL_METHOD_DEFINE( GnomePrintUnit*, gnome_print_unit_get_by_abbreviation, - (const guchar *abbreviation), (abbreviation), NULL ) - wxDL_METHOD_DEFINE( gboolean, gnome_print_convert_distance, - (gdouble *distance, const GnomePrintUnit *from, const GnomePrintUnit *to), (distance, from, to), false ) - - wxDL_METHOD_DEFINE( GnomePrintConfig*, gnome_print_config_default, - (void), (), NULL ) - wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set, - (GnomePrintConfig *config, const guchar *key, const guchar *value), (config, key, value), false ) - wxDL_METHOD_DEFINE( gboolean, gnome_print_config_get_length, - (GnomePrintConfig *config, const guchar *key, gdouble *val, const GnomePrintUnit **unit), (config, key, val, unit), false ) - - wxDL_METHOD_DEFINE( GtkWidget*, gnome_print_dialog_new, - (GnomePrintJob *gpj, const guchar *title, gint flags), (gpj, title, flags), NULL ) - wxDL_METHOD_DEFINE( void, gnome_print_dialog_construct_range_page, - (GnomePrintDialog *gpd, gint flags, gint start, gint end, - const guchar *currentlabel, const guchar *rangelabel), - (gpd, flags, start, end, currentlabel, rangelabel), /**/ ) - wxDL_METHOD_DEFINE( void, gnome_print_dialog_get_copies, - (GnomePrintDialog *gpd, gint *copies, gboolean *collate), (gpd, copies, collate), /**/ ) - wxDL_METHOD_DEFINE( void, gnome_print_dialog_set_copies, - (GnomePrintDialog *gpd, gint copies, gint collate), (gpd, copies, collate), /**/ ) - wxDL_METHOD_DEFINE( GnomePrintRangeType, gnome_print_dialog_get_range, - (GnomePrintDialog *gpd), (gpd), GNOME_PRINT_RANGETYPE_NONE ) - wxDL_METHOD_DEFINE( int, gnome_print_dialog_get_range_page, - (GnomePrintDialog *gpd, gint *start, gint *end), (gpd, start, end), 0 ) - - wxDL_METHOD_DEFINE( GtkWidget*, gnome_paper_selector_new_with_flags, - (GnomePrintConfig *config, gint flags), (config, flags), NULL ) - - wxDL_METHOD_DEFINE( GtkWidget*, gnome_print_job_preview_new, - (GnomePrintJob *gpm, const guchar *title), (gpm, title), NULL ) -}; - -wxGnomePrintLibrary::wxGnomePrintLibrary() -{ - m_gnome_print_lib = NULL; - m_gnome_printui_lib = NULL; - - wxLogNull log; - - m_gnome_print_lib = new wxDynamicLibrary( wxT("libgnomeprint-2-2.so.0") ); - m_ok = m_gnome_print_lib->IsLoaded(); - if (!m_ok) return; - - m_gnome_printui_lib = new wxDynamicLibrary( wxT("libgnomeprintui-2-2.so.0") ); - m_ok = m_gnome_printui_lib->IsLoaded(); - if (!m_ok) return; - - InitializeMethods(); -} - -wxGnomePrintLibrary::~wxGnomePrintLibrary() -{ - if (m_gnome_print_lib) - delete m_gnome_print_lib; - if (m_gnome_printui_lib) - delete m_gnome_printui_lib; -} - -bool wxGnomePrintLibrary::IsOk() -{ - return m_ok; -} - -void wxGnomePrintLibrary::InitializeMethods() -{ - m_ok = false; - bool success; - - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_newpath, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_moveto, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_lineto, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_curveto, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_arcto, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_closepath, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_stroke, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_fill, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_setrgbcolor, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_setlinewidth, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_setdash, success ) - - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_rgbimage, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_rgbaimage, success ) - - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_concat, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_scale, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_rotate, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_translate, success ) - - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_gsave, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_grestore, success ) - - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_beginpage, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_showpage, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_end_doc, success ) - - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_pango_create_layout, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_pango_layout, success ) - - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_new, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_get_context, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_close, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_print, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_get_page_size, success ) - - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_unit_get_by_abbreviation, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_convert_distance, success ) - - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_default, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_set, success ) - wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_get_length, success ) - - wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_new, success ) - wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_construct_range_page, success ) - wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_get_copies, success ) - wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_set_copies, success ) - wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_get_range, success ) - wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_get_range_page, success ) - - wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_paper_selector_new_with_flags, success ) - - wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_job_preview_new, success ) - - m_ok = true; -} - -static wxGnomePrintLibrary* gs_lgp = NULL; - -//---------------------------------------------------------------------------- -// wxGnomePrintNativeData -//---------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxGnomePrintNativeData, wxPrintNativeDataBase) - -wxGnomePrintNativeData::wxGnomePrintNativeData() -{ - m_config = gs_lgp->gnome_print_config_default(); - m_job = gs_lgp->gnome_print_job_new( m_config ); -} - -wxGnomePrintNativeData::~wxGnomePrintNativeData() -{ - g_object_unref (G_OBJECT (m_config)); -} - -bool wxGnomePrintNativeData::TransferTo( wxPrintData &data ) -{ - // TODO - return true; -} - -bool wxGnomePrintNativeData::TransferFrom( const wxPrintData &data ) -{ - // TODO - return true; -} - -//---------------------------------------------------------------------------- -// wxGnomePrintFactory -//---------------------------------------------------------------------------- - -wxPrinterBase* wxGnomePrintFactory::CreatePrinter( wxPrintDialogData *data ) -{ - return new wxGnomePrinter( data ); -} - -wxPrintPreviewBase *wxGnomePrintFactory::CreatePrintPreview( wxPrintout *preview, - wxPrintout *printout, - wxPrintDialogData *data ) -{ - return new wxPostScriptPrintPreview( preview, printout, data ); -} - -wxPrintPreviewBase *wxGnomePrintFactory::CreatePrintPreview( wxPrintout *preview, - wxPrintout *printout, - wxPrintData *data ) -{ - return new wxPostScriptPrintPreview( preview, printout, data ); -} - -wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent, - wxPrintDialogData *data ) -{ - return new wxGnomePrintDialog( parent, data ); -} - -wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent, - wxPrintData *data ) -{ - return new wxGnomePrintDialog( parent, data ); -} - -wxPageSetupDialogBase *wxGnomePrintFactory::CreatePageSetupDialog( wxWindow *parent, - wxPageSetupDialogData * data ) -{ -// The native page setup dialog is broken. It -// miscalculates newly entered values for the -// margins if you have not chose "points" but -// e.g. centimerters. -// This has been fixed in GNOME CVS (maybe -// fixed in libgnomeprintui 2.8.1) - - return new wxGnomePageSetupDialog( parent, data ); -} - -bool wxGnomePrintFactory::HasPrintSetupDialog() -{ - return false; -} - -wxDialog *wxGnomePrintFactory::CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ) -{ - return NULL; -} - -bool wxGnomePrintFactory::HasOwnPrintToFile() -{ - return true; -} - -bool wxGnomePrintFactory::HasPrinterLine() -{ - return true; -} - -wxString wxGnomePrintFactory::CreatePrinterLine() -{ - // redundant now - return wxEmptyString; -} - -bool wxGnomePrintFactory::HasStatusLine() -{ - // redundant now - return true; -} - -wxString wxGnomePrintFactory::CreateStatusLine() -{ - // redundant now - return wxEmptyString; -} - -wxPrintNativeDataBase *wxGnomePrintFactory::CreatePrintNativeData() -{ - return new wxGnomePrintNativeData; -} - -//---------------------------------------------------------------------------- -// wxGnomePrintSetupDialog -//---------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxGnomePrintDialog, wxPrintDialogBase) - -wxGnomePrintDialog::wxGnomePrintDialog( wxWindow *parent, wxPrintDialogData *data ) - : wxPrintDialogBase(parent, wxID_ANY, _("Print"), - wxPoint(0, 0), wxSize(600, 600), - wxDEFAULT_DIALOG_STYLE | - wxTAB_TRAVERSAL) -{ - if (data) - m_printDialogData = *data; - - Init(); -} - -wxGnomePrintDialog::wxGnomePrintDialog( wxWindow *parent, wxPrintData *data ) - : wxPrintDialogBase(parent, wxID_ANY, _("Print"), - wxPoint(0, 0), wxSize(600, 600), - wxDEFAULT_DIALOG_STYLE | - wxTAB_TRAVERSAL) -{ - if (data) - m_printDialogData = *data; - - Init(); -} - -void wxGnomePrintDialog::Init() -{ - wxPrintData data = m_printDialogData.GetPrintData(); - - wxGnomePrintNativeData *native = - (wxGnomePrintNativeData*) data.GetNativeData(); - - m_widget = gs_lgp->gnome_print_dialog_new( native->GetPrintJob(), - (guchar*)"Print", - GNOME_PRINT_DIALOG_RANGE|GNOME_PRINT_DIALOG_COPIES ); - - int flag = 0; - if (m_printDialogData.GetEnableSelection()) - flag |= GNOME_PRINT_RANGE_SELECTION; - if (m_printDialogData.GetEnablePageNumbers()) - flag |= GNOME_PRINT_RANGE_ALL|GNOME_PRINT_RANGE_RANGE; - - gs_lgp->gnome_print_dialog_construct_range_page( (GnomePrintDialog*) m_widget, - flag, - m_printDialogData.GetMinPage(), - m_printDialogData.GetMaxPage(), - NULL, - NULL ); -} - -wxGnomePrintDialog::~wxGnomePrintDialog() -{ - m_widget = NULL; -} - -int wxGnomePrintDialog::ShowModal() -{ - // Transfer data from m_printDalogData to dialog here - - int response = gtk_dialog_run (GTK_DIALOG (m_widget)); - - if (response == GNOME_PRINT_DIALOG_RESPONSE_CANCEL) - { - gtk_widget_destroy(m_widget); - m_widget = NULL; - - return wxID_CANCEL; - } - - gint copies = 1; - gboolean collate = false; - gs_lgp->gnome_print_dialog_get_copies( (GnomePrintDialog*) m_widget, &copies, &collate ); - m_printDialogData.SetNoCopies( copies ); - m_printDialogData.SetCollate( collate ); - - switch (gs_lgp->gnome_print_dialog_get_range( (GnomePrintDialog*) m_widget )) - { - case GNOME_PRINT_RANGE_SELECTION: - m_printDialogData.SetSelection( true ); - break; - case GNOME_PRINT_RANGE_ALL: - m_printDialogData.SetAllPages( true ); - m_printDialogData.SetFromPage( 0 ); - m_printDialogData.SetToPage( 9999 ); - break; - case GNOME_PRINT_RANGE_RANGE: - default: - gint start,end; - gs_lgp->gnome_print_dialog_get_range_page( (GnomePrintDialog*) m_widget, &start, &end ); - m_printDialogData.SetFromPage( start ); - m_printDialogData.SetToPage( end ); - break; - } - - gtk_widget_destroy(m_widget); - m_widget = NULL; - - if (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW) - return wxID_PREVIEW; - - return wxID_OK; -} - -wxDC *wxGnomePrintDialog::GetPrintDC() -{ - // Later - return NULL; -} - -bool wxGnomePrintDialog::Validate() -{ - return true; -} - -bool wxGnomePrintDialog::TransferDataToWindow() -{ - return true; -} - -bool wxGnomePrintDialog::TransferDataFromWindow() -{ - return true; -} - -//---------------------------------------------------------------------------- -// wxGnomePageSetupDialog -//---------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxGnomePageSetupDialog, wxPageSetupDialogBase) - -wxGnomePageSetupDialog::wxGnomePageSetupDialog( wxWindow *parent, - wxPageSetupDialogData* data ) -{ - if (data) - m_pageDialogData = *data; - - wxGnomePrintNativeData *native = - (wxGnomePrintNativeData*) m_pageDialogData.GetPrintData().GetNativeData(); - - // This is required as the page setup dialog - // calculates wrong values otherwise. - gs_lgp->gnome_print_config_set( native->GetPrintConfig(), - (const guchar*) GNOME_PRINT_KEY_PREFERED_UNIT, - (const guchar*) "Pts" ); - - m_widget = gtk_dialog_new(); - - gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( _("Page setup") ) ); - - GtkWidget *main = gs_lgp->gnome_paper_selector_new_with_flags( native->GetPrintConfig(), - GNOME_PAPER_SELECTOR_MARGINS|GNOME_PAPER_SELECTOR_FEED_ORIENTATION ); - gtk_container_set_border_width (GTK_CONTAINER (main), 8); - gtk_widget_show (main); - - gtk_container_add( GTK_CONTAINER (GTK_DIALOG (m_widget)->vbox), main ); - - gtk_dialog_set_has_separator (GTK_DIALOG (m_widget), TRUE); - - gtk_dialog_add_buttons (GTK_DIALOG (m_widget), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - - gtk_dialog_set_default_response (GTK_DIALOG (m_widget), - GTK_RESPONSE_OK); -} - -wxGnomePageSetupDialog::~wxGnomePageSetupDialog() -{ -} - -wxPageSetupDialogData& wxGnomePageSetupDialog::GetPageSetupDialogData() -{ - return m_pageDialogData; -} - -int wxGnomePageSetupDialog::ShowModal() -{ - wxGnomePrintNativeData *native = - (wxGnomePrintNativeData*) m_pageDialogData.GetPrintData().GetNativeData(); - GnomePrintConfig *config = native->GetPrintConfig(); - - // Transfer data from m_pageDialogData to native dialog - - int ret = gtk_dialog_run( GTK_DIALOG(m_widget) ); - - if (ret == GTK_RESPONSE_OK) - { - // Transfer data back to m_pageDialogData - - // I don't know how querying the last parameter works - // I cannot test it as the dialog is currently broken - // anyways (it only works for points). - double ml,mr,mt,mb,pw,ph; - gs_lgp->gnome_print_config_get_length (config, - (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_LEFT, &ml, NULL); - gs_lgp->gnome_print_config_get_length (config, - (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT, &mr, NULL); - gs_lgp->gnome_print_config_get_length (config, - (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_TOP, &mt, NULL); - gs_lgp->gnome_print_config_get_length (config, - (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, &mb, NULL); - gs_lgp->gnome_print_config_get_length (config, - (const guchar*) GNOME_PRINT_KEY_PAPER_WIDTH, &pw, NULL); - gs_lgp->gnome_print_config_get_length (config, - (const guchar*) GNOME_PRINT_KEY_PAPER_HEIGHT, &ph, NULL); - - // This probably assumes that the user entered the - // values in Pts. Since that is the only the dialog - // works right now, we need to fix this later. - const GnomePrintUnit *mm_unit = gs_lgp->gnome_print_unit_get_by_abbreviation( (const guchar*) "mm" ); - const GnomePrintUnit *pts_unit = gs_lgp->gnome_print_unit_get_by_abbreviation( (const guchar*) "Pts" ); - gs_lgp->gnome_print_convert_distance( &ml, pts_unit, mm_unit ); - gs_lgp->gnome_print_convert_distance( &mr, pts_unit, mm_unit ); - gs_lgp->gnome_print_convert_distance( &mt, pts_unit, mm_unit ); - gs_lgp->gnome_print_convert_distance( &mb, pts_unit, mm_unit ); - gs_lgp->gnome_print_convert_distance( &pw, pts_unit, mm_unit ); - gs_lgp->gnome_print_convert_distance( &ph, pts_unit, mm_unit ); - - m_pageDialogData.SetMarginTopLeft( wxPoint( (int)(ml+0.5), (int)(mt+0.5)) ); - m_pageDialogData.SetMarginBottomRight( wxPoint( (int)(mr+0.5), (int)(mb+0.5)) ); - - m_pageDialogData.SetPaperSize( wxSize( (int)(pw+0.5), (int)(ph+0.5) ) ); - -#if 0 - wxPrintf( wxT("paper %d %d, top margin %d\n"), - m_pageDialogData.GetPaperSize().x, - m_pageDialogData.GetPaperSize().y, - m_pageDialogData.GetMarginTopLeft().x ); -#endif - - ret = wxID_OK; - } - else - { - ret = wxID_CANCEL; - } - - gtk_widget_destroy( m_widget ); - m_widget = NULL; - - return ret; -} - -bool wxGnomePageSetupDialog::Validate() -{ - return true; -} - -bool wxGnomePageSetupDialog::TransferDataToWindow() -{ - return true; -} - -bool wxGnomePageSetupDialog::TransferDataFromWindow() -{ - return true; -} - -//---------------------------------------------------------------------------- -// wxGnomePrinter -//---------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxGnomePrinter, wxPrinterBase) - -wxGnomePrinter::wxGnomePrinter( wxPrintDialogData *data ) : - wxPrinterBase( data ) -{ - m_gpc = NULL; - m_native_preview = false; -} - -wxGnomePrinter::~wxGnomePrinter() -{ -} - -bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) -{ - if (!printout) - { - sm_lastError = wxPRINTER_ERROR; - return false; - } - - wxPrintData printdata = GetPrintDialogData().GetPrintData(); - wxGnomePrintNativeData *native = - (wxGnomePrintNativeData*) printdata.GetNativeData(); - - GnomePrintJob *job = gs_lgp->gnome_print_job_new( native->GetPrintConfig() ); - m_gpc = gs_lgp->gnome_print_job_get_context (job); - - // The GnomePrintJob is temporarily stored in the - // native print data as the native print dialog - // needs to access it. - native->SetPrintJob( job ); - - - printout->SetIsPreview(false); - - if (m_printDialogData.GetMinPage() < 1) - m_printDialogData.SetMinPage(1); - if (m_printDialogData.GetMaxPage() < 1) - m_printDialogData.SetMaxPage(9999); - - wxDC *dc; - if (prompt) - dc = PrintDialog( parent ); - else - dc = new wxGnomePrintDC( this ); - - if (m_native_preview) - printout->SetIsPreview(true); - - if (!dc) - { - gs_lgp->gnome_print_job_close( job ); - g_object_unref (G_OBJECT (job)); - sm_lastError = wxPRINTER_ERROR; - return false; - } - - wxSize ScreenPixels = wxGetDisplaySize(); - wxSize ScreenMM = wxGetDisplaySizeMM(); - - printout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()), - (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) ); - printout->SetPPIPrinter( wxGnomePrintDC::GetResolution(), - wxGnomePrintDC::GetResolution() ); - - printout->SetDC(dc); - - int w, h; - dc->GetSize(&w, &h); - printout->SetPageSizePixels((int)w, (int)h); - dc->GetSizeMM(&w, &h); - printout->SetPageSizeMM((int)w, (int)h); - - printout->OnPreparePrinting(); - - // Get some parameters from the printout, if defined - int fromPage, toPage; - int minPage, maxPage; - printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); - - if (maxPage == 0) - { - gs_lgp->gnome_print_job_close( job ); - g_object_unref (G_OBJECT (job)); - sm_lastError = wxPRINTER_ERROR; - return false; - } - - printout->OnBeginPrinting(); - - int minPageNum = minPage, maxPageNum = maxPage; - - if ( !m_printDialogData.GetAllPages() ) - { - minPageNum = m_printDialogData.GetFromPage(); - maxPageNum = m_printDialogData.GetToPage(); - } - - - int copyCount; - for ( copyCount = 1; - copyCount <= m_printDialogData.GetNoCopies(); - copyCount++ ) - { - if (!printout->OnBeginDocument(minPageNum, maxPageNum)) - { - wxLogError(_("Could not start printing.")); - sm_lastError = wxPRINTER_ERROR; - break; - } - - int pn; - for ( pn = minPageNum; - pn <= maxPageNum && printout->HasPage(pn); - pn++ ) - { - dc->StartPage(); - printout->OnPrintPage(pn); - dc->EndPage(); - } - - printout->OnEndDocument(); - printout->OnEndPrinting(); - } - - gs_lgp->gnome_print_job_close( job ); - if (m_native_preview) - { - wxString title( _("Print preview") ); - gtk_widget_show( gs_lgp->gnome_print_job_preview_new( job, (const guchar*)(const char*)wxGTK_CONV(title) )); - } - else - { - gs_lgp->gnome_print_job_print( job ); - } - - g_object_unref (G_OBJECT (job)); - delete dc; - - return (sm_lastError == wxPRINTER_NO_ERROR); -} - -wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent ) -{ - wxGnomePrintDialog dialog( parent, &m_printDialogData ); - int ret = dialog.ShowModal(); - if (ret == wxID_CANCEL) - { - sm_lastError = wxPRINTER_CANCELLED; - return NULL; - } - - m_native_preview = ret == wxID_PREVIEW; - - m_printDialogData = dialog.GetPrintDialogData(); - return new wxGnomePrintDC( this ); -} - -bool wxGnomePrinter::Setup( wxWindow *parent ) -{ - return false; -} - -//----------------------------------------------------------------------------- -// wxGnomePrintDC -//----------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxGnomePrintDC, wxDC) - -wxGnomePrintDC::wxGnomePrintDC( wxGnomePrinter *printer ) -{ - m_printer = printer; - - m_gpc = printer->GetPrintContext(); - - m_layout = gs_lgp->gnome_print_pango_create_layout( m_gpc ); - m_fontdesc = pango_font_description_from_string( "Sans 12" ); - - m_currentRed = 0; - m_currentBlue = 0; - m_currentGreen = 0; - - m_signX = 1; // default x-axis left to right - m_signY = -1; // default y-axis bottom up -> top down -} - -wxGnomePrintDC::~wxGnomePrintDC() -{ -} - -bool wxGnomePrintDC::Ok() const -{ - return true; -} - -bool wxGnomePrintDC::DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style ) -{ - return false; -} - -bool wxGnomePrintDC::DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const -{ - return false; -} - -void wxGnomePrintDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) -{ - if (m_pen.GetStyle() == wxTRANSPARENT) return; - - SetPen( m_pen ); - - gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(x1), YLOG2DEV(y1) ); - gs_lgp->gnome_print_lineto ( m_gpc, XLOG2DEV(x2), YLOG2DEV(y2) ); - gs_lgp->gnome_print_stroke ( m_gpc); - - CalcBoundingBox( x1, y1 ); - CalcBoundingBox( x2, y2 ); -} - -void wxGnomePrintDC::DoCrossHair(wxCoord x, wxCoord y) -{ -} - -void wxGnomePrintDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc) -{ - double dx = x1 - xc; - double dy = y1 - yc; - double radius = sqrt((double)(dx*dx+dy*dy)); - double alpha1, alpha2; - if (x1 == x2 && y1 == y2) - { - alpha1 = 0.0; - alpha2 = 360.0; - } - else - if (radius == 0.0) - { - alpha1 = alpha2 = 0.0; - } - else - { - alpha1 = (x1 - xc == 0) ? - (y1 - yc < 0) ? 90.0 : -90.0 : - -atan2(double(y1-yc), double(x1-xc)) * RAD2DEG; - alpha2 = (x2 - xc == 0) ? - (y2 - yc < 0) ? 90.0 : -90.0 : - -atan2(double(y2-yc), double(x2-xc)) * RAD2DEG; - - while (alpha1 <= 0) alpha1 += 360; - while (alpha2 <= 0) alpha2 += 360; // adjust angles to be between - while (alpha1 > 360) alpha1 -= 360; // 0 and 360 degree - while (alpha2 > 360) alpha2 -= 360; - } - - if (m_brush.GetStyle() != wxTRANSPARENT) - { - SetBrush( m_brush ); - gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc) ); - gs_lgp->gnome_print_arcto( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL((int)radius), alpha1, alpha2, 0 ); - - gs_lgp->gnome_print_fill( m_gpc ); - } - - if (m_pen.GetStyle() != wxTRANSPARENT) - { - SetPen (m_pen); - gs_lgp->gnome_print_newpath( m_gpc ); - gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc) ); - gs_lgp->gnome_print_arcto( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL((int)radius), alpha1, alpha2, 0 ); - gs_lgp->gnome_print_closepath( m_gpc ); - - gs_lgp->gnome_print_stroke( m_gpc ); - } - - CalcBoundingBox (x1, y1); - CalcBoundingBox (x2, y2); - CalcBoundingBox (xc, yc); -} - -void wxGnomePrintDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) -{ - x += w/2; - y += h/2; - - int xx = XLOG2DEV(x); - int yy = YLOG2DEV(y); - - gs_lgp->gnome_print_gsave( m_gpc ); - - gs_lgp->gnome_print_translate( m_gpc, xx, yy ); - double scale = (double)YLOG2DEVREL(h) / (double) XLOG2DEVREL(w); - gs_lgp->gnome_print_scale( m_gpc, 1.0, scale ); - - xx = 0; - yy = 0; - - if (m_brush.GetStyle () != wxTRANSPARENT) - { - SetBrush( m_brush ); - - gs_lgp->gnome_print_moveto ( m_gpc, xx, yy ); - gs_lgp->gnome_print_arcto( m_gpc, xx, yy, - XLOG2DEVREL(w)/2, sa, ea, 0 ); - gs_lgp->gnome_print_moveto ( m_gpc, xx, yy ); - - gs_lgp->gnome_print_fill( m_gpc ); - } - - if (m_pen.GetStyle () != wxTRANSPARENT) - { - SetPen (m_pen); - - gs_lgp->gnome_print_arcto( m_gpc, xx, yy, - XLOG2DEVREL(w)/2, sa, ea, 0 ); - - gs_lgp->gnome_print_stroke( m_gpc ); - } - - gs_lgp->gnome_print_grestore( m_gpc ); - - CalcBoundingBox( x, y ); - CalcBoundingBox( x+w, y+h ); -} - -void wxGnomePrintDC::DoDrawPoint(wxCoord x, wxCoord y) -{ -} - -void wxGnomePrintDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) -{ - if (m_pen.GetStyle() == wxTRANSPARENT) return; - - if (n <= 0) return; - - SetPen (m_pen); - - int i; - for ( i =0; ignome_print_moveto ( m_gpc, XLOG2DEV(points[0].x+xoffset), YLOG2DEV(points[0].y+yoffset) ); - - for (i = 1; i < n; i++) - gs_lgp->gnome_print_lineto ( m_gpc, XLOG2DEV(points[i].x+xoffset), YLOG2DEV(points[i].y+yoffset) ); - - gs_lgp->gnome_print_stroke ( m_gpc); -} - -void wxGnomePrintDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) -{ - if (n==0) return; - - if (m_brush.GetStyle () != wxTRANSPARENT) - { - SetBrush( m_brush ); - - int x = points[0].x + xoffset; - int y = points[0].y + yoffset; - CalcBoundingBox( x, y ); - gs_lgp->gnome_print_newpath( m_gpc ); - gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); - int i; - for (i = 1; i < n; i++) - { - int x = points[i].x + xoffset; - int y = points[i].y + yoffset; - gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); - CalcBoundingBox( x, y ); - } - gs_lgp->gnome_print_closepath( m_gpc ); - gs_lgp->gnome_print_fill( m_gpc ); - } - - if (m_pen.GetStyle () != wxTRANSPARENT) - { - SetPen (m_pen); - - int x = points[0].x + xoffset; - int y = points[0].y + yoffset; - gs_lgp->gnome_print_newpath( m_gpc ); - gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); - int i; - for (i = 1; i < n; i++) - { - int x = points[i].x + xoffset; - int y = points[i].y + yoffset; - gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); - CalcBoundingBox( x, y ); - } - gs_lgp->gnome_print_closepath( m_gpc ); - gs_lgp->gnome_print_stroke( m_gpc ); - } -} - -void wxGnomePrintDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) -{ - wxDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); -} - -void wxGnomePrintDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) -{ - if (m_brush.GetStyle () != wxTRANSPARENT) - { - SetBrush( m_brush ); - - gs_lgp->gnome_print_newpath( m_gpc ); - gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); - gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y) ); - gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y + height) ); - gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y + height) ); - gs_lgp->gnome_print_closepath( m_gpc ); - gs_lgp->gnome_print_fill( m_gpc ); - - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); - } - - if (m_pen.GetStyle () != wxTRANSPARENT) - { - SetPen (m_pen); - - gs_lgp->gnome_print_newpath( m_gpc ); - gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); - gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y) ); - gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y + height) ); - gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y + height) ); - gs_lgp->gnome_print_closepath( m_gpc ); - gs_lgp->gnome_print_stroke( m_gpc ); - - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); - } -} - -void wxGnomePrintDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) -{ - wxCoord rad = (wxCoord) radius; - - if (m_brush.GetStyle() != wxTRANSPARENT) - { - SetBrush(m_brush); - gs_lgp->gnome_print_newpath(m_gpc); - gs_lgp->gnome_print_moveto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y)); - gs_lgp->gnome_print_curveto(m_gpc, - XLOG2DEV(x + rad),YLOG2DEV(y), - XLOG2DEV(x),YLOG2DEV(y), - XLOG2DEV(x),YLOG2DEV(y + rad)); - gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x),YLOG2DEV(y + height - rad)); - gs_lgp->gnome_print_curveto(m_gpc, - XLOG2DEV(x),YLOG2DEV(y + height - rad), - XLOG2DEV(x),YLOG2DEV(y + height), - XLOG2DEV(x + rad),YLOG2DEV(y + height)); - gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width - rad),YLOG2DEV(y + height)); - gs_lgp->gnome_print_curveto(m_gpc, - XLOG2DEV(x + width - rad),YLOG2DEV(y + height), - XLOG2DEV(x + width),YLOG2DEV(y + height), - XLOG2DEV(x + width),YLOG2DEV(y + height - rad)); - gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width),YLOG2DEV(y + rad)); - gs_lgp->gnome_print_curveto(m_gpc, - XLOG2DEV(x + width),YLOG2DEV(y + rad), - XLOG2DEV(x + width),YLOG2DEV(y), - XLOG2DEV(x + width - rad),YLOG2DEV(y)); - gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y)); - gs_lgp->gnome_print_closepath(m_gpc); - gs_lgp->gnome_print_fill(m_gpc); - - CalcBoundingBox(x,y); - CalcBoundingBox(x+width,y+height); - } - - if (m_pen.GetStyle() != wxTRANSPARENT) - { - SetPen(m_pen); - gs_lgp->gnome_print_newpath(m_gpc); - gs_lgp->gnome_print_moveto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y)); - gs_lgp->gnome_print_curveto(m_gpc, - XLOG2DEV(x + rad),YLOG2DEV(y), - XLOG2DEV(x),YLOG2DEV(y), - XLOG2DEV(x),YLOG2DEV(y + rad)); - gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x),YLOG2DEV(y + height - rad)); - gs_lgp->gnome_print_curveto(m_gpc, - XLOG2DEV(x),YLOG2DEV(y + height - rad), - XLOG2DEV(x),YLOG2DEV(y + height), - XLOG2DEV(x + rad),YLOG2DEV(y + height)); - gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width - rad),YLOG2DEV(y + height)); - gs_lgp->gnome_print_curveto(m_gpc, - XLOG2DEV(x + width - rad),YLOG2DEV(y + height), - XLOG2DEV(x + width),YLOG2DEV(y + height), - XLOG2DEV(x + width),YLOG2DEV(y + height - rad)); - gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width),YLOG2DEV(y + rad)); - gs_lgp->gnome_print_curveto(m_gpc, - XLOG2DEV(x + width),YLOG2DEV(y + rad), - XLOG2DEV(x + width),YLOG2DEV(y), - XLOG2DEV(x + width - rad),YLOG2DEV(y)); - gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y)); - gs_lgp->gnome_print_closepath(m_gpc); - gs_lgp->gnome_print_stroke(m_gpc); - - CalcBoundingBox(x,y); - CalcBoundingBox(x+width,y+height); - } -} - -void wxGnomePrintDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) -{ - if (m_brush.GetStyle () != wxTRANSPARENT) - { - SetBrush( m_brush ); - - gs_lgp->gnome_print_newpath( m_gpc ); - gs_lgp->gnome_print_moveto( m_gpc, - XLOG2DEV(x), YLOG2DEV(y+height/2) ); - - // start with top half - gs_lgp->gnome_print_curveto( m_gpc, - XLOG2DEV(x), YLOG2DEV(y), - XLOG2DEV(x+width), YLOG2DEV(y), - XLOG2DEV(x+width), YLOG2DEV(y+height/2) ); - // lower half - gs_lgp->gnome_print_curveto( m_gpc, - XLOG2DEV(x+width), YLOG2DEV(y+height), - XLOG2DEV(x), YLOG2DEV(y+height), - XLOG2DEV(x), YLOG2DEV(y+height/2) ); - - gs_lgp->gnome_print_closepath( m_gpc ); - gs_lgp->gnome_print_fill( m_gpc ); - - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); - } - - if (m_pen.GetStyle () != wxTRANSPARENT) - { - SetPen (m_pen); - - gs_lgp->gnome_print_newpath( m_gpc ); - gs_lgp->gnome_print_moveto( m_gpc, - XLOG2DEV(x), YLOG2DEV(y+height/2) ); - - // start with top half - gs_lgp->gnome_print_curveto( m_gpc, - XLOG2DEV(x), YLOG2DEV(y), - XLOG2DEV(x+width), YLOG2DEV(y), - XLOG2DEV(x+width), YLOG2DEV(y+height/2) ); - // lower half - gs_lgp->gnome_print_curveto( m_gpc, - XLOG2DEV(x+width), YLOG2DEV(y+height), - XLOG2DEV(x), YLOG2DEV(y+height), - XLOG2DEV(x), YLOG2DEV(y+height/2) ); - - gs_lgp->gnome_print_closepath( m_gpc ); - gs_lgp->gnome_print_stroke( m_gpc ); - - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); - } -} - -#if wxUSE_SPLINES -void wxGnomePrintDC::DoDrawSpline(wxList *points) -{ - SetPen (m_pen); - - double c, d, x1, y1, x2, y2, x3, y3; - wxPoint *p, *q; - - wxList::compatibility_iterator node = points->GetFirst(); - p = (wxPoint *)node->GetData(); - x1 = p->x; - y1 = p->y; - - node = node->GetNext(); - p = (wxPoint *)node->GetData(); - c = p->x; - d = p->y; - x3 = - (double)(x1 + c) / 2; - y3 = - (double)(y1 + d) / 2; - - gs_lgp->gnome_print_newpath( m_gpc ); - gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV((wxCoord)x1), YLOG2DEV((wxCoord)y1) ); - gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) ); - - CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 ); - CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 ); - - node = node->GetNext(); - while (node) - { - q = (wxPoint *)node->GetData(); - - x1 = x3; - y1 = y3; - x2 = c; - y2 = d; - c = q->x; - d = q->y; - x3 = (double)(x2 + c) / 2; - y3 = (double)(y2 + d) / 2; - - gs_lgp->gnome_print_curveto(m_gpc, - XLOG2DEV((wxCoord)x1), YLOG2DEV((wxCoord)y1), - XLOG2DEV((wxCoord)x2), YLOG2DEV((wxCoord)y2), - XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) ); - - CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 ); - CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 ); - - node = node->GetNext(); - } - - gs_lgp->gnome_print_lineto ( m_gpc, XLOG2DEV((wxCoord)c), YLOG2DEV((wxCoord)d) ); - - gs_lgp->gnome_print_stroke( m_gpc ); -} -#endif // wxUSE_SPLINES - -bool wxGnomePrintDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask, - wxCoord xsrcMask, wxCoord ysrcMask) -{ - wxCHECK_MSG( source, false, wxT("invalid source dc") ); - - // blit into a bitmap - wxBitmap bitmap( width, height ); - wxMemoryDC memDC; - memDC.SelectObject(bitmap); - memDC.Blit(0, 0, width, height, source, xsrc, ysrc, rop); /* TODO: Blit transparently? */ - memDC.SelectObject(wxNullBitmap); - - // draw bitmap. scaling and positioning is done there - DrawBitmap( bitmap, xdest, ydest ); - - return true; -} - -void wxGnomePrintDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) -{ - DoDrawBitmap( icon, x, y, true ); -} - -void wxGnomePrintDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask ) -{ - if (!bitmap.Ok()) return; - - if (bitmap.HasPixbuf()) - { - GdkPixbuf *pixbuf = bitmap.GetPixbuf(); - guchar *raw_image = gdk_pixbuf_get_pixels( pixbuf ); - bool has_alpha = gdk_pixbuf_get_has_alpha( pixbuf ); - int rowstride = gdk_pixbuf_get_rowstride( pixbuf ); - int height = gdk_pixbuf_get_height( pixbuf ); - int width = gdk_pixbuf_get_width( pixbuf ); - - gs_lgp->gnome_print_gsave( m_gpc ); - double matrix[6]; - matrix[0] = XLOG2DEVREL(width); - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = YLOG2DEVREL(height); - matrix[4] = XLOG2DEV(x); - matrix[5] = YLOG2DEV(y+height); - gs_lgp->gnome_print_concat( m_gpc, matrix ); - gs_lgp->gnome_print_moveto( m_gpc, 0, 0 ); - if (has_alpha) - gs_lgp->gnome_print_rgbaimage( m_gpc, (guchar *)raw_image, width, height, rowstride ); - else - gs_lgp->gnome_print_rgbimage( m_gpc, (guchar *)raw_image, width, height, rowstride ); - gs_lgp->gnome_print_grestore( m_gpc ); - } - else - { - wxImage image = bitmap.ConvertToImage(); - - if (!image.Ok()) return; - - gs_lgp->gnome_print_gsave( m_gpc ); - double matrix[6]; - matrix[0] = XLOG2DEVREL(image.GetWidth()); - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = YLOG2DEVREL(image.GetHeight()); - matrix[4] = XLOG2DEV(x); - matrix[5] = YLOG2DEV(y+image.GetHeight()); - gs_lgp->gnome_print_concat( m_gpc, matrix ); - gs_lgp->gnome_print_moveto( m_gpc, 0, 0 ); - gs_lgp->gnome_print_rgbimage( m_gpc, (guchar*) image.GetData(), image.GetWidth(), image.GetHeight(), image.GetWidth()*3 ); - gs_lgp->gnome_print_grestore( m_gpc ); - } -} - -void wxGnomePrintDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y ) -{ - DoDrawRotatedText( text, x, y, 0.0 ); -} - -void wxGnomePrintDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) -{ - x = XLOG2DEV(x); - y = YLOG2DEV(y); - - bool underlined = m_font.Ok() && m_font.GetUnderlined(); - -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); - if ( !wdata ) - return; - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); -#endif - - size_t datalen = strlen((const char*)data); - pango_layout_set_text( m_layout, (const char*) data, datalen); - - if (underlined) - { - PangoAttrList *attrs = pango_attr_list_new(); - PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE); - a->start_index = 0; - a->end_index = datalen; - pango_attr_list_insert(attrs, a); - pango_layout_set_attributes(m_layout, attrs); - pango_attr_list_unref(attrs); - } - - if (m_textForegroundColour.Ok()) - { - unsigned char red = m_textForegroundColour.Red(); - unsigned char blue = m_textForegroundColour.Blue(); - unsigned char green = m_textForegroundColour.Green(); - - if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue)) - { - double redPS = (double)(red) / 255.0; - double bluePS = (double)(blue) / 255.0; - double greenPS = (double)(green) / 255.0; - - gs_lgp->gnome_print_setrgbcolor( m_gpc, redPS, greenPS, bluePS ); - - m_currentRed = red; - m_currentBlue = blue; - m_currentGreen = green; - } - } - - int w,h; - - if (fabs(m_scaleY - 1.0) > 0.00001) - { - // If there is a user or actually any scale applied to - // the device context, scale the font. - - // scale font description - gint oldSize = pango_font_description_get_size( m_fontdesc ); - double size = oldSize; - size = size * m_scaleY; - pango_font_description_set_size( m_fontdesc, (gint)size ); - - // actually apply scaled font - pango_layout_set_font_description( m_layout, m_fontdesc ); - - pango_layout_get_pixel_size( m_layout, &w, &h ); -#if 0 - if ( m_backgroundMode == wxSOLID ) - { - gdk_gc_set_foreground(m_textGC, m_textBackgroundColour.GetColor()); - gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h); - gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor()); - } -#endif - // Draw layout. - gs_lgp->gnome_print_moveto (m_gpc, x, y); - if (fabs(angle) > 0.00001) - { - gs_lgp->gnome_print_gsave( m_gpc ); - gs_lgp->gnome_print_rotate( m_gpc, angle ); - gs_lgp->gnome_print_pango_layout( m_gpc, m_layout ); - gs_lgp->gnome_print_grestore( m_gpc ); - } - else - { - gs_lgp->gnome_print_pango_layout( m_gpc, m_layout ); - } - - // reset unscaled size - pango_font_description_set_size( m_fontdesc, oldSize ); - - // actually apply unscaled font - pango_layout_set_font_description( m_layout, m_fontdesc ); - } - else - { - pango_layout_get_pixel_size( m_layout, &w, &h ); -#if 0 - if ( m_backgroundMode == wxSOLID ) - { - gdk_gc_set_foreground(m_textGC, m_textBackgroundColour.GetColor()); - gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h); - gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor()); - } -#endif - // Draw layout. - gs_lgp->gnome_print_moveto (m_gpc, x, y); - if (fabs(angle) > 0.00001) - { - gs_lgp->gnome_print_gsave( m_gpc ); - gs_lgp->gnome_print_rotate( m_gpc, angle ); - gs_lgp->gnome_print_pango_layout( m_gpc, m_layout ); - gs_lgp->gnome_print_grestore( m_gpc ); - } - else - { - gs_lgp->gnome_print_pango_layout( m_gpc, m_layout ); - } - } - - if (underlined) - { - // undo underline attributes setting: - pango_layout_set_attributes(m_layout, NULL); - } - - CalcBoundingBox (x + w, y + h); -} - -void wxGnomePrintDC::Clear() -{ -} - -void wxGnomePrintDC::SetFont( const wxFont& font ) -{ - m_font = font; - - if (m_font.Ok()) - { - if (m_fontdesc) - pango_font_description_free( m_fontdesc ); - - m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description ); - - pango_layout_set_font_description( m_layout, m_fontdesc ); - } -} - -void wxGnomePrintDC::SetPen( const wxPen& pen ) -{ - if (!pen.Ok()) return; - - m_pen = pen; - - gs_lgp->gnome_print_setlinewidth( m_gpc, XLOG2DEVREL( 1000 * m_pen.GetWidth() ) / 1000.0f ); - - static const double dotted[] = {2.0, 5.0}; - static const double short_dashed[] = {4.0, 4.0}; - static const double wxCoord_dashed[] = {4.0, 8.0}; - static const double dotted_dashed[] = {6.0, 6.0, 2.0, 6.0}; - - switch (m_pen.GetStyle()) - { - case wxDOT: gs_lgp->gnome_print_setdash( m_gpc, 2, dotted, 0 ); break; - case wxSHORT_DASH: gs_lgp->gnome_print_setdash( m_gpc, 2, short_dashed, 0 ); break; - case wxLONG_DASH: gs_lgp->gnome_print_setdash( m_gpc, 2, wxCoord_dashed, 0 ); break; - case wxDOT_DASH: gs_lgp->gnome_print_setdash( m_gpc, 4, dotted_dashed, 0 ); break; - case wxSOLID: - case wxTRANSPARENT: - default: gs_lgp->gnome_print_setdash( m_gpc, 0, NULL, 0 ); break; - } - - - unsigned char red = m_pen.GetColour().Red(); - unsigned char blue = m_pen.GetColour().Blue(); - unsigned char green = m_pen.GetColour().Green(); - - if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue)) - { - double redPS = (double)(red) / 255.0; - double bluePS = (double)(blue) / 255.0; - double greenPS = (double)(green) / 255.0; - - gs_lgp->gnome_print_setrgbcolor( m_gpc, redPS, greenPS, bluePS ); - - m_currentRed = red; - m_currentBlue = blue; - m_currentGreen = green; - } -} - -void wxGnomePrintDC::SetBrush( const wxBrush& brush ) -{ - if (!brush.Ok()) return; - - m_brush = brush; - - // Brush colour - unsigned char red = m_brush.GetColour().Red(); - unsigned char blue = m_brush.GetColour().Blue(); - unsigned char green = m_brush.GetColour().Green(); - - if (!m_colour) - { - // Anything not white is black - if (! (red == (unsigned char) 255 && - blue == (unsigned char) 255 && - green == (unsigned char) 255) ) - { - red = (unsigned char) 0; - green = (unsigned char) 0; - blue = (unsigned char) 0; - } - // setgray here ? - } - - if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue)) - { - double redPS = (double)(red) / 255.0; - double bluePS = (double)(blue) / 255.0; - double greenPS = (double)(green) / 255.0; - - gs_lgp->gnome_print_setrgbcolor( m_gpc, redPS, greenPS, bluePS ); - - m_currentRed = red; - m_currentBlue = blue; - m_currentGreen = green; - } -} - -void wxGnomePrintDC::SetLogicalFunction( int function ) -{ -} - -void wxGnomePrintDC::SetBackground( const wxBrush& brush ) -{ -} - -void wxGnomePrintDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) -{ -} - -void wxGnomePrintDC::DestroyClippingRegion() -{ -} - -bool wxGnomePrintDC::StartDoc(const wxString& message) -{ - SetDeviceOrigin( 0,0 ); - - return true; -} - -void wxGnomePrintDC::EndDoc() -{ - gs_lgp->gnome_print_end_doc( m_gpc ); -} - -void wxGnomePrintDC::StartPage() -{ - gs_lgp->gnome_print_beginpage( m_gpc, (const guchar*) "page" ); -} - -void wxGnomePrintDC::EndPage() -{ - gs_lgp->gnome_print_showpage( m_gpc ); -} - -wxCoord wxGnomePrintDC::GetCharHeight() const -{ - pango_layout_set_text( m_layout, "H", 1 ); - - int w,h; - pango_layout_get_pixel_size( m_layout, &w, &h ); - - return h; -} - -wxCoord wxGnomePrintDC::GetCharWidth() const -{ - pango_layout_set_text( m_layout, "H", 1 ); - - int w,h; - pango_layout_get_pixel_size( m_layout, &w, &h ); - - return w; -} - -void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height, - wxCoord *descent, - wxCoord *externalLeading, - wxFont *theFont ) const -{ - if ( width ) - *width = 0; - if ( height ) - *height = 0; - if ( descent ) - *descent = 0; - if ( externalLeading ) - *externalLeading = 0; - - if (string.empty()) - { - return; - } - - // Set new font description - if (theFont) - pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description ); - - // Set layout's text -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); - const char *dataUTF8 = (const char *)data; -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); - if ( !wdata ) - { - if (width) (*width) = 0; - if (height) (*height) = 0; - return; - } - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - const char *dataUTF8 = (const char *)data; -#endif - - if ( !dataUTF8 ) - { - // hardly ideal, but what else can we do if conversion failed? - return; - } - - pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) ); - - int w,h; - pango_layout_get_pixel_size( m_layout, &w, &h ); - - if (width) - *width = (wxCoord)(w / m_scaleX); - if (height) - *height = (wxCoord)(h / m_scaleY); - if (descent) - { - PangoLayoutIter *iter = pango_layout_get_iter(m_layout); - int baseline = pango_layout_iter_get_baseline(iter); - pango_layout_iter_free(iter); - *descent = h - PANGO_PIXELS(baseline); - } - - // Reset old font description - if (theFont) - pango_layout_set_font_description( m_layout, m_fontdesc ); -} - -void wxGnomePrintDC::DoGetSize(int* width, int* height) const -{ - wxGnomePrintNativeData *native = - (wxGnomePrintNativeData*) m_printData.GetNativeData(); - - // Query page size. This seems to omit the margins - // right now, although it shouldn't - double pw,ph; - gs_lgp->gnome_print_job_get_page_size( native->GetPrintJob(), &pw, &ph ); - - if (width) - *width = (int) (pw + 0.5); - if (height) - *height = (int) (ph + 0.5); -} - -void wxGnomePrintDC::DoGetSizeMM(int *width, int *height) const -{ - wxGnomePrintNativeData *native = - (wxGnomePrintNativeData*) m_printData.GetNativeData(); - - // This code assumes values in Pts. - - double pw,ph; - gs_lgp->gnome_print_job_get_page_size( native->GetPrintJob(), &pw, &ph ); - - // Convert to mm. - - const GnomePrintUnit *mm_unit = gs_lgp->gnome_print_unit_get_by_abbreviation( (const guchar*) "mm" ); - const GnomePrintUnit *pts_unit = gs_lgp->gnome_print_unit_get_by_abbreviation( (const guchar*) "Pts" ); - gs_lgp->gnome_print_convert_distance( &pw, pts_unit, mm_unit ); - gs_lgp->gnome_print_convert_distance( &ph, pts_unit, mm_unit ); - - if (width) - *width = (int) (pw + 0.5); - if (height) - *height = (int) (ph + 0.5); -} - -wxSize wxGnomePrintDC::GetPPI() const -{ - return wxSize(72,72); -} - -void wxGnomePrintDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) -{ - m_signX = (xLeftRight ? 1 : -1); - m_signY = (yBottomUp ? 1 : -1); - - ComputeScaleAndOrigin(); -} - -void wxGnomePrintDC::SetDeviceOrigin( wxCoord x, wxCoord y ) -{ - int h = 0; - int w = 0; - GetSize( &w, &h ); - - wxDC::SetDeviceOrigin( x, h-y ); -} - -void wxGnomePrintDC::SetResolution(int ppi) -{ -} - -int wxGnomePrintDC::GetResolution() -{ - return 72; -} - - -class wxGnomePrintModule: public wxModule -{ -public: - wxGnomePrintModule() {} - bool OnInit(); - void OnExit(); - -private: - DECLARE_DYNAMIC_CLASS(wxGnomePrintModule) -}; - -bool wxGnomePrintModule::OnInit() -{ - gs_lgp = new wxGnomePrintLibrary; - if (gs_lgp->IsOk()) - wxPrintFactory::SetPrintFactory( new wxGnomePrintFactory ); - return true; -} - -void wxGnomePrintModule::OnExit() -{ - delete gs_lgp; -} - -IMPLEMENT_DYNAMIC_CLASS(wxGnomePrintModule, wxModule) - -#endif - // wxUSE_LIBGNOMEPRINT diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index 40fb0c0a0c..f88efbcf38 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/listbox.cpp +// Name: src/gtk1/listbox.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -21,7 +21,7 @@ #include "wx/intl.h" #include "wx/checklst.h" #include "wx/settings.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #if wxUSE_TOOLTIPS #include "wx/tooltip.h" @@ -887,16 +887,12 @@ wxString wxListBox::GetRealLabel(GList *item) const wxString str; -#ifdef __WXGTK20__ - str = wxGTK_CONV_BACK( gtk_label_get_text( label ) ); -#else str = wxString( label->label ); -#endif #if wxUSE_CHECKLISTBOX // checklistboxes have "[±] " prepended to their lables, remove it // - // NB: 4 below is the length of wxCHECKLBOX_STRING from wx/gtk/checklst.h + // NB: 4 below is the length of wxCHECKLBOX_STRING from wx/gtk1/checklst.h if ( m_hasCheckBoxes ) str.erase(0, 4); #endif // wxUSE_CHECKLISTBOX diff --git a/src/gtk1/mdi.cpp b/src/gtk1/mdi.cpp index 0b0c9d4abb..9f853fcae7 100644 --- a/src/gtk1/mdi.cpp +++ b/src/gtk1/mdi.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/mdi.cpp +// Name: src/gtk1/mdi.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -18,12 +18,12 @@ #include "wx/dialog.h" #include "wx/menu.h" #include "wx/intl.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include #include #include -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/win_gtk.h" //----------------------------------------------------------------------------- // constants diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 2a2e7bdc25..9db5c31b27 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -20,34 +20,19 @@ #include "wx/accel.h" #endif // wxUSE_ACCEL -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include -// FIXME: is this right? somehow I don't think so (VZ) -#ifdef __WXGTK20__ - #include - - #define gtk_accel_group_attach(g, o) gtk_window_add_accel_group((o), (g)) - #define gtk_accel_group_detach(g, o) gtk_window_remove_accel_group((o), (g)) - #define gtk_menu_ensure_uline_accel_group(m) gtk_menu_get_accel_group(m) - - #define ACCEL_OBJECT GtkWindow - #define ACCEL_OBJECTS(a) (a)->acceleratables - #define ACCEL_OBJ_CAST(obj) ((GtkWindow*) obj) -#else // GTK+ 1.x - #define ACCEL_OBJECT GtkObject - #define ACCEL_OBJECTS(a) (a)->attach_objects - #define ACCEL_OBJ_CAST(obj) GTK_OBJECT(obj) -#endif +#define ACCEL_OBJECT GtkObject +#define ACCEL_OBJECTS(a) (a)->attach_objects +#define ACCEL_OBJ_CAST(obj) GTK_OBJECT(obj) // we use normal item but with a special id for the menu title static const int wxGTK_TITLE_ID = -3; // defined in window.cpp -#ifndef __WXGTK20__ - extern guint32 wxGtkTimeLastClick; -#endif +extern guint32 wxGtkTimeLastClick; //----------------------------------------------------------------------------- // idle system @@ -167,9 +152,7 @@ void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long st } m_menubar = gtk_menu_bar_new(); -#ifndef __WXGTK20__ m_accel = gtk_accel_group_new(); -#endif if (style & wxMB_DOCKABLE) { @@ -227,10 +210,8 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win ) while (top_frame->GetParent() && !(top_frame->IsTopLevel())) top_frame = top_frame->GetParent(); -#ifndef __WXGTK20__ // support for native hot keys gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) ); -#endif wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) @@ -272,12 +253,10 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win ) while (top_frame->GetParent() && !(top_frame->IsTopLevel())) top_frame = top_frame->GetParent(); -#ifndef __WXGTK20__ // support for native key accelerators indicated by underscroes ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget); if ( !g_slist_find( ACCEL_OBJECTS(m_accel), obj ) ) gtk_accel_group_attach( m_accel, obj ); -#endif wxMenuList::compatibility_iterator node = m_menus.GetFirst(); while (node) @@ -295,10 +274,8 @@ void wxMenuBar::UnsetInvokingWindow( wxWindow *win ) while (top_frame->GetParent() && !(top_frame->IsTopLevel())) top_frame = top_frame->GetParent(); -#ifndef __WXGTK20__ // support for native key accelerators indicated by underscroes gtk_accel_group_detach( m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) ); -#endif wxMenuList::compatibility_iterator node = m_menus.GetFirst(); while (node) @@ -325,9 +302,6 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos) menu->SetTitle( str ); // The "m_owner" is the "menu item" -#ifdef __WXGTK20__ - menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) ); -#else menu->m_owner = gtk_menu_item_new_with_label( wxGTK_CONV( str ) ); GtkLabel *label = GTK_LABEL( GTK_BIN(menu->m_owner)->child ); // set new text @@ -343,7 +317,6 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos) GDK_MOD1_MASK, GTK_ACCEL_LOCKED); } -#endif gtk_widget_show( menu->m_owner ); @@ -774,16 +747,6 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text) continue; } -#ifdef __WXGTK20__ - if ( *pc == wxT('\\') ) - { - // GTK 2.0 escapes "xxx/xxx" to "xxx\/xxx" - pc++; - label += *pc; - continue; - } -#endif - if ( (*pc == wxT('&')) && (*(pc+1) != wxT('&')) ) { // wxMSW escapes "&" @@ -823,16 +786,12 @@ void wxMenuItem::SetText( const wxString& str ) else label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); -#ifdef __WXGTK20__ - gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV(m_text) ); -#else // set new text gtk_label_set( label, wxGTK_CONV( m_text ) ); // reparse key accel (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); -#endif } guint accel_key; @@ -1013,51 +972,22 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) GtkWidget *menuItem; wxString text; -#ifndef __WXGTK20__ GtkLabel* label; -#endif if ( mitem->IsSeparator() ) { -#ifdef __WXGTK20__ - menuItem = gtk_separator_menu_item_new(); -#else // TODO menuItem = gtk_menu_item_new(); -#endif } else if (mitem->GetBitmap().Ok()) { text = mitem->GetText(); const wxBitmap *bitmap = &mitem->GetBitmap(); -#ifdef __WXGTK20__ - menuItem = gtk_image_menu_item_new_with_mnemonic( wxGTK_CONV( text ) ); - - GtkWidget *image; - if (bitmap->HasPixbuf()) - { - image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf()); - } - else - { - GdkPixmap *gdk_pixmap = bitmap->GetPixmap(); - GdkBitmap *gdk_bitmap = bitmap->GetMask() ? - bitmap->GetMask()->GetBitmap() : - (GdkBitmap*) NULL; - image = gtk_image_new_from_pixmap( gdk_pixmap, gdk_bitmap ); - } - - gtk_widget_show(image); - - gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menuItem), image ); - -#else // TODO wxUnusedVar(bitmap); menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) ); label = GTK_LABEL( GTK_BIN(menuItem)->child ); -#endif m_prevRadio = NULL; } @@ -1070,14 +1000,10 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) { case wxITEM_CHECK: { -#ifdef __WXGTK20__ - menuItem = gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV( text ) ); -#else menuItem = gtk_check_menu_item_new_with_label( wxGTK_CONV( text ) ); label = GTK_LABEL( GTK_BIN(menuItem)->child ); // set new text gtk_label_set_text( label, wxGTK_CONV( text ) ); -#endif m_prevRadio = NULL; break; } @@ -1088,25 +1014,16 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) if ( m_prevRadio == NULL ) { // start of a new radio group -#ifdef __WXGTK20__ - m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) ); -#else m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) ); label = GTK_LABEL( GTK_BIN(menuItem)->child ); // set new text gtk_label_set_text( label, wxGTK_CONV( text ) ); -#endif } else // continue the radio group { -#ifdef __WXGTK20__ - group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (m_prevRadio)); - m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) ); -#else group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (m_prevRadio)); m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) ); label = GTK_LABEL( GTK_BIN(menuItem)->child ); -#endif } break; } @@ -1117,12 +1034,8 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) case wxITEM_NORMAL: { -#ifdef __WXGTK20__ - menuItem = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( text ) ); -#else menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) ); label = GTK_LABEL( GTK_BIN(menuItem)->child ); -#endif m_prevRadio = NULL; break; } @@ -1184,7 +1097,6 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) (gpointer)this ); } -#ifndef __WXGTK20__ guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) ); if (accel_key != GDK_VoidSymbol) { @@ -1195,7 +1107,6 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) GDK_MOD1_MASK, GTK_ACCEL_LOCKED); } -#endif } mitem->SetMenuItem(menuItem); @@ -1560,9 +1471,6 @@ void SetInvokingWindow( wxMenu *menu, wxWindow* win ) extern "C" void wxPopupMenuPositionCallback( GtkMenu *menu, gint *x, gint *y, -#ifdef __WXGTK20__ - gboolean * WXUNUSED(whatever), -#endif gpointer user_data ) { // ensure that the menu appears entirely on screen @@ -1626,11 +1534,7 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y ) posfunc, // function to position it userdata, // client data 0, // button used to activate it -#ifdef __WXGTK20__ - gtk_get_current_event_time() -#else wxGtkTimeLastClick // the time of activation -#endif ); while (is_waiting) diff --git a/src/gtk1/minifram.cpp b/src/gtk1/minifram.cpp index 3e4e04231f..c60a64cb35 100644 --- a/src/gtk1/minifram.cpp +++ b/src/gtk1/minifram.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/minifram.cpp +// Name: src/gtk1/minifram.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -17,8 +17,8 @@ #include "wx/dcscreen.h" #include "gtk/gtk.h" -#include "wx/gtk/win_gtk.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/win_gtk.h" +#include "wx/gtk1/private.h" #include #include @@ -112,7 +112,6 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g // "draw" of m_mainWidget //----------------------------------------------------------------------------- -#ifndef __WXGTK20__ extern "C" { static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxFrame *win ) { @@ -154,7 +153,6 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU } } } -#endif //----------------------------------------------------------------------------- // "button_press_event" of m_mainWidget @@ -379,10 +377,8 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); -#ifndef __WXGTK20__ gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this ); -#endif /* these are required for dragging the mini frame around */ gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event", @@ -401,11 +397,7 @@ void wxMiniFrame::SetTitle( const wxString &title ) { wxFrame::SetTitle( title ); -#ifdef __WXGTK20__ - gdk_window_invalidate_rect( GTK_PIZZA(m_mainWidget)->bin_window, NULL, true ); -#else gtk_widget_draw( m_mainWidget, (GdkRectangle*) NULL ); -#endif } #endif diff --git a/src/gtk1/msgdlg.cpp b/src/gtk1/msgdlg.cpp index 6c12db782e..6bdc9f5c90 100644 --- a/src/gtk1/msgdlg.cpp +++ b/src/gtk1/msgdlg.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/msgdlg.cpp +// Name: src/gtk1/msgdlg.cpp // Purpose: wxMessageDialog for GTK+2 // Author: Vaclav Slavik // Modified by: @@ -15,116 +15,3 @@ #ifdef __BORLANDC__ #pragma hdrstop #endif - -#if wxUSE_MSGDLG && defined(__WXGTK20__) && !defined(__WXGPE__) - -#include "wx/msgdlg.h" -#include "wx/gtk/private.h" -#include - -#include "wx/intl.h" - -IMPLEMENT_CLASS(wxMessageDialog, wxDialog) - -wxMessageDialog::wxMessageDialog(wxWindow *parent, - const wxString& message, - const wxString& caption, - long style, - const wxPoint& WXUNUSED(pos)) -{ - m_caption = caption; - m_message = message; - SetMessageDialogStyle(style); - m_parent = wxGetTopLevelParent(parent); - - GtkMessageType type = GTK_MESSAGE_ERROR; - GtkButtonsType buttons = GTK_BUTTONS_OK; - - if (style & wxYES_NO) - { - buttons = GTK_BUTTONS_YES_NO; - } - - if (style & wxOK) - { - if (style & wxCANCEL) - buttons = GTK_BUTTONS_OK_CANCEL; - else - buttons = GTK_BUTTONS_OK; - } - - 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 - { - // GTK+ doesn't have a "typeless" msg box, so try to auto detect... - type = style & wxYES ? GTK_MESSAGE_QUESTION : GTK_MESSAGE_INFO; - } - - m_widget = gtk_message_dialog_new(m_parent ? - GTK_WINDOW(m_parent->m_widget) : NULL, - GTK_DIALOG_MODAL, - type, buttons, - "%s", (const char*)wxGTK_CONV(m_message)); - if (m_caption != wxMessageBoxCaptionStr) - gtk_window_set_title(GTK_WINDOW(m_widget), wxGTK_CONV(m_caption)); - - if (style & wxYES_NO) - { - if (style & wxCANCEL) - gtk_dialog_add_button(GTK_DIALOG(m_widget), GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL); - if (style & wxNO_DEFAULT) - gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_NO); - else - gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_YES); - } - - if (m_parent) - gtk_window_set_transient_for(GTK_WINDOW(m_widget), - GTK_WINDOW(m_parent->m_widget)); -} - -wxMessageDialog::~wxMessageDialog() -{ -} - -int wxMessageDialog::ShowModal() -{ - // This should be necessary, but otherwise the - // parent TLW will disappear.. - if (m_parent) - gtk_window_present( GTK_WINDOW(m_parent->m_widget) ); - - gint result = gtk_dialog_run(GTK_DIALOG(m_widget)); - gtk_widget_destroy(m_widget); - m_widget = NULL; - - switch (result) - { - default: - wxFAIL_MSG(_T("unexpected GtkMessageDialog return code")); - // fall through - - case GTK_RESPONSE_CANCEL: - case GTK_RESPONSE_DELETE_EVENT: - case GTK_RESPONSE_CLOSE: - return wxID_CANCEL; - case GTK_RESPONSE_OK: - return wxID_OK; - case GTK_RESPONSE_YES: - return wxID_YES; - case GTK_RESPONSE_NO: - return wxID_NO; - } -} - - -#endif // wxUSE_MSGDLG && defined(__WXGTK20__) - diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index fa18809974..ca7fc31f13 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -22,8 +22,8 @@ #include "wx/bitmap.h" #include "wx/fontutil.h" -#include "wx/gtk/private.h" -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/private.h" +#include "wx/gtk1/win_gtk.h" #include @@ -738,7 +738,9 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const const size_t count = GetPageCount(); size_t i = 0; -#ifdef __WXGTK20__ + // MR: Code to fix HitTest index return when tabs are scrolled. + // No idea if it would work for GTK1 +#if 0 GtkNotebook * notebook = GTK_NOTEBOOK(m_widget); if (gtk_notebook_get_scrollable(notebook)); i = g_list_position( notebook->children, notebook->first_tab ); @@ -750,11 +752,7 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const GtkWidget *box = nb_page->m_box; // VZ: don't know how to find the border width in GTK+ 1.2 -#ifdef __WXGTK20__ - const gint border = gtk_container_get_border_width(GTK_CONTAINER(box)); -#else // !GTK+ 2.x const gint border = 0; -#endif if ( IsPointInsideWidget(pt, box, x, y, border) ) { // ok, we're inside this tab -- now find out where, if needed diff --git a/src/gtk1/pen.cpp b/src/gtk1/pen.cpp index 26e47769b1..b88a212c19 100644 --- a/src/gtk1/pen.cpp +++ b/src/gtk1/pen.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/pen.cpp +// Name: src/gtk1/pen.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ diff --git a/src/gtk1/popupwin.cpp b/src/gtk1/popupwin.cpp index 72139ffb01..d595744fab 100644 --- a/src/gtk1/popupwin.cpp +++ b/src/gtk1/popupwin.cpp @@ -21,7 +21,7 @@ #include #include -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/win_gtk.h" //----------------------------------------------------------------------------- // idle system diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index abe3aed93d..156ca7c879 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/radiobox.cpp +// Name: src/gtk1/radiobox.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -18,10 +18,10 @@ #include "wx/frame.h" #include "wx/log.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/win_gtk.h" //----------------------------------------------------------------------------- // idle system @@ -385,11 +385,7 @@ wxString wxRadioBox::GetString( int n ) const GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) ); -#ifdef __WXGTK20__ - wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) ); -#else wxString str( label->label ); -#endif return str; } @@ -529,10 +525,6 @@ void wxRadioBox::DoApplyWidgetStyle(GtkRcStyle *style) { gtk_widget_modify_style( m_widget, style ); -#ifdef __WXGTK20__ - gtk_widget_modify_style(GTK_FRAME(m_widget)->label_widget, style); -#endif - wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { diff --git a/src/gtk1/radiobut.cpp b/src/gtk1/radiobut.cpp index cc9f90751f..278cfbabd2 100644 --- a/src/gtk1/radiobut.cpp +++ b/src/gtk1/radiobut.cpp @@ -14,7 +14,7 @@ #include "wx/radiobut.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" //----------------------------------------------------------------------------- // idle system diff --git a/src/gtk1/region.cpp b/src/gtk1/region.cpp index 93aef5fc16..2e212047d1 100644 --- a/src/gtk1/region.cpp +++ b/src/gtk1/region.cpp @@ -21,9 +21,8 @@ #include "wx/region.h" #include "wx/log.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" -#ifndef __WXGTK20__ // ---------------------------------------------------------------------------- // wxGdkRegion: creates a new region in ctor and destroys in dtor @@ -41,7 +40,6 @@ private: GdkRegion *m_region; }; -#endif // __WXGTK20__ // ---------------------------------------------------------------------------- // wxRegionRefData: private class containing the information about the region @@ -58,11 +56,7 @@ public: wxRegionRefData(const wxRegionRefData& refData) : wxObjectRefData() { -#ifdef __WXGTK20__ - m_region = gdk_region_copy(refData.m_region); -#else m_region = gdk_regions_union(wxGdkRegion(), refData.m_region); -#endif } ~wxRegionRefData() @@ -100,21 +94,13 @@ void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h) m_refData = new wxRegionRefData(); -#ifdef __WXGTK20__ - M_REGIONDATA->m_region = gdk_region_rectangle( &rect ); -#else M_REGIONDATA->m_region = gdk_region_union_with_rect( wxGdkRegion(), &rect ); -#endif } wxRegion::wxRegion( GdkRegion *region ) { m_refData = new wxRegionRefData(); -#ifdef __WXGTK20__ - M_REGIONDATA->m_region = gdk_region_copy( region ); -#else M_REGIONDATA->m_region = gdk_regions_union(wxGdkRegion(), region); -#endif } wxRegion::wxRegion( size_t n, const wxPoint *points, int fillStyle ) @@ -202,13 +188,9 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) rect.width = width; rect.height = height; -#ifdef __WXGTK20__ - gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect ); -#else GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect ); gdk_region_destroy( M_REGIONDATA->m_region ); M_REGIONDATA->m_region = reg; -#endif } return TRUE; @@ -234,13 +216,9 @@ bool wxRegion::Union( const wxRegion& region ) AllocExclusive(); } -#ifdef __WXGTK20__ - gdk_region_union( M_REGIONDATA->m_region, region.GetRegion() ); -#else GdkRegion *reg = gdk_regions_union( M_REGIONDATA->m_region, region.GetRegion() ); gdk_region_destroy( M_REGIONDATA->m_region ); M_REGIONDATA->m_region = reg; -#endif return TRUE; } @@ -272,13 +250,9 @@ bool wxRegion::Intersect( const wxRegion& region ) AllocExclusive(); -#ifdef __WXGTK20__ - gdk_region_intersect( M_REGIONDATA->m_region, region.GetRegion() ); -#else GdkRegion *reg = gdk_regions_intersect( M_REGIONDATA->m_region, region.GetRegion() ); gdk_region_destroy( M_REGIONDATA->m_region ); M_REGIONDATA->m_region = reg; -#endif return TRUE; } @@ -308,13 +282,9 @@ bool wxRegion::Subtract( const wxRegion& region ) AllocExclusive(); -#ifdef __WXGTK20__ - gdk_region_subtract( M_REGIONDATA->m_region, region.GetRegion() ); -#else GdkRegion *reg = gdk_regions_subtract( M_REGIONDATA->m_region, region.GetRegion() ); gdk_region_destroy( M_REGIONDATA->m_region ); M_REGIONDATA->m_region = reg; -#endif return TRUE; } @@ -343,13 +313,9 @@ bool wxRegion::Xor( const wxRegion& region ) AllocExclusive(); -#ifdef __WXGTK20__ - gdk_region_xor( M_REGIONDATA->m_region, region.GetRegion() ); -#else GdkRegion *reg = gdk_regions_xor( M_REGIONDATA->m_region, region.GetRegion() ); gdk_region_destroy( M_REGIONDATA->m_region ); M_REGIONDATA->m_region = reg; -#endif return TRUE; } @@ -458,8 +424,6 @@ GdkRegion *wxRegion::GetRegion() const // wxRegionIterator // ---------------------------------------------------------------------------- -#ifndef __WXGTK20__ - // the following structures must match the private structures // in X11 region code ( xc/lib/X11/region.h ) @@ -477,7 +441,6 @@ struct _XRegion { _XBox *rects, extents; }; -#endif // GTK+ 1.x class wxRIRefData: public wxObjectRefData { @@ -508,27 +471,6 @@ void wxRIRefData::CreateRects( const wxRegion& region ) if (!gdkregion) return; -#ifdef __WXGTK20__ - GdkRectangle *gdkrects = NULL; - gint numRects = 0; - gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects ); - - m_numRects = numRects; - if (numRects) - { - m_rects = new wxRect[m_numRects]; - for (size_t i=0; i < m_numRects; ++i) - { - GdkRectangle &gr = gdkrects[i]; - wxRect &wr = m_rects[i]; - wr.x = gr.x; - wr.y = gr.y; - wr.width = gr.width; - wr.height = gr.height; - } - } - g_free( gdkrects ); -#else // GTK+ 1.x Region r = ((GdkRegionPrivate *)gdkregion)->xregion; if (r) { @@ -547,7 +489,6 @@ void wxRIRefData::CreateRects( const wxRegion& region ) } } } -#endif // GTK+ 2.0/1.x } wxRegionIterator::wxRegionIterator() diff --git a/src/gtk1/renderer.cpp b/src/gtk1/renderer.cpp index 7c0a375e80..65efb88eae 100644 --- a/src/gtk1/renderer.cpp +++ b/src/gtk1/renderer.cpp @@ -26,22 +26,12 @@ #include "wx/renderer.h" #include -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/win_gtk.h" #include "wx/window.h" #include "wx/dc.h" #include "wx/dcclient.h" -#ifdef __WXGTK20__ - #include "wx/settings.h" -#endif // GTK 2.0 - -#ifdef __WXGTK20__ - #define WXUNUSED_IN_GTK1(arg) arg -#else - #define WXUNUSED_IN_GTK1(arg) -#endif - // RR: After a correction to the orientation of the sash // this doesn't seem to be required anymore and it // seems to confuse some themes so USE_ERASE_RECT=0 @@ -60,14 +50,6 @@ public: const wxRect& rect, int flags = 0); -#ifdef __WXGTK20__ - // draw the expanded/collapsed icon for a tree control item - virtual void DrawTreeItemButton(wxWindow *win, - wxDC& dc, - const wxRect& rect, - int flags = 0); -#endif // GTK+ 2.0 - virtual void DrawSplitterBorder(wxWindow *win, wxDC& dc, const wxRect& rect, @@ -96,11 +78,6 @@ private: // used by DrawHeaderButton and DrawComboBoxDropButton static GtkWidget *GetButtonWidget(); - -#ifdef __WXGTK20__ - // used by DrawTreeItemButton() - static GtkWidget *GetTreeWidget(); -#endif // GTK+ 2.0 }; // ============================================================================ @@ -137,28 +114,6 @@ wxRendererGTK::GetButtonWidget() return s_button; } -#ifdef __WXGTK20__ - -GtkWidget * -wxRendererGTK::GetTreeWidget() -{ - static GtkWidget *s_tree = NULL; - static GtkWidget *s_window = NULL; - - if ( !s_tree ) - { - s_tree = gtk_tree_view_new(); - s_window = gtk_window_new( GTK_WINDOW_POPUP ); - gtk_widget_realize( s_window ); - gtk_container_add( GTK_CONTAINER(s_window), s_tree ); - gtk_widget_realize( s_tree ); - } - - return s_tree; -} - -#endif // GTK+ 2.0 - // ---------------------------------------------------------------------------- // list/tree controls drawing // ---------------------------------------------------------------------------- @@ -187,66 +142,19 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win, ); } -#ifdef __WXGTK20__ - -// draw a ">" or "v" button -void -wxRendererGTK::DrawTreeItemButton(wxWindow* win, - wxDC& dc, const wxRect& rect, int flags) -{ - GtkWidget *tree = GetTreeWidget(); - - GtkStateType state; - if ( flags & wxCONTROL_CURRENT ) - state = GTK_STATE_PRELIGHT; - else - state = GTK_STATE_NORMAL; - - // VZ: I don't know how to get the size of the expander so as to centre it - // in the given rectangle, +2/3 below is just what looks good here... - gtk_paint_expander - ( - tree->style, - GTK_PIZZA(win->m_wxwindow)->bin_window, - state, - NULL, - tree, - "treeview", - dc.LogicalToDeviceX(rect.x) + 2, - dc.LogicalToDeviceY(rect.y) + 3, - flags & wxCONTROL_EXPANDED ? GTK_EXPANDER_EXPANDED - : GTK_EXPANDER_COLLAPSED - ); -} - -#endif // GTK+ 2.0 - // ---------------------------------------------------------------------------- // splitter sash drawing // ---------------------------------------------------------------------------- -#ifndef __WXGTK20__ - // the full sash width (should be even) - static const wxCoord SASH_SIZE = 8; +// the full sash width (should be even) +static const wxCoord SASH_SIZE = 8; - // margin around the sash - static const wxCoord SASH_MARGIN = 2; -#endif // GTK+ 2.x/1.x +// margin around the sash +static const wxCoord SASH_MARGIN = 2; static int GetGtkSplitterFullSize() { -#ifdef __WXGTK20__ - static GtkWidget *s_paned = NULL; - if (s_paned == NULL) - s_paned = gtk_vpaned_new(); - - gint handle_size; - gtk_widget_style_get (s_paned, "handle_size", &handle_size, NULL); - - return handle_size; -#else return SASH_SIZE + SASH_MARGIN; -#endif } wxSplitterRenderParams @@ -257,11 +165,7 @@ wxRendererGTK::GetSplitterParams(const wxWindow *WXUNUSED(win)) ( GetGtkSplitterFullSize(), 0, -#ifdef __WXGTK20__ - true // hot sensitive -#else // GTK+ 1.x false // not -#endif // GTK+ 2.x/1.x ); } @@ -280,7 +184,7 @@ wxRendererGTK::DrawSplitterSash(wxWindow *win, const wxSize& size, wxCoord position, wxOrientation orient, - int WXUNUSED_IN_GTK1(flags)) + int WXUNUSED(flags)) { if ( !win->m_wxwindow->window ) { @@ -350,23 +254,6 @@ wxRendererGTK::DrawSplitterSash(wxWindow *win, ); #endif -#ifdef __WXGTK20__ - gtk_paint_handle - ( - win->m_wxwindow->style, - GTK_PIZZA(win->m_wxwindow)->bin_window, - flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL, - GTK_SHADOW_NONE, - NULL /* no clipping */, - win->m_wxwindow, - "paned", - rect.x, - rect.y, - rect.width, - rect.height, - isVert ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL - ); -#else // GTK+ 1.x // leave some margin before sash itself position += SASH_MARGIN / 2; @@ -404,7 +291,6 @@ wxRendererGTK::DrawSplitterSash(wxWindow *win, isVert ? size.y - 2*SASH_SIZE : position, SASH_SIZE, SASH_SIZE ); -#endif // GTK+ 2.x/1.x } void @@ -506,4 +392,3 @@ wxRendererGTK::DrawComboBoxDropButton(wxWindow *win, DrawDropArrow(win,dc,rect,flags); } - diff --git a/src/gtk1/scrolbar.cpp b/src/gtk1/scrolbar.cpp index 9172d9b8b9..bc2977ba69 100644 --- a/src/gtk1/scrolbar.cpp +++ b/src/gtk1/scrolbar.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/scrolbar.cpp +// Name: src/gtk1/scrolbar.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -16,7 +16,7 @@ #include "wx/utils.h" #include "wx/math.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" //----------------------------------------------------------------------------- // idle system @@ -118,10 +118,8 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget, g_currentUpDownEvent = wxEVT_SCROLL_LINEUP; } -#ifndef __WXGTK20__ // There is no slider field any more win->m_isScrolling = (gdk_event->window == widget->slider); -#endif return FALSE; } @@ -345,12 +343,10 @@ bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window ) { GtkRange *range = GTK_RANGE(m_widget); return ( (window == GTK_WIDGET(range)->window) -#ifndef __WXGTK20__ || (window == range->trough) || (window == range->slider) || (window == range->step_forw) || (window == range->step_back) -#endif // GTK+ 1.x ); } diff --git a/src/gtk1/scrolwin.cpp b/src/gtk1/scrolwin.cpp index 70a9298be2..ab086f50c1 100644 --- a/src/gtk1/scrolwin.cpp +++ b/src/gtk1/scrolwin.cpp @@ -26,7 +26,7 @@ #endif #include "wx/scrolwin.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" // ============================================================================ // implementation diff --git a/src/gtk1/settings.cpp b/src/gtk1/settings.cpp index ad07a8affb..7eb099a0af 100644 --- a/src/gtk1/settings.cpp +++ b/src/gtk1/settings.cpp @@ -344,36 +344,7 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) { if (!gs_objects.m_fontSystem.Ok()) { -#ifdef __WXGTK20__ - GtkWidget *widget = gtk_button_new(); - GtkStyle *def = gtk_rc_get_style( widget ); - if ( !def || !def->font_desc ) - def = gtk_widget_get_default_style(); - if ( def && def->font_desc ) - { - wxNativeFontInfo info; - info.description = - pango_font_description_copy(def->font_desc); - gs_objects.m_fontSystem = wxFont(info); - } - else - { - GtkSettings *settings = gtk_settings_get_default(); - gchar *font_name = NULL; - g_object_get ( settings, - "gtk-font-name", - &font_name, - NULL); - if (!font_name) - gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); - else - gs_objects.m_fontSystem = wxFont(wxString::FromAscii(font_name)); - g_free (font_name); - } - gtk_widget_destroy( widget ); -#else gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); -#endif } return gs_objects.m_fontSystem; } @@ -385,184 +356,27 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win ) { -#ifdef __WXGTK20__ - bool success = false; - - guchar *data = NULL; - GdkWindow *window = NULL; - if(win && GTK_WIDGET_REALIZED(win->GetHandle())) - window = win->GetHandle()->window; -#endif - switch (index) { -#ifdef __WXGTK20__ - case wxSYS_BORDER_X: - case wxSYS_BORDER_Y: - case wxSYS_EDGE_X: - case wxSYS_EDGE_Y: - case wxSYS_FRAMESIZE_X: - case wxSYS_FRAMESIZE_Y: - // If a window is specified/realized, and it is a toplevel window, we can query from wm. - // The returned border thickness is outside the client area in that case. - if (window) - { - wxTopLevelWindow *tlw = wxDynamicCast(win, wxTopLevelWindow); - if (!tlw) - return -1; // not a tlw, not sure how to approach - else - { - // Check if wm supports frame extents - we can't know - // the border widths if it does not. -#if GTK_CHECK_VERSION(2,2,0) - if (!gtk_check_version(2,2,0)) - { - if (!gdk_x11_screen_supports_net_wm_hint( - gdk_drawable_get_screen(window), - gdk_atom_intern("_NET_FRAME_EXTENTS", false) ) ) - return -1; - } - else -#endif - { - if (!gdk_net_wm_supports(gdk_atom_intern("_NET_FRAME_EXTENTS", false))) - return -1; - } - - // Get the frame extents from the windowmanager. - // In most cases the top extent is the titlebar, so we use the bottom extent - // for the heights. - - Atom type; - gint format; - gulong nitems; - -#if GTK_CHECK_VERSION(2,2,0) - if (!gtk_check_version(2,2,0)) - { - gulong bytes_after; - success = (XGetWindowProperty (GDK_DISPLAY_XDISPLAY(gdk_drawable_get_display(window)), - GDK_WINDOW_XWINDOW(window), - gdk_x11_get_xatom_by_name_for_display ( - gdk_drawable_get_display(window), - "_NET_FRAME_EXTENTS" ), - 0, // left, right, top, bottom, CARDINAL[4]/32 - G_MAXLONG, // size of long - false, // do not delete property - XA_CARDINAL, // 32 bit - &type, &format, &nitems, &bytes_after, &data - ) == Success); - } -#endif - if (success) - { - int border_return = -1; - - if ((type == XA_CARDINAL) && (format == 32) && (nitems >= 4) && (data)) - { - long *borders; - borders = (long*)data; - switch(index) - { - case wxSYS_BORDER_X: - case wxSYS_EDGE_X: - case wxSYS_FRAMESIZE_X: - border_return = borders[1]; // width of right extent - break; - default: - border_return = borders[3]; // height of bottom extent - break; - } - } - - if (data) - XFree(data); - - return border_return; - } - } - } - - return -1; // no window specified -#endif // gtk2 - case wxSYS_CURSOR_X: case wxSYS_CURSOR_Y: -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - if (window) - return gdk_display_get_default_cursor_size(gdk_drawable_get_display(window)); - else - return gdk_display_get_default_cursor_size(gdk_display_get_default()); - } - else -#endif - return 16; - -#ifdef __WXGTK20__ - case wxSYS_DCLICK_X: - case wxSYS_DCLICK_Y: - gint dclick_distance; -#if GTK_CHECK_VERSION(2,2,0) - if (window && !gtk_check_version(2,2,0)) - g_object_get(gtk_settings_get_for_screen(gdk_drawable_get_screen(window)), - "gtk-double-click-distance", &dclick_distance, NULL); - else -#endif - g_object_get(gtk_settings_get_default(), - "gtk-double-click-distance", &dclick_distance, NULL); - - return dclick_distance * 2; -#endif // gtk2 - -#ifdef __WXGTK20__ - case wxSYS_DRAG_X: - case wxSYS_DRAG_Y: - gint drag_threshold; -#if GTK_CHECK_VERSION(2,2,0) - if (window && !gtk_check_version(2,2,0)) - { - g_object_get( - gtk_settings_get_for_screen(gdk_drawable_get_screen(window)), - "gtk-dnd-drag-threshold", - &drag_threshold, NULL); - } - else -#endif - { - g_object_get(gtk_settings_get_default(), - "gtk-dnd-drag-threshold", &drag_threshold, NULL); - } - - return drag_threshold * 2; -#endif + return 16; // MBN: ditto for icons case wxSYS_ICON_X: return 32; case wxSYS_ICON_Y: return 32; case wxSYS_SCREEN_X: -#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,2,0) - if (window && !gtk_check_version(2,2,0)) - return gdk_screen_get_width(gdk_drawable_get_screen(window)); - else -#endif - return gdk_screen_width(); + return gdk_screen_width(); case wxSYS_SCREEN_Y: -#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,2,0) - if (window && !gtk_check_version(2,2,0)) - return gdk_screen_get_height(gdk_drawable_get_screen(window)); - else -#endif - return gdk_screen_height(); + return gdk_screen_height(); case wxSYS_HSCROLL_Y: return 15; case wxSYS_VSCROLL_X: return 15; // a gtk1 implementation should be possible too if gtk2 efficiency/convenience functions aren't used -#ifdef __WXGTK20__ +#if 0 case wxSYS_CAPTION_Y: if (!window) // No realized window specified, and no implementation for that case yet. diff --git a/src/gtk1/slider.cpp b/src/gtk1/slider.cpp index ba70dee257..594d0ae265 100644 --- a/src/gtk1/slider.cpp +++ b/src/gtk1/slider.cpp @@ -16,7 +16,7 @@ #include "wx/utils.h" #include "wx/math.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" //----------------------------------------------------------------------------- // idle system @@ -93,25 +93,7 @@ static void gtk_slider_callback( GtkAdjustment *adjust, return; wxEventType evtType; -#ifdef __WXGTK20__ - if ( win->m_isScrolling ) - evtType = wxEVT_SCROLL_THUMBTRACK; - // it could seem that UP/DOWN are inversed but this is what wxMSW does - else if ( AreSameAdjustValues(diff, adjust->step_increment) ) - evtType = wxEVT_SCROLL_LINEDOWN; - else if ( AreSameAdjustValues(diff, -adjust->step_increment) ) - evtType = wxEVT_SCROLL_LINEUP; - else if ( AreSameAdjustValues(diff, adjust->page_increment) ) - evtType = wxEVT_SCROLL_PAGEDOWN; - else if ( AreSameAdjustValues(diff, -adjust->page_increment) ) - evtType = wxEVT_SCROLL_PAGEUP; - else if ( AreSameAdjustValues(adjust->value, adjust->lower) ) - evtType = wxEVT_SCROLL_TOP; - else if ( AreSameAdjustValues(adjust->value, adjust->upper) ) - evtType = wxEVT_SCROLL_BOTTOM; -#else evtType = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget)); -#endif ProcessScrollEvent(win, evtType, dvalue); @@ -202,11 +184,6 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); -#ifdef __WXGTK20__ - if (style & wxSL_INVERSE) - gtk_range_set_inverted( GTK_RANGE(m_widget), TRUE ); -#endif - GtkEnableEvents(); gtk_signal_connect( GTK_OBJECT(m_widget), "button_press_event", @@ -333,15 +310,11 @@ int wxSlider::GetLineSize() const bool wxSlider::IsOwnGtkWindow( GdkWindow *window ) { GtkRange *range = GTK_RANGE(m_widget); -#ifdef __WXGTK20__ - return (range->event_window == window); -#else return ( (window == GTK_WIDGET(range)->window) || (window == range->trough) || (window == range->slider) || (window == range->step_forw) || (window == range->step_back) ); -#endif } void wxSlider::GtkDisableEvents() diff --git a/src/gtk1/spinbutt.cpp b/src/gtk1/spinbutt.cpp index b91d902de2..0af1e68f5d 100644 --- a/src/gtk1/spinbutt.cpp +++ b/src/gtk1/spinbutt.cpp @@ -17,7 +17,7 @@ #include "wx/utils.h" #include "wx/math.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" //----------------------------------------------------------------------------- // idle system diff --git a/src/gtk1/spinctrl.cpp b/src/gtk1/spinctrl.cpp index e782a6334a..9820526690 100644 --- a/src/gtk1/spinctrl.cpp +++ b/src/gtk1/spinctrl.cpp @@ -19,7 +19,7 @@ #include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED #include "wx/math.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" //----------------------------------------------------------------------------- // idle system diff --git a/src/gtk1/statbmp.cpp b/src/gtk1/statbmp.cpp index 64d3931648..59c3c7e555 100644 --- a/src/gtk1/statbmp.cpp +++ b/src/gtk1/statbmp.cpp @@ -34,14 +34,12 @@ wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap Create( parent, id, bitmap, pos, size, style, name ); } -#ifndef __WXGTK20__ // empty bitmap, so that we can create GtkPixmap widget: static char * bogus_xpm[] = { "2 2 1 1", " c None", " ", " "}; -#endif bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, const wxPoint &pos, const wxSize &size, @@ -58,12 +56,8 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi m_bitmap = bitmap; -#ifdef __WXGTK20__ - m_widget = gtk_image_new(); -#else wxBitmap bmp(bitmap.Ok() ? bitmap : wxBitmap(bogus_xpm)); m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL); -#endif if (bitmap.Ok()) SetBitmap(bitmap); @@ -84,7 +78,6 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap ) if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); -#ifdef __WXGTK20__ if (m_bitmap.HasPixbuf()) { gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget), @@ -93,9 +86,6 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap ) else gtk_image_set_from_pixmap(GTK_IMAGE(m_widget), m_bitmap.GetPixmap(), mask); -#else - gtk_pixmap_set(GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask); -#endif InvalidateBestSize(); SetSize(GetBestSize()); diff --git a/src/gtk1/statbox.cpp b/src/gtk1/statbox.cpp index c000c1306a..a2542e88e2 100644 --- a/src/gtk1/statbox.cpp +++ b/src/gtk1/statbox.cpp @@ -13,7 +13,7 @@ #if wxUSE_STATBOX #include "wx/statbox.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include "gdk/gdk.h" #include "gtk/gtk.h" @@ -88,9 +88,6 @@ void wxStaticBox::SetLabel( const wxString& label ) void wxStaticBox::DoApplyWidgetStyle(GtkRcStyle *style) { gtk_widget_modify_style(m_widget, style); -#ifdef __WXGTK20__ - gtk_widget_modify_style(GTK_FRAME(m_widget)->label_widget, style); -#endif } // static diff --git a/src/gtk1/stattext.cpp b/src/gtk1/stattext.cpp index 59817b5027..b8d9145e50 100644 --- a/src/gtk1/stattext.cpp +++ b/src/gtk1/stattext.cpp @@ -13,7 +13,7 @@ #if wxUSE_STATTEXT #include "wx/stattext.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include "gdk/gdk.h" #include "gtk/gtk.h" @@ -87,36 +87,13 @@ bool wxStaticText::Create(wxWindow *parent, PostCreation(size); - // the bug below only happens with GTK 2 -#ifdef __WXGTK20__ - if ( justify != GTK_JUSTIFY_LEFT ) - { - // if we let GTK call wxgtk_window_size_request_callback the label - // always shrinks to its minimal size for some reason and so no - // alignment except the default left doesn't work (in fact it does, - // but you don't see it) - gtk_signal_disconnect_by_func - ( - GTK_OBJECT(m_widget), - GTK_SIGNAL_FUNC(wxgtk_window_size_request_callback), - (gpointer) this - ); - } -#endif // __WXGTK20__ - return TRUE; } wxString wxStaticText::GetLabel() const { GtkLabel *label = GTK_LABEL(m_widget); - -#ifdef __WXGTK20__ - wxString str = wxGTK_CONV_BACK( gtk_label_get_text( label ) ); -#else wxString str = wxString( label->label ); -#endif - return wxString(str); } @@ -124,23 +101,7 @@ void wxStaticText::SetLabel( const wxString &label ) { wxControl::SetLabel(label); -#ifdef __WXGTK20__ - // Build the colorized version of the label (markup only allowed - // under GTK2): - if (m_foregroundColour.Ok()) - { - // If the color has been set, create a markup string to pass to - // the label setter - wxString colorlabel; - colorlabel.Printf(_T("%s"), - m_foregroundColour.Red(), m_foregroundColour.Green(), - m_foregroundColour.Blue(), - wxEscapeStringForPangoMarkup(label).c_str()); - gtk_label_set_markup( GTK_LABEL(m_widget), wxGTK_CONV( colorlabel ) ); - } - else -#endif - gtk_label_set( GTK_LABEL(m_widget), wxGTK_CONV( m_label ) ); + gtk_label_set( GTK_LABEL(m_widget), wxGTK_CONV( m_label ) ); // adjust the label size to the new label unless disabled if (!HasFlag(wxST_NO_AUTORESIZE)) @@ -175,11 +136,9 @@ wxSize wxStaticText::DoGetBestSize() const // Do not return any arbitrary default value... wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") ); -#ifndef __WXGTK20__ // This resets the internal GTK1 size calculation, which // otherwise would be cashed (incorrectly) gtk_label_set_pattern( GTK_LABEL(m_widget), NULL ); -#endif // GetBestSize is supposed to return unwrapped size gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE ); diff --git a/src/gtk1/taskbar.cpp b/src/gtk1/taskbar.cpp index 930099e687..aaa37b3c0d 100644 --- a/src/gtk1/taskbar.cpp +++ b/src/gtk1/taskbar.cpp @@ -11,134 +11,3 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" - -#include "wx/gtk/taskbarpriv.h" -#include "wx/log.h" -#include "wx/frame.h" -#include "wx/menu.h" - -#include - -#ifdef __WXGTK20__ -#include -#if GTK_CHECK_VERSION(2, 1, 0) - -#include "gtk/gtk.h" - -#include "eggtrayicon.h" - -wxTaskBarIconAreaBase::wxTaskBarIconAreaBase() -{ - if (IsProtocolSupported()) - { - m_widget = GTK_WIDGET(egg_tray_icon_new("systray icon")); - gtk_window_set_resizable(GTK_WINDOW(m_widget), false); - - wxLogTrace(_T("systray"), _T("using freedesktop.org systray spec")); - } - - wxTopLevelWindow::Create( - NULL, wxID_ANY, _T("systray icon"), - wxDefaultPosition, wxDefaultSize, - wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR | wxSIMPLE_BORDER | - wxFRAME_SHAPED, - wxEmptyString /*eggtray doesn't like setting wmclass*/); - - m_invokingWindow = NULL; -} - -bool wxTaskBarIconAreaBase::IsProtocolSupported() -{ - static int s_supported = -1; - if (s_supported == -1) - { - Display *display = GDK_DISPLAY(); - Screen *screen = DefaultScreenOfDisplay(display); - - wxString name; - name.Printf(_T("_NET_SYSTEM_TRAY_S%d"), XScreenNumberOfScreen(screen)); - Atom atom = XInternAtom(display, name.ToAscii(), False); - - Window manager = XGetSelectionOwner(display, atom); - - s_supported = (manager != None); - } - - return (bool)s_supported; -} - -//----------------------------------------------------------------------------- -// Pop-up menu stuff -//----------------------------------------------------------------------------- - -extern "C" WXDLLIMPEXP_CORE void gtk_pop_hide_callback( GtkWidget *widget, bool* is_waiting ); - -extern WXDLLIMPEXP_CORE void SetInvokingWindow( wxMenu *menu, wxWindow* win ); - -extern "C" WXDLLIMPEXP_CORE - void wxPopupMenuPositionCallback( GtkMenu *menu, - gint *x, gint *y, - gboolean * WXUNUSED(whatever), - gpointer user_data ); - -#if wxUSE_MENUS_NATIVE -bool wxTaskBarIconAreaBase::DoPopupMenu( wxMenu *menu, int x, int y ) -{ - wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") ); - - wxCHECK_MSG( menu != NULL, false, wxT("invalid popup-menu") ); - - // NOTE: if you change this code, you need to update - // the same code in window.cpp as well. This - // is ugly code duplication, I know, - - SetInvokingWindow( menu, this ); - - menu->UpdateUI( m_invokingWindow ); - - bool is_waiting = true; - - gulong handler = gtk_signal_connect( GTK_OBJECT(menu->m_menu), - "hide", - GTK_SIGNAL_FUNC(gtk_pop_hide_callback), - (gpointer)&is_waiting ); - - wxPoint pos; - gpointer userdata; - GtkMenuPositionFunc posfunc; - if ( x == -1 && y == -1 ) - { - // use GTK's default positioning algorithm - userdata = NULL; - posfunc = NULL; - } - else - { - pos = ClientToScreen(wxPoint(x, y)); - userdata = &pos; - posfunc = wxPopupMenuPositionCallback; - } - - gtk_menu_popup( - GTK_MENU(menu->m_menu), - (GtkWidget *) NULL, // parent menu shell - (GtkWidget *) NULL, // parent menu item - posfunc, // function to position it - userdata, // client data - 0, // button used to activate it - gtk_get_current_event_time() - ); - - while (is_waiting) - { - gtk_main_iteration(); - } - - gtk_signal_disconnect(GTK_OBJECT(menu->m_menu), handler); - - return true; -} -#endif // wxUSE_MENUS_NATIVE - -#endif // __WXGTK20__ -#endif // GTK_CHECK_VERSION(2, 1, 0) diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp index 555803cd80..b81c5c77ec 100644 --- a/src/gtk1/tbargtk.cpp +++ b/src/gtk1/tbargtk.cpp @@ -26,7 +26,7 @@ #include "wx/frame.h" #include -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" // ---------------------------------------------------------------------------- // globals @@ -56,11 +56,7 @@ static void GetGtkStyle(long style, { *gtkStyle = style & wxTB_NOICONS ? GTK_TOOLBAR_TEXT - : ( -#ifdef __WXGTK20__ - style & wxTB_HORZ_LAYOUT ? GTK_TOOLBAR_BOTH_HORIZ : -#endif // __WXGTK20__ - GTK_TOOLBAR_BOTH); + : GTK_TOOLBAR_BOTH; } else // no text, hence we must have the icons or what would we show? { @@ -128,12 +124,7 @@ public: { GdkBitmap *mask = bitmap.GetMask() ? bitmap.GetMask()->GetBitmap() : (GdkBitmap *)NULL; -#ifdef __WXGTK20__ - if (bitmap.HasPixbuf()) - gtk_image_set_from_pixbuf( GTK_IMAGE(m_pixmap), bitmap.GetPixbuf() ); - else -#endif // !__WXGTK20__ - gtk_pixmap_set( GTK_PIXMAP(m_pixmap), bitmap.GetPixmap(), mask ); + gtk_pixmap_set( GTK_PIXMAP(m_pixmap), bitmap.GetPixmap(), mask ); } } @@ -292,20 +283,11 @@ bool wxToolBar::Create( wxWindow *parent, return false; } -#ifdef __WXGTK20__ - m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() ); - GtkSetStyle(); - - // Doesn't work this way. - // GtkToolbarSpaceStyle space_style = GTK_TOOLBAR_SPACE_EMPTY; - // gtk_widget_style_set (GTK_WIDGET (m_toolbar), "space_style", &space_style, NULL); -#else GtkOrientation orient; GtkToolbarStyle gtkStyle; GetGtkStyle(style, &orient, >kStyle); m_toolbar = GTK_TOOLBAR( gtk_toolbar_new(orient, gtkStyle) ); -#endif SetToolSeparation(7); @@ -328,11 +310,8 @@ bool wxToolBar::Create( wxWindow *parent, gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); - // FIXME: there is no such function for toolbars in 2.0 -#ifndef __WXGTK20__ if (style & wxTB_FLAT) gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE ); -#endif m_parent->DoAddChild( this ); @@ -363,13 +342,9 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) { wxToolBarTool *tool = (wxToolBarTool *)toolBase; -#ifndef __WXGTK20__ // if we have inserted a space before all the tools we must change the GTK // index by 1 size_t posGtk = m_xMargin > 1 ? pos + 1 : pos; -#else - size_t posGtk = pos; -#endif if ( tool->IsButton() ) { @@ -388,26 +363,14 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) GtkWidget *tool_pixmap = (GtkWidget *)NULL; + GdkPixmap *pixmap = bitmap.GetPixmap(); -#ifdef __WXGTK20__ - if (bitmap.HasPixbuf()) - { - tool_pixmap = gtk_image_new(); - tool->m_pixmap = tool_pixmap; - tool->SetPixmap(bitmap); - } - else -#endif - { - GdkPixmap *pixmap = bitmap.GetPixmap(); + GdkBitmap *mask = (GdkBitmap *)NULL; + if ( bitmap.GetMask() ) + mask = bitmap.GetMask()->GetBitmap(); - GdkBitmap *mask = (GdkBitmap *)NULL; - if ( bitmap.GetMask() ) - mask = bitmap.GetMask()->GetBitmap(); - - tool_pixmap = gtk_pixmap_new( pixmap, mask ); - gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE ); - } + tool_pixmap = gtk_pixmap_new( pixmap, mask ); + gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE ); gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 ); @@ -527,12 +490,6 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *toolBase) case wxTOOL_STYLE_BUTTON: gtk_widget_destroy( tool->m_item ); break; - -#ifdef __WXGTK20__ - case wxTOOL_STYLE_SEPARATOR: - gtk_toolbar_remove_space( m_toolbar, pos ); - break; -#endif } InvalidateBestSize(); @@ -595,10 +552,8 @@ void wxToolBar::SetMargins( int x, int y ) wxCHECK_RET( GetToolsCount() == 0, wxT("wxToolBar::SetMargins must be called before adding tools.") ); -#ifndef __WXGTK20__ if (x > 1) gtk_toolbar_append_space( m_toolbar ); // oh well -#endif m_xMargin = x; m_yMargin = y; @@ -606,10 +561,7 @@ void wxToolBar::SetMargins( int x, int y ) void wxToolBar::SetToolSeparation( int separation ) { - // FIXME: this function disappeared -#ifndef __WXGTK20__ gtk_toolbar_set_space_size( m_toolbar, separation ); -#endif m_toolSeparation = separation; } @@ -683,15 +635,11 @@ void wxToolBar::OnInternalIdle() wxVisualAttributes wxToolBar::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) { -#ifdef __WXGTK20__ - return GetDefaultAttributesFromGTKWidget(gtk_toolbar_new); -#else wxVisualAttributes attr; GtkWidget* widget = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); attr = GetDefaultAttributesFromGTKWidget(widget); gtk_widget_destroy(widget); return attr; -#endif } #endif // wxUSE_TOOLBAR_NATIVE diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index a6dfa4b31d..e7117ec992 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -25,7 +25,7 @@ #include #include "wx/math.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include //----------------------------------------------------------------------------- @@ -46,142 +46,6 @@ extern wxWindowGTK *g_delayedFocus; // helpers // ---------------------------------------------------------------------------- -#ifdef __WXGTK20__ -extern "C" { -static void wxGtkOnRemoveTag(GtkTextBuffer *buffer, - GtkTextTag *tag, - GtkTextIter *start, - GtkTextIter *end, - char *prefix) -{ - gchar *name; - g_object_get (tag, "name", &name, NULL); - - if (!name || strncmp(name, prefix, strlen(prefix))) - // anonymous tag or not starting with prefix - don't remove - g_signal_stop_emission_by_name(buffer, "remove_tag"); - - g_free(name); -} -} - -extern "C" { -static void wxGtkTextApplyTagsFromAttr(GtkTextBuffer *text_buffer, - const wxTextAttr& attr, - GtkTextIter *start, - GtkTextIter *end) -{ - static gchar buf[1024]; - GtkTextTag *tag; - - gulong remove_handler_id = g_signal_connect( text_buffer, "remove_tag", - G_CALLBACK(wxGtkOnRemoveTag), gpointer("WX")); - gtk_text_buffer_remove_all_tags(text_buffer, start, end); - g_signal_handler_disconnect( text_buffer, remove_handler_id ); - - if (attr.HasFont()) - { - char *font_string; - PangoFontDescription *font_description = attr.GetFont().GetNativeFontInfo()->description; - font_string = pango_font_description_to_string(font_description); - g_snprintf(buf, sizeof(buf), "WXFONT %s", font_string); - tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ), - buf ); - if (!tag) - tag = gtk_text_buffer_create_tag( text_buffer, buf, - "font-desc", font_description, - NULL ); - gtk_text_buffer_apply_tag (text_buffer, tag, start, end); - g_free (font_string); - } - - if (attr.HasTextColour()) - { - GdkColor *colFg = attr.GetTextColour().GetColor(); - g_snprintf(buf, sizeof(buf), "WXFORECOLOR %d %d %d", - colFg->red, colFg->green, colFg->blue); - tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ), - buf ); - if (!tag) - tag = gtk_text_buffer_create_tag( text_buffer, buf, - "foreground-gdk", colFg, NULL ); - gtk_text_buffer_apply_tag (text_buffer, tag, start, end); - } - - if (attr.HasBackgroundColour()) - { - GdkColor *colBg = attr.GetBackgroundColour().GetColor(); - g_snprintf(buf, sizeof(buf), "WXBACKCOLOR %d %d %d", - colBg->red, colBg->green, colBg->blue); - tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ), - buf ); - if (!tag) - tag = gtk_text_buffer_create_tag( text_buffer, buf, - "background-gdk", colBg, NULL ); - gtk_text_buffer_apply_tag (text_buffer, tag, start, end); - } - - if (attr.HasAlignment()) - { - GtkTextIter para_start, para_end = *end; - gtk_text_buffer_get_iter_at_line( text_buffer, - ¶_start, - gtk_text_iter_get_line(start) ); - gtk_text_iter_forward_line(¶_end); - - remove_handler_id = g_signal_connect( text_buffer, "remove_tag", - G_CALLBACK(wxGtkOnRemoveTag), - gpointer("WXALIGNMENT")); - gtk_text_buffer_remove_all_tags( text_buffer, ¶_start, ¶_end ); - g_signal_handler_disconnect( text_buffer, remove_handler_id ); - - GtkJustification align; - switch (attr.GetAlignment()) - { - default: - align = GTK_JUSTIFY_LEFT; - break; - case wxTEXT_ALIGNMENT_RIGHT: - align = GTK_JUSTIFY_RIGHT; - break; - case wxTEXT_ALIGNMENT_CENTER: - align = GTK_JUSTIFY_CENTER; - break; - // gtk+ doesn't support justify as of gtk+-2.7.4 - } - - g_snprintf(buf, sizeof(buf), "WXALIGNMENT %d", align); - tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ), - buf ); - if (!tag) - tag = gtk_text_buffer_create_tag( text_buffer, buf, - "justification", align, NULL ); - gtk_text_buffer_apply_tag( text_buffer, tag, ¶_start, ¶_end ); - } -} -} - -extern "C" { -static void wxGtkTextInsert(GtkWidget *text, - GtkTextBuffer *text_buffer, - const wxTextAttr& attr, - const wxCharBuffer& buffer) - -{ - gint start_offset; - GtkTextIter iter, start; - - gtk_text_buffer_get_iter_at_mark( text_buffer, &iter, - gtk_text_buffer_get_insert (text_buffer) ); - start_offset = gtk_text_iter_get_offset (&iter); - gtk_text_buffer_insert( text_buffer, &iter, buffer, strlen(buffer) ); - - gtk_text_buffer_get_iter_at_offset (text_buffer, &start, start_offset); - - wxGtkTextApplyTagsFromAttr(text_buffer, attr, &start, &iter); -} -} -#else extern "C" { static void wxGtkTextInsert(GtkWidget *text, const wxTextAttr& attr, @@ -201,7 +65,6 @@ static void wxGtkTextInsert(GtkWidget *text, gtk_text_insert( GTK_TEXT(text), font, colFg, colBg, txt, len ); } } -#endif // GTK 1.x // ---------------------------------------------------------------------------- // "insert_text" for GtkEntry @@ -245,215 +108,6 @@ gtk_insert_text_callback(GtkEditable *editable, } } -#ifdef __WXGTK20__ -// Implementation of wxTE_AUTO_URL for wxGTK2 by Mart Raudsepp, - -extern "C" { -static void -au_apply_tag_callback(GtkTextBuffer *buffer, - GtkTextTag *tag, - GtkTextIter *start, - GtkTextIter *end, - gpointer textctrl) -{ - if(tag == gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buffer), "wxUrl")) - g_signal_stop_emission_by_name(buffer, "apply_tag"); -} -} - -//----------------------------------------------------------------------------- -// GtkTextCharPredicates for gtk_text_iter_*_find_char -//----------------------------------------------------------------------------- - -extern "C" { -static gboolean -pred_whitespace (gunichar ch, gpointer user_data) -{ - return g_unichar_isspace(ch); -} -} - -extern "C" { -static gboolean -pred_non_whitespace (gunichar ch, gpointer user_data) -{ - return !g_unichar_isspace(ch); -} -} - -extern "C" { -static gboolean -pred_nonpunct (gunichar ch, gpointer user_data) -{ - return !g_unichar_ispunct(ch); -} -} - -extern "C" { -static gboolean -pred_nonpunct_or_slash (gunichar ch, gpointer user_data) -{ - return !g_unichar_ispunct(ch) || ch == '/'; -} -} - -//----------------------------------------------------------------------------- -// Check for links between s and e and correct tags as necessary -//----------------------------------------------------------------------------- - -// This function should be made match better while being efficient at one point. -// Most probably with a row of regular expressions. -extern "C" { -static void -au_check_word( GtkTextIter *s, GtkTextIter *e ) -{ - static const char *URIPrefixes[] = - { - "http://", - "ftp://", - "www.", - "ftp.", - "mailto://", - "https://", - "file://", - "nntp://", - "news://", - "telnet://", - "mms://", - "gopher://", - "prospero://", - "wais://", - }; - - GtkTextIter start = *s, end = *e; - GtkTextBuffer *buffer = gtk_text_iter_get_buffer(s); - - // Get our special link tag - GtkTextTag *tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buffer), "wxUrl"); - - // Get rid of punctuation from beginning and end. - // Might want to move this to au_check_range if an improved link checking doesn't - // use some intelligent punctuation checking itself (beware of undesired iter modifications). - if(g_unichar_ispunct( gtk_text_iter_get_char( &start ) ) ) - gtk_text_iter_forward_find_char( &start, pred_nonpunct, NULL, e ); - - gtk_text_iter_backward_find_char( &end, pred_nonpunct_or_slash, NULL, &start ); - gtk_text_iter_forward_char(&end); - - gchar* text = gtk_text_iter_get_text( &start, &end ); - size_t len = strlen(text), prefix_len; - size_t n; - - for( n = 0; n < WXSIZEOF(URIPrefixes); ++n ) - { - prefix_len = strlen(URIPrefixes[n]); - if((len > prefix_len) && !strncasecmp(text, URIPrefixes[n], prefix_len)) - break; - } - - if(n < WXSIZEOF(URIPrefixes)) - { - gulong signal_id = g_signal_handler_find(buffer, - (GSignalMatchType) (G_SIGNAL_MATCH_FUNC), - 0, 0, NULL, - (gpointer)au_apply_tag_callback, NULL); - - g_signal_handler_block(buffer, signal_id); - gtk_text_buffer_apply_tag(buffer, tag, &start, &end); - g_signal_handler_unblock(buffer, signal_id); - } -} -} - -extern "C" { -static void -au_check_range(GtkTextIter *s, - GtkTextIter *range_end) -{ - GtkTextIter range_start = *s; - GtkTextIter word_end; - GtkTextBuffer *buffer = gtk_text_iter_get_buffer(s); - GtkTextTag *tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buffer), "wxUrl"); - - gtk_text_buffer_remove_tag(buffer, tag, s, range_end); - - if(g_unichar_isspace(gtk_text_iter_get_char(&range_start))) - gtk_text_iter_forward_find_char(&range_start, pred_non_whitespace, NULL, range_end); - - while(!gtk_text_iter_equal(&range_start, range_end)) - { - word_end = range_start; - gtk_text_iter_forward_find_char(&word_end, pred_whitespace, NULL, range_end); - - // Now we should have a word delimited by range_start and word_end, correct link tags - au_check_word(&range_start, &word_end); - - range_start = word_end; - gtk_text_iter_forward_find_char(&range_start, pred_non_whitespace, NULL, range_end); - } -} -} - -//----------------------------------------------------------------------------- -// "insert-text" for GtkTextBuffer -//----------------------------------------------------------------------------- - -extern "C" { -static void -au_insert_text_callback(GtkTextBuffer *buffer, - GtkTextIter *end, - gchar *text, - gint len, - wxTextCtrl *win) -{ - if (!len || !(win->GetWindowStyleFlag() & wxTE_AUTO_URL) ) - return; - - GtkTextIter start = *end; - gtk_text_iter_backward_chars(&start, g_utf8_strlen(text, len)); - - GtkTextIter line_start = start; - GtkTextIter line_end = *end; - GtkTextIter words_start = start; - GtkTextIter words_end = *end; - - gtk_text_iter_set_line(&line_start, gtk_text_iter_get_line(&start)); - gtk_text_iter_forward_to_line_end(&line_end); - gtk_text_iter_backward_find_char(&words_start, pred_whitespace, NULL, &line_start); - gtk_text_iter_forward_find_char(&words_end, pred_whitespace, NULL, &line_end); - - au_check_range(&words_start, &words_end); -} -} - -//----------------------------------------------------------------------------- -// "delete-range" for GtkTextBuffer -//----------------------------------------------------------------------------- - -extern "C" { -static void -au_delete_range_callback(GtkTextBuffer *buffer, - GtkTextIter *start, - GtkTextIter *end, - wxTextCtrl *win) -{ - if( !(win->GetWindowStyleFlag() & wxTE_AUTO_URL) ) - return; - - GtkTextIter line_start = *start, line_end = *end; - - gtk_text_iter_set_line(&line_start, gtk_text_iter_get_line(start)); - gtk_text_iter_forward_to_line_end(&line_end); - gtk_text_iter_backward_find_char(start, pred_whitespace, NULL, &line_start); - gtk_text_iter_forward_find_char(end, pred_whitespace, NULL, &line_end); - - au_check_range(start, end); -} -} - - -#endif - //----------------------------------------------------------------------------- // "changed" //----------------------------------------------------------------------------- @@ -471,9 +125,7 @@ gtk_text_changed_callback( GtkWidget *widget, wxTextCtrl *win ) wxapp_install_idle_handler(); win->SetModified(); -#ifndef __WXGTK20__ win->UpdateFontIfNeeded(); -#endif // !__WXGTK20__ wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() ); event.SetEventObject( win ); @@ -481,25 +133,10 @@ gtk_text_changed_callback( GtkWidget *widget, wxTextCtrl *win ) } } -//----------------------------------------------------------------------------- -// "expose_event" from scrolled window and textview -//----------------------------------------------------------------------------- - -#ifdef __WXGTK20__ -extern "C" { -static gboolean -gtk_text_exposed_callback( GtkWidget *widget, GdkEventExpose *event, wxTextCtrl *win ) -{ - return TRUE; -} -} -#endif - //----------------------------------------------------------------------------- // "changed" from vertical scrollbar //----------------------------------------------------------------------------- -#ifndef __WXGTK20__ extern "C" { static void gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) @@ -512,14 +149,11 @@ gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) win->CalculateScrollbar(); } } -#endif // ---------------------------------------------------------------------------- // redraw callback for multiline text // ---------------------------------------------------------------------------- -#ifndef __WXGTK20__ - // redrawing a GtkText from inside a wxYield() call results in crashes (the // text sample shows it in its "Add lines" command which shows wxProgressDialog // which implicitly calls wxYield()) so we override GtkText::draw() and simply @@ -546,8 +180,6 @@ static void wxgtk_text_draw( GtkWidget *widget, GdkRectangle *rect) } } -#endif // __WXGTK20__ - //----------------------------------------------------------------------------- // wxTextCtrl //----------------------------------------------------------------------------- @@ -568,18 +200,6 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste) EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo) EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo) - -#ifdef __WXGTK20__ - // wxTE_AUTO_URL wxTextUrl support. Currently only creates - // wxTextUrlEvent in the same cases as wxMSW, more can be added here. - EVT_MOTION (wxTextCtrl::OnUrlMouseEvent) - EVT_LEFT_DOWN (wxTextCtrl::OnUrlMouseEvent) - EVT_LEFT_UP (wxTextCtrl::OnUrlMouseEvent) - EVT_LEFT_DCLICK (wxTextCtrl::OnUrlMouseEvent) - EVT_RIGHT_DOWN (wxTextCtrl::OnUrlMouseEvent) - EVT_RIGHT_UP (wxTextCtrl::OnUrlMouseEvent) - EVT_RIGHT_DCLICK(wxTextCtrl::OnUrlMouseEvent) -#endif END_EVENT_TABLE() void wxTextCtrl::Init() @@ -589,21 +209,10 @@ void wxTextCtrl::Init() SetUpdateFont(false); m_text = m_vScrollbar = (GtkWidget *)NULL; -#ifdef __WXGTK20__ - m_frozenness = 0; - m_gdkHandCursor = NULL; - m_gdkXTermCursor = NULL; -#endif } wxTextCtrl::~wxTextCtrl() { -#ifdef __WXGTK20__ - if(m_gdkHandCursor) - gdk_cursor_unref(m_gdkHandCursor); - if(m_gdkXTermCursor) - gdk_cursor_unref(m_gdkXTermCursor); -#endif } wxTextCtrl::wxTextCtrl( wxWindow *parent, @@ -646,50 +255,6 @@ bool wxTextCtrl::Create( wxWindow *parent, if (multi_line) { -#ifdef __WXGTK20__ - // Create view - m_text = gtk_text_view_new(); - - m_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); - - // create scrolled window - m_widget = gtk_scrolled_window_new( NULL, NULL ); - gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( m_widget ), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); - - // Insert view into scrolled window - gtk_container_add( GTK_CONTAINER(m_widget), m_text ); - - // translate wx wrapping style to GTK+ - GtkWrapMode wrap; - if ( HasFlag( wxTE_DONTWRAP ) ) - wrap = GTK_WRAP_NONE; - else if ( HasFlag( wxTE_CHARWRAP ) ) - wrap = GTK_WRAP_CHAR; - else if ( HasFlag( wxTE_WORDWRAP ) ) - wrap = GTK_WRAP_WORD; - else // HasFlag(wxTE_BESTWRAP) always true as wxTE_BESTWRAP == 0 - { - // GTK_WRAP_WORD_CHAR seems to be new in GTK+ 2.4 -#ifdef __WXGTK24__ - if ( !gtk_check_version(2,4,0) ) - { - wrap = GTK_WRAP_WORD_CHAR; - } - else -#endif - wrap = GTK_WRAP_WORD; - } - - gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), wrap ); - - if (!HasFlag(wxNO_BORDER)) - gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_widget), GTK_SHADOW_IN ); - - gtk_widget_add_events( GTK_WIDGET(m_text), GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK ); - - GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); -#else // GTK+ 1 // create our control ... m_text = gtk_text_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); @@ -712,18 +277,12 @@ bool wxTextCtrl::Create( wxWindow *parent, GTK_FILL, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), 0, 0); -#endif // GTK+ 2/1 } else { // a single-line text control: no need for scrollbars m_widget = m_text = gtk_entry_new(); - -#ifdef __WXGTK20__ - if (style & wxNO_BORDER) - g_object_set( GTK_ENTRY(m_text), "has-frame", FALSE, NULL ); -#endif } m_parent->DoAddChild( this ); @@ -735,7 +294,6 @@ bool wxTextCtrl::Create( wxWindow *parent, if (multi_line) gtk_widget_show(m_text); -#ifndef __WXGTK20__ if (multi_line) { gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed", @@ -753,14 +311,9 @@ bool wxTextCtrl::Create( wxWindow *parent, draw = wxgtk_text_draw; } } -#endif // GTK+ 1.x if (!value.empty()) { -#ifdef __WXGTK20__ - SetValue( value ); -#else - #if !GTK_CHECK_VERSION(1, 2, 0) // if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in // gtk_editable_insert_text() @@ -780,8 +333,6 @@ bool wxTextCtrl::Create( wxWindow *parent, // Bring editable's cursor uptodate. Bug in GTK. SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) )); } - -#endif } if (style & wxTE_PASSWORD) @@ -794,92 +345,16 @@ bool wxTextCtrl::Create( wxWindow *parent, { if (!multi_line) gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE ); -#ifdef __WXGTK20__ - else - gtk_text_view_set_editable( GTK_TEXT_VIEW( m_text), FALSE); -#else } else { if (multi_line) gtk_text_set_editable( GTK_TEXT(m_text), 1 ); -#endif - } - -#ifdef __WXGTK20__ - if (multi_line) - { - if (style & wxTE_RIGHT) - gtk_text_view_set_justification( GTK_TEXT_VIEW(m_text), GTK_JUSTIFY_RIGHT ); - else if (style & wxTE_CENTRE) - gtk_text_view_set_justification( GTK_TEXT_VIEW(m_text), GTK_JUSTIFY_CENTER ); - // Left justify (alignment) is the default and we don't need to apply GTK_JUSTIFY_LEFT - } - else - { -#ifdef __WXGTK24__ - // gtk_entry_set_alignment was introduced in gtk+-2.3.5 - if (!gtk_check_version(2,4,0)) - { - if (style & wxTE_RIGHT) - gtk_entry_set_alignment( GTK_ENTRY(m_text), 1.0 ); - else if (style & wxTE_CENTRE) - gtk_entry_set_alignment( GTK_ENTRY(m_text), 0.5 ); - } -#endif } -#endif // __WXGTK20__ // We want to be notified about text changes. -#ifdef __WXGTK20__ - if (multi_line) - { - g_signal_connect( G_OBJECT(m_buffer), "changed", - GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - - // .. and handle URLs on multi-line controls with wxTE_AUTO_URL style - if (style & wxTE_AUTO_URL) - { - GtkTextIter start, end; - m_gdkHandCursor = gdk_cursor_new(GDK_HAND2); - m_gdkXTermCursor = gdk_cursor_new(GDK_XTERM); - - // We create our wxUrl tag here for slight efficiency gain - we - // don't have to check for the tag existance in callbacks, - // hereby it's guaranteed to exist. - gtk_text_buffer_create_tag(m_buffer, "wxUrl", - "foreground", "blue", - "underline", PANGO_UNDERLINE_SINGLE, - NULL); - - // Check for URLs after each text change - g_signal_connect_after( G_OBJECT(m_buffer), "insert_text", - GTK_SIGNAL_FUNC(au_insert_text_callback), (gpointer)this); - g_signal_connect_after( G_OBJECT(m_buffer), "delete_range", - GTK_SIGNAL_FUNC(au_delete_range_callback), (gpointer)this); - - // Block all wxUrl tag applying unless we do it ourselves, in which case we - // block this callback temporarily. This takes care of gtk+ internal - // gtk_text_buffer_insert_range* calls that would copy our URL tag otherwise, - // which is undesired because only a part of the URL might be copied. - // The insert-text signal emitted inside it will take care of newly formed - // or wholly copied URLs. - g_signal_connect( G_OBJECT(m_buffer), "apply_tag", - GTK_SIGNAL_FUNC(au_apply_tag_callback), NULL); - - // Check for URLs in the initial string passed to Create - gtk_text_buffer_get_start_iter(m_buffer, &start); - gtk_text_buffer_get_end_iter(m_buffer, &end); - au_check_range(&start, &end); - } - } - else -#endif - - { - gtk_signal_connect( GTK_OBJECT(m_text), "changed", - GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - } + gtk_signal_connect( GTK_OBJECT(m_text), "changed", + GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); m_cursor = wxCursor( wxCURSOR_IBEAM ); @@ -892,7 +367,6 @@ bool wxTextCtrl::Create( wxWindow *parent, void wxTextCtrl::CalculateScrollbar() { -#ifndef __WXGTK20__ if ((m_windowStyle & wxTE_MULTILINE) == 0) return; GtkAdjustment *adj = GTK_TEXT(m_text)->vadj; @@ -913,7 +387,6 @@ void wxTextCtrl::CalculateScrollbar() m_vScrollbarVisible = true; } } -#endif } wxString wxTextCtrl::GetValue() const @@ -923,28 +396,10 @@ wxString wxTextCtrl::GetValue() const wxString tmp; if (m_windowStyle & wxTE_MULTILINE) { -#ifdef __WXGTK20__ - GtkTextIter start; - gtk_text_buffer_get_start_iter( m_buffer, &start ); - GtkTextIter end; - gtk_text_buffer_get_end_iter( m_buffer, &end ); - gchar *text = gtk_text_buffer_get_text( m_buffer, &start, &end, TRUE ); - -#if wxUSE_UNICODE - wxWCharBuffer buffer( wxConvUTF8.cMB2WX( text ) ); -#else - wxCharBuffer buffer( wxConvLocal.cWC2WX( wxConvUTF8.cMB2WC( text ) ) ); -#endif - if ( buffer ) - tmp = buffer; - - g_free( text ); -#else gint len = gtk_text_get_length( GTK_TEXT(m_text) ); char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len ); tmp = text; g_free( text ); -#endif } else { @@ -960,30 +415,10 @@ void wxTextCtrl::SetValue( const wxString &value ) if (m_windowStyle & wxTE_MULTILINE) { -#ifdef __WXGTK20__ - -#if wxUSE_UNICODE - wxCharBuffer buffer( wxConvUTF8.cWX2MB( value) ); -#else - wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( value ) ) ); -#endif - if (gtk_text_buffer_get_char_count(m_buffer) != 0) - IgnoreNextTextUpdate(); - - if ( !buffer ) - { - // what else can we do? at least don't crash... - return; - } - - gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) ); - -#else gint len = gtk_text_get_length( GTK_TEXT(m_text) ); gtk_editable_delete_text( GTK_EDITABLE(m_text), 0, len ); len = 0; gtk_editable_insert_text( GTK_EDITABLE(m_text), value.mbc_str(), value.Length(), &len ); -#endif } else { @@ -1012,30 +447,6 @@ void wxTextCtrl::WriteText( const wxString &text ) if ( m_windowStyle & wxTE_MULTILINE ) { -#ifdef __WXGTK20__ - -#if wxUSE_UNICODE - wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) ); -#else - wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) ); -#endif - if ( !buffer ) - { - // what else can we do? at least don't crash... - return; - } - - // TODO: Call whatever is needed to delete the selection. - wxGtkTextInsert( m_text, m_buffer, m_defaultStyle, buffer ); - - GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(m_widget) ); - // Scroll to cursor, but only if scrollbar thumb is at the very bottom - if ( wxIsSameDouble(adj->value, adj->upper - adj->page_size) ) - { - gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text), - gtk_text_buffer_get_insert( m_buffer ), 0.0, FALSE, 0.0, 1.0 ); - } -#else // GTK 1.x // After cursor movements, gtk_text_get_point() is wrong by one. gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) ); @@ -1054,7 +465,6 @@ void wxTextCtrl::WriteText( const wxString &text ) // Bring editable's cursor back uptodate. SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) )); -#endif // GTK 1.x/2.0 } else // single line { @@ -1064,24 +474,7 @@ void wxTextCtrl::WriteText( const wxString &text ) // This moves the cursor pos to behind the inserted text. gint len = GET_EDITABLE_POS(m_text); -#ifdef __WXGTK20__ - -#if wxUSE_UNICODE - wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) ); -#else - wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) ); -#endif - if ( !buffer ) - { - // what else can we do? at least don't crash... - return; - } - - gtk_editable_insert_text( GTK_EDITABLE(m_text), buffer, strlen(buffer), &len ); - -#else gtk_editable_insert_text( GTK_EDITABLE(m_text), text.c_str(), text.Len(), &len ); -#endif // Bring entry's cursor uptodate. gtk_entry_set_position( GTK_ENTRY(m_text), len ); @@ -1100,7 +493,6 @@ wxString wxTextCtrl::GetLineText( long lineNo ) const { if (m_windowStyle & wxTE_MULTILINE) { -#ifndef __WXGTK20__ gint len = gtk_text_get_length( GTK_TEXT(m_text) ); char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len ); @@ -1124,16 +516,6 @@ wxString wxTextCtrl::GetLineText( long lineNo ) const { return wxEmptyString; } -#else - GtkTextIter line; - gtk_text_buffer_get_iter_at_line(m_buffer,&line,lineNo); - GtkTextIter end = line; - gtk_text_iter_forward_to_line_end(&end); - gchar *text = gtk_text_buffer_get_text(m_buffer,&line,&end,TRUE); - wxString result(wxGTK_CONV_BACK(text)); - g_free(text); - return result; -#endif } else { @@ -1153,15 +535,6 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const { if ( m_windowStyle & wxTE_MULTILINE ) { -#ifdef __WXGTK20__ - GtkTextIter iter; - gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, pos); - if (gtk_text_iter_is_end(&iter)) - return false; - - *y = gtk_text_iter_get_line(&iter); - *x = gtk_text_iter_get_line_offset(&iter); -#else wxString text = GetValue(); // cast to prevent warning. But pos really should've been unsigned. @@ -1182,7 +555,6 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const else (*x)++; } -#endif } else // single line control { @@ -1205,54 +577,23 @@ long wxTextCtrl::XYToPosition(long x, long y ) const { if (!(m_windowStyle & wxTE_MULTILINE)) return 0; -#ifdef __WXGTK20__ - GtkTextIter iter; - if (y >= gtk_text_buffer_get_line_count (m_buffer)) - return -1; - - gtk_text_buffer_get_iter_at_line(m_buffer, &iter, y); - if (x >= gtk_text_iter_get_chars_in_line (&iter)) - return -1; - - return gtk_text_iter_get_offset(&iter) + x; -#else long pos=0; for( int i=0; i last_line) - return -1; - - GtkTextIter iter; - gtk_text_buffer_get_iter_at_line(m_buffer, &iter, lineNo); - // get_chars_in_line return includes paragraph delimiters, so need to subtract 1 IF it is not the last line - return gtk_text_iter_get_chars_in_line(&iter) - ((lineNo == last_line) ? 0 : 1); - } - else -#endif - { - wxString str = GetLineText (lineNo); - return (int) str.Length(); - } + wxString str = GetLineText (lineNo); + return (int) str.Length(); } int wxTextCtrl::GetNumberOfLines() const { if (m_windowStyle & wxTE_MULTILINE) { -#ifdef __WXGTK20__ - return gtk_text_buffer_get_line_count( m_buffer ); -#else gint len = gtk_text_get_length( GTK_TEXT(m_text) ); char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len ); @@ -1273,7 +614,6 @@ int wxTextCtrl::GetNumberOfLines() const { return 0; } -#endif } else { @@ -1287,16 +627,6 @@ void wxTextCtrl::SetInsertionPoint( long pos ) if ( IsMultiLine() ) { -#ifdef __WXGTK20__ - GtkTextIter iter; - gtk_text_buffer_get_iter_at_offset( m_buffer, &iter, pos ); - gtk_text_buffer_place_cursor( m_buffer, &iter ); - gtk_text_view_scroll_mark_onscreen - ( - GTK_TEXT_VIEW(m_text), - gtk_text_buffer_get_insert( m_buffer ) - ); -#else // GTK+ 1.x gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); @@ -1313,7 +643,6 @@ void wxTextCtrl::SetInsertionPoint( long pos ) // bring editable's cursor uptodate. Bug in GTK. SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) )); -#endif // GTK+ 2/1 } else { @@ -1330,13 +659,7 @@ void wxTextCtrl::SetInsertionPointEnd() if (m_windowStyle & wxTE_MULTILINE) { -#ifdef __WXGTK20__ - GtkTextIter end; - gtk_text_buffer_get_end_iter( m_buffer, &end ); - gtk_text_buffer_place_cursor( m_buffer, &end ); -#else SetInsertionPoint(gtk_text_get_length(GTK_TEXT(m_text))); -#endif } else { @@ -1350,11 +673,7 @@ void wxTextCtrl::SetEditable( bool editable ) if (m_windowStyle & wxTE_MULTILINE) { -#ifdef __WXGTK20__ - gtk_text_view_set_editable( GTK_TEXT_VIEW(m_text), editable ); -#else gtk_text_set_editable( GTK_TEXT(m_text), editable ); -#endif } else { @@ -1372,12 +691,8 @@ bool wxTextCtrl::Enable( bool enable ) if (m_windowStyle & wxTE_MULTILINE) { -#ifdef __WXGTK20__ - SetEditable( enable ); -#else gtk_text_set_editable( GTK_TEXT(m_text), enable ); OnParentEnable(enable); -#endif } else { @@ -1482,7 +797,6 @@ void wxTextCtrl::SetSelection( long from, long to ) to = GetValue().Length(); } -#ifndef __WXGTK20__ if ( (m_windowStyle & wxTE_MULTILINE) && !GTK_TEXT(m_text)->line_start_cache ) { @@ -1490,20 +804,10 @@ void wxTextCtrl::SetSelection( long from, long to ) wxLogDebug(_T("Can't call SetSelection() before realizing the control")); return; } -#endif if (m_windowStyle & wxTE_MULTILINE) { -#ifdef __WXGTK20__ - GtkTextIter fromi, toi; - gtk_text_buffer_get_iter_at_offset( m_buffer, &fromi, from ); - gtk_text_buffer_get_iter_at_offset( m_buffer, &toi, to ); - - gtk_text_buffer_place_cursor( m_buffer, &toi ); - gtk_text_buffer_move_mark_by_name( m_buffer, "selection_bound", &fromi ); -#else gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to ); -#endif } else { @@ -1515,13 +819,6 @@ void wxTextCtrl::ShowPosition( long pos ) { if (m_windowStyle & wxTE_MULTILINE) { -#ifdef __WXGTK20__ - GtkTextIter iter; - gtk_text_buffer_get_start_iter( m_buffer, &iter ); - gtk_text_iter_set_offset( &iter, pos ); - GtkTextMark *mark = gtk_text_buffer_create_mark( m_buffer, NULL, &iter, TRUE ); - gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text), mark, 0.0, FALSE, 0.0, 0.0 ); -#else // GTK 1.x GtkAdjustment *vp = GTK_TEXT(m_text)->vadj; float totalLines = (float) GetNumberOfLines(); long posX; @@ -1530,62 +827,13 @@ void wxTextCtrl::ShowPosition( long pos ) float posLine = (float) posY; float p = (posLine/totalLines)*(vp->upper - vp->lower) + vp->lower; gtk_adjustment_set_value(GTK_TEXT(m_text)->vadj, p); -#endif // GTK 1.x/2.x - } -} - -#ifdef __WXGTK20__ - -wxTextCtrlHitTestResult -wxTextCtrl::HitTest(const wxPoint& pt, long *pos) const -{ - if ( !IsMultiLine() ) - { - // not supported - return wxTE_HT_UNKNOWN; } - - int x, y; - gtk_text_view_window_to_buffer_coords - ( - GTK_TEXT_VIEW(m_text), - GTK_TEXT_WINDOW_TEXT, - pt.x, pt.y, - &x, &y - ); - - GtkTextIter iter; - gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(m_text), &iter, x, y); - if ( pos ) - *pos = gtk_text_iter_get_offset(&iter); - - return wxTE_HT_ON_TEXT; } -#endif // __WXGTK20__ - long wxTextCtrl::GetInsertionPoint() const { wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") ); - -#ifdef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - { - // There is no direct accessor for the cursor, but - // internally, the cursor is the "mark" called - // "insert" in the text view's btree structure. - - GtkTextMark *mark = gtk_text_buffer_get_insert( m_buffer ); - GtkTextIter cursor; - gtk_text_buffer_get_iter_at_mark( m_buffer, &cursor, mark ); - - return gtk_text_iter_get_offset( &cursor ); - } - else -#endif - { - return (long) GET_EDITABLE_POS(m_text); - } + return (long) GET_EDITABLE_POS(m_text); } wxTextPos wxTextCtrl::GetLastPosition() const @@ -1596,14 +844,7 @@ wxTextPos wxTextCtrl::GetLastPosition() const if (m_windowStyle & wxTE_MULTILINE) { -#ifdef __WXGTK20__ - GtkTextIter end; - gtk_text_buffer_get_end_iter( m_buffer, &end ); - - pos = gtk_text_iter_get_offset( &end ); -#else pos = gtk_text_get_length( GTK_TEXT(m_text) ); -#endif } else { @@ -1616,18 +857,6 @@ wxTextPos wxTextCtrl::GetLastPosition() const void wxTextCtrl::Remove( long from, long to ) { wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - -#ifdef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - { - GtkTextIter fromi, toi; - gtk_text_buffer_get_iter_at_offset( m_buffer, &fromi, from ); - gtk_text_buffer_get_iter_at_offset( m_buffer, &toi, to ); - - gtk_text_buffer_delete( m_buffer, &fromi, &toi ); - } - else // single line -#endif gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); } @@ -1639,10 +868,6 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value ) if (!value.empty()) { -#ifdef __WXGTK20__ - SetInsertionPoint( from ); - WriteText( value ); -#else // GTK 1.x gint pos = (gint)from; #if wxUSE_UNICODE wxWX2MBbuf buf = value.mbc_str(); @@ -1650,44 +875,25 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value ) #else gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos ); #endif // wxUSE_UNICODE -#endif // GTK 1.x/2.x } } void wxTextCtrl::Cut() { wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - -#ifdef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - g_signal_emit_by_name(m_text, "cut-clipboard"); - else -#endif - gtk_editable_cut_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG); + gtk_editable_cut_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG); } void wxTextCtrl::Copy() { wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - -#ifdef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - g_signal_emit_by_name(m_text, "copy-clipboard"); - else -#endif - gtk_editable_copy_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG); + gtk_editable_copy_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG); } void wxTextCtrl::Paste() { wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - -#ifdef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - g_signal_emit_by_name(m_text, "paste-clipboard"); - else -#endif - gtk_editable_paste_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG); + gtk_editable_paste_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG); } // Undo/redo @@ -1727,33 +933,12 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const gint to = -1; bool haveSelection = false; -#ifdef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - { - GtkTextIter ifrom, ito; - if ( gtk_text_buffer_get_selection_bounds(m_buffer, &ifrom, &ito) ) - { - haveSelection = true; - from = gtk_text_iter_get_offset(&ifrom); - to = gtk_text_iter_get_offset(&ito); - } - } - else // not multi-line - { - if ( gtk_editable_get_selection_bounds( GTK_EDITABLE(m_text), - &from, &to) ) - { - haveSelection = true; - } - } -#else // not GTK2 if ( (GTK_EDITABLE(m_text)->has_selection) ) { haveSelection = true; from = (long) GTK_EDITABLE(m_text)->selection_start_pos; to = (long) GTK_EDITABLE(m_text)->selection_end_pos; } -#endif if (! haveSelection ) from = to = GetInsertionPoint(); @@ -1776,19 +961,7 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const bool wxTextCtrl::IsEditable() const { wxCHECK_MSG( m_text != NULL, false, wxT("invalid text ctrl") ); - -#ifdef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - { - return gtk_text_view_get_editable(GTK_TEXT_VIEW(m_text)); - } - else - { - return gtk_editable_get_editable(GTK_EDITABLE(m_text)); - } -#else return GTK_EDITABLE(m_text)->editable; -#endif } bool wxTextCtrl::IsModified() const @@ -1846,11 +1019,7 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) { if (m_windowStyle & wxTE_MULTILINE) { -#ifdef __WXGTK20__ - return window == gtk_text_view_get_window( GTK_TEXT_VIEW( m_text ), GTK_TEXT_WINDOW_TEXT ); // pure guesswork -#else return (window == GTK_TEXT(m_text)->text_area); -#endif } else { @@ -1885,16 +1054,9 @@ void wxTextCtrl::ChangeFontGlobally() { // this method is very inefficient and hence should be called as rarely as // possible! - // - // TODO: it can be implemented much more efficiently for GTK2 -#ifndef __WXGTK20__ wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE) && m_updateFont, _T("shouldn't be called for single line controls") ); -#else - wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE), - _T("shouldn't be called for single line controls") ); -#endif wxString value = GetValue(); if ( !value.empty() ) @@ -1906,16 +1068,12 @@ void wxTextCtrl::ChangeFontGlobally() } } -#ifndef __WXGTK20__ - void wxTextCtrl::UpdateFontIfNeeded() { if ( m_updateFont ) ChangeFontGlobally(); } -#endif // GTK+ 1.x - bool wxTextCtrl::SetForegroundColour(const wxColour& colour) { if ( !wxControl::SetForegroundColour(colour) ) @@ -1934,24 +1092,20 @@ bool wxTextCtrl::SetBackgroundColour( const wxColour &colour ) if ( !wxControl::SetBackgroundColour( colour ) ) return false; -#ifndef __WXGTK20__ if (!m_widget->window) return false; -#endif if (!m_backgroundColour.Ok()) return false; if (m_windowStyle & wxTE_MULTILINE) { -#ifndef __WXGTK20__ GdkWindow *window = GTK_TEXT(m_text)->text_area; if (!window) return false; m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); gdk_window_set_background( window, m_backgroundColour.GetColor() ); gdk_window_clear( window ); -#endif } // change active background color too @@ -1970,23 +1124,6 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) return true; } -#ifdef __WXGTK20__ - gint l = gtk_text_buffer_get_char_count( m_buffer ); - - wxCHECK_MSG( start >= 0 && end <= l, false, - _T("invalid range in wxTextCtrl::SetStyle") ); - - GtkTextIter starti, endi; - gtk_text_buffer_get_iter_at_offset( m_buffer, &starti, start ); - gtk_text_buffer_get_iter_at_offset( m_buffer, &endi, end ); - - // use the attributes from style which are set in it and fall back - // first to the default style and then to the text control default - // colours for the others - wxTextAttr attr = wxTextAttr::Combine(style, m_defaultStyle, this); - - wxGtkTextApplyTagsFromAttr( m_buffer, attr, &starti, &endi ); -#else // VERY dirty way to do that - removes the required text and re-adds it // with styling (FIXME) @@ -2023,7 +1160,6 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) /* does not seem to help under GTK+ 1.2 !!! gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */ SetInsertionPoint( old_pos ); -#endif return true; } @@ -2095,7 +1231,6 @@ void wxTextCtrl::OnInternalIdle() if (cursor.Ok()) { -#ifndef __WXGTK20__ GdkWindow *window = (GdkWindow*) NULL; if (HasFlag(wxTE_MULTILINE)) window = GTK_TEXT(m_text)->text_area; @@ -2111,7 +1246,6 @@ void wxTextCtrl::OnInternalIdle() window = m_widget->window; if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget))) gdk_window_set_cursor( window, cursor.GetCursor() ); -#endif } if (g_delayedFocus == this) @@ -2144,21 +1278,7 @@ void wxTextCtrl::Freeze() { if ( HasFlag(wxTE_MULTILINE) ) { -#ifdef __WXGTK20__ - if ( !m_frozenness++ ) - { - // freeze textview updates and remove buffer - g_signal_connect( G_OBJECT(m_text), "expose_event", - GTK_SIGNAL_FUNC(gtk_text_exposed_callback), (gpointer)this); - g_signal_connect( G_OBJECT(m_widget), "expose_event", - GTK_SIGNAL_FUNC(gtk_text_exposed_callback), (gpointer)this); - gtk_widget_set_sensitive(m_widget, false); - g_object_ref(m_buffer); - gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), gtk_text_buffer_new(NULL)); - } -#else gtk_text_freeze(GTK_TEXT(m_text)); -#endif } } @@ -2166,81 +1286,11 @@ void wxTextCtrl::Thaw() { if ( HasFlag(wxTE_MULTILINE) ) { -#ifdef __WXGTK20__ - wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") ); - - if ( !--m_frozenness ) - { - // Reattach buffer and thaw textview updates - gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), m_buffer); - g_object_unref(m_buffer); - gtk_widget_set_sensitive(m_widget, true); - g_signal_handlers_disconnect_by_func(m_widget, (gpointer)gtk_text_exposed_callback, this); - g_signal_handlers_disconnect_by_func(m_text, (gpointer)gtk_text_exposed_callback, this); - } -#else GTK_TEXT(m_text)->vadj->value = 0.0; gtk_text_thaw(GTK_TEXT(m_text)); -#endif - } -} - -// ---------------------------------------------------------------------------- -// wxTextUrlEvent passing if style & wxTE_AUTO_URL -// ---------------------------------------------------------------------------- - -#ifdef __WXGTK20__ - -// FIXME: when dragging on a link the sample gets an "Unknown event". -// This might be an excessive event from us or a buggy wxMouseEvent::Moving() or -// a buggy sample, or something else -void wxTextCtrl::OnUrlMouseEvent(wxMouseEvent& event) -{ - event.Skip(); - if(!(m_windowStyle & wxTE_AUTO_URL)) - return; - - gint x, y; - GtkTextIter start, end; - GtkTextTag *tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(m_buffer), - "wxUrl"); - - gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(m_text), GTK_TEXT_WINDOW_WIDGET, - event.GetX(), event.GetY(), &x, &y); - - gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(m_text), &end, x, y); - if (!gtk_text_iter_has_tag(&end, tag)) - { - gdk_window_set_cursor(gtk_text_view_get_window(GTK_TEXT_VIEW(m_text), - GTK_TEXT_WINDOW_TEXT), m_gdkXTermCursor); - return; } - - gdk_window_set_cursor(gtk_text_view_get_window(GTK_TEXT_VIEW(m_text), - GTK_TEXT_WINDOW_TEXT), m_gdkHandCursor); - - start = end; - if(!gtk_text_iter_begins_tag(&start, tag)) - gtk_text_iter_backward_to_tag_toggle(&start, tag); - if(!gtk_text_iter_ends_tag(&end, tag)) - gtk_text_iter_forward_to_tag_toggle(&end, tag); - - // Native context menu is probably not desired on an URL. - // Consider making this dependant on ProcessEvent(wxTextUrlEvent) return value - if(event.GetEventType() == wxEVT_RIGHT_DOWN) - event.Skip(false); - - wxTextUrlEvent url_event(m_windowId, event, - gtk_text_iter_get_offset(&start), - gtk_text_iter_get_offset(&end)); - - InitCommandEvent(url_event); - // Is that a good idea? Seems not (pleasure with gtk_text_view_start_selection_drag) - //event.Skip(!GetEventHandler()->ProcessEvent(url_event)); - GetEventHandler()->ProcessEvent(url_event); } -#endif // gtk2 // ---------------------------------------------------------------------------- // scrolling @@ -2251,11 +1301,7 @@ GtkAdjustment *wxTextCtrl::GetVAdj() const if ( !IsMultiLine() ) return NULL; -#ifdef __WXGTK20__ - return gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(m_widget)); -#else return GTK_TEXT(m_text)->vadj; -#endif } bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff) @@ -2277,12 +1323,7 @@ bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff) } adj->value = value; - -#ifdef __WXGTK20__ - gtk_adjustment_value_changed(GTK_ADJUSTMENT(adj)); -#else gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed"); -#endif return true; } @@ -2293,12 +1334,8 @@ bool wxTextCtrl::ScrollLines(int lines) if ( !adj ) return false; -#ifdef __WXGTK20__ - int diff = (int)ceil(lines*adj->step_increment); -#else // this is hardcoded to 10 in GTK+ 1.2 (great idea) int diff = 10*lines; -#endif return DoScroll(adj, diff); } diff --git a/src/gtk1/tglbtn.cpp b/src/gtk1/tglbtn.cpp index cf8a289b9e..d8696cb8a5 100644 --- a/src/gtk1/tglbtn.cpp +++ b/src/gtk1/tglbtn.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/tglbtn.cpp +// Name: wx/gtk1/tglbtn.cpp // Purpose: Definition of the wxToggleButton class, which implements a // toggle button under wxGTK. // Author: John Norris, minor changes by Axel Schlueter @@ -18,7 +18,7 @@ #if wxUSE_TOGGLEBTN -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" extern void wxapp_install_idle_handler(); extern bool g_isIdle; diff --git a/src/gtk1/tooltip.cpp b/src/gtk1/tooltip.cpp index 3b04c2c35d..b44b027d64 100644 --- a/src/gtk1/tooltip.cpp +++ b/src/gtk1/tooltip.cpp @@ -17,7 +17,7 @@ #include "wx/tooltip.h" #include "wx/window.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" //----------------------------------------------------------------------------- // global data diff --git a/src/gtk1/toplevel.cpp b/src/gtk1/toplevel.cpp index 21f458ae64..8c521b4282 100644 --- a/src/gtk1/toplevel.cpp +++ b/src/gtk1/toplevel.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/toplevel.cpp +// Name: src/gtk1/toplevel.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -30,7 +30,7 @@ #include "wx/control.h" #include "wx/app.h" #include "wx/dcclient.h" -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include "wx/timer.h" #include "wx/settings.h" #include "wx/evtloop.h" @@ -41,7 +41,7 @@ #include #include -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/win_gtk.h" #include "wx/unix/utilsx11.h" @@ -103,12 +103,7 @@ static void wxgtk_window_set_urgency_hint (GtkWindow *win, static gint gtk_frame_urgency_timer_callback( wxTopLevelWindowGTK *win ) { -#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,7,0) - if(!gtk_check_version(2,7,0)) - gtk_window_set_urgency_hint(GTK_WINDOW( win->m_widget ), FALSE); - else -#endif - wxgtk_window_set_urgency_hint(GTK_WINDOW( win->m_widget ), FALSE); + wxgtk_window_set_urgency_hint(GTK_WINDOW( win->m_widget ), FALSE); win->m_urgency_hint = -2; return FALSE; @@ -153,14 +148,7 @@ static gint gtk_frame_focus_in_callback( GtkWidget *widget, gtk_timeout_remove( win->m_urgency_hint ); // no break, fallthrough to remove hint too case -1: -#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,7,0) - if(!gtk_check_version(2,7,0)) - gtk_window_set_urgency_hint(GTK_WINDOW( widget ), FALSE); - else -#endif - { - wxgtk_window_set_urgency_hint(GTK_WINDOW( widget ), FALSE); - } + wxgtk_window_set_urgency_hint(GTK_WINDOW( widget ), FALSE); win->m_urgency_hint = -2; break; @@ -400,8 +388,6 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev // "draw" of m_client //----------------------------------------------------------------------------- -#ifndef __WXGTK20__ - extern "C" { static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win ) { @@ -417,8 +403,6 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW } } -#endif // GTK+ 1.x - // ---------------------------------------------------------------------------- // wxTopLevelWindowGTK itself // ---------------------------------------------------------------------------- @@ -517,17 +501,7 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, { if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) { -#ifdef __WXGTK20__ - m_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); - // Tell WM that this is a dialog window and make it center - // on parent by default (this is what GtkDialog ctor does): - gtk_window_set_type_hint(GTK_WINDOW(m_widget), - GDK_WINDOW_TYPE_HINT_DIALOG); - gtk_window_set_position(GTK_WINDOW(m_widget), - GTK_WIN_POS_CENTER_ON_PARENT); -#else m_widget = gtk_window_new(GTK_WINDOW_DIALOG); -#endif } else { @@ -562,26 +536,6 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, GTK_WINDOW(topParent->m_widget) ); } -#if GTK_CHECK_VERSION(2,2,0) - if (!gtk_check_version(2,2,0)) - { - if (style & wxFRAME_NO_TASKBAR) - { - gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), TRUE); - } - } -#endif - -#ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) - { - if (style & wxSTAY_ON_TOP) - { - gtk_window_set_keep_above(GTK_WINDOW(m_widget), TRUE); - } - } -#endif - if (!name.empty()) gtk_window_set_wmclass( GTK_WINDOW(m_widget), wxGTK_CONV( name ), wxGTK_CONV( name ) ); @@ -602,10 +556,8 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, // For m_mainWidget themes gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); -#ifndef __WXGTK20__ gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); -#endif } // m_wxwindow only represents the client area without toolbar and menubar @@ -841,11 +793,7 @@ bool wxTopLevelWindowGTK::Show( bool show ) void wxTopLevelWindowGTK::Raise() { -#ifdef __WXGTK20__ - gtk_window_present( GTK_WINDOW( m_widget ) ); -#else wxWindow::Raise(); -#endif } void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) ) @@ -1149,21 +1097,6 @@ void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) wxTopLevelWindowBase::SetIcons( icons ); -#ifdef __WXGTK20__ - GList *list = NULL; - size_t max = icons.m_icons.GetCount(); - - for (size_t i = 0; i < max; i++) - { - if (icons.m_icons[i].Ok()) - { - list = g_list_prepend(list, icons.m_icons[i].GetPixbuf()); - } - } - gtk_window_set_icon_list(GTK_WINDOW(m_widget), list); - g_list_free(list); - -#else // !__WXGTK20__ GdkWindow* window = m_widget->window; if (!window) return; @@ -1180,7 +1113,6 @@ void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ), (WXWindow)GDK_WINDOW_XWINDOW( window ), icons ); -#endif // !__WXGTK20__ } // ---------------------------------------------------------------------------- @@ -1189,49 +1121,24 @@ void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) void wxTopLevelWindowGTK::Maximize(bool maximize) { -#ifdef __WXGTK20__ - if (maximize) - gtk_window_maximize( GTK_WINDOW( m_widget ) ); - else - gtk_window_unmaximize( GTK_WINDOW( m_widget ) ); -#else wxFAIL_MSG( _T("not implemented") ); -#endif } bool wxTopLevelWindowGTK::IsMaximized() const { -#ifdef __WXGTK20__ - if(!m_widget->window) - return false; - - return gdk_window_get_state(m_widget->window) & GDK_WINDOW_STATE_MAXIMIZED; -#else // wxFAIL_MSG( _T("not implemented") ); // This is an approximation return false; -#endif } void wxTopLevelWindowGTK::Restore() { -#ifdef __WXGTK20__ - // "Present" seems similar enough to "restore" - gtk_window_present( GTK_WINDOW( m_widget ) ); -#else wxFAIL_MSG( _T("not implemented") ); -#endif } void wxTopLevelWindowGTK::Iconize( bool iconize ) { -#ifdef __WXGTK20__ - if (iconize) - gtk_window_iconify( GTK_WINDOW( m_widget ) ); - else - gtk_window_deiconify( GTK_WINDOW( m_widget ) ); -#else if (iconize) { GdkWindow *window = m_widget->window; @@ -1243,7 +1150,6 @@ void wxTopLevelWindowGTK::Iconize( bool iconize ) GDK_WINDOW_XWINDOW( window ), DefaultScreen( GDK_DISPLAY() ) ); } -#endif } bool wxTopLevelWindowGTK::IsIconized() const @@ -1292,14 +1198,10 @@ static bool do_shape_combine_region(GdkWindow* window, const wxRegion& region) } else { -#ifdef __WXGTK20__ - gdk_window_shape_combine_region(window, region.GetRegion(), 0, 0); -#else wxBitmap bmp = region.ConvertToBitmap(); bmp.SetMask(new wxMask(bmp, *wxBLACK)); GdkBitmap* mask = bmp.GetMask()->GetBitmap(); gdk_window_shape_combine_mask(window, mask, 0, 0); -#endif return true; } } @@ -1354,39 +1256,12 @@ void wxTopLevelWindowGTK::RequestUserAttention(int flags) } } -#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,7,0) - if(!gtk_check_version(2,7,0)) - gtk_window_set_urgency_hint(GTK_WINDOW( m_widget ), new_hint_value); - else -#endif - wxgtk_window_set_urgency_hint(GTK_WINDOW( m_widget ), new_hint_value); + wxgtk_window_set_urgency_hint(GTK_WINDOW( m_widget ), new_hint_value); } void wxTopLevelWindowGTK::SetWindowStyleFlag( long style ) { -#ifdef __WXGTK20__ - // Store which styles were changed - long styleChanges = style ^ m_windowStyle; -#endif - // Process wxWindow styles. This also updates the internal variable // Therefore m_windowStyle bits carry now the _new_ style values wxWindow::SetWindowStyleFlag(style); - -#ifdef __WXGTK20__ - // just return for now if widget does not exist yet - if (!m_widget) - return; - -#ifdef __WXGTK24__ - if ( (styleChanges & wxSTAY_ON_TOP) && !gtk_check_version(2,4,0) ) - gtk_window_set_keep_above(GTK_WINDOW(m_widget), m_windowStyle & wxSTAY_ON_TOP); -#endif // GTK+ 2.4 -#if GTK_CHECK_VERSION(2,2,0) - if ( (styleChanges & wxFRAME_NO_TASKBAR) && !gtk_check_version(2,2,0) ) - { - gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), m_windowStyle & wxFRAME_NO_TASKBAR); - } -#endif // GTK+ 2.2 -#endif // GTK+ 2.0 } diff --git a/src/gtk1/treegtk.cpp b/src/gtk1/treegtk.cpp index d1adda4004..58722ba8ac 100644 --- a/src/gtk1/treegtk.cpp +++ b/src/gtk1/treegtk.cpp @@ -20,7 +20,7 @@ #include "wx/wx.h" #endif -#include "wx/gtk/treectrl.h" +#include "wx/gtk1/treectrl.h" #include "wx/textctrl.h" #include "wx/log.h" diff --git a/src/gtk1/utilsgtk.cpp b/src/gtk1/utilsgtk.cpp index 4d780162b6..e05a766246 100644 --- a/src/gtk1/utilsgtk.cpp +++ b/src/gtk1/utilsgtk.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/utilsgtk.cpp +// Name: src/gtk1/utilsgtk.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -31,9 +31,7 @@ #include "glib.h" #include "gdk/gdk.h" #include "gtk/gtk.h" -#ifndef __WXGTK20__ #include "gtk/gtkfeatures.h" -#endif #include "gdk/gdkx.h" #ifdef HAVE_X11_XKBLIB_H @@ -81,43 +79,6 @@ bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) ) } #endif -#ifdef __WXGTK20__ -// Escapes string so that it is valid Pango markup XML string: -wxString wxEscapeStringForPangoMarkup(const wxString& str) -{ - size_t len = str.length(); - wxString out; - out.Alloc(len); - for (size_t i = 0; i < len; i++) - { - wxChar c = str[i]; - switch (c) - { - case _T('&'): - out << _T("&"); - break; - case _T('<'): - out << _T("<"); - break; - case _T('>'): - out << _T(">"); - break; - case _T('\''): - out << _T("'"); - break; - case _T('"'): - out << _T("""); - break; - default: - out << c; - break; - } - } - return out; -} -#endif - - // ---------------------------------------------------------------------------- // display characterstics // ---------------------------------------------------------------------------- @@ -168,11 +129,7 @@ int wxDisplayDepth() wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo() { static wxToolkitInfo info; -#ifdef __WXGTK20__ - info.shortName = _T("gtk2"); -#else info.shortName = _T("gtk"); -#endif info.name = _T("wxGTK"); #ifdef __WXUNIVERSAL__ info.shortName << _T("univ"); diff --git a/src/gtk1/win_gtk.c b/src/gtk1/win_gtk.c index 44222ba55c..f0734d3864 100644 --- a/src/gtk1/win_gtk.c +++ b/src/gtk1/win_gtk.c @@ -14,7 +14,7 @@ #endif #include "wx/setup.h" -#include "wx/gtk/win_gtk.h" +#include "wx/gtk1/win_gtk.h" #include "gtk/gtksignal.h" #include "gtk/gtkprivate.h" #include "gdk/gdkx.h" @@ -23,8 +23,6 @@ extern "C" { #endif /* __cplusplus */ -#ifndef __WXGTK20__ - #include #include #include @@ -32,7 +30,6 @@ extern "C" { #define IS_ONSCREEN(x,y) ((x >= G_MINSHORT) && (x <= G_MAXSHORT) && \ (y >= G_MINSHORT) && (y <= G_MAXSHORT)) -#endif typedef struct _GtkPizzaAdjData GtkPizzaAdjData; @@ -54,10 +51,8 @@ static void gtk_pizza_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_pizza_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -#ifndef __WXGTK20__ static void gtk_pizza_draw (GtkWidget *widget, GdkRectangle *area); -#endif /* __WXGTK20__ */ static gint gtk_pizza_expose (GtkWidget *widget, GdkEventExpose *event); static void gtk_pizza_style_set (GtkWidget *widget, @@ -76,7 +71,6 @@ static void gtk_pizza_allocate_child (GtkPizza *pizza, static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget, gpointer cb_data); -#ifndef __WXGTK20__ static void gtk_pizza_position_child (GtkPizza *pizza, GtkPizzaChild *child); static void gtk_pizza_position_children (GtkPizza *pizza); @@ -87,7 +81,6 @@ static GdkFilterReturn gtk_pizza_filter (GdkXEvent *gdk_xevent, static GdkFilterReturn gtk_pizza_main_filter (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data); -#endif /* __WXGTK20__ */ static GtkType gtk_pizza_child_type (GtkContainer *container); @@ -96,15 +89,9 @@ static void gtk_pizza_scroll_set_adjustments (GtkPizza *pizza, GtkAdjustment *vadj); -#ifdef __WXGTK20__ - GtkContainerClass *pizza_parent_class = NULL; -#else static GtkContainerClass *pizza_parent_class = NULL; -#endif -#ifndef __WXGTK20__ static gboolean gravity_works; -#endif GtkType gtk_pizza_get_type () @@ -113,22 +100,6 @@ gtk_pizza_get_type () if (!pizza_type) { - -#ifdef __WXGTK20__ - static const GTypeInfo pizza_info = - { - sizeof (GtkPizzaClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_pizza_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkPizza), - 16, /* n_preallocs */ - (GInstanceInitFunc) gtk_pizza_init, - }; - pizza_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkPizza", &pizza_info, (GTypeFlags)0); -#else GtkTypeInfo pizza_info = { "GtkPizza", @@ -141,53 +112,11 @@ gtk_pizza_get_type () (GtkClassInitFunc) NULL, }; pizza_type = gtk_type_unique (gtk_container_get_type (), &pizza_info); -#endif } return pizza_type; } -#ifdef __WXGTK20__ -/* Marshaller needed for set_scroll_adjustments signal, - generated with GLib-2.4.6 glib-genmarshal */ -#define g_marshal_value_peek_object(v) g_value_get_object (v) -static void -g_cclosure_user_marshal_VOID__OBJECT_OBJECT (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data) -{ - typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT) (gpointer data1, - gpointer arg_1, - gpointer arg_2, - gpointer data2); - register GMarshalFunc_VOID__OBJECT_OBJECT callback; - register GCClosure *cc = (GCClosure*) closure; - register gpointer data1, data2; - - g_return_if_fail (n_param_values == 3); - - if (G_CCLOSURE_SWAP_DATA (closure)) - { - data1 = closure->data; - data2 = g_value_peek_pointer (param_values + 0); - } - else - { - data1 = g_value_peek_pointer (param_values + 0); - data2 = closure->data; - } - callback = (GMarshalFunc_VOID__OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback); - - callback (data1, - g_marshal_value_peek_object (param_values + 1), - g_marshal_value_peek_object (param_values + 2), - data2); -} -#endif /* __WXGTK20__ */ - static void gtk_pizza_class_init (GtkPizzaClass *klass) { @@ -205,9 +134,7 @@ gtk_pizza_class_init (GtkPizzaClass *klass) widget_class->unrealize = gtk_pizza_unrealize; widget_class->size_request = gtk_pizza_size_request; widget_class->size_allocate = gtk_pizza_size_allocate; -#ifndef __WXGTK20__ widget_class->draw = gtk_pizza_draw; -#endif widget_class->expose_event = gtk_pizza_expose; widget_class->style_set = gtk_pizza_style_set; @@ -220,27 +147,12 @@ gtk_pizza_class_init (GtkPizzaClass *klass) klass->set_scroll_adjustments = gtk_pizza_scroll_set_adjustments; widget_class->set_scroll_adjustments_signal = -#ifdef __WXGTK20__ - g_signal_new( - "set_scroll_adjustments", - G_TYPE_FROM_CLASS(object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(GtkPizzaClass, set_scroll_adjustments), - NULL, - NULL, - g_cclosure_user_marshal_VOID__OBJECT_OBJECT, - G_TYPE_NONE, - 2, - GTK_TYPE_ADJUSTMENT, - GTK_TYPE_ADJUSTMENT); -#else gtk_signal_new ("set_scroll_adjustments", GTK_RUN_LAST, object_class->type, GTK_SIGNAL_OFFSET (GtkPizzaClass, set_scroll_adjustments), gtk_marshal_NONE__POINTER_POINTER, GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); -#endif /* __WXGTK20__ */ } static GtkType @@ -372,10 +284,8 @@ gtk_pizza_put (GtkPizza *pizza, gtk_widget_set_parent (widget, GTK_WIDGET (pizza)); -#ifndef __WXGTK20__ /* FIXME? */ if (!IS_ONSCREEN (x, y)) GTK_PRIVATE_SET_FLAG (widget, GTK_IS_OFFSCREEN); -#endif gtk_widget_set_usize (widget, width, height); } @@ -541,11 +451,7 @@ gtk_pizza_map (GtkWidget *widget) if ( GTK_WIDGET_VISIBLE (child->widget) && !GTK_WIDGET_MAPPED (child->widget) && -#ifdef __WXGTK20__ - TRUE) -#else !GTK_WIDGET_IS_OFFSCREEN (child->widget)) -#endif { gtk_widget_map (child->widget); } @@ -620,9 +526,6 @@ gtk_pizza_realize (GtkWidget *widget) attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= GDK_EXPOSURE_MASK | -#ifdef __WXGTK20__ - GDK_SCROLL_MASK | -#endif GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | @@ -650,14 +553,12 @@ gtk_pizza_realize (GtkWidget *widget) gdk_window_set_back_pixmap( pizza->bin_window, NULL, FALSE ); */ -#ifndef __WXGTK20__ /* add filters for intercepting visibility and expose events */ gdk_window_add_filter (widget->window, gtk_pizza_main_filter, pizza); gdk_window_add_filter (pizza->bin_window, gtk_pizza_filter, pizza); /* we NEED gravity or we'll give up */ gravity_works = gdk_window_set_static_gravities (pizza->bin_window, TRUE); -#endif // !__WXGTK20__ /* cannot be done before realisation */ children = pizza->children; @@ -764,15 +665,11 @@ gtk_pizza_size_allocate (GtkWidget *widget, child = children->data; children = children->next; -#ifndef __WXGTK20__ gtk_pizza_position_child (pizza, child); -#endif gtk_pizza_allocate_child (pizza, child); } } -#ifndef __WXGTK20__ - static void gtk_pizza_draw (GtkWidget *widget, GdkRectangle *area) @@ -809,18 +706,14 @@ gtk_pizza_draw (GtkWidget *widget, } } -#endif /* __WXGTK20__ */ - static gint gtk_pizza_expose (GtkWidget *widget, GdkEventExpose *event) { GtkPizza *pizza; -#ifndef __WXGTK20__ GtkPizzaChild *child; GdkEventExpose child_event; GList *children; -#endif g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_PIZZA (widget), FALSE); @@ -835,14 +728,6 @@ gtk_pizza_expose (GtkWidget *widget, if (pizza->external_expose) return FALSE; -#ifdef __WXGTK20__ - - (* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, event); - - return FALSE; - -#else - children = pizza->children; while (children) { @@ -860,8 +745,6 @@ gtk_pizza_expose (GtkWidget *widget, } return TRUE; - -#endif } static void @@ -920,9 +803,7 @@ gtk_pizza_remove (GtkContainer *container, /* security checks */ g_return_if_fail (GTK_IS_WIDGET (widget)); -#ifndef __WXGTK20__ GTK_PRIVATE_UNSET_FLAG (widget, GTK_IS_OFFSCREEN); -#endif break; } @@ -1020,7 +901,6 @@ gtk_pizza_adjust_allocations (GtkPizza *pizza, } } -#ifndef __WXGTK20__ static void gtk_pizza_position_child (GtkPizza *pizza, GtkPizzaChild *child) @@ -1081,7 +961,6 @@ gtk_pizza_expose_predicate (Display *display, else return False; } -#endif /* __WXGTK20__ */ /* This is the main routine to do the scrolling. Scrolling is * done by "Guffaw" scrolling, as in the Mozilla XFE, with @@ -1098,15 +977,6 @@ gtk_pizza_expose_predicate (Display *display, void gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy) { -#ifdef __WXGTK20__ - pizza->xoffset += dx; - pizza->yoffset += dy; - - gtk_pizza_adjust_allocations (pizza, -dx, -dy); - - if (pizza->bin_window) - gdk_window_scroll( pizza->bin_window, -dx, -dy ); -#else // !__WXGTK20__ GtkWidget *widget; XEvent xevent; XID win; @@ -1238,11 +1108,9 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy) } } } -#endif /* __WXGTK20__/!__WXGTK20__ */ } -#ifndef __WXGTK20__ /* The main event filter. Actually, we probably don't really need * to install this as a filter at all, since we are calling it * directly above in the expose-handling hack. But in case scrollbars @@ -1330,8 +1198,6 @@ gtk_pizza_main_filter (GdkXEvent *gdk_xevent, return GDK_FILTER_CONTINUE; } -#endif /* __WXGTK20__ */ - #ifdef __cplusplus } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 29faacac74..eebfa24d1e 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -55,7 +55,7 @@ #include "wx/math.h" #include -#include "wx/gtk/private.h" +#include "wx/gtk1/private.h" #include #include #include @@ -63,22 +63,7 @@ #include #include -#include "wx/gtk/win_gtk.h" - -#ifdef __WXGTK20__ -#include -#endif - - -#ifdef __WXGTK20__ - #ifdef HAVE_XIM - #undef HAVE_XIM - #endif -#endif - -#ifdef __WXGTK20__ -extern GtkContainerClass *pizza_parent_class; -#endif +#include "wx/gtk1/win_gtk.h" //----------------------------------------------------------------------------- // documentation on internals @@ -239,9 +224,7 @@ wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL; // hack: we need something to pass to gtk_menu_popup, so we store the time of // the last click here (extern: used from gtk/menu.cpp) -#ifndef __WXGTK20__ guint32 wxGtkTimeLastClick = 0; -#endif extern bool g_mainThreadLocked; @@ -272,23 +255,11 @@ gdk_window_warp_pointer (GdkWindow *window, gint x, gint y) { -#ifndef __WXGTK20__ GdkWindowPrivate *priv; -#endif if (!window) window = GDK_ROOT_PARENT(); -#ifdef __WXGTK20__ - if (!GDK_WINDOW_DESTROYED(window)) - { - XWarpPointer (GDK_WINDOW_XDISPLAY(window), - None, /* not source window -> move from anywhere */ - GDK_WINDOW_XID(window), /* dest window */ - 0, 0, 0, 0, /* not source window -> move from anywhere */ - x, y ); - } -#else priv = (GdkWindowPrivate*) window; if (!priv->destroyed) @@ -299,7 +270,6 @@ gdk_window_warp_pointer (GdkWindow *window, 0, 0, 0, 0, /* not source window -> move from anywhere */ x, y ); } -#endif } //----------------------------------------------------------------------------- @@ -433,11 +403,6 @@ static gint gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g draw_frame( widget, win ); -#ifdef __WXGTK20__ - - (* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event); - -#endif return TRUE; } } @@ -446,8 +411,6 @@ static gint gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g // "draw" of m_widget //----------------------------------------------------------------------------- -#ifndef __WXGTK20__ - extern "C" { static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindowGTK *win ) { @@ -455,8 +418,6 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU } } -#endif // GTK+ < 2.0 - //----------------------------------------------------------------------------- // "size_request" of m_widget //----------------------------------------------------------------------------- @@ -522,47 +483,6 @@ static int gtk_window_expose_callback( GtkWidget *widget, if (g_isIdle) wxapp_install_idle_handler(); -#ifdef __WXGTK20__ - // This callback gets called in drawing-idle time under - // GTK 2.0, so we don't need to defer anything to idle - // time anymore. - - GtkPizza *pizza = GTK_PIZZA( widget ); - if (gdk_event->window != pizza->bin_window) return FALSE; - -#if 0 - if (win->GetName()) - { - wxPrintf( wxT("OnExpose from ") ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - wxPrintf( win->GetClassInfo()->GetClassName() ); - wxPrintf( wxT(" %d %d %d %d\n"), (int)gdk_event->area.x, - (int)gdk_event->area.y, - (int)gdk_event->area.width, - (int)gdk_event->area.height ); - } - - gtk_paint_box - ( - win->m_wxwindow->style, - pizza->bin_window, - GTK_STATE_NORMAL, - GTK_SHADOW_OUT, - (GdkRectangle*) NULL, - win->m_wxwindow, - (char *)"button", // const_cast - 20,20,24,24 - ); -#endif - - win->GetUpdateRegion() = wxRegion( gdk_event->region ); - - win->GtkSendPaintEvents(); - - - // Let parent window draw window-less widgets - (* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event); -#else // This gets called immediately after an expose event // under GTK 1.2 so we collect the calls and wait for // the idle handler to pick things up. @@ -578,7 +498,6 @@ static int gtk_window_expose_callback( GtkWidget *widget, // Actual redrawing takes place in idle time. // win->GtkUpdate(); -#endif return FALSE; } @@ -588,8 +507,6 @@ static int gtk_window_expose_callback( GtkWidget *widget, // "event" of m_wxwindow //----------------------------------------------------------------------------- -#ifndef __WXGTK20__ - // GTK thinks it is clever and filters out a certain amount of "unneeded" // expose events. We need them, of course, so we override the main event // procedure in GtkWidget by giving our own handler for all system events. @@ -612,14 +529,10 @@ gint gtk_window_event_event_callback( GtkWidget *widget, } } -#endif // !GTK+ 2 - //----------------------------------------------------------------------------- // "draw" of m_wxwindow //----------------------------------------------------------------------------- -#ifndef __WXGTK20__ - // This callback is a complete replacement of the gtk_pizza_draw() function, // which is disabled. @@ -701,8 +614,6 @@ static void gtk_window_draw_callback( GtkWidget *widget, } } -#endif - //----------------------------------------------------------------------------- // "key_press_event" from any window //----------------------------------------------------------------------------- @@ -1125,24 +1036,6 @@ wxTranslateGTKKeyEventToWx(wxKeyEvent& event, } -#ifdef __WXGTK20__ -struct wxGtkIMData -{ - GtkIMContext *context; - GdkEventKey *lastKeyEvent; - - wxGtkIMData() - { - context = gtk_im_multicontext_new(); - lastKeyEvent = NULL; - } - ~wxGtkIMData() - { - g_object_unref(context); - } -}; -#endif - extern "C" { static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, @@ -1170,39 +1063,12 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, return_after_IM = true; } -#ifdef __WXGTK20__ - // 2005.01.26 modified by Hong Jen Yee (hzysoft@sina.com.tw): - // When we get a key_press event here, it could be originate - // from the current widget or its child widgets. However, only the widget - // with the INPUT FOCUS can generate the INITIAL key_press event. That is, - // if the CURRENT widget doesn't have the FOCUS at all, this event definitely - // originated from its child widgets and shouldn't be passed to IM context. - // In fact, what a GTK+ IM should do is filtering keyEvents and convert them - // into text input ONLY WHEN THE WIDGET HAS INPUT FOCUS. Besides, when current - // widgets has both IM context and input focus, the event should be filtered - // by gtk_im_context_filter_keypress(). - // Then, we should, according to GTK+ 2.0 API doc, return whatever it returns. - if ((!ret) && (win->m_imData != NULL) && ( wxWindow::FindFocus() == win )) - { - // We should let GTK+ IM filter key event first. According to GTK+ 2.0 API - // docs, if IM filter returns true, no further processing should be done. - // we should send the key_down event anyway. - bool intercepted_by_IM = gtk_im_context_filter_keypress(win->m_imData->context, gdk_event); - win->m_imData->lastKeyEvent = NULL; - if (intercepted_by_IM) - { - wxLogTrace(TRACE_KEYS, _T("Key event intercepted by IM")); - return true; - } - } -#endif if (return_after_IM) return false; - + // Emit KEY_DOWN event ret = win->GetEventHandler()->ProcessEvent( event ); -#ifndef __WXGTK20__ // This is for GTK+ 1.2 only. The char event generatation for GTK+ 2.0 is done // in the "commit" handler. @@ -1261,8 +1127,6 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, return true; } -#endif // #ifndef __WXGTK20__ - #if wxUSE_ACCEL if (!ret) { @@ -1404,65 +1268,6 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, } } -#ifdef __WXGTK20__ -extern "C" { -static void gtk_wxwindow_commit_cb (GtkIMContext *context, - const gchar *str, - wxWindow *window) -{ - wxKeyEvent event( wxEVT_KEY_DOWN ); - - // take modifiers, cursor position, timestamp etc. from the last - // key_press_event that was fed into Input Method: - if (window->m_imData->lastKeyEvent) - { - wxFillOtherKeyEventFields(event, - window, window->m_imData->lastKeyEvent); - } - -#if wxUSE_UNICODE - const wxWCharBuffer data = wxConvUTF8.cMB2WC( (char*)str ); -#else - const wxWCharBuffer wdata = wxConvUTF8.cMB2WC( (char*)str ); - const wxCharBuffer data = wxConvLocal.cWC2MB( wdata ); -#endif // wxUSE_UNICODE - if( !(const wxChar*)data ) - return; - - bool ret = false; - - // Implement OnCharHook by checking ancestor top level windows - wxWindow *parent = window; - while (parent && !parent->IsTopLevel()) - parent = parent->GetParent(); - - for( const wxChar* pstr = data; *pstr; pstr++ ) - { -#if wxUSE_UNICODE - event.m_uniChar = *pstr; - // Backward compatible for ISO-8859-1 - event.m_keyCode = *pstr < 256 ? event.m_uniChar : 0; - wxLogTrace(TRACE_KEYS, _T("IM sent character '%c'"), event.m_uniChar); -#else - event.m_keyCode = *pstr; -#endif // wxUSE_UNICODE - if (parent) - { - event.SetEventType( wxEVT_CHAR_HOOK ); - ret = parent->GetEventHandler()->ProcessEvent( event ); - } - - if (!ret) - { - event.SetEventType(wxEVT_CHAR); - ret = window->GetEventHandler()->ProcessEvent( event ); - } - } -} -} -#endif - - //----------------------------------------------------------------------------- // "key_release_event" from any window //----------------------------------------------------------------------------- @@ -1696,21 +1501,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, wxEventType event_type = wxEVT_NULL; - // GdkDisplay is a GTK+ 2.2.0 thing -#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2, 2, 0) - if ( gdk_event->type == GDK_2BUTTON_PRESS && - !gtk_check_version(2,2,0) && - gdk_event->button >= 1 && gdk_event->button <= 3 ) - { - // Reset GDK internal timestamp variables in order to disable GDK - // triple click events. GDK will then next time believe no button has - // been clicked just before, and send a normal button click event. - GdkDisplay* display = gtk_widget_get_display (widget); - display->button_click_time[1] = 0; - display->button_click_time[0] = 0; - } -#endif // GTK 2+ - if (gdk_event->button == 1) { // note that GDK generates triple click events which are not supported @@ -1799,7 +1589,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, if ( !g_captureWindow ) win = FindWindowForMouseEvent(win, event.m_x, event.m_y); -#ifndef __WXGTK20__ wxGtkTimeLastClick = gdk_event->time; if (event_type == wxEVT_LEFT_DCLICK) @@ -1813,7 +1602,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, return FALSE; } } -#endif // !__WXGTK20__ if (win->GetEventHandler()->ProcessEvent( event )) { @@ -1980,80 +1768,6 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, } } -#ifdef __WXGTK20__ -//----------------------------------------------------------------------------- -// "mouse_wheel_event" -//----------------------------------------------------------------------------- - -extern "C" { -static gint gtk_window_wheel_callback (GtkWidget * widget, - GdkEventScroll * gdk_event, - wxWindowGTK * win) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - wxEventType event_type = wxEVT_NULL; - if (gdk_event->direction == GDK_SCROLL_UP) - event_type = wxEVT_MOUSEWHEEL; - else if (gdk_event->direction == GDK_SCROLL_DOWN) - event_type = wxEVT_MOUSEWHEEL; - else - return FALSE; - - wxMouseEvent event( event_type ); - // Can't use InitMouse macro because scroll events don't have button - event.SetTimestamp( gdk_event->time ); - event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); - event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); - event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); - event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); - event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK); - event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK); - event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK); - event.m_linesPerAction = 3; - event.m_wheelDelta = 120; - if (gdk_event->direction == GDK_SCROLL_UP) - event.m_wheelRotation = 120; - else - event.m_wheelRotation = -120; - - wxPoint pt = win->GetClientAreaOrigin(); - event.m_x = (wxCoord)gdk_event->x - pt.x; - event.m_y = (wxCoord)gdk_event->y - pt.y; - - event.SetEventObject( win ); - event.SetId( win->GetId() ); - event.SetTimestamp( gdk_event->time ); - - if (win->GetEventHandler()->ProcessEvent( event )) - { - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "scroll_event" ); - return TRUE; - } - - return FALSE; -} -} - -//----------------------------------------------------------------------------- -// "popup-menu" -//----------------------------------------------------------------------------- -extern "C" { -static gboolean wxgtk_window_popup_menu_callback(GtkWidget*, wxWindowGTK* win) -{ - wxContextMenuEvent event( - wxEVT_CONTEXT_MENU, - win->GetId(), - wxPoint(-1, -1)); - event.SetEventObject(win); - return win->GetEventHandler()->ProcessEvent(event); -} -} -#endif // __WXGTK20__ - //----------------------------------------------------------------------------- // "focus_in_event" //----------------------------------------------------------------------------- @@ -2083,11 +1797,6 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, if (g_isIdle) wxapp_install_idle_handler(); -#ifdef __WXGTK20__ - if (win->m_imData) - gtk_im_context_focus_in(win->m_imData->context); -#endif - g_focusWindowLast = g_focusWindow = win; @@ -2137,11 +1846,6 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEventFocus *gdk if (g_isIdle) wxapp_install_idle_handler(); -#ifdef __WXGTK20__ - if (win->m_imData) - gtk_im_context_focus_out(win->m_imData->context); -#endif - wxLogTrace( TRACE_FOCUS, _T("%s: focus out"), win->GetName().c_str() ); @@ -2306,9 +2010,7 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, win->m_oldVerticalPos = adjust->value; -#ifndef __WXGTK20__ GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(win->m_widget); -#endif wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->vscrollbar)); int value = (int)(adjust->value+0.5); @@ -2339,9 +2041,7 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, float diff = adjust->value - win->m_oldHorizontalPos; if (fabs(diff) < 0.2) return; -#ifndef __WXGTK20__ GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(win->m_widget); -#endif wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->hscrollbar)); win->m_oldHorizontalPos = adjust->value; @@ -2372,9 +2072,7 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget, g_blockEventsOnScroll = true; // FIXME: there is no 'slider' field in GTK+ 2.0 any more -#ifndef __WXGTK20__ win->m_isScrolling = (gdk_event->window == widget->slider); -#endif return FALSE; } @@ -2454,15 +2152,6 @@ gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win ) if (g_isIdle) wxapp_install_idle_handler(); -#ifdef __WXGTK20__ - if (win->m_imData) - { - GtkPizza *pizza = GTK_PIZZA( m_widget ); - gtk_im_context_set_client_window( win->m_imData->context, - pizza->bin_window ); - } -#endif - wxWindowCreateEvent event( win ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); @@ -2751,15 +2440,10 @@ void wxWindowGTK::Init() m_cursor = *wxSTANDARD_CURSOR; -#ifdef __WXGTK20__ - m_imData = NULL; - m_dirtyTabOrder = false; -#else #ifdef HAVE_XIM m_ic = (GdkIC*) NULL; m_icattr = (GdkICAttr*) NULL; #endif -#endif } wxWindowGTK::wxWindowGTK() @@ -2925,11 +2609,6 @@ wxWindowGTK::~wxWindowGTK() gdk_ic_attr_destroy (m_icattr); #endif -#ifdef __WXGTK20__ - // delete before the widgets to avoid a crash on solaris - delete m_imData; -#endif - if (m_wxwindow) { gtk_widget_destroy( m_wxwindow ); @@ -2973,7 +2652,6 @@ void wxWindowGTK::PostCreation() gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); -#ifndef __WXGTK20__ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); @@ -2982,30 +2660,14 @@ void wxWindowGTK::PostCreation() gtk_signal_connect( GTK_OBJECT(m_wxwindow), "event", GTK_SIGNAL_FUNC(gtk_window_event_event_callback), (gpointer)this ); } -#else - // gtk_widget_set_redraw_on_allocate( GTK_WIDGET(m_wxwindow), !HasFlag( wxFULL_REPAINT_ON_RESIZE ) ); -#endif } -#ifdef __WXGTK20__ - // Create input method handler - m_imData = new wxGtkIMData; - - // Cannot handle drawing preedited text yet - gtk_im_context_set_use_preedit( m_imData->context, FALSE ); - - g_signal_connect (G_OBJECT (m_imData->context), "commit", - G_CALLBACK (gtk_wxwindow_commit_cb), this); -#endif - // these are called when the "sunken" or "raised" borders are drawn gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event", GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); -#ifndef __WXGTK20__ gtk_signal_connect( GTK_OBJECT(m_widget), "draw", GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this ); -#endif } // focus handling @@ -3094,13 +2756,6 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget ) gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event", GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); -#ifdef __WXGTK20__ - gtk_signal_connect( GTK_OBJECT(widget), "scroll_event", - GTK_SIGNAL_FUNC(gtk_window_wheel_callback), (gpointer)this ); - g_signal_connect(widget, "popup_menu", - G_CALLBACK(wxgtk_window_popup_menu_callback), this); -#endif - gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event", GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); @@ -3198,23 +2853,10 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags /* the default button has a border around it */ if (GTK_WIDGET_CAN_DEFAULT(m_widget)) { -#ifdef __WXGTK20__ - GtkBorder *default_border = NULL; - gtk_widget_style_get( m_widget, "default_border", &default_border, NULL ); - if (default_border) - { - left_border += default_border->left; - right_border += default_border->right; - top_border += default_border->top; - bottom_border += default_border->bottom; - g_free( default_border ); - } -#else left_border = 6; right_border = 6; top_border = 6; bottom_border = 5; -#endif } DoMoveWindow( m_x-top_border, @@ -3253,10 +2895,6 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags void wxWindowGTK::OnInternalIdle() { -#ifdef __WXGTK20__ - if ( m_dirtyTabOrder ) - RealizeTabOrder(); -#endif // Update style if the window was not yet realized // and SetBackgroundStyle(wxBG_STYLE_CUSTOM) was called if (m_needsStyleChange) @@ -3590,31 +3228,9 @@ int wxWindowGTK::GetCharHeight() const wxFont font = GetFont(); wxCHECK_MSG( font.Ok(), 12, wxT("invalid font") ); -#ifdef __WXGTK20__ - PangoContext *context = NULL; - if (m_widget) - context = gtk_widget_get_pango_context( m_widget ); - - if (!context) - return 0; - - PangoFontDescription *desc = font.GetNativeFontInfo()->description; - PangoLayout *layout = pango_layout_new(context); - pango_layout_set_font_description(layout, desc); - pango_layout_set_text(layout, "H", 1); - PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; - - PangoRectangle rect; - pango_layout_line_get_extents(line, NULL, &rect); - - g_object_unref( G_OBJECT( layout ) ); - - return (int) PANGO_PIXELS(rect.height); -#else GdkFont *gfont = font.GetInternalFont( 1.0 ); return gfont->ascent + gfont->descent; -#endif } int wxWindowGTK::GetCharWidth() const @@ -3624,31 +3240,9 @@ int wxWindowGTK::GetCharWidth() const wxFont font = GetFont(); wxCHECK_MSG( font.Ok(), 8, wxT("invalid font") ); -#ifdef __WXGTK20__ - PangoContext *context = NULL; - if (m_widget) - context = gtk_widget_get_pango_context( m_widget ); - - if (!context) - return 0; - - PangoFontDescription *desc = font.GetNativeFontInfo()->description; - PangoLayout *layout = pango_layout_new(context); - pango_layout_set_font_description(layout, desc); - pango_layout_set_text(layout, "g", 1); - PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; - - PangoRectangle rect; - pango_layout_line_get_extents(line, NULL, &rect); - - g_object_unref( G_OBJECT( layout ) ); - - return (int) PANGO_PIXELS(rect.width); -#else GdkFont *gfont = font.GetInternalFont( 1.0 ); return gdk_string_width( gfont, "g" ); -#endif } void wxWindowGTK::GetTextExtent( const wxString& string, @@ -3669,54 +3263,11 @@ void wxWindowGTK::GetTextExtent( const wxString& string, return; } -#ifdef __WXGTK20__ - PangoContext *context = NULL; - if (m_widget) - context = gtk_widget_get_pango_context( m_widget ); - - if (!context) - { - if (x) (*x) = 0; - if (y) (*y) = 0; - return; - } - - PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description; - PangoLayout *layout = pango_layout_new(context); - pango_layout_set_font_description(layout, desc); - { -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); -#endif - } - - PangoRectangle rect; - pango_layout_get_extents(layout, NULL, &rect); - - if (x) (*x) = (wxCoord) PANGO_PIXELS(rect.width); - if (y) (*y) = (wxCoord) PANGO_PIXELS(rect.height); - if (descent) - { - PangoLayoutIter *iter = pango_layout_get_iter(layout); - int baseline = pango_layout_iter_get_baseline(iter); - pango_layout_iter_free(iter); - *descent = *y - PANGO_PIXELS(baseline); - } - if (externalLeading) (*externalLeading) = 0; // ?? - - g_object_unref( G_OBJECT( layout ) ); -#else GdkFont *font = fontToUse.GetInternalFont( 1.0 ); if (x) (*x) = gdk_string_width( font, wxGTK_CONV( string ) ); if (y) (*y) = font->ascent + font->descent; if (descent) (*descent) = font->descent; if (externalLeading) (*externalLeading) = 0; // ?? -#endif } void wxWindowGTK::SetFocus() @@ -3737,13 +3288,6 @@ void wxWindowGTK::SetFocus() } else if (m_widget) { -#ifdef __WXGTK20__ - if (GTK_IS_CONTAINER(m_widget)) - { - gtk_widget_child_focus( m_widget, GTK_DIR_TAB_FORWARD ); - } - else -#endif if (GTK_WIDGET_CAN_FOCUS(m_widget) && !GTK_WIDGET_HAS_FOCUS (m_widget) ) { @@ -3768,13 +3312,11 @@ void wxWindowGTK::SetFocus() } } else -#ifndef __WXGTK20__ if (GTK_IS_CONTAINER(m_widget)) { gtk_container_focus( GTK_CONTAINER(m_widget), GTK_DIR_TAB_FORWARD ); } else -#endif { wxLogTrace(TRACE_FOCUS, _T("Can't set focus to %s(%s)"), @@ -3839,62 +3381,6 @@ void wxWindowGTK::DoAddChild(wxWindowGTK *child) (*m_insertCallback)(this, child); } -#ifdef __WXGTK20__ - -void wxWindowGTK::AddChild(wxWindowBase *child) -{ - wxWindowBase::AddChild(child); - m_dirtyTabOrder = true; - if (g_isIdle) - wxapp_install_idle_handler(); -} - -void wxWindowGTK::RemoveChild(wxWindowBase *child) -{ - wxWindowBase::RemoveChild(child); - m_dirtyTabOrder = true; - if (g_isIdle) - wxapp_install_idle_handler(); -} - -void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, MoveKind move) -{ - wxWindowBase::DoMoveInTabOrder(win, move); - m_dirtyTabOrder = true; - if (g_isIdle) - wxapp_install_idle_handler(); -} - -void wxWindowGTK::RealizeTabOrder() -{ - if (m_wxwindow) - { - if (m_children.size() > 0) - { - GList *chain = NULL; - - for (wxWindowList::const_iterator i = m_children.begin(); - i != m_children.end(); ++i) - { - chain = g_list_prepend(chain, (*i)->m_widget); - } - - chain = g_list_reverse(chain); - - gtk_container_set_focus_chain(GTK_CONTAINER(m_wxwindow), chain); - g_list_free(chain); - } - else - { - gtk_container_unset_focus_chain(GTK_CONTAINER(m_wxwindow)); - } - } - - m_dirtyTabOrder = false; -} - -#endif // __WXGTK20__ - void wxWindowGTK::Raise() { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -3964,7 +3450,6 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect ) if (!m_widget->window) return; -#ifndef __WXGTK20__ if (g_isIdle) wxapp_install_idle_handler(); @@ -4024,27 +3509,6 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect ) gtk_widget_draw( m_widget, (GdkRectangle*) NULL ); } } -#else // GTK+ 2 - if (m_wxwindow) - { - GdkRectangle gdk_rect, - *p; - if (rect) - { - gdk_rect.x = rect->x; - gdk_rect.y = rect->y; - gdk_rect.width = rect->width; - gdk_rect.height = rect->height; - p = &gdk_rect; - } - else // invalidate everything - { - p = NULL; - } - - gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, p, TRUE ); - } -#endif // GTK+ 1/2 } void wxWindowGTK::Update() @@ -4060,13 +3524,8 @@ void wxWindowGTK::Update() void wxWindowGTK::GtkUpdate() { -#ifdef __WXGTK20__ - if (m_wxwindow && GTK_PIZZA(m_wxwindow)->bin_window) - gdk_window_process_updates( GTK_PIZZA(m_wxwindow)->bin_window, FALSE ); -#else if (!m_updateRegion.IsEmpty()) GtkSendPaintEvents(); -#endif // for consistency with other platforms (and also because it's convenient // to be able to update an entire TLW by calling Update() only once), we @@ -4083,9 +3542,7 @@ void wxWindowGTK::GtkSendPaintEvents() { if (!m_wxwindow) { -#ifndef __WXGTK20__ m_clearRegion.Clear(); -#endif m_updateRegion.Clear(); return; } @@ -4129,17 +3586,6 @@ void wxWindowGTK::GtkSendPaintEvents() } else -#ifdef __WXGTK20__ - { - wxWindowDC dc( (wxWindow*)this ); - dc.SetClippingRegion( m_updateRegion ); - - wxEraseEvent erase_event( GetId(), &dc ); - erase_event.SetEventObject( this ); - - GetEventHandler()->ProcessEvent(erase_event); - } -#else // if (!m_clearRegion.IsEmpty()) // Always send an erase event under GTK 1.2 { wxWindowDC dc( (wxWindow*)this ); @@ -4170,7 +3616,6 @@ void wxWindowGTK::GtkSendPaintEvents() } m_clearRegion.Clear(); } -#endif wxNcPaintEvent nc_paint_event( GetId() ); nc_paint_event.SetEventObject( this ); @@ -4182,7 +3627,7 @@ void wxWindowGTK::GtkSendPaintEvents() m_clipPaintRegion = false; -#if !defined(__WXUNIVERSAL__) && !defined(__WXGTK20__) +#if !defined(__WXUNIVERSAL__) // The following code will result in all window-less widgets // being redrawn because the wxWidgets class is allowed to // paint over the window-less widgets. @@ -4232,7 +3677,6 @@ void wxWindowGTK::ClearBackground() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); -#ifndef __WXGTK20__ if (m_wxwindow && m_wxwindow->window) { m_clearRegion.Clear(); @@ -4242,7 +3686,6 @@ void wxWindowGTK::ClearBackground() // Better do this in idle? GtkUpdate(); } -#endif } #if wxUSE_TOOLTIPS @@ -4304,13 +3747,6 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) return true; } -#ifdef __WXGTK20__ -PangoContext *wxWindowGTK::GtkGetPangoDefaultContext() -{ - return gtk_widget_get_pango_context( m_widget ); -} -#endif - GtkRcStyle *wxWindowGTK::CreateWidgetStyle(bool forceStyle) { // do we need to apply any changes at all? @@ -4325,13 +3761,8 @@ GtkRcStyle *wxWindowGTK::CreateWidgetStyle(bool forceStyle) if ( m_font.Ok() ) { -#ifdef __WXGTK20__ - style->font_desc = - pango_font_description_copy( m_font.GetNativeFontInfo()->description ); -#else wxString xfontname = m_font.GetNativeFontInfo()->GetXFontName(); style->fontset_name = g_strdup(xfontname.c_str()); -#endif } if ( m_foregroundColour.Ok() ) @@ -4687,7 +4118,6 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) // No scrolling requested. if ((dx == 0) && (dy == 0)) return; -#ifndef __WXGTK20__ if (!m_updateRegion.IsEmpty()) { m_updateRegion.Offset( dx, dy ); @@ -4707,7 +4137,6 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) GetClientSize( &cw, &ch ); m_clearRegion.Intersect( 0, 0, cw, ch ); } -#endif m_clipPaintRegion = true; -- 2.45.2