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
This commit is contained in:
Mart Raudsepp
2006-01-23 01:14:32 +00:00
parent 9fa72bd2a6
commit 3cbab64109
57 changed files with 403 additions and 6777 deletions

View File

@@ -73,7 +73,7 @@
#endif // HAVE_POLL/!HAVE_POLL #endif // HAVE_POLL/!HAVE_POLL
#include "wx/unix/private.h" #include "wx/unix/private.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
@@ -173,21 +173,17 @@ bool wxApp::Yield(bool onlyIfNeeded)
void wxApp::WakeUpIdle() void wxApp::WakeUpIdle()
{ {
#ifndef __WXGTK20__
#if wxUSE_THREADS #if wxUSE_THREADS
if (!wxThread::IsMain()) if (!wxThread::IsMain())
wxMutexGuiEnter(); wxMutexGuiEnter();
#endif // wxUSE_THREADS_ #endif // wxUSE_THREADS_
#endif // __WXGTK2__
wxapp_install_idle_handler(); wxapp_install_idle_handler();
#ifndef __WXGTK20__
#if wxUSE_THREADS #if wxUSE_THREADS
if (!wxThread::IsMain()) if (!wxThread::IsMain())
wxMutexGuiLeave(); wxMutexGuiLeave();
#endif // wxUSE_THREADS_ #endif // wxUSE_THREADS_
#endif // __WXGTK2__
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -245,11 +241,7 @@ static gint wxapp_idle_callback( gpointer WXUNUSED(data) )
if (wxTopLevelWindows.GetCount() > 0) if (wxTopLevelWindows.GetCount() > 0)
{ {
wxWindow* win = (wxWindow*) wxTopLevelWindows.GetLast()->GetData(); wxWindow* win = (wxWindow*) wxTopLevelWindows.GetLast()->GetData();
#ifdef __WXGTK20__
if (win->IsKindOf(CLASSINFO(wxMessageDialog)))
#else
if (win->IsKindOf(CLASSINFO(wxGenericMessageDialog))) if (win->IsKindOf(CLASSINFO(wxGenericMessageDialog)))
#endif
win->OnInternalIdle(); win->OnInternalIdle();
} }
return TRUE; return TRUE;
@@ -469,14 +461,9 @@ bool wxApp::OnInitGui()
// chosen a specific visual, then derive the GdkVisual from that // chosen a specific visual, then derive the GdkVisual from that
if (m_glVisualInfo != NULL) 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( GdkVisual* vis = gdkx_visual_get(
((XVisualInfo *) m_glVisualInfo) ->visualid ); ((XVisualInfo *) m_glVisualInfo) ->visualid );
gtk_widget_set_default_visual( vis ); gtk_widget_set_default_visual( vis );
#endif
GdkColormap *colormap = gdk_colormap_new( vis, FALSE ); GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
gtk_widget_set_default_colormap( colormap ); gtk_widget_set_default_colormap( colormap );
@@ -490,13 +477,8 @@ bool wxApp::OnInitGui()
else else
if ((gdk_visual_get_best() != gdk_visual_get_system()) && (m_useBestVisual)) 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(); GdkVisual* vis = gdk_visual_get_best();
gtk_widget_set_default_visual( vis ); gtk_widget_set_default_visual( vis );
#endif
GdkColormap *colormap = gdk_colormap_new( vis, FALSE ); GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
gtk_widget_set_default_colormap( colormap ); gtk_widget_set_default_colormap( colormap );
@@ -575,7 +557,7 @@ GdkVisual *wxApp::GetGdkVisual()
bool wxApp::Initialize(int& argc, wxChar **argv) bool wxApp::Initialize(int& argc, wxChar **argv)
{ {
bool init_result; bool init_result;
#if wxUSE_THREADS #if wxUSE_THREADS
// GTK 1.2 up to version 1.2.3 has broken threads // GTK 1.2 up to version 1.2.3 has broken threads
if ((gtk_major_version == 1) && 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_ // We should have the wxUSE_WCHAR_T test on the _outside_
#if wxUSE_WCHAR_T #if wxUSE_WCHAR_T
#if defined(__WXGTK20__)
// gtk+ 2.0 supports Unicode through UTF-8 strings
wxConvCurrent = &wxConvUTF8;
#else // GTK 1.x
if (!wxOKlibc()) if (!wxOKlibc())
wxConvCurrent = &wxConvLocal; wxConvCurrent = &wxConvLocal;
#endif
#else // !wxUSE_WCHAR_T #else // !wxUSE_WCHAR_T
if (!wxOKlibc()) if (!wxOKlibc())
wxConvCurrent = (wxMBConv*) NULL; wxConvCurrent = (wxMBConv*) NULL;
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T #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 #if wxUSE_UNICODE
// gtk_init() wants UTF-8, not wchar_t, so convert // gtk_init() wants UTF-8, not wchar_t, so convert
int i; int i;
@@ -648,7 +596,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
argvGTK[argc] = NULL; argvGTK[argc] = NULL;
int argcGTK = argc; int argcGTK = argc;
#ifdef __WXGPE__ #ifdef __WXGPE__
init_result = true; // is there a _check() version of this? init_result = true; // is there a _check() version of this?
gpe_application_init( &argcGTK, &argvGTK ); 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?")); wxLogError(wxT("Unable to initialize gtk, is DISPLAY set properly?"));
return false; return false;
} }
// we can not enter threads before gtk_init is done // we can not enter threads before gtk_init is done
gdk_threads_enter(); gdk_threads_enter();

View File

@@ -19,296 +19,3 @@
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
#pragma hdrstop #pragma hdrstop
#endif #endif
#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#include "wx/artprov.h"
#include "wx/module.h"
#include "wx/gtk/private.h"
#include <gtk/gtk.h>
// 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__)

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/bitmap.cpp // Name: src/gtk1/bitmap.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// RCS-ID: $Id$ // RCS-ID: $Id$
@@ -20,33 +20,24 @@
#include "wx/dcmemory.h" #include "wx/dcmemory.h"
#include "wx/app.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 <gdk/gdk.h> #include <gdk/gdk.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#ifdef __WXGTK20__ #include <gdk/gdkrgb.h>
#include <gdk/gdkimage.h>
#else // GTK+ 1.2
#include <gdk/gdkrgb.h>
#endif // GTK+ 2.0/1.2
#include "wx/math.h" #include "wx/math.h"
extern void gdk_wx_draw_bitmap (GdkDrawable *drawable, extern
GdkGC *gc, void gdk_wx_draw_bitmap (GdkDrawable *drawable,
GdkDrawable *src, GdkGC *gc,
gint xsrc, GdkDrawable *src,
gint ysrc, gint xsrc,
gint xdest, gint ysrc,
gint ydest, gint xdest,
gint width, gint ydest,
gint height); gint width,
gint height);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// data // data
@@ -240,9 +231,6 @@ public:
GdkPixmap *m_pixmap; GdkPixmap *m_pixmap;
GdkBitmap *m_bitmap; GdkBitmap *m_bitmap;
#ifdef __WXGTK20__
GdkPixbuf *m_pixbuf;
#endif
wxMask *m_mask; wxMask *m_mask;
int m_width; int m_width;
int m_height; int m_height;
@@ -254,9 +242,6 @@ wxBitmapRefData::wxBitmapRefData()
{ {
m_pixmap = (GdkPixmap *) NULL; m_pixmap = (GdkPixmap *) NULL;
m_bitmap = (GdkBitmap *) NULL; m_bitmap = (GdkBitmap *) NULL;
#ifdef __WXGTK20__
m_pixbuf = (GdkPixbuf *) NULL;
#endif
m_mask = (wxMask *) NULL; m_mask = (wxMask *) NULL;
m_width = 0; m_width = 0;
m_height = 0; m_height = 0;
@@ -270,10 +255,6 @@ wxBitmapRefData::~wxBitmapRefData()
gdk_pixmap_unref( m_pixmap ); gdk_pixmap_unref( m_pixmap );
if (m_bitmap) if (m_bitmap)
gdk_bitmap_unref( m_bitmap ); gdk_bitmap_unref( m_bitmap );
#ifdef __WXGTK20__
if (m_pixbuf)
gdk_pixbuf_unref( m_pixbuf );
#endif
delete m_mask; delete m_mask;
#if wxUSE_PALETTE #if wxUSE_PALETTE
delete m_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_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
M_BMPDATA->m_bpp = 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 else
{ {
M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth ); 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; wxBitmap bmp;
#ifdef __WXGTK20__ GdkImage *img = (GdkImage*) NULL;
if (HasPixbuf()) if (GetPixmap())
{ img = gdk_image_get( GetPixmap(), 0, 0, GetWidth(), GetHeight() );
bmp.SetWidth(width); else if (GetBitmap())
bmp.SetHeight(height); img = gdk_image_get( GetBitmap(), 0, 0, GetWidth(), GetHeight() );
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);
}
else else
#endif // __WXGTK20__ 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())
{ {
GdkImage *img = (GdkImage*) NULL; GdkVisual *visual = gdk_window_get_visual( GetPixmap() );
if (GetPixmap()) if (visual == NULL)
img = gdk_image_get( GetPixmap(), 0, 0, GetWidth(), GetHeight() ); visual = wxTheApp->GetGdkVisual();
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") ); bpp = visual->depth;
bmp = wxBitmap(width,height,bpp);
dstpix = bmp.GetPixmap();
gc = gdk_gc_new( dstpix );
}
int bpp = -1; char *dst = NULL;
long dstbyteperline = 0;
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);
}
GdkGC *gc = NULL; // be careful to use the right scaling factor
GdkPixmap *dstpix = NULL; float scx = (float)M_BMPDATA->m_width/(float)newx;
if (GetPixmap()) 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));
// 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;
for (int w = 0; w < width; w++)
{ {
GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); guint32 pixval;
if (visual == NULL) int x = tablex[w];
visual = wxTheApp->GetGdkVisual(); if (x == old_x)
pixval = old_pixval;
else
{
pixval = gdk_image_get_pixel( img, x, tabley[h] );
old_pixval = pixval;
old_x = x;
}
bpp = visual->depth; if (bpp == 1)
bmp = wxBitmap(width,height,bpp); {
dstpix = bmp.GetPixmap(); if (!pixval)
gc = gdk_gc_new( dstpix ); {
char bit=1;
char shift = bit << (w % 8);
outbyte |= shift;
}
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);
}
} }
char *dst = NULL; // do not forget the last byte
long dstbyteperline = 0; if ((bpp == 1) && (width % 8 != 0))
dst[h*dstbyteperline+width/8] = outbyte;
}
if (GetBitmap()) gdk_image_destroy( img );
{ if (gc) gdk_gc_unref( gc );
bpp = 1;
dstbyteperline = width/8*M_BMPDATA->m_bpp;
if (width*M_BMPDATA->m_bpp % 8 != 0)
dstbyteperline++;
dst = (char*) malloc(dstbyteperline*height);
}
// be careful to use the right scaling factor if (bpp == 1)
float scx = (float)M_BMPDATA->m_width/(float)newx; {
float scy = (float)M_BMPDATA->m_height/(float)newy; bmp = wxBitmap( (const char *)dst, width, height, 1 );
// prepare accel-tables free( dst );
int *tablex = (int *)calloc(width,sizeof(int)); }
int *tabley = (int *)calloc(height,sizeof(int));
// accel table filled with clipped values if (GetMask())
for (int x = 0; x < width; x++) {
tablex[x] = (int) (scx * (x+clipx)); dstbyteperline = width/8;
for (int y = 0; y < height; y++) if (width % 8 != 0)
tabley[y] = (int) (scy * (y+clipy)); 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++) for (int h = 0; h < height; h++)
{ {
char outbyte = 0; char outbyte = 0;
@@ -471,101 +491,35 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
old_x = x; old_x = x;
} }
if (bpp == 1) if (pixval)
{ {
if (!pixval) char bit=1;
{ char shift = bit << (w % 8);
char bit=1; outbyte |= shift;
char shift = bit << (w % 8);
outbyte |= shift;
}
if ((w+1)%8==0)
{
dst[h*dstbyteperline+w/8] = outbyte;
outbyte = 0;
}
} }
else
if ((w+1)%8 == 0)
{ {
GdkColor col; dst[h*dstbyteperline+w/8] = outbyte;
col.pixel = pixval; outbyte = 0;
gdk_gc_set_foreground( gc, &col );
gdk_draw_point( dstpix, gc, w, h);
} }
} }
// do not forget the last byte // do not forget the last byte
if ((bpp == 1) && (width % 8 != 0)) if (width % 8 != 0)
dst[h*dstbyteperline+width/8] = outbyte; 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 ); 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; return bmp;
} }
@@ -587,10 +541,6 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
} }
else else
{ {
#ifdef __WXGTK20__
if (image.HasAlpha())
return CreateFromImageAsPixbuf(image);
#endif
return CreateFromImageAsPixmap(image); return CreateFromImageAsPixmap(image);
} }
} }
@@ -935,51 +885,6 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
return true; 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 wxBitmap::ConvertToImage() const
{ {
wxImage image; wxImage image;
@@ -995,172 +900,141 @@ wxImage wxBitmap::ConvertToImage() const
return wxNullImage; return wxNullImage;
} }
#ifdef __WXGTK20__ // the colour used as transparent one in wxImage and the one it is
if (HasPixbuf()) // 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())
{ {
GdkPixbuf *pixbuf = GetPixbuf(); gdk_image = gdk_image_get( GetPixmap(),
wxASSERT( gdk_pixbuf_get_has_alpha(pixbuf) ); 0, 0,
GetWidth(), GetHeight() );
int w = GetWidth(); }
int h = GetHeight(); else if (GetBitmap())
{
image.SetAlpha(); gdk_image = gdk_image_get( GetBitmap(),
0, 0,
unsigned char *alpha = image.GetAlpha(); GetWidth(), GetHeight() );
unsigned char *in = gdk_pixbuf_get_pixels(pixbuf);
unsigned char *out = data;
int rowinc = gdk_pixbuf_get_rowstride(pixbuf) - 4 * w;
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];
}
}
} }
else else
#endif // __WXGTK20__
{ {
// the colour used as transparent one in wxImage and the one it is wxFAIL_MSG( wxT("Ill-formed bitmap") );
// 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; wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") );
if (HasPixmap()) 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 );
}
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;
}
GdkColormap *cmap = gtk_widget_get_default_colormap();
long pos = 0;
for (int j = 0; j < GetHeight(); j++)
{
for (int i = 0; i < GetWidth(); i++)
{ {
gdk_image = gdk_image_get( GetPixmap(), wxUint32 pixel = gdk_image_get_pixel( gdk_image, i, j );
0, 0, if (bpp == 1)
GetWidth(), GetHeight() );
}
else if (GetBitmap())
{
gdk_image = gdk_image_get( GetBitmap(),
0, 0,
GetWidth(), GetHeight() );
}
else
{
wxFAIL_MSG( wxT("Ill-formed bitmap") );
}
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() );
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;
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();
long pos = 0;
for (int j = 0; j < GetHeight(); j++)
{
for (int i = 0; i < GetWidth(); i++)
{ {
wxUint32 pixel = gdk_image_get_pixel( gdk_image, i, j ); if (pixel == 0)
if (bpp == 1)
{ {
if (pixel == 0) data[pos] = 0;
{ data[pos+1] = 0;
data[pos] = 0; data[pos+2] = 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)
{
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 else
{ {
wxFAIL_MSG( wxT("Image conversion failed. Unknown visual type.") ); data[pos] = 255;
data[pos+1] = 255;
data[pos+2] = 255;
} }
if (gdk_image_mask)
{
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;
}
}
pos += 3;
} }
} 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.") );
}
gdk_image_destroy( gdk_image ); if (gdk_image_mask)
if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); {
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;
}
}
pos += 3;
}
} }
gdk_image_destroy( gdk_image );
if (gdk_image_mask) gdk_image_destroy( gdk_image_mask );
return image; return image;
} }
@@ -1222,12 +1096,7 @@ bool wxBitmap::operator != ( const wxBitmap& bmp ) const
bool wxBitmap::Ok() const bool wxBitmap::Ok() const
{ {
return (m_refData != NULL) && return (m_refData != NULL) &&
( (M_BMPDATA->m_bitmap || M_BMPDATA->m_pixmap);
#ifdef __WXGTK20__
M_BMPDATA->m_pixbuf ||
#endif
M_BMPDATA->m_bitmap || M_BMPDATA->m_pixmap
);
} }
int wxBitmap::GetHeight() const 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 ); wxBitmap ret( rect.width, rect.height, M_BMPDATA->m_bpp );
wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") ); wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") );
#ifdef __WXGTK20__ if (ret.GetPixmap())
if (HasPixbuf())
{ {
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, GdkGC *gc = gdk_gc_new( ret.GetPixmap() );
gdk_pixbuf_get_has_alpha(GetPixbuf()), gdk_draw_pixmap( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height );
8, rect.width, rect.height); gdk_gc_destroy( gc );
ret.SetPixbuf(pixbuf);
gdk_pixbuf_copy_area(GetPixbuf(),
rect.x, rect.y, rect.width, rect.height,
pixbuf, 0, 0);
} }
else else
#endif // __WXGTK20__
{ {
if (ret.GetPixmap()) GdkGC *gc = gdk_gc_new( ret.GetBitmap() );
{ GdkColor col;
GdkGC *gc = gdk_gc_new( ret.GetPixmap() ); col.pixel = 0xFFFFFF;
gdk_draw_pixmap( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); gdk_gc_set_foreground( gc, &col );
gdk_gc_destroy( gc ); col.pixel = 0;
} gdk_gc_set_background( gc, &col );
else 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()) if (GetMask())
@@ -1439,9 +1293,6 @@ void wxBitmap::SetPixmap( GdkPixmap *pixmap )
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
M_BMPDATA->m_pixmap = pixmap; M_BMPDATA->m_pixmap = pixmap;
#ifdef __WXGTK20__
PurgeOtherRepresentations(Pixmap);
#endif
} }
void wxBitmap::SetBitmap( GdkPixmap *bitmap ) void wxBitmap::SetBitmap( GdkPixmap *bitmap )
@@ -1450,28 +1301,12 @@ void wxBitmap::SetBitmap( GdkPixmap *bitmap )
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
M_BMPDATA->m_bitmap = bitmap; M_BMPDATA->m_bitmap = bitmap;
#ifdef __WXGTK20__
PurgeOtherRepresentations(Pixmap);
#endif
} }
GdkPixmap *wxBitmap::GetPixmap() const GdkPixmap *wxBitmap::GetPixmap() const
{ {
wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, wxT("invalid bitmap") ); 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; return M_BMPDATA->m_pixmap;
} }
@@ -1489,113 +1324,9 @@ GdkBitmap *wxBitmap::GetBitmap() const
return M_BMPDATA->m_bitmap; 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) 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; return NULL;
#endif
} }
void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data)) void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data))
@@ -1605,18 +1336,11 @@ void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data))
bool wxBitmap::HasAlpha() const bool wxBitmap::HasAlpha() const
{ {
#ifdef __WXGTK20__
return HasPixbuf();
#else
return false; return false;
#endif
} }
void wxBitmap::UseAlpha() void wxBitmap::UseAlpha()
{ {
#ifdef __WXGTK20__
GetPixbuf();
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -16,7 +16,7 @@
#include "wx/bmpbuttn.h" #include "wx/bmpbuttn.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
@@ -224,29 +224,14 @@ void wxBitmapButton::OnSetBitmap()
{ {
// initial bitmap // initial bitmap
GtkWidget *pixmap; 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); pixmap = gtk_pixmap_new(the_one.GetPixmap(), mask);
#endif
gtk_widget_show(pixmap); gtk_widget_show(pixmap);
gtk_container_add(GTK_CONTAINER(m_widget), pixmap); gtk_container_add(GTK_CONTAINER(m_widget), pixmap);
} }
else else
{ // subsequent bitmaps { // 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); GtkPixmap *pixmap = GTK_PIXMAP(child);
gtk_pixmap_set(pixmap, the_one.GetPixmap(), mask); gtk_pixmap_set(pixmap, the_one.GetPixmap(), mask);
#endif
} }
} }

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/brush.cpp // Name: src/gtk1/brush.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$

View File

@@ -17,8 +17,8 @@
#include "wx/button.h" #include "wx/button.h"
#include "wx/stockitem.h" #include "wx/stockitem.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // 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 */ /* the default button has a border around it */
if (GTK_WIDGET_CAN_DEFAULT(m_widget)) 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; left_border = 6;
right_border = 6; right_border = 6;
top_border = 6; top_border = 6;
bottom_border = 5; bottom_border = 5;
#endif
win->DoMoveWindow( win->m_x-top_border, win->DoMoveWindow( win->m_x-top_border,
win->m_y-left_border, win->m_y-left_border,
win->m_width+left_border+right_border, win->m_width+left_border+right_border,
@@ -130,11 +117,7 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
return FALSE; return FALSE;
} }
#ifdef __WXGTK20__
m_widget = gtk_button_new_with_mnemonic("");
#else
m_widget = gtk_button_new_with_label(""); m_widget = gtk_button_new_with_label("");
#endif
float x_alignment = 0.5; float x_alignment = 0.5;
if (HasFlag(wxBU_LEFT)) if (HasFlag(wxBU_LEFT))
@@ -148,18 +131,9 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
else if (HasFlag(wxBU_BOTTOM)) else if (HasFlag(wxBU_BOTTOM))
y_alignment = 1.0; y_alignment = 1.0;
#ifdef __WXGTK24__ if (GTK_IS_MISC(BUTTON_CHILD(m_widget)))
if (!gtk_check_version(2,4,0)) gtk_misc_set_alignment (GTK_MISC (BUTTON_CHILD (m_widget)),
{
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)),
x_alignment, y_alignment); x_alignment, y_alignment);
}
SetLabel(label); SetLabel(label);
@@ -197,40 +171,7 @@ void wxButton::SetDefault()
/* static */ /* static */
wxSize wxButtonBase::GetDefaultSize() 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); return wxSize(80,26);
#endif
} }
void wxButton::SetLabel( const wxString &lbl ) void wxButton::SetLabel( const wxString &lbl )
@@ -246,25 +187,7 @@ void wxButton::SetLabel( const wxString &lbl )
const wxString labelGTK = GTKConvertMnemonics(label); 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)); gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), wxGTK_CONV(labelGTK));
#endif // GTK+ 2/1
} }
bool wxButton::Enable( bool enable ) bool wxButton::Enable( bool enable )
@@ -279,11 +202,7 @@ bool wxButton::Enable( bool enable )
bool wxButton::IsOwnGtkWindow( GdkWindow *window ) bool wxButton::IsOwnGtkWindow( GdkWindow *window )
{ {
#ifdef __WXGTK20__
return GTK_BUTTON(m_widget)->event_window;
#else
return (window == m_widget->window); return (window == m_widget->window);
#endif
} }
void wxButton::DoApplyWidgetStyle(GtkRcStyle *style) void wxButton::DoApplyWidgetStyle(GtkRcStyle *style)
@@ -313,9 +232,7 @@ wxSize wxButton::DoGetBestSize() const
GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT );
} }
#ifndef __WXGTK20__
ret.x += 10; // add a few pixels for sloppy (but common) themes ret.x += 10; // add a few pixels for sloppy (but common) themes
#endif
if (!HasFlag(wxBU_EXACTFIT)) if (!HasFlag(wxBU_EXACTFIT))
{ {

View File

@@ -16,7 +16,7 @@
#include "wx/checkbox.h" #include "wx/checkbox.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system
@@ -48,60 +48,8 @@ static void gtk_checkbox_toggled_callback(GtkWidget *widget, wxCheckBox *cb)
if (cb->m_blockEvent) return; 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()); wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId());
#ifdef __WXGTK20__
event.SetInt(cb->Get3StateValue());
#else
event.SetInt(cb->GetValue()); event.SetInt(cb->GetValue());
#endif
event.SetEventObject(cb); event.SetEventObject(cb);
cb->GetEventHandler()->ProcessEvent(event); cb->GetEventHandler()->ProcessEvent(event);
} }
@@ -197,34 +145,9 @@ bool wxCheckBox::GetValue() const
{ {
wxCHECK_MSG( m_widgetCheckbox != NULL, FALSE, wxT("invalid checkbox") ); 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; 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 ) void wxCheckBox::SetLabel( const wxString& label )
{ {
wxCHECK_RET( m_widgetLabel != NULL, wxT("invalid checkbox") ); wxCHECK_RET( m_widgetLabel != NULL, wxT("invalid checkbox") );

View File

@@ -15,7 +15,7 @@
#if wxUSE_CHECKLISTBOX #if wxUSE_CHECKLISTBOX
#include "wx/checklst.h" #include "wx/checklst.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/choice.cpp // Name: src/gtk1/choice.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -14,7 +14,7 @@
#include "wx/choice.h" #include "wx/choice.h"
#include "wx/arrstr.h" #include "wx/arrstr.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system
@@ -45,9 +45,6 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *
int selection = wxNOT_FOUND; 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()) ) ); GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(choice->GetHandle()) ) );
int count = 0; int count = 0;
@@ -63,7 +60,7 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *
child = child->next; child = child->next;
count++; count++;
} }
#endif
choice->m_selection_hack = selection; choice->m_selection_hack = selection;
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() ); 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") ); 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 ); wxString tmp( label->label );
#endif
if (string.IsSameAs( tmp, bCase )) if (string.IsSameAs( tmp, bCase ))
return count; return count;
child = child->next; child = child->next;
@@ -427,11 +421,7 @@ wxString wxChoice::GetString( int n ) const
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") ); 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 ); return wxString( label->label );
#endif
} }
child = child->next; child = child->next;
count++; count++;
@@ -622,11 +612,7 @@ wxSize wxChoice::DoGetBestSize() const
bool wxChoice::IsOwnGtkWindow( GdkWindow *window ) bool wxChoice::IsOwnGtkWindow( GdkWindow *window )
{ {
#ifdef __WXGTK20__
return GTK_BUTTON(m_widget)->event_window;
#else
return (window == m_widget->window); return (window == m_widget->window);
#endif
} }
// static // static

View File

@@ -36,10 +36,6 @@
GdkAtom g_clipboardAtom = 0; GdkAtom g_clipboardAtom = 0;
GdkAtom g_targetsAtom = 0; GdkAtom g_targetsAtom = 0;
#if defined(__WXGTK20__) && wxUSE_UNICODE
extern GdkAtom g_altTextAtom;
#endif
// the trace mask we use with wxLogTrace() - call // the trace mask we use with wxLogTrace() - call
// wxLog::AddTraceMask(TRACE_CLIPBOARD) to enable the trace messages from here // wxLog::AddTraceMask(TRACE_CLIPBOARD) to enable the trace messages from here
// (there will be a *lot* of them!) // (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. // Text data will be in UTF8 in Unicode mode.
data->GetDataHere( selection_data->target, d ); data->GetDataHere( selection_data->target, d );
#ifdef __WXGTK20__ gtk_selection_data_set(
// 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(
selection_data, selection_data,
GDK_SELECTION_TYPE_STRING, GDK_SELECTION_TYPE_STRING,
8*sizeof(gchar), 8 * sizeof(gchar),
(unsigned char*) d, (unsigned char*) d,
size-1 ); size-1 );
}
free(d); free(d);
} }
@@ -533,15 +514,6 @@ bool wxClipboard::IsSupported( const wxDataFormat& format )
while (m_waiting) gtk_main_iteration(); 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; return m_formatSupported;
} }

View File

@@ -15,133 +15,3 @@
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif #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__)

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/colour.cpp // Name: src/gtk1/colour.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -12,7 +12,7 @@
#include "wx/colour.h" #include "wx/colour.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
@@ -92,14 +92,9 @@ void wxColourRefData::FreeColour()
{ {
if (m_colormap) 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; GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) m_colormap;
if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) ||
(private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) (private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR))
#endif
{ {
int idx = m_color.pixel; int idx = m_color.pixel;
colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] - 1; colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] - 1;
@@ -117,14 +112,8 @@ void wxColourRefData::AllocColour( GdkColormap *cmap )
FreeColour(); FreeColour();
#ifdef __WXGTK20__
if ( (cmap->visual->type == GDK_VISUAL_GRAYSCALE) || if ( (cmap->visual->type == GDK_VISUAL_GRAYSCALE) ||
(cmap->visual->type == GDK_VISUAL_PSEUDO_COLOR) ) (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 ); m_hasPixel = gdk_colormap_alloc_color( cmap, &m_color, FALSE, TRUE );
int idx = m_color.pixel; int idx = m_color.pixel;

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/combobox.cpp // Name: src/gtk1/combobox.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -20,7 +20,7 @@
#include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED #include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system
@@ -238,16 +238,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
// and case-sensitive // and case-sensitive
gtk_combo_set_case_sensitive( GTK_COMBO(m_widget), TRUE ); 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; GtkWidget *list = GTK_COMBO(m_widget)->list;
#ifndef __WXGTK20__
// gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE ); // gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE );
#endif
for (int i = 0; i < n; i++) 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 ); GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child ); GtkLabel *label = GTK_LABEL( bin->child );
#ifdef __WXGTK20__
wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
#else
wxString str( label->label ); wxString str( label->label );
#endif
if (item.IsSameAs( str , bCase ) ) if (item.IsSameAs( str , bCase ) )
return count; return count;
@@ -607,11 +596,7 @@ wxString wxComboBox::GetString( int n ) const
{ {
GtkBin *bin = GTK_BIN( child->data ); GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child ); GtkLabel *label = GTK_LABEL( bin->child );
#ifdef __WXGTK20__
str = wxGTK_CONV_BACK( gtk_label_get_text(label) );
#else
str = wxString( label->label ); str = wxString( label->label );
#endif
} }
else else
{ {
@@ -632,11 +617,7 @@ wxString wxComboBox::GetStringSelection() const
{ {
GtkBin *bin = GTK_BIN( selection->data ); GtkBin *bin = GTK_BIN( selection->data );
GtkLabel *label = GTK_LABEL( bin->child ); GtkLabel *label = GTK_LABEL( bin->child );
#ifdef __WXGTK20__
wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
#else
wxString tmp( label->label ); wxString tmp( label->label );
#endif
return tmp; return tmp;
} }
@@ -832,15 +813,8 @@ void wxComboBox::GetSelection( long* from, long* to ) const
if (IsEditable()) if (IsEditable())
{ {
GtkEditable *editable = GTK_EDITABLE(GTK_COMBO(m_widget)->entry); 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; *from = (long) editable->selection_start_pos;
*to = (long) editable->selection_end_pos; *to = (long) editable->selection_end_pos;
#endif
} }
} }

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/control.cpp // Name: src/gtk1/control.cpp
// Purpose: wxControl implementation for wxGTK // Purpose: wxControl implementation for wxGTK
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -16,7 +16,7 @@
#include "wx/control.h" #include "wx/control.h"
#include "wx/fontutil.h" #include "wx/fontutil.h"
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
// ============================================================================ // ============================================================================
// wxControl implementation // wxControl implementation
@@ -107,11 +107,7 @@ void wxControl::GTKSetLabelForLabel(GtkLabel *w, const wxString& label)
const wxString labelGTK = GTKConvertMnemonics(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)); gtk_label_set(w, wxGTK_CONV(labelGTK));
#endif
} }
void wxControl::GTKSetLabelForFrame(GtkFrame *w, const wxString& label) void wxControl::GTKSetLabelForFrame(GtkFrame *w, const wxString& label)
@@ -208,11 +204,7 @@ wxString wxControl::GTKRemoveMnemonics(const wxString& label)
/* static */ /* static */
wxString wxControl::GTKConvertMnemonics(const wxString& label) wxString wxControl::GTKConvertMnemonics(const wxString& label)
{ {
#ifdef __WXGTK20__
return GTKProcessMnemonics(label, MNEMONICS_CONVERT);
#else
return GTKRemoveMnemonics(label); return GTKRemoveMnemonics(label);
#endif
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -263,33 +255,8 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
style->bg[state].blue >> SHIFT); style->bg[state].blue >> SHIFT);
// get the style's font // 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? // TODO: isn't there a way to get a standard gtk 1.2 font?
attr.font = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); attr.font = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
#endif
return attr; return attr;
} }

View File

@@ -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 // wxFileDataObject
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -21,7 +21,7 @@
#include "wx/log.h" #include "wx/log.h"
#include "wx/fontutil.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 #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( src, _T("NULL src in gdk_wx_draw_bitmap") );
wxCHECK_RET( gc, _T("NULL gc 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 *drawable_private;
GdkWindowPrivate *src_private; GdkWindowPrivate *src_private;
GdkGCPrivate *gc_private; GdkGCPrivate *gc_private;
@@ -132,7 +117,6 @@ void gdk_wx_draw_bitmap(GdkDrawable *drawable,
width, height, width, height,
xdest, ydest, xdest, ydest,
1 ); 1 );
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -288,11 +272,6 @@ wxWindowDC::wxWindowDC()
m_isMemDC = false; m_isMemDC = false;
m_isScreenDC = false; m_isScreenDC = false;
m_owner = (wxWindow *)NULL; m_owner = (wxWindow *)NULL;
#ifdef __WXGTK20__
m_context = (PangoContext *)NULL;
m_layout = (PangoLayout *)NULL;
m_fontdesc = (PangoFontDescription *)NULL;
#endif
} }
wxWindowDC::wxWindowDC( wxWindow *window ) wxWindowDC::wxWindowDC( wxWindow *window )
@@ -322,12 +301,6 @@ wxWindowDC::wxWindowDC( wxWindow *window )
wxASSERT_MSG( widget, wxT("DC needs a widget") ); 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 ); GtkPizza *pizza = GTK_PIZZA( widget );
m_window = pizza->bin_window; m_window = pizza->bin_window;
@@ -357,13 +330,6 @@ wxWindowDC::wxWindowDC( wxWindow *window )
wxWindowDC::~wxWindowDC() wxWindowDC::~wxWindowDC()
{ {
Destroy(); 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() void wxWindowDC::SetUpDC()
@@ -1126,13 +1092,11 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
if ((w != ww) || (h != hh)) if ((w != ww) || (h != hh))
use_bitmap = use_bitmap.Rescale( 0, 0, ww, hh, ww, 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. // 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 // Pixbufs-based bitmaps with alpha channel don't have a mask, so we
// have to call GetPixmap() here -- it converts the pixbuf into pixmap // have to call GetPixmap() here -- it converts the pixbuf into pixmap
// and also creates the mask as a side-effect: // and also creates the mask as a side-effect:
use_bitmap.GetPixmap(); use_bitmap.GetPixmap();
#endif
// apply mask if any // apply mask if any
GdkBitmap *mask = (GdkBitmap *) NULL; 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 // drawing a mono-bitmap (XBitmap) we use the current text GC
if (is_mono) 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 ); gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), 0, 0, xx, yy, -1, -1 );
#endif
} }
else else
{ {
#if GTK_CHECK_VERSION(2,2,0) gdk_draw_pixmap(m_window, m_penGC,
if (!gtk_check_version(2,2,0) && use_bitmap.HasPixbuf()) use_bitmap.GetPixmap(),
{ 0, 0, xx, yy, -1, -1);
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);
}
} }
// remove mask again if any // remove mask again if any
@@ -1442,21 +1381,8 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest,
if (is_mono) 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 ); // 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 ); gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, cx, cy, cw, ch );
#endif
} }
else else
{ {
@@ -1529,100 +1455,13 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
if (text.empty()) return; if (text.empty()) return;
#ifndef __WXGTK20__
GdkFont *font = m_font.GetInternalFont( m_scaleY ); GdkFont *font = m_font.GetInternalFont( m_scaleY );
wxCHECK_RET( font, wxT("invalid font") ); wxCHECK_RET( font, wxT("invalid font") );
#endif
x = XLOG2DEV(x); x = XLOG2DEV(x);
y = YLOG2DEV(y); 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 width = gdk_string_width( font, text.mbc_str() );
wxCoord height = font->ascent + font->descent; 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++; if (font->descent > 0) ul_y++;
gdk_draw_line( m_window, m_textGC, x, ul_y, x + width, 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); width = wxCoord(width / m_scaleX);
height = wxCoord(height / m_scaleY); height = wxCoord(height / m_scaleY);
@@ -1671,11 +1509,6 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y,
wxCoord w; wxCoord w;
wxCoord h; 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 ); GdkFont *font = m_font.GetInternalFont( m_scaleY );
wxCHECK_RET( font, wxT("invalid font") ); 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 // the size of the text
w = gdk_string_width( font, text.mbc_str() ); w = gdk_string_width( font, text.mbc_str() );
h = font->ascent + font->descent; h = font->ascent + font->descent;
#endif
// draw the string normally // draw the string normally
wxBitmap src(w, h); wxBitmap src(w, h);
wxMemoryDC dc; wxMemoryDC dc;
@@ -1786,53 +1619,6 @@ void wxWindowDC::DoGetTextExtent(const wxString &string,
return; 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; wxFont fontToUse = m_font;
if (theFont) if (theFont)
fontToUse = *theFont; fontToUse = *theFont;
@@ -1847,37 +1633,22 @@ void wxWindowDC::DoGetTextExtent(const wxString &string,
*height = wxCoord((font->ascent + font->descent) / m_scaleY); *height = wxCoord((font->ascent + font->descent) / m_scaleY);
if (descent) if (descent)
*descent = wxCoord(font->descent / m_scaleY); *descent = wxCoord(font->descent / m_scaleY);
#endif // GTK+ 2/1
} }
wxCoord wxWindowDC::GetCharWidth() const 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 ); GdkFont *font = m_font.GetInternalFont( m_scaleY );
wxCHECK_MSG( font, -1, wxT("invalid font") ); wxCHECK_MSG( font, -1, wxT("invalid font") );
return wxCoord(gdk_string_width( font, "H" ) / m_scaleX); return wxCoord(gdk_string_width( font, "H" ) / m_scaleX);
#endif
} }
wxCoord wxWindowDC::GetCharHeight() const 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 ); GdkFont *font = m_font.GetInternalFont( m_scaleY );
wxCHECK_MSG( font, -1, wxT("invalid font") ); wxCHECK_MSG( font, -1, wxT("invalid font") );
return wxCoord((font->ascent + font->descent) / m_scaleY); return wxCoord((font->ascent + font->descent) / m_scaleY);
#endif
} }
void wxWindowDC::Clear() void wxWindowDC::Clear()
@@ -1921,37 +1692,6 @@ void wxWindowDC::Clear()
void wxWindowDC::SetFont( const wxFont &font ) void wxWindowDC::SetFont( const wxFont &font )
{ {
m_font = 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 ) void wxWindowDC::SetPen( const wxPen &pen )
@@ -2433,13 +2173,9 @@ wxSize wxWindowDC::GetPPI() const
int wxWindowDC::GetDepth() const int wxWindowDC::GetDepth() const
{ {
#ifdef __WXGTK20__
return gdk_drawable_get_depth(m_window);
#else
wxFAIL_MSG(wxT("not implemented")); wxFAIL_MSG(wxT("not implemented"));
return -1; return -1;
#endif
} }

View File

@@ -26,15 +26,6 @@ wxMemoryDC::wxMemoryDC() : wxWindowDC()
m_ok = FALSE; m_ok = FALSE;
m_cmap = gtk_widget_get_default_colormap(); 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) ) wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
@@ -44,19 +35,10 @@ wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
m_cmap = gtk_widget_get_default_colormap(); 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() wxMemoryDC::~wxMemoryDC()
{ {
#ifdef __WXGTK20__
g_object_unref(m_context);
#endif
} }
void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
@@ -74,10 +56,6 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
m_window = m_selected.GetBitmap(); m_window = m_selected.GetBitmap();
} }
#ifdef __WXGTK20__
m_selected.PurgeOtherRepresentations(wxBitmap::Pixmap);
#endif
m_isMemDC = TRUE; m_isMemDC = TRUE;
SetUpDC(); SetUpDC();

View File

@@ -37,15 +37,6 @@ wxScreenDC::wxScreenDC()
m_cmap = gdk_colormap_get_system(); m_cmap = gdk_colormap_get_system();
m_window = GDK_ROOT_PARENT(); 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; m_isScreenDC = TRUE;
SetUpDC(); SetUpDC();

View File

@@ -20,7 +20,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// global data // global data

View File

@@ -22,7 +22,7 @@
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include <gdk/gdkprivate.h> #include <gdk/gdkprivate.h>
@@ -506,13 +506,7 @@ GdkAtom wxDropTarget::GetMatchingPair()
GList *child = m_dragContext->targets; GList *child = m_dragContext->targets;
while (child) while (child)
{ {
// in GTK+ 1.x GdkAtom was a gulong, but now it's a pointer GdkAtom formatAtom = GPOINTER_TO_INT(child->data);
GdkAtom formatAtom =
#ifdef __WXGTK20__
(GdkAtom)(child->data);
#else
GPOINTER_TO_INT(child->data);
#endif
wxDataFormat format( formatAtom ); wxDataFormat format( formatAtom );
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
@@ -823,18 +817,14 @@ void wxDropSource::PrepareIcon( int action, GdkDragContext *context )
gdk_window_get_size (pixmap, &width, &height); gdk_window_get_size (pixmap, &width, &height);
GdkColormap *colormap = gtk_widget_get_colormap( m_widget ); GdkColormap *colormap = gtk_widget_get_colormap( m_widget );
#ifndef __WXGTK20__
gtk_widget_push_visual (gdk_colormap_get_visual (colormap)); gtk_widget_push_visual (gdk_colormap_get_visual (colormap));
#endif
gtk_widget_push_colormap (colormap); gtk_widget_push_colormap (colormap);
m_iconWindow = gtk_window_new (GTK_WINDOW_POPUP); 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_events (m_iconWindow, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
gtk_widget_set_app_paintable (GTK_WIDGET (m_iconWindow), TRUE); gtk_widget_set_app_paintable (GTK_WIDGET (m_iconWindow), TRUE);
#ifndef __WXGTK20__
gtk_widget_pop_visual (); gtk_widget_pop_visual ();
#endif
gtk_widget_pop_colormap (); gtk_widget_pop_colormap ();
gtk_widget_set_usize (m_iconWindow, width, height); gtk_widget_set_usize (m_iconWindow, width, height);

View File

@@ -17,107 +17,6 @@
#include "wx/filedlg.h" #include "wx/filedlg.h"
#ifdef __WXGTK24__
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <unistd.h> // 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 // wxFileDialog
@@ -137,138 +36,26 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
: wxGenericFileDialog(parent, message, defaultDir, defaultFileName, : wxGenericFileDialog(parent, message, defaultDir, defaultFileName,
wildCard, style, pos, true ) 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 ); wxGenericFileDialog::Create( parent, message, defaultDir, defaultFileName, wildCard, style, pos );
} }
wxFileDialog::~wxFileDialog() 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 ) void wxFileDialog::OnFakeOk( wxCommandEvent &event )
{ {
#ifdef __WXGTK24__ wxGenericFileDialog::OnListOk( event );
if (!gtk_check_version(2,4,0))
wxDialog::OnOK( event );
else
#endif
wxGenericFileDialog::OnListOk( event );
} }
int wxFileDialog::ShowModal() int wxFileDialog::ShowModal()
{ {
#ifdef __WXGTK24__ return wxGenericFileDialog::ShowModal();
if (!gtk_check_version(2,4,0))
return wxDialog::ShowModal();
else
#endif
return wxGenericFileDialog::ShowModal();
} }
bool wxFileDialog::Show( bool show ) bool wxFileDialog::Show( bool show )
{ {
#ifdef __WXGTK24__ return wxGenericFileDialog::Show( show );
if (!gtk_check_version(2,4,0))
return wxDialog::Show( show );
else
#endif
return wxGenericFileDialog::Show( show );
} }
void wxFileDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags ) 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 wxString wxFileDialog::GetPath() const
{ {
#ifdef __WXGTK24__ return wxGenericFileDialog::GetPath();
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();
} }
void wxFileDialog::GetFilenames(wxArrayString& files) const void wxFileDialog::GetFilenames(wxArrayString& files) const
{ {
#ifdef __WXGTK24__ wxGenericFileDialog::GetFilenames( files );
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 );
} }
void wxFileDialog::GetPaths(wxArrayString& paths) const void wxFileDialog::GetPaths(wxArrayString& paths) const
{ {
#ifdef __WXGTK24__ wxGenericFileDialog::GetPaths( paths );
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 );
} }
void wxFileDialog::SetMessage(const wxString& message) void wxFileDialog::SetMessage(const wxString& message)
{ {
#ifdef __WXGTK24__ wxGenericFileDialog::SetMessage( message );
if (!gtk_check_version(2,4,0))
{
m_message = message;
SetTitle(message);
}
else
#endif
wxGenericFileDialog::SetMessage( message );
} }
void wxFileDialog::SetPath(const wxString& path) void wxFileDialog::SetPath(const wxString& path)
{ {
#ifdef __WXGTK24__ wxGenericFileDialog::SetPath( path );
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 );
} }
void wxFileDialog::SetDirectory(const wxString& dir) void wxFileDialog::SetDirectory(const wxString& dir)
{ {
#ifdef __WXGTK24__ wxGenericFileDialog::SetDirectory( dir );
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 );
} }
wxString wxFileDialog::GetDirectory() const wxString wxFileDialog::GetDirectory() const
{ {
#ifdef __WXGTK24__ return wxGenericFileDialog::GetDirectory();
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();
} }
void wxFileDialog::SetFilename(const wxString& name) void wxFileDialog::SetFilename(const wxString& name)
{ {
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) wxGenericFileDialog::SetFilename( name );
{
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 );
} }
wxString wxFileDialog::GetFilename() const wxString wxFileDialog::GetFilename() const
{ {
#ifdef __WXGTK24__ return wxGenericFileDialog::GetFilename();
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();
} }
void wxFileDialog::SetWildcard(const wxString& wildCard) void wxFileDialog::SetWildcard(const wxString& wildCard)
{ {
#ifdef __WXGTK24__ wxGenericFileDialog::SetWildcard( wildCard );
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 );
} }
void wxFileDialog::SetFilterIndex(int filterIndex) void wxFileDialog::SetFilterIndex(int filterIndex)
{ {
#ifdef __WXGTK24__ wxGenericFileDialog::SetFilterIndex( filterIndex );
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 );
} }
int wxFileDialog::GetFilterIndex() const int wxFileDialog::GetFilterIndex() const
{ {
#ifdef __WXGTK24__ return wxGenericFileDialog::GetFilterIndex();
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();
} }
#endif // wxUSE_FILEDLG #endif // wxUSE_FILEDLG

View File

@@ -29,7 +29,7 @@
#include <strings.h> #include <strings.h>
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include <gdk/gdkprivate.h> #include <gdk/gdkprivate.h>
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -73,13 +73,8 @@ public:
// do we have the native font info? // do we have the native font info?
bool HasNativeFont() const 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 // only use m_nativeFontInfo if it had been initialized
return !m_nativeFontInfo.IsDefault(); return !m_nativeFontInfo.IsDefault();
#endif // GTK 2.0/1.x
} }
// setters: all of them also take care to modify m_nativeFontInfo if we // 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 // VZ: I need this as my gdb either shows wildly wrong values or crashes
// when I ask it to "p fontRefData" :-( // when I ask it to "p fontRefData" :-(
#if defined(__WXDEBUG__) && !defined(__WXGTK20__) #if defined(__WXDEBUG__)
void Dump() const void Dump() const
{ {
wxPrintf(_T("%s-%s-%s-%d-%d\n"), wxPrintf(_T("%s-%s-%s-%d-%d\n"),
@@ -135,10 +130,8 @@ private:
// clear m_scaled_xfonts if any // clear m_scaled_xfonts if any
void ClearGdkFonts(); void ClearGdkFonts();
#ifndef __WXGTK20__
// the map of font sizes to "GdkFont *" // the map of font sizes to "GdkFont *"
wxScaledFontList m_scaled_xfonts; wxScaledFontList m_scaled_xfonts;
#endif // GTK 2.0/1.x
int m_pointSize; int m_pointSize;
int m_family, int m_family,
@@ -186,84 +179,12 @@ void wxFontRefData::Init(int pointSize,
m_encoding = encoding; m_encoding = encoding;
m_noAA = FALSE; 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() void wxFontRefData::InitFromNative()
{ {
m_noAA = FALSE; 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 // get the font parameters from the XLFD
// ------------------------------------- // -------------------------------------
@@ -361,7 +282,6 @@ void wxFontRefData::InitFromNative()
// may be give a warning here? or use wxFontMapper? // may be give a warning here? or use wxFontMapper?
m_encoding = wxFONTENCODING_SYSTEM; m_encoding = wxFONTENCODING_SYSTEM;
} }
#endif // GTK 2.0/1.x
} }
wxFontRefData::wxFontRefData( const wxFontRefData& data ) wxFontRefData::wxFontRefData( const wxFontRefData& data )
@@ -395,19 +315,14 @@ wxFontRefData::wxFontRefData(int size, int family, int style,
wxFontRefData::wxFontRefData(const wxString& fontname) wxFontRefData::wxFontRefData(const wxString& fontname)
{ {
// VZ: FromString() should really work in both cases, doesn't it? // FromString() should really work in GTK1 too, doesn't it?
#ifdef __WXGTK20__
m_nativeFontInfo.FromString( fontname );
#else // GTK 1.x
m_nativeFontInfo.SetXFontName(fontname); m_nativeFontInfo.SetXFontName(fontname);
#endif // GTK 2.0/1.x
InitFromNative(); InitFromNative();
} }
void wxFontRefData::ClearGdkFonts() void wxFontRefData::ClearGdkFonts()
{ {
#ifndef __WXGTK20__
for ( wxScaledFontList::iterator i = m_scaled_xfonts.begin(); for ( wxScaledFontList::iterator i = m_scaled_xfonts.begin();
i != m_scaled_xfonts.end(); i != m_scaled_xfonts.end();
++i ) ++i )
@@ -417,7 +332,6 @@ void wxFontRefData::ClearGdkFonts()
} }
m_scaled_xfonts.clear(); m_scaled_xfonts.clear();
#endif // GTK 1.x
} }
wxFontRefData::~wxFontRefData() wxFontRefData::~wxFontRefData()
@@ -433,9 +347,6 @@ void wxFontRefData::SetPointSize(int pointSize)
{ {
m_pointSize = pointSize; m_pointSize = pointSize;
#ifdef __WXGTK20__
m_nativeFontInfo.SetPointSize(pointSize);
#else
if ( HasNativeFont() ) if ( HasNativeFont() )
{ {
wxString size; wxString size;
@@ -446,7 +357,6 @@ void wxFontRefData::SetPointSize(int pointSize)
m_nativeFontInfo.SetXFontComponent(wxXLFD_POINTSIZE, size); m_nativeFontInfo.SetXFontComponent(wxXLFD_POINTSIZE, size);
} }
#endif
} }
void wxFontRefData::SetFamily(int family) void wxFontRefData::SetFamily(int family)
@@ -460,9 +370,6 @@ void wxFontRefData::SetStyle(int style)
{ {
m_style = style; m_style = style;
#ifdef __WXGTK20__
m_nativeFontInfo.SetStyle((wxFontStyle)style);
#else
if ( HasNativeFont() ) if ( HasNativeFont() )
{ {
wxString slant; wxString slant;
@@ -486,16 +393,12 @@ void wxFontRefData::SetStyle(int style)
m_nativeFontInfo.SetXFontComponent(wxXLFD_SLANT, slant); m_nativeFontInfo.SetXFontComponent(wxXLFD_SLANT, slant);
} }
#endif
} }
void wxFontRefData::SetWeight(int weight) void wxFontRefData::SetWeight(int weight)
{ {
m_weight = weight; m_weight = weight;
#ifdef __WXGTK20__
m_nativeFontInfo.SetWeight((wxFontWeight)weight);
#else //!__WXGTK20__
if ( HasNativeFont() ) if ( HasNativeFont() )
{ {
wxString boldness; wxString boldness;
@@ -520,7 +423,6 @@ void wxFontRefData::SetWeight(int weight)
m_nativeFontInfo.SetXFontComponent(wxXLFD_WEIGHT, boldness); m_nativeFontInfo.SetXFontComponent(wxXLFD_WEIGHT, boldness);
} }
#endif
} }
void wxFontRefData::SetUnderlined(bool underlined) void wxFontRefData::SetUnderlined(bool underlined)
@@ -534,21 +436,16 @@ void wxFontRefData::SetFaceName(const wxString& facename)
{ {
m_faceName = facename; m_faceName = facename;
#ifdef __WXGTK20__
m_nativeFontInfo.SetFaceName(facename);
#else
if ( HasNativeFont() ) if ( HasNativeFont() )
{ {
m_nativeFontInfo.SetXFontComponent(wxXLFD_FAMILY, facename); m_nativeFontInfo.SetXFontComponent(wxXLFD_FAMILY, facename);
} }
#endif
} }
void wxFontRefData::SetEncoding(wxFontEncoding encoding) void wxFontRefData::SetEncoding(wxFontEncoding encoding)
{ {
m_encoding = encoding; m_encoding = encoding;
#ifndef __WXGTK20__
if ( HasNativeFont() ) if ( HasNativeFont() )
{ {
wxNativeEncodingInfo info; wxNativeEncodingInfo info;
@@ -558,7 +455,6 @@ void wxFontRefData::SetEncoding(wxFontEncoding encoding)
m_nativeFontInfo.SetXFontComponent(wxXLFD_ENCODING, info.xencoding); m_nativeFontInfo.SetXFontComponent(wxXLFD_ENCODING, info.xencoding);
} }
} }
#endif
} }
void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info) void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info)
@@ -586,17 +482,7 @@ wxFont::wxFont(const wxNativeFontInfo& info)
{ {
Init(); Init();
#ifdef __WXGTK20__
Create( info.GetPointSize(),
info.GetFamily(),
info.GetStyle(),
info.GetWeight(),
info.GetUnderlined(),
info.GetFaceName(),
info.GetEncoding() );
#else
(void) Create(info.GetXFontName()); (void) Create(info.GetXFontName());
#endif
} }
bool wxFont::Create( int pointSize, bool wxFont::Create( int pointSize,
@@ -745,7 +631,6 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
{ {
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") ); wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
#ifndef __WXGTK20__
if ( !M_FONTDATA->HasNativeFont() ) if ( !M_FONTDATA->HasNativeFont() )
{ {
// NB: this call has important side-effect: it not only finds // 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 // by calling its SetXFontName method
GetInternalFont(); GetInternalFont();
} }
#endif
return &(M_FONTDATA->m_nativeFontInfo); return &(M_FONTDATA->m_nativeFontInfo);
} }
@@ -762,7 +646,6 @@ bool wxFont::IsFixedWidth() const
{ {
wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") ); wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") );
#ifndef __WXGTK20__
if ( M_FONTDATA->HasNativeFont() ) if ( M_FONTDATA->HasNativeFont() )
{ {
// the monospace fonts are supposed to have "M" in the spacing field // 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'); return spacing.Upper() == _T('M');
} }
#endif
return wxFontBase::IsFixedWidth(); return wxFontBase::IsFixedWidth();
} }
@@ -847,7 +729,6 @@ void wxFont::SetNoAntiAliasing( bool no )
// get internal representation of font // get internal representation of font
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef __WXGTK20__
static GdkFont *g_systemDefaultGuiFont = (GdkFont*) NULL; static GdkFont *g_systemDefaultGuiFont = (GdkFont*) NULL;
// this is also used from tbargtk.cpp and tooltip.cpp, hence extern // this is also used from tbargtk.cpp and tooltip.cpp, hence extern
@@ -939,5 +820,3 @@ GdkFont *wxFont::GetInternalFont( float scale ) const
return font; return font;
} }
#endif // not GTK 2.0

View File

@@ -23,7 +23,7 @@
#include "wx/debug.h" #include "wx/debug.h"
#include "wx/msgdlg.h" #include "wx/msgdlg.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // 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); GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget);
#ifndef __WXGTK20__
GdkFont *gfont = gtk_font_selection_dialog_get_font(fontdlg); GdkFont *gfont = gtk_font_selection_dialog_get_font(fontdlg);
if (!gfont) if (!gfont)
@@ -78,7 +77,6 @@ void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dial
wxOK | wxICON_ERROR); wxOK | wxICON_ERROR);
return; return;
} }
#endif
gchar *fontname = gtk_font_selection_dialog_get_font_name(fontdlg); gchar *fontname = gtk_font_selection_dialog_get_font_name(fontdlg);
dialog->SetChosenFont( fontname); dialog->SetChosenFont( fontname);
@@ -138,18 +136,14 @@ bool wxFontDialog::DoCreate(wxWindow *parent)
gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked", gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked",
GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this );
#ifndef __WXGTK20__
// strange way to internationalize // strange way to internationalize
gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), _("OK") ); gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), _("OK") );
#endif
gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked", gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked",
GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this );
#ifndef __WXGTK20__
// strange way to internationalize // strange way to internationalize
gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), _("Cancel") ); gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), _("Cancel") );
#endif
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this );
@@ -162,13 +156,10 @@ bool wxFontDialog::DoCreate(wxWindow *parent)
if ( info ) if ( info )
{ {
#ifdef __WXGTK20__
const wxString& fontname = info->ToString();
#else
const wxString& fontname = info->GetXFontName(); const wxString& fontname = info->GetXFontName();
if ( !fontname ) if ( !fontname )
font.GetInternalFont(); font.GetInternalFont();
#endif
gtk_font_selection_dialog_set_font_name(sel, wxGTK_CONV(fontname)); gtk_font_selection_dialog_set_font_name(sel, wxGTK_CONV(fontname));
} }
else else

View File

@@ -34,12 +34,12 @@
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include <glib.h> #include <glib.h>
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants

View File

@@ -30,7 +30,7 @@ extern "C"
#include "gdk/gdkx.h" #include "gdk/gdkx.h"
} }
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
// DLL options compatibility check: // DLL options compatibility check:
#include "wx/build.h" #include "wx/build.h"
@@ -255,7 +255,6 @@ gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_e
// "draw" of m_wxwindow // "draw" of m_wxwindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __WXGTK20__
extern "C" { extern "C" {
static void static void
gtk_glwindow_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxGLCanvas *win ) 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 ); rect->width, rect->height );
} }
} }
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "size_allocate" of m_wxwindow // "size_allocate" of m_wxwindow
@@ -397,7 +395,7 @@ bool wxGLCanvas::Create( wxWindow *parent,
GdkColormap *colormap; GdkColormap *colormap;
// MR: This needs a fix for lower gtk+ versions too. Might need to rethink logic (FIXME) // 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)) if (!gtk_check_version(2,2,0))
{ {
wxWindow::Create( parent, id, pos, size, style, name ); wxWindow::Create( parent, id, pos, size, style, name );
@@ -429,10 +427,6 @@ bool wxGLCanvas::Create( wxWindow *parent,
m_glWidget = m_wxwindow; 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_pizza_set_clear( GTK_PIZZA(m_wxwindow), FALSE );
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize", 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_connect( GTK_OBJECT(m_wxwindow), "expose_event",
GTK_SIGNAL_FUNC(gtk_glwindow_expose_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_glwindow_expose_callback), (gpointer)this );
#ifndef __WXGTK20__
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
GTK_SIGNAL_FUNC(gtk_glwindow_draw_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_glwindow_draw_callback), (gpointer)this );
#endif
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_glcanvas_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_glcanvas_size_callback), (gpointer)this );
#ifdef __WXGTK20__ gtk_widget_pop_visual();
if (gtk_check_version(2,2,0) != NULL) gtk_widget_pop_colormap();
#endif
{
gtk_widget_pop_visual();
gtk_widget_pop_colormap();
}
// if our parent window is already visible, we had been realized before we // 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 // connected to the "realize" signal and hence our m_glContext hasn't been

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/listbox.cpp // Name: src/gtk1/listbox.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -21,7 +21,7 @@
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/checklst.h" #include "wx/checklst.h"
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
#include "wx/tooltip.h" #include "wx/tooltip.h"
@@ -887,16 +887,12 @@ wxString wxListBox::GetRealLabel(GList *item) const
wxString str; wxString str;
#ifdef __WXGTK20__
str = wxGTK_CONV_BACK( gtk_label_get_text( label ) );
#else
str = wxString( label->label ); str = wxString( label->label );
#endif
#if wxUSE_CHECKLISTBOX #if wxUSE_CHECKLISTBOX
// checklistboxes have "[<5B>] " prepended to their lables, remove it // checklistboxes have "[<5B>] " 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 ) if ( m_hasCheckBoxes )
str.erase(0, 4); str.erase(0, 4);
#endif // wxUSE_CHECKLISTBOX #endif // wxUSE_CHECKLISTBOX

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/mdi.cpp // Name: src/gtk1/mdi.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -18,12 +18,12 @@
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include <glib.h> #include <glib.h>
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// constants // constants

View File

@@ -20,34 +20,19 @@
#include "wx/accel.h" #include "wx/accel.h"
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
// FIXME: is this right? somehow I don't think so (VZ) #define ACCEL_OBJECT GtkObject
#ifdef __WXGTK20__ #define ACCEL_OBJECTS(a) (a)->attach_objects
#include <glib-object.h> #define ACCEL_OBJ_CAST(obj) GTK_OBJECT(obj)
#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
// we use normal item but with a special id for the menu title // we use normal item but with a special id for the menu title
static const int wxGTK_TITLE_ID = -3; static const int wxGTK_TITLE_ID = -3;
// defined in window.cpp // defined in window.cpp
#ifndef __WXGTK20__ extern guint32 wxGtkTimeLastClick;
extern guint32 wxGtkTimeLastClick;
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // 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(); m_menubar = gtk_menu_bar_new();
#ifndef __WXGTK20__
m_accel = gtk_accel_group_new(); m_accel = gtk_accel_group_new();
#endif
if (style & wxMB_DOCKABLE) if (style & wxMB_DOCKABLE)
{ {
@@ -227,10 +210,8 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win )
while (top_frame->GetParent() && !(top_frame->IsTopLevel())) while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent(); top_frame = top_frame->GetParent();
#ifndef __WXGTK20__
// support for native hot keys // support for native hot keys
gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) ); gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
#endif
wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
while (node) while (node)
@@ -272,12 +253,10 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win )
while (top_frame->GetParent() && !(top_frame->IsTopLevel())) while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent(); top_frame = top_frame->GetParent();
#ifndef __WXGTK20__
// support for native key accelerators indicated by underscroes // support for native key accelerators indicated by underscroes
ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget); ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget);
if ( !g_slist_find( ACCEL_OBJECTS(m_accel), obj ) ) if ( !g_slist_find( ACCEL_OBJECTS(m_accel), obj ) )
gtk_accel_group_attach( m_accel, obj ); gtk_accel_group_attach( m_accel, obj );
#endif
wxMenuList::compatibility_iterator node = m_menus.GetFirst(); wxMenuList::compatibility_iterator node = m_menus.GetFirst();
while (node) while (node)
@@ -295,10 +274,8 @@ void wxMenuBar::UnsetInvokingWindow( wxWindow *win )
while (top_frame->GetParent() && !(top_frame->IsTopLevel())) while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent(); top_frame = top_frame->GetParent();
#ifndef __WXGTK20__
// support for native key accelerators indicated by underscroes // support for native key accelerators indicated by underscroes
gtk_accel_group_detach( m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) ); gtk_accel_group_detach( m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
#endif
wxMenuList::compatibility_iterator node = m_menus.GetFirst(); wxMenuList::compatibility_iterator node = m_menus.GetFirst();
while (node) while (node)
@@ -325,9 +302,6 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos)
menu->SetTitle( str ); menu->SetTitle( str );
// The "m_owner" is the "menu item" // 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 ) ); menu->m_owner = gtk_menu_item_new_with_label( wxGTK_CONV( str ) );
GtkLabel *label = GTK_LABEL( GTK_BIN(menu->m_owner)->child ); GtkLabel *label = GTK_LABEL( GTK_BIN(menu->m_owner)->child );
// set new text // set new text
@@ -343,7 +317,6 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos)
GDK_MOD1_MASK, GDK_MOD1_MASK,
GTK_ACCEL_LOCKED); GTK_ACCEL_LOCKED);
} }
#endif
gtk_widget_show( menu->m_owner ); gtk_widget_show( menu->m_owner );
@@ -774,16 +747,6 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
continue; 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('&')) ) if ( (*pc == wxT('&')) && (*(pc+1) != wxT('&')) )
{ {
// wxMSW escapes "&" // wxMSW escapes "&"
@@ -823,16 +786,12 @@ void wxMenuItem::SetText( const wxString& str )
else else
label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); 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 // set new text
gtk_label_set( label, wxGTK_CONV( m_text ) ); gtk_label_set( label, wxGTK_CONV( m_text ) );
// reparse key accel // reparse key accel
(void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) ); (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
#endif
} }
guint accel_key; guint accel_key;
@@ -1013,51 +972,22 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
GtkWidget *menuItem; GtkWidget *menuItem;
wxString text; wxString text;
#ifndef __WXGTK20__
GtkLabel* label; GtkLabel* label;
#endif
if ( mitem->IsSeparator() ) if ( mitem->IsSeparator() )
{ {
#ifdef __WXGTK20__
menuItem = gtk_separator_menu_item_new();
#else
// TODO // TODO
menuItem = gtk_menu_item_new(); menuItem = gtk_menu_item_new();
#endif
} }
else if (mitem->GetBitmap().Ok()) else if (mitem->GetBitmap().Ok())
{ {
text = mitem->GetText(); text = mitem->GetText();
const wxBitmap *bitmap = &mitem->GetBitmap(); 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 // TODO
wxUnusedVar(bitmap); wxUnusedVar(bitmap);
menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) ); menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
label = GTK_LABEL( GTK_BIN(menuItem)->child ); label = GTK_LABEL( GTK_BIN(menuItem)->child );
#endif
m_prevRadio = NULL; m_prevRadio = NULL;
} }
@@ -1070,14 +1000,10 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
{ {
case wxITEM_CHECK: 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 ) ); menuItem = gtk_check_menu_item_new_with_label( wxGTK_CONV( text ) );
label = GTK_LABEL( GTK_BIN(menuItem)->child ); label = GTK_LABEL( GTK_BIN(menuItem)->child );
// set new text // set new text
gtk_label_set_text( label, wxGTK_CONV( text ) ); gtk_label_set_text( label, wxGTK_CONV( text ) );
#endif
m_prevRadio = NULL; m_prevRadio = NULL;
break; break;
} }
@@ -1088,25 +1014,16 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
if ( m_prevRadio == NULL ) if ( m_prevRadio == NULL )
{ {
// start of a new radio group // 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 ) ); m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
label = GTK_LABEL( GTK_BIN(menuItem)->child ); label = GTK_LABEL( GTK_BIN(menuItem)->child );
// set new text // set new text
gtk_label_set_text( label, wxGTK_CONV( text ) ); gtk_label_set_text( label, wxGTK_CONV( text ) );
#endif
} }
else // continue the radio group 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)); 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 ) ); m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
label = GTK_LABEL( GTK_BIN(menuItem)->child ); label = GTK_LABEL( GTK_BIN(menuItem)->child );
#endif
} }
break; break;
} }
@@ -1117,12 +1034,8 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
case wxITEM_NORMAL: 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 ) ); menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
label = GTK_LABEL( GTK_BIN(menuItem)->child ); label = GTK_LABEL( GTK_BIN(menuItem)->child );
#endif
m_prevRadio = NULL; m_prevRadio = NULL;
break; break;
} }
@@ -1184,7 +1097,6 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
(gpointer)this ); (gpointer)this );
} }
#ifndef __WXGTK20__
guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) ); guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
if (accel_key != GDK_VoidSymbol) if (accel_key != GDK_VoidSymbol)
{ {
@@ -1195,7 +1107,6 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
GDK_MOD1_MASK, GDK_MOD1_MASK,
GTK_ACCEL_LOCKED); GTK_ACCEL_LOCKED);
} }
#endif
} }
mitem->SetMenuItem(menuItem); mitem->SetMenuItem(menuItem);
@@ -1560,9 +1471,6 @@ void SetInvokingWindow( wxMenu *menu, wxWindow* win )
extern "C" extern "C"
void wxPopupMenuPositionCallback( GtkMenu *menu, void wxPopupMenuPositionCallback( GtkMenu *menu,
gint *x, gint *y, gint *x, gint *y,
#ifdef __WXGTK20__
gboolean * WXUNUSED(whatever),
#endif
gpointer user_data ) gpointer user_data )
{ {
// ensure that the menu appears entirely on screen // 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 posfunc, // function to position it
userdata, // client data userdata, // client data
0, // button used to activate it 0, // button used to activate it
#ifdef __WXGTK20__
gtk_get_current_event_time()
#else
wxGtkTimeLastClick // the time of activation wxGtkTimeLastClick // the time of activation
#endif
); );
while (is_waiting) while (is_waiting)

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/minifram.cpp // Name: src/gtk1/minifram.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -17,8 +17,8 @@
#include "wx/dcscreen.h" #include "wx/dcscreen.h"
#include "gtk/gtk.h" #include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gdk/gdkprivate.h> #include <gdk/gdkprivate.h>
@@ -112,7 +112,6 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g
// "draw" of m_mainWidget // "draw" of m_mainWidget
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __WXGTK20__
extern "C" { extern "C" {
static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxFrame *win ) 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 // "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_connect( GTK_OBJECT(m_mainWidget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );
#ifndef __WXGTK20__
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this );
#endif
/* these are required for dragging the mini frame around */ /* these are required for dragging the mini frame around */
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event", gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event",
@@ -401,11 +397,7 @@ void wxMiniFrame::SetTitle( const wxString &title )
{ {
wxFrame::SetTitle( 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 ); gtk_widget_draw( m_mainWidget, (GdkRectangle*) NULL );
#endif
} }
#endif #endif

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/msgdlg.cpp // Name: src/gtk1/msgdlg.cpp
// Purpose: wxMessageDialog for GTK+2 // Purpose: wxMessageDialog for GTK+2
// Author: Vaclav Slavik // Author: Vaclav Slavik
// Modified by: // Modified by:
@@ -15,116 +15,3 @@
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif #endif
#if wxUSE_MSGDLG && defined(__WXGTK20__) && !defined(__WXGPE__)
#include "wx/msgdlg.h"
#include "wx/gtk/private.h"
#include <gtk/gtk.h>
#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__)

View File

@@ -22,8 +22,8 @@
#include "wx/bitmap.h" #include "wx/bitmap.h"
#include "wx/fontutil.h" #include "wx/fontutil.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
@@ -738,7 +738,9 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
const size_t count = GetPageCount(); const size_t count = GetPageCount();
size_t i = 0; 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); GtkNotebook * notebook = GTK_NOTEBOOK(m_widget);
if (gtk_notebook_get_scrollable(notebook)); if (gtk_notebook_get_scrollable(notebook));
i = g_list_position( notebook->children, notebook->first_tab ); 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; GtkWidget *box = nb_page->m_box;
// VZ: don't know how to find the border width in GTK+ 1.2 // 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; const gint border = 0;
#endif
if ( IsPointInsideWidget(pt, box, x, y, border) ) if ( IsPointInsideWidget(pt, box, x, y, border) )
{ {
// ok, we're inside this tab -- now find out where, if needed // ok, we're inside this tab -- now find out where, if needed

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/pen.cpp // Name: src/gtk1/pen.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$

View File

@@ -21,7 +21,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/radiobox.cpp // Name: src/gtk1/radiobox.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -18,10 +18,10 @@
#include "wx/frame.h" #include "wx/frame.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system
@@ -385,11 +385,7 @@ wxString wxRadioBox::GetString( int n ) const
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) ); 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 ); wxString str( label->label );
#endif
return str; return str;
} }
@@ -529,10 +525,6 @@ void wxRadioBox::DoApplyWidgetStyle(GtkRcStyle *style)
{ {
gtk_widget_modify_style( m_widget, 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(); wxList::compatibility_iterator node = m_boxes.GetFirst();
while (node) while (node)
{ {

View File

@@ -14,7 +14,7 @@
#include "wx/radiobut.h" #include "wx/radiobut.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system

View File

@@ -21,9 +21,8 @@
#include "wx/region.h" #include "wx/region.h"
#include "wx/log.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 // wxGdkRegion: creates a new region in ctor and destroys in dtor
@@ -41,7 +40,6 @@ private:
GdkRegion *m_region; GdkRegion *m_region;
}; };
#endif // __WXGTK20__
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegionRefData: private class containing the information about the region // wxRegionRefData: private class containing the information about the region
@@ -58,11 +56,7 @@ public:
wxRegionRefData(const wxRegionRefData& refData) wxRegionRefData(const wxRegionRefData& refData)
: wxObjectRefData() : wxObjectRefData()
{ {
#ifdef __WXGTK20__
m_region = gdk_region_copy(refData.m_region);
#else
m_region = gdk_regions_union(wxGdkRegion(), refData.m_region); m_region = gdk_regions_union(wxGdkRegion(), refData.m_region);
#endif
} }
~wxRegionRefData() ~wxRegionRefData()
@@ -100,21 +94,13 @@ void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
m_refData = new wxRegionRefData(); 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 ); M_REGIONDATA->m_region = gdk_region_union_with_rect( wxGdkRegion(), &rect );
#endif
} }
wxRegion::wxRegion( GdkRegion *region ) wxRegion::wxRegion( GdkRegion *region )
{ {
m_refData = new wxRegionRefData(); m_refData = new wxRegionRefData();
#ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_copy( region );
#else
M_REGIONDATA->m_region = gdk_regions_union(wxGdkRegion(), region); M_REGIONDATA->m_region = gdk_regions_union(wxGdkRegion(), region);
#endif
} }
wxRegion::wxRegion( size_t n, const wxPoint *points, int fillStyle ) 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.width = width;
rect.height = height; 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 ); GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
gdk_region_destroy( M_REGIONDATA->m_region ); gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg; M_REGIONDATA->m_region = reg;
#endif
} }
return TRUE; return TRUE;
@@ -234,13 +216,9 @@ bool wxRegion::Union( const wxRegion& region )
AllocExclusive(); AllocExclusive();
} }
#ifdef __WXGTK20__
gdk_region_union( M_REGIONDATA->m_region, region.GetRegion() );
#else
GdkRegion *reg = gdk_regions_union( M_REGIONDATA->m_region, region.GetRegion() ); GdkRegion *reg = gdk_regions_union( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region ); gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg; M_REGIONDATA->m_region = reg;
#endif
return TRUE; return TRUE;
} }
@@ -272,13 +250,9 @@ bool wxRegion::Intersect( const wxRegion& region )
AllocExclusive(); AllocExclusive();
#ifdef __WXGTK20__
gdk_region_intersect( M_REGIONDATA->m_region, region.GetRegion() );
#else
GdkRegion *reg = gdk_regions_intersect( M_REGIONDATA->m_region, region.GetRegion() ); GdkRegion *reg = gdk_regions_intersect( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region ); gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg; M_REGIONDATA->m_region = reg;
#endif
return TRUE; return TRUE;
} }
@@ -308,13 +282,9 @@ bool wxRegion::Subtract( const wxRegion& region )
AllocExclusive(); AllocExclusive();
#ifdef __WXGTK20__
gdk_region_subtract( M_REGIONDATA->m_region, region.GetRegion() );
#else
GdkRegion *reg = gdk_regions_subtract( M_REGIONDATA->m_region, region.GetRegion() ); GdkRegion *reg = gdk_regions_subtract( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region ); gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg; M_REGIONDATA->m_region = reg;
#endif
return TRUE; return TRUE;
} }
@@ -343,13 +313,9 @@ bool wxRegion::Xor( const wxRegion& region )
AllocExclusive(); AllocExclusive();
#ifdef __WXGTK20__
gdk_region_xor( M_REGIONDATA->m_region, region.GetRegion() );
#else
GdkRegion *reg = gdk_regions_xor( M_REGIONDATA->m_region, region.GetRegion() ); GdkRegion *reg = gdk_regions_xor( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region ); gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg; M_REGIONDATA->m_region = reg;
#endif
return TRUE; return TRUE;
} }
@@ -458,8 +424,6 @@ GdkRegion *wxRegion::GetRegion() const
// wxRegionIterator // wxRegionIterator
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef __WXGTK20__
// the following structures must match the private structures // the following structures must match the private structures
// in X11 region code ( xc/lib/X11/region.h ) // in X11 region code ( xc/lib/X11/region.h )
@@ -477,7 +441,6 @@ struct _XRegion {
_XBox *rects, extents; _XBox *rects, extents;
}; };
#endif // GTK+ 1.x
class wxRIRefData: public wxObjectRefData class wxRIRefData: public wxObjectRefData
{ {
@@ -508,27 +471,6 @@ void wxRIRefData::CreateRects( const wxRegion& region )
if (!gdkregion) if (!gdkregion)
return; 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; Region r = ((GdkRegionPrivate *)gdkregion)->xregion;
if (r) if (r)
{ {
@@ -547,7 +489,6 @@ void wxRIRefData::CreateRects( const wxRegion& region )
} }
} }
} }
#endif // GTK+ 2.0/1.x
} }
wxRegionIterator::wxRegionIterator() wxRegionIterator::wxRegionIterator()

View File

@@ -26,22 +26,12 @@
#include "wx/renderer.h" #include "wx/renderer.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
#include "wx/window.h" #include "wx/window.h"
#include "wx/dc.h" #include "wx/dc.h"
#include "wx/dcclient.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 // RR: After a correction to the orientation of the sash
// this doesn't seem to be required anymore and it // this doesn't seem to be required anymore and it
// seems to confuse some themes so USE_ERASE_RECT=0 // seems to confuse some themes so USE_ERASE_RECT=0
@@ -60,14 +50,6 @@ public:
const wxRect& rect, const wxRect& rect,
int flags = 0); 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, virtual void DrawSplitterBorder(wxWindow *win,
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
@@ -96,11 +78,6 @@ private:
// used by DrawHeaderButton and DrawComboBoxDropButton // used by DrawHeaderButton and DrawComboBoxDropButton
static GtkWidget *GetButtonWidget(); static GtkWidget *GetButtonWidget();
#ifdef __WXGTK20__
// used by DrawTreeItemButton()
static GtkWidget *GetTreeWidget();
#endif // GTK+ 2.0
}; };
// ============================================================================ // ============================================================================
@@ -137,28 +114,6 @@ wxRendererGTK::GetButtonWidget()
return s_button; 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 // 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 // splitter sash drawing
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef __WXGTK20__ // the full sash width (should be even)
// the full sash width (should be even) static const wxCoord SASH_SIZE = 8;
static const wxCoord SASH_SIZE = 8;
// margin around the sash // margin around the sash
static const wxCoord SASH_MARGIN = 2; static const wxCoord SASH_MARGIN = 2;
#endif // GTK+ 2.x/1.x
static int GetGtkSplitterFullSize() 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; return SASH_SIZE + SASH_MARGIN;
#endif
} }
wxSplitterRenderParams wxSplitterRenderParams
@@ -257,11 +165,7 @@ wxRendererGTK::GetSplitterParams(const wxWindow *WXUNUSED(win))
( (
GetGtkSplitterFullSize(), GetGtkSplitterFullSize(),
0, 0,
#ifdef __WXGTK20__
true // hot sensitive
#else // GTK+ 1.x
false // not false // not
#endif // GTK+ 2.x/1.x
); );
} }
@@ -280,7 +184,7 @@ wxRendererGTK::DrawSplitterSash(wxWindow *win,
const wxSize& size, const wxSize& size,
wxCoord position, wxCoord position,
wxOrientation orient, wxOrientation orient,
int WXUNUSED_IN_GTK1(flags)) int WXUNUSED(flags))
{ {
if ( !win->m_wxwindow->window ) if ( !win->m_wxwindow->window )
{ {
@@ -350,23 +254,6 @@ wxRendererGTK::DrawSplitterSash(wxWindow *win,
); );
#endif #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 // leave some margin before sash itself
position += SASH_MARGIN / 2; position += SASH_MARGIN / 2;
@@ -404,7 +291,6 @@ wxRendererGTK::DrawSplitterSash(wxWindow *win,
isVert ? size.y - 2*SASH_SIZE : position, isVert ? size.y - 2*SASH_SIZE : position,
SASH_SIZE, SASH_SIZE SASH_SIZE, SASH_SIZE
); );
#endif // GTK+ 2.x/1.x
} }
void void
@@ -506,4 +392,3 @@ wxRendererGTK::DrawComboBoxDropButton(wxWindow *win,
DrawDropArrow(win,dc,rect,flags); DrawDropArrow(win,dc,rect,flags);
} }

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/scrolbar.cpp // Name: src/gtk1/scrolbar.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -16,7 +16,7 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/math.h" #include "wx/math.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system
@@ -118,10 +118,8 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget,
g_currentUpDownEvent = wxEVT_SCROLL_LINEUP; g_currentUpDownEvent = wxEVT_SCROLL_LINEUP;
} }
#ifndef __WXGTK20__
// There is no slider field any more // There is no slider field any more
win->m_isScrolling = (gdk_event->window == widget->slider); win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
return FALSE; return FALSE;
} }
@@ -345,12 +343,10 @@ bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window )
{ {
GtkRange *range = GTK_RANGE(m_widget); GtkRange *range = GTK_RANGE(m_widget);
return ( (window == GTK_WIDGET(range)->window) return ( (window == GTK_WIDGET(range)->window)
#ifndef __WXGTK20__
|| (window == range->trough) || (window == range->trough)
|| (window == range->slider) || (window == range->slider)
|| (window == range->step_forw) || (window == range->step_forw)
|| (window == range->step_back) || (window == range->step_back)
#endif // GTK+ 1.x
); );
} }

View File

@@ -26,7 +26,7 @@
#endif #endif
#include "wx/scrolwin.h" #include "wx/scrolwin.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
// ============================================================================ // ============================================================================
// implementation // implementation

View File

@@ -344,36 +344,7 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
{ {
if (!gs_objects.m_fontSystem.Ok()) 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 ); gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
#endif
} }
return gs_objects.m_fontSystem; return gs_objects.m_fontSystem;
} }
@@ -385,184 +356,27 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win ) 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) 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_X:
case wxSYS_CURSOR_Y: case wxSYS_CURSOR_Y:
#ifdef __WXGTK24__ return 16;
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
// MBN: ditto for icons // MBN: ditto for icons
case wxSYS_ICON_X: return 32; case wxSYS_ICON_X: return 32;
case wxSYS_ICON_Y: return 32; case wxSYS_ICON_Y: return 32;
case wxSYS_SCREEN_X: case wxSYS_SCREEN_X:
#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,2,0) return gdk_screen_width();
if (window && !gtk_check_version(2,2,0))
return gdk_screen_get_width(gdk_drawable_get_screen(window));
else
#endif
return gdk_screen_width();
case wxSYS_SCREEN_Y: case wxSYS_SCREEN_Y:
#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,2,0) return gdk_screen_height();
if (window && !gtk_check_version(2,2,0))
return gdk_screen_get_height(gdk_drawable_get_screen(window));
else
#endif
return gdk_screen_height();
case wxSYS_HSCROLL_Y: return 15; case wxSYS_HSCROLL_Y: return 15;
case wxSYS_VSCROLL_X: return 15; case wxSYS_VSCROLL_X: return 15;
// a gtk1 implementation should be possible too if gtk2 efficiency/convenience functions aren't used // a gtk1 implementation should be possible too if gtk2 efficiency/convenience functions aren't used
#ifdef __WXGTK20__ #if 0
case wxSYS_CAPTION_Y: case wxSYS_CAPTION_Y:
if (!window) if (!window)
// No realized window specified, and no implementation for that case yet. // No realized window specified, and no implementation for that case yet.

View File

@@ -16,7 +16,7 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/math.h" #include "wx/math.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system
@@ -93,25 +93,7 @@ static void gtk_slider_callback( GtkAdjustment *adjust,
return; return;
wxEventType evtType; 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)); evtType = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));
#endif
ProcessScrollEvent(win, evtType, dvalue); 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) ); 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(); GtkEnableEvents();
gtk_signal_connect( GTK_OBJECT(m_widget), gtk_signal_connect( GTK_OBJECT(m_widget),
"button_press_event", "button_press_event",
@@ -333,15 +310,11 @@ int wxSlider::GetLineSize() const
bool wxSlider::IsOwnGtkWindow( GdkWindow *window ) bool wxSlider::IsOwnGtkWindow( GdkWindow *window )
{ {
GtkRange *range = GTK_RANGE(m_widget); GtkRange *range = GTK_RANGE(m_widget);
#ifdef __WXGTK20__
return (range->event_window == window);
#else
return ( (window == GTK_WIDGET(range)->window) return ( (window == GTK_WIDGET(range)->window)
|| (window == range->trough) || (window == range->trough)
|| (window == range->slider) || (window == range->slider)
|| (window == range->step_forw) || (window == range->step_forw)
|| (window == range->step_back) ); || (window == range->step_back) );
#endif
} }
void wxSlider::GtkDisableEvents() void wxSlider::GtkDisableEvents()

View File

@@ -17,7 +17,7 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/math.h" #include "wx/math.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system

View File

@@ -19,7 +19,7 @@
#include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED #include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED
#include "wx/math.h" #include "wx/math.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system

View File

@@ -34,14 +34,12 @@ wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap
Create( parent, id, bitmap, pos, size, style, name ); Create( parent, id, bitmap, pos, size, style, name );
} }
#ifndef __WXGTK20__
// empty bitmap, so that we can create GtkPixmap widget: // empty bitmap, so that we can create GtkPixmap widget:
static char * bogus_xpm[] = { static char * bogus_xpm[] = {
"2 2 1 1", "2 2 1 1",
" c None", " c None",
" ", " ",
" "}; " "};
#endif
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
@@ -58,12 +56,8 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
m_bitmap = bitmap; m_bitmap = bitmap;
#ifdef __WXGTK20__
m_widget = gtk_image_new();
#else
wxBitmap bmp(bitmap.Ok() ? bitmap : wxBitmap(bogus_xpm)); wxBitmap bmp(bitmap.Ok() ? bitmap : wxBitmap(bogus_xpm));
m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL); m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL);
#endif
if (bitmap.Ok()) if (bitmap.Ok())
SetBitmap(bitmap); SetBitmap(bitmap);
@@ -84,7 +78,6 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
if (m_bitmap.GetMask()) if (m_bitmap.GetMask())
mask = m_bitmap.GetMask()->GetBitmap(); mask = m_bitmap.GetMask()->GetBitmap();
#ifdef __WXGTK20__
if (m_bitmap.HasPixbuf()) if (m_bitmap.HasPixbuf())
{ {
gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget), gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget),
@@ -93,9 +86,6 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
else else
gtk_image_set_from_pixmap(GTK_IMAGE(m_widget), gtk_image_set_from_pixmap(GTK_IMAGE(m_widget),
m_bitmap.GetPixmap(), mask); m_bitmap.GetPixmap(), mask);
#else
gtk_pixmap_set(GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask);
#endif
InvalidateBestSize(); InvalidateBestSize();
SetSize(GetBestSize()); SetSize(GetBestSize());

View File

@@ -13,7 +13,7 @@
#if wxUSE_STATBOX #if wxUSE_STATBOX
#include "wx/statbox.h" #include "wx/statbox.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include "gdk/gdk.h" #include "gdk/gdk.h"
#include "gtk/gtk.h" #include "gtk/gtk.h"
@@ -88,9 +88,6 @@ void wxStaticBox::SetLabel( const wxString& label )
void wxStaticBox::DoApplyWidgetStyle(GtkRcStyle *style) void wxStaticBox::DoApplyWidgetStyle(GtkRcStyle *style)
{ {
gtk_widget_modify_style(m_widget, style); gtk_widget_modify_style(m_widget, style);
#ifdef __WXGTK20__
gtk_widget_modify_style(GTK_FRAME(m_widget)->label_widget, style);
#endif
} }
// static // static

View File

@@ -13,7 +13,7 @@
#if wxUSE_STATTEXT #if wxUSE_STATTEXT
#include "wx/stattext.h" #include "wx/stattext.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include "gdk/gdk.h" #include "gdk/gdk.h"
#include "gtk/gtk.h" #include "gtk/gtk.h"
@@ -87,36 +87,13 @@ bool wxStaticText::Create(wxWindow *parent,
PostCreation(size); 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; return TRUE;
} }
wxString wxStaticText::GetLabel() const wxString wxStaticText::GetLabel() const
{ {
GtkLabel *label = GTK_LABEL(m_widget); GtkLabel *label = GTK_LABEL(m_widget);
#ifdef __WXGTK20__
wxString str = wxGTK_CONV_BACK( gtk_label_get_text( label ) );
#else
wxString str = wxString( label->label ); wxString str = wxString( label->label );
#endif
return wxString(str); return wxString(str);
} }
@@ -124,23 +101,7 @@ void wxStaticText::SetLabel( const wxString &label )
{ {
wxControl::SetLabel(label); wxControl::SetLabel(label);
#ifdef __WXGTK20__ gtk_label_set( GTK_LABEL(m_widget), wxGTK_CONV( m_label ) );
// 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("<span foreground=\"#%02x%02x%02x\">%s</span>"),
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 ) );
// adjust the label size to the new label unless disabled // adjust the label size to the new label unless disabled
if (!HasFlag(wxST_NO_AUTORESIZE)) if (!HasFlag(wxST_NO_AUTORESIZE))
@@ -175,11 +136,9 @@ wxSize wxStaticText::DoGetBestSize() const
// Do not return any arbitrary default value... // Do not return any arbitrary default value...
wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") ); wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") );
#ifndef __WXGTK20__
// This resets the internal GTK1 size calculation, which // This resets the internal GTK1 size calculation, which
// otherwise would be cashed (incorrectly) // otherwise would be cashed (incorrectly)
gtk_label_set_pattern( GTK_LABEL(m_widget), NULL ); gtk_label_set_pattern( GTK_LABEL(m_widget), NULL );
#endif
// GetBestSize is supposed to return unwrapped size // GetBestSize is supposed to return unwrapped size
gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE ); gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );

View File

@@ -11,134 +11,3 @@
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
#include "wx/gtk/taskbarpriv.h"
#include "wx/log.h"
#include "wx/frame.h"
#include "wx/menu.h"
#include <gdk/gdkx.h>
#ifdef __WXGTK20__
#include <gtk/gtkversion.h>
#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)

View File

@@ -26,7 +26,7 @@
#include "wx/frame.h" #include "wx/frame.h"
#include <glib.h> #include <glib.h>
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// globals // globals
@@ -56,11 +56,7 @@ static void GetGtkStyle(long style,
{ {
*gtkStyle = style & wxTB_NOICONS *gtkStyle = style & wxTB_NOICONS
? GTK_TOOLBAR_TEXT ? GTK_TOOLBAR_TEXT
: ( : GTK_TOOLBAR_BOTH;
#ifdef __WXGTK20__
style & wxTB_HORZ_LAYOUT ? GTK_TOOLBAR_BOTH_HORIZ :
#endif // __WXGTK20__
GTK_TOOLBAR_BOTH);
} }
else // no text, hence we must have the icons or what would we show? 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 *mask = bitmap.GetMask() ? bitmap.GetMask()->GetBitmap()
: (GdkBitmap *)NULL; : (GdkBitmap *)NULL;
#ifdef __WXGTK20__ gtk_pixmap_set( GTK_PIXMAP(m_pixmap), bitmap.GetPixmap(), mask );
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 );
} }
} }
@@ -292,20 +283,11 @@ bool wxToolBar::Create( wxWindow *parent,
return false; 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; GtkOrientation orient;
GtkToolbarStyle gtkStyle; GtkToolbarStyle gtkStyle;
GetGtkStyle(style, &orient, &gtkStyle); GetGtkStyle(style, &orient, &gtkStyle);
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new(orient, gtkStyle) ); m_toolbar = GTK_TOOLBAR( gtk_toolbar_new(orient, gtkStyle) );
#endif
SetToolSeparation(7); SetToolSeparation(7);
@@ -328,11 +310,8 @@ bool wxToolBar::Create( wxWindow *parent,
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); 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) if (style & wxTB_FLAT)
gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE ); gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );
#endif
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
@@ -363,13 +342,9 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
{ {
wxToolBarTool *tool = (wxToolBarTool *)toolBase; wxToolBarTool *tool = (wxToolBarTool *)toolBase;
#ifndef __WXGTK20__
// if we have inserted a space before all the tools we must change the GTK // if we have inserted a space before all the tools we must change the GTK
// index by 1 // index by 1
size_t posGtk = m_xMargin > 1 ? pos + 1 : pos; size_t posGtk = m_xMargin > 1 ? pos + 1 : pos;
#else
size_t posGtk = pos;
#endif
if ( tool->IsButton() ) if ( tool->IsButton() )
{ {
@@ -388,26 +363,14 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
GtkWidget *tool_pixmap = (GtkWidget *)NULL; GtkWidget *tool_pixmap = (GtkWidget *)NULL;
GdkPixmap *pixmap = bitmap.GetPixmap();
#ifdef __WXGTK20__ GdkBitmap *mask = (GdkBitmap *)NULL;
if (bitmap.HasPixbuf()) if ( bitmap.GetMask() )
{ mask = bitmap.GetMask()->GetBitmap();
tool_pixmap = gtk_image_new();
tool->m_pixmap = tool_pixmap;
tool->SetPixmap(bitmap);
}
else
#endif
{
GdkPixmap *pixmap = bitmap.GetPixmap();
GdkBitmap *mask = (GdkBitmap *)NULL; tool_pixmap = gtk_pixmap_new( pixmap, mask );
if ( bitmap.GetMask() ) gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE );
mask = bitmap.GetMask()->GetBitmap();
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 ); 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: case wxTOOL_STYLE_BUTTON:
gtk_widget_destroy( tool->m_item ); gtk_widget_destroy( tool->m_item );
break; break;
#ifdef __WXGTK20__
case wxTOOL_STYLE_SEPARATOR:
gtk_toolbar_remove_space( m_toolbar, pos );
break;
#endif
} }
InvalidateBestSize(); InvalidateBestSize();
@@ -595,10 +552,8 @@ void wxToolBar::SetMargins( int x, int y )
wxCHECK_RET( GetToolsCount() == 0, wxCHECK_RET( GetToolsCount() == 0,
wxT("wxToolBar::SetMargins must be called before adding tools.") ); wxT("wxToolBar::SetMargins must be called before adding tools.") );
#ifndef __WXGTK20__
if (x > 1) if (x > 1)
gtk_toolbar_append_space( m_toolbar ); // oh well gtk_toolbar_append_space( m_toolbar ); // oh well
#endif
m_xMargin = x; m_xMargin = x;
m_yMargin = y; m_yMargin = y;
@@ -606,10 +561,7 @@ void wxToolBar::SetMargins( int x, int y )
void wxToolBar::SetToolSeparation( int separation ) void wxToolBar::SetToolSeparation( int separation )
{ {
// FIXME: this function disappeared
#ifndef __WXGTK20__
gtk_toolbar_set_space_size( m_toolbar, separation ); gtk_toolbar_set_space_size( m_toolbar, separation );
#endif
m_toolSeparation = separation; m_toolSeparation = separation;
} }
@@ -683,15 +635,11 @@ void wxToolBar::OnInternalIdle()
wxVisualAttributes wxVisualAttributes
wxToolBar::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) wxToolBar::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
{ {
#ifdef __WXGTK20__
return GetDefaultAttributesFromGTKWidget(gtk_toolbar_new);
#else
wxVisualAttributes attr; wxVisualAttributes attr;
GtkWidget* widget = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); GtkWidget* widget = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
attr = GetDefaultAttributesFromGTKWidget(widget); attr = GetDefaultAttributesFromGTKWidget(widget);
gtk_widget_destroy(widget); gtk_widget_destroy(widget);
return attr; return attr;
#endif
} }
#endif // wxUSE_TOOLBAR_NATIVE #endif // wxUSE_TOOLBAR_NATIVE

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/tglbtn.cpp // Name: wx/gtk1/tglbtn.cpp
// Purpose: Definition of the wxToggleButton class, which implements a // Purpose: Definition of the wxToggleButton class, which implements a
// toggle button under wxGTK. // toggle button under wxGTK.
// Author: John Norris, minor changes by Axel Schlueter // Author: John Norris, minor changes by Axel Schlueter
@@ -18,7 +18,7 @@
#if wxUSE_TOGGLEBTN #if wxUSE_TOGGLEBTN
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
extern void wxapp_install_idle_handler(); extern void wxapp_install_idle_handler();
extern bool g_isIdle; extern bool g_isIdle;

View File

@@ -17,7 +17,7 @@
#include "wx/tooltip.h" #include "wx/tooltip.h"
#include "wx/window.h" #include "wx/window.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// global data // global data

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/toplevel.cpp // Name: src/gtk1/toplevel.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -30,7 +30,7 @@
#include "wx/control.h" #include "wx/control.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include "wx/timer.h" #include "wx/timer.h"
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/evtloop.h" #include "wx/evtloop.h"
@@ -41,7 +41,7 @@
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
#include "wx/unix/utilsx11.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 ) static gint gtk_frame_urgency_timer_callback( wxTopLevelWindowGTK *win )
{ {
#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,7,0) wxgtk_window_set_urgency_hint(GTK_WINDOW( win->m_widget ), FALSE);
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);
win->m_urgency_hint = -2; win->m_urgency_hint = -2;
return FALSE; return FALSE;
@@ -153,14 +148,7 @@ static gint gtk_frame_focus_in_callback( GtkWidget *widget,
gtk_timeout_remove( win->m_urgency_hint ); gtk_timeout_remove( win->m_urgency_hint );
// no break, fallthrough to remove hint too // no break, fallthrough to remove hint too
case -1: case -1:
#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,7,0) wxgtk_window_set_urgency_hint(GTK_WINDOW( widget ), FALSE);
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);
}
win->m_urgency_hint = -2; win->m_urgency_hint = -2;
break; break;
@@ -400,8 +388,6 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev
// "draw" of m_client // "draw" of m_client
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __WXGTK20__
extern "C" { extern "C" {
static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win ) 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 // wxTopLevelWindowGTK itself
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -517,17 +501,7 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
{ {
if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) 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); m_widget = gtk_window_new(GTK_WINDOW_DIALOG);
#endif
} }
else else
{ {
@@ -562,26 +536,6 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
GTK_WINDOW(topParent->m_widget) ); 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()) if (!name.empty())
gtk_window_set_wmclass( GTK_WINDOW(m_widget), wxGTK_CONV( name ), wxGTK_CONV( name ) ); 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 // For m_mainWidget themes
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
#ifndef __WXGTK20__
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
#endif
} }
// m_wxwindow only represents the client area without toolbar and menubar // m_wxwindow only represents the client area without toolbar and menubar
@@ -841,11 +793,7 @@ bool wxTopLevelWindowGTK::Show( bool show )
void wxTopLevelWindowGTK::Raise() void wxTopLevelWindowGTK::Raise()
{ {
#ifdef __WXGTK20__
gtk_window_present( GTK_WINDOW( m_widget ) );
#else
wxWindow::Raise(); wxWindow::Raise();
#endif
} }
void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) ) 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 ); 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; GdkWindow* window = m_widget->window;
if (!window) if (!window)
return; return;
@@ -1180,7 +1113,6 @@ void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons )
wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ), wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ),
(WXWindow)GDK_WINDOW_XWINDOW( window ), icons ); (WXWindow)GDK_WINDOW_XWINDOW( window ), icons );
#endif // !__WXGTK20__
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -1189,49 +1121,24 @@ void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons )
void wxTopLevelWindowGTK::Maximize(bool maximize) 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") ); wxFAIL_MSG( _T("not implemented") );
#endif
} }
bool wxTopLevelWindowGTK::IsMaximized() const 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") ); // wxFAIL_MSG( _T("not implemented") );
// This is an approximation // This is an approximation
return false; return false;
#endif
} }
void wxTopLevelWindowGTK::Restore() void wxTopLevelWindowGTK::Restore()
{ {
#ifdef __WXGTK20__
// "Present" seems similar enough to "restore"
gtk_window_present( GTK_WINDOW( m_widget ) );
#else
wxFAIL_MSG( _T("not implemented") ); wxFAIL_MSG( _T("not implemented") );
#endif
} }
void wxTopLevelWindowGTK::Iconize( bool iconize ) 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) if (iconize)
{ {
GdkWindow *window = m_widget->window; GdkWindow *window = m_widget->window;
@@ -1243,7 +1150,6 @@ void wxTopLevelWindowGTK::Iconize( bool iconize )
GDK_WINDOW_XWINDOW( window ), GDK_WINDOW_XWINDOW( window ),
DefaultScreen( GDK_DISPLAY() ) ); DefaultScreen( GDK_DISPLAY() ) );
} }
#endif
} }
bool wxTopLevelWindowGTK::IsIconized() const bool wxTopLevelWindowGTK::IsIconized() const
@@ -1292,14 +1198,10 @@ static bool do_shape_combine_region(GdkWindow* window, const wxRegion& region)
} }
else else
{ {
#ifdef __WXGTK20__
gdk_window_shape_combine_region(window, region.GetRegion(), 0, 0);
#else
wxBitmap bmp = region.ConvertToBitmap(); wxBitmap bmp = region.ConvertToBitmap();
bmp.SetMask(new wxMask(bmp, *wxBLACK)); bmp.SetMask(new wxMask(bmp, *wxBLACK));
GdkBitmap* mask = bmp.GetMask()->GetBitmap(); GdkBitmap* mask = bmp.GetMask()->GetBitmap();
gdk_window_shape_combine_mask(window, mask, 0, 0); gdk_window_shape_combine_mask(window, mask, 0, 0);
#endif
return true; return true;
} }
} }
@@ -1354,39 +1256,12 @@ void wxTopLevelWindowGTK::RequestUserAttention(int flags)
} }
} }
#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,7,0) wxgtk_window_set_urgency_hint(GTK_WINDOW( m_widget ), new_hint_value);
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);
} }
void wxTopLevelWindowGTK::SetWindowStyleFlag( long style ) 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 // Process wxWindow styles. This also updates the internal variable
// Therefore m_windowStyle bits carry now the _new_ style values // Therefore m_windowStyle bits carry now the _new_ style values
wxWindow::SetWindowStyleFlag(style); 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
} }

View File

@@ -20,7 +20,7 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#include "wx/gtk/treectrl.h" #include "wx/gtk1/treectrl.h"
#include "wx/textctrl.h" #include "wx/textctrl.h"
#include "wx/log.h" #include "wx/log.h"

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/utilsgtk.cpp // Name: src/gtk1/utilsgtk.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -31,9 +31,7 @@
#include "glib.h" #include "glib.h"
#include "gdk/gdk.h" #include "gdk/gdk.h"
#include "gtk/gtk.h" #include "gtk/gtk.h"
#ifndef __WXGTK20__
#include "gtk/gtkfeatures.h" #include "gtk/gtkfeatures.h"
#endif
#include "gdk/gdkx.h" #include "gdk/gdkx.h"
#ifdef HAVE_X11_XKBLIB_H #ifdef HAVE_X11_XKBLIB_H
@@ -81,43 +79,6 @@ bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
} }
#endif #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("&amp;");
break;
case _T('<'):
out << _T("&lt;");
break;
case _T('>'):
out << _T("&gt;");
break;
case _T('\''):
out << _T("&apos;");
break;
case _T('"'):
out << _T("&quot;");
break;
default:
out << c;
break;
}
}
return out;
}
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// display characterstics // display characterstics
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -168,11 +129,7 @@ int wxDisplayDepth()
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo() wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
{ {
static wxToolkitInfo info; static wxToolkitInfo info;
#ifdef __WXGTK20__
info.shortName = _T("gtk2");
#else
info.shortName = _T("gtk"); info.shortName = _T("gtk");
#endif
info.name = _T("wxGTK"); info.name = _T("wxGTK");
#ifdef __WXUNIVERSAL__ #ifdef __WXUNIVERSAL__
info.shortName << _T("univ"); info.shortName << _T("univ");

View File

@@ -14,7 +14,7 @@
#endif #endif
#include "wx/setup.h" #include "wx/setup.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
#include "gtk/gtksignal.h" #include "gtk/gtksignal.h"
#include "gtk/gtkprivate.h" #include "gtk/gtkprivate.h"
#include "gdk/gdkx.h" #include "gdk/gdkx.h"
@@ -23,8 +23,6 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifndef __WXGTK20__
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
@@ -32,7 +30,6 @@ extern "C" {
#define IS_ONSCREEN(x,y) ((x >= G_MINSHORT) && (x <= G_MAXSHORT) && \ #define IS_ONSCREEN(x,y) ((x >= G_MINSHORT) && (x <= G_MAXSHORT) && \
(y >= G_MINSHORT) && (y <= G_MAXSHORT)) (y >= G_MINSHORT) && (y <= G_MAXSHORT))
#endif
typedef struct _GtkPizzaAdjData GtkPizzaAdjData; typedef struct _GtkPizzaAdjData GtkPizzaAdjData;
@@ -54,10 +51,8 @@ static void gtk_pizza_size_request (GtkWidget *widget,
GtkRequisition *requisition); GtkRequisition *requisition);
static void gtk_pizza_size_allocate (GtkWidget *widget, static void gtk_pizza_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
#ifndef __WXGTK20__
static void gtk_pizza_draw (GtkWidget *widget, static void gtk_pizza_draw (GtkWidget *widget,
GdkRectangle *area); GdkRectangle *area);
#endif /* __WXGTK20__ */
static gint gtk_pizza_expose (GtkWidget *widget, static gint gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event); GdkEventExpose *event);
static void gtk_pizza_style_set (GtkWidget *widget, 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, static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
gpointer cb_data); gpointer cb_data);
#ifndef __WXGTK20__
static void gtk_pizza_position_child (GtkPizza *pizza, static void gtk_pizza_position_child (GtkPizza *pizza,
GtkPizzaChild *child); GtkPizzaChild *child);
static void gtk_pizza_position_children (GtkPizza *pizza); 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, static GdkFilterReturn gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
GdkEvent *event, GdkEvent *event,
gpointer data); gpointer data);
#endif /* __WXGTK20__ */
static GtkType gtk_pizza_child_type (GtkContainer *container); static GtkType gtk_pizza_child_type (GtkContainer *container);
@@ -96,15 +89,9 @@ static void gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
GtkAdjustment *vadj); GtkAdjustment *vadj);
#ifdef __WXGTK20__
GtkContainerClass *pizza_parent_class = NULL;
#else
static GtkContainerClass *pizza_parent_class = NULL; static GtkContainerClass *pizza_parent_class = NULL;
#endif
#ifndef __WXGTK20__
static gboolean gravity_works; static gboolean gravity_works;
#endif
GtkType GtkType
gtk_pizza_get_type () gtk_pizza_get_type ()
@@ -113,22 +100,6 @@ gtk_pizza_get_type ()
if (!pizza_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 = GtkTypeInfo pizza_info =
{ {
"GtkPizza", "GtkPizza",
@@ -141,53 +112,11 @@ gtk_pizza_get_type ()
(GtkClassInitFunc) NULL, (GtkClassInitFunc) NULL,
}; };
pizza_type = gtk_type_unique (gtk_container_get_type (), &pizza_info); pizza_type = gtk_type_unique (gtk_container_get_type (), &pizza_info);
#endif
} }
return pizza_type; 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 static void
gtk_pizza_class_init (GtkPizzaClass *klass) gtk_pizza_class_init (GtkPizzaClass *klass)
{ {
@@ -205,9 +134,7 @@ gtk_pizza_class_init (GtkPizzaClass *klass)
widget_class->unrealize = gtk_pizza_unrealize; widget_class->unrealize = gtk_pizza_unrealize;
widget_class->size_request = gtk_pizza_size_request; widget_class->size_request = gtk_pizza_size_request;
widget_class->size_allocate = gtk_pizza_size_allocate; widget_class->size_allocate = gtk_pizza_size_allocate;
#ifndef __WXGTK20__
widget_class->draw = gtk_pizza_draw; widget_class->draw = gtk_pizza_draw;
#endif
widget_class->expose_event = gtk_pizza_expose; widget_class->expose_event = gtk_pizza_expose;
widget_class->style_set = gtk_pizza_style_set; 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; klass->set_scroll_adjustments = gtk_pizza_scroll_set_adjustments;
widget_class->set_scroll_adjustments_signal = 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_signal_new ("set_scroll_adjustments",
GTK_RUN_LAST, GTK_RUN_LAST,
object_class->type, object_class->type,
GTK_SIGNAL_OFFSET (GtkPizzaClass, set_scroll_adjustments), GTK_SIGNAL_OFFSET (GtkPizzaClass, set_scroll_adjustments),
gtk_marshal_NONE__POINTER_POINTER, gtk_marshal_NONE__POINTER_POINTER,
GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
#endif /* __WXGTK20__ */
} }
static GtkType static GtkType
@@ -372,10 +284,8 @@ gtk_pizza_put (GtkPizza *pizza,
gtk_widget_set_parent (widget, GTK_WIDGET (pizza)); gtk_widget_set_parent (widget, GTK_WIDGET (pizza));
#ifndef __WXGTK20__ /* FIXME? */
if (!IS_ONSCREEN (x, y)) if (!IS_ONSCREEN (x, y))
GTK_PRIVATE_SET_FLAG (widget, GTK_IS_OFFSCREEN); GTK_PRIVATE_SET_FLAG (widget, GTK_IS_OFFSCREEN);
#endif
gtk_widget_set_usize (widget, width, height); gtk_widget_set_usize (widget, width, height);
} }
@@ -541,11 +451,7 @@ gtk_pizza_map (GtkWidget *widget)
if ( GTK_WIDGET_VISIBLE (child->widget) && if ( GTK_WIDGET_VISIBLE (child->widget) &&
!GTK_WIDGET_MAPPED (child->widget) && !GTK_WIDGET_MAPPED (child->widget) &&
#ifdef __WXGTK20__
TRUE)
#else
!GTK_WIDGET_IS_OFFSCREEN (child->widget)) !GTK_WIDGET_IS_OFFSCREEN (child->widget))
#endif
{ {
gtk_widget_map (child->widget); 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 = gtk_widget_get_events (widget);
attributes.event_mask |= GDK_EXPOSURE_MASK | attributes.event_mask |= GDK_EXPOSURE_MASK |
#ifdef __WXGTK20__
GDK_SCROLL_MASK |
#endif
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_MOTION_MASK | GDK_BUTTON_MOTION_MASK |
@@ -650,14 +553,12 @@ gtk_pizza_realize (GtkWidget *widget)
gdk_window_set_back_pixmap( pizza->bin_window, NULL, FALSE ); gdk_window_set_back_pixmap( pizza->bin_window, NULL, FALSE );
*/ */
#ifndef __WXGTK20__
/* add filters for intercepting visibility and expose events */ /* add filters for intercepting visibility and expose events */
gdk_window_add_filter (widget->window, gtk_pizza_main_filter, pizza); gdk_window_add_filter (widget->window, gtk_pizza_main_filter, pizza);
gdk_window_add_filter (pizza->bin_window, gtk_pizza_filter, pizza); gdk_window_add_filter (pizza->bin_window, gtk_pizza_filter, pizza);
/* we NEED gravity or we'll give up */ /* we NEED gravity or we'll give up */
gravity_works = gdk_window_set_static_gravities (pizza->bin_window, TRUE); gravity_works = gdk_window_set_static_gravities (pizza->bin_window, TRUE);
#endif // !__WXGTK20__
/* cannot be done before realisation */ /* cannot be done before realisation */
children = pizza->children; children = pizza->children;
@@ -764,15 +665,11 @@ gtk_pizza_size_allocate (GtkWidget *widget,
child = children->data; child = children->data;
children = children->next; children = children->next;
#ifndef __WXGTK20__
gtk_pizza_position_child (pizza, child); gtk_pizza_position_child (pizza, child);
#endif
gtk_pizza_allocate_child (pizza, child); gtk_pizza_allocate_child (pizza, child);
} }
} }
#ifndef __WXGTK20__
static void static void
gtk_pizza_draw (GtkWidget *widget, gtk_pizza_draw (GtkWidget *widget,
GdkRectangle *area) GdkRectangle *area)
@@ -809,18 +706,14 @@ gtk_pizza_draw (GtkWidget *widget,
} }
} }
#endif /* __WXGTK20__ */
static gint static gint
gtk_pizza_expose (GtkWidget *widget, gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event) GdkEventExpose *event)
{ {
GtkPizza *pizza; GtkPizza *pizza;
#ifndef __WXGTK20__
GtkPizzaChild *child; GtkPizzaChild *child;
GdkEventExpose child_event; GdkEventExpose child_event;
GList *children; GList *children;
#endif
g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PIZZA (widget), FALSE); g_return_val_if_fail (GTK_IS_PIZZA (widget), FALSE);
@@ -835,14 +728,6 @@ gtk_pizza_expose (GtkWidget *widget,
if (pizza->external_expose) if (pizza->external_expose)
return FALSE; return FALSE;
#ifdef __WXGTK20__
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, event);
return FALSE;
#else
children = pizza->children; children = pizza->children;
while (children) while (children)
{ {
@@ -860,8 +745,6 @@ gtk_pizza_expose (GtkWidget *widget,
} }
return TRUE; return TRUE;
#endif
} }
static void static void
@@ -920,9 +803,7 @@ gtk_pizza_remove (GtkContainer *container,
/* security checks */ /* security checks */
g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GTK_IS_WIDGET (widget));
#ifndef __WXGTK20__
GTK_PRIVATE_UNSET_FLAG (widget, GTK_IS_OFFSCREEN); GTK_PRIVATE_UNSET_FLAG (widget, GTK_IS_OFFSCREEN);
#endif
break; break;
} }
@@ -1020,7 +901,6 @@ gtk_pizza_adjust_allocations (GtkPizza *pizza,
} }
} }
#ifndef __WXGTK20__
static void static void
gtk_pizza_position_child (GtkPizza *pizza, gtk_pizza_position_child (GtkPizza *pizza,
GtkPizzaChild *child) GtkPizzaChild *child)
@@ -1081,7 +961,6 @@ gtk_pizza_expose_predicate (Display *display,
else else
return False; return False;
} }
#endif /* __WXGTK20__ */
/* This is the main routine to do the scrolling. Scrolling is /* This is the main routine to do the scrolling. Scrolling is
* done by "Guffaw" scrolling, as in the Mozilla XFE, with * done by "Guffaw" scrolling, as in the Mozilla XFE, with
@@ -1098,15 +977,6 @@ gtk_pizza_expose_predicate (Display *display,
void void
gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy) 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; GtkWidget *widget;
XEvent xevent; XEvent xevent;
XID win; 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 /* The main event filter. Actually, we probably don't really need
* to install this as a filter at all, since we are calling it * to install this as a filter at all, since we are calling it
* directly above in the expose-handling hack. But in case scrollbars * 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; return GDK_FILTER_CONTINUE;
} }
#endif /* __WXGTK20__ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -55,7 +55,7 @@
#include "wx/math.h" #include "wx/math.h"
#include <ctype.h> #include <ctype.h>
#include "wx/gtk/private.h" #include "wx/gtk1/private.h"
#include <gdk/gdkprivate.h> #include <gdk/gdkprivate.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
@@ -63,22 +63,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gtk/gtkprivate.h> #include <gtk/gtkprivate.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk1/win_gtk.h"
#ifdef __WXGTK20__
#include <pango/pangox.h>
#endif
#ifdef __WXGTK20__
#ifdef HAVE_XIM
#undef HAVE_XIM
#endif
#endif
#ifdef __WXGTK20__
extern GtkContainerClass *pizza_parent_class;
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// documentation on internals // 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 // 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) // the last click here (extern: used from gtk/menu.cpp)
#ifndef __WXGTK20__
guint32 wxGtkTimeLastClick = 0; guint32 wxGtkTimeLastClick = 0;
#endif
extern bool g_mainThreadLocked; extern bool g_mainThreadLocked;
@@ -272,23 +255,11 @@ gdk_window_warp_pointer (GdkWindow *window,
gint x, gint x,
gint y) gint y)
{ {
#ifndef __WXGTK20__
GdkWindowPrivate *priv; GdkWindowPrivate *priv;
#endif
if (!window) if (!window)
window = GDK_ROOT_PARENT(); 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; priv = (GdkWindowPrivate*) window;
if (!priv->destroyed) if (!priv->destroyed)
@@ -299,7 +270,6 @@ gdk_window_warp_pointer (GdkWindow *window,
0, 0, 0, 0, /* not source window -> move from anywhere */ 0, 0, 0, 0, /* not source window -> move from anywhere */
x, y ); x, y );
} }
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -433,11 +403,6 @@ static gint gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g
draw_frame( widget, win ); draw_frame( widget, win );
#ifdef __WXGTK20__
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event);
#endif
return TRUE; return TRUE;
} }
} }
@@ -446,8 +411,6 @@ static gint gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g
// "draw" of m_widget // "draw" of m_widget
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __WXGTK20__
extern "C" { extern "C" {
static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindowGTK *win ) 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 // "size_request" of m_widget
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -522,47 +483,6 @@ static int gtk_window_expose_callback( GtkWidget *widget,
if (g_isIdle) if (g_isIdle)
wxapp_install_idle_handler(); 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 // This gets called immediately after an expose event
// under GTK 1.2 so we collect the calls and wait for // under GTK 1.2 so we collect the calls and wait for
// the idle handler to pick things up. // 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. // Actual redrawing takes place in idle time.
// win->GtkUpdate(); // win->GtkUpdate();
#endif
return FALSE; return FALSE;
} }
@@ -588,8 +507,6 @@ static int gtk_window_expose_callback( GtkWidget *widget,
// "event" of m_wxwindow // "event" of m_wxwindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __WXGTK20__
// GTK thinks it is clever and filters out a certain amount of "unneeded" // 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 // 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. // 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 // "draw" of m_wxwindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __WXGTK20__
// This callback is a complete replacement of the gtk_pizza_draw() function, // This callback is a complete replacement of the gtk_pizza_draw() function,
// which is disabled. // which is disabled.
@@ -701,8 +614,6 @@ static void gtk_window_draw_callback( GtkWidget *widget,
} }
} }
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "key_press_event" from any window // "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" { extern "C" {
static gint gtk_window_key_press_callback( GtkWidget *widget, static gint gtk_window_key_press_callback( GtkWidget *widget,
GdkEventKey *gdk_event, GdkEventKey *gdk_event,
@@ -1170,39 +1063,12 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
return_after_IM = true; 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) if (return_after_IM)
return false; return false;
// Emit KEY_DOWN event // Emit KEY_DOWN event
ret = win->GetEventHandler()->ProcessEvent( 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 // This is for GTK+ 1.2 only. The char event generatation for GTK+ 2.0 is done
// in the "commit" handler. // in the "commit" handler.
@@ -1261,8 +1127,6 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
return true; return true;
} }
#endif // #ifndef __WXGTK20__
#if wxUSE_ACCEL #if wxUSE_ACCEL
if (!ret) 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 // "key_release_event" from any window
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -1696,21 +1501,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
wxEventType event_type = wxEVT_NULL; 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) if (gdk_event->button == 1)
{ {
// note that GDK generates triple click events which are not supported // 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 ) if ( !g_captureWindow )
win = FindWindowForMouseEvent(win, event.m_x, event.m_y); win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
#ifndef __WXGTK20__
wxGtkTimeLastClick = gdk_event->time; wxGtkTimeLastClick = gdk_event->time;
if (event_type == wxEVT_LEFT_DCLICK) if (event_type == wxEVT_LEFT_DCLICK)
@@ -1813,7 +1602,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
return FALSE; return FALSE;
} }
} }
#endif // !__WXGTK20__
if (win->GetEventHandler()->ProcessEvent( event )) 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" // "focus_in_event"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -2083,11 +1797,6 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
if (g_isIdle) if (g_isIdle)
wxapp_install_idle_handler(); wxapp_install_idle_handler();
#ifdef __WXGTK20__
if (win->m_imData)
gtk_im_context_focus_in(win->m_imData->context);
#endif
g_focusWindowLast = g_focusWindowLast =
g_focusWindow = win; g_focusWindow = win;
@@ -2137,11 +1846,6 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEventFocus *gdk
if (g_isIdle) if (g_isIdle)
wxapp_install_idle_handler(); wxapp_install_idle_handler();
#ifdef __WXGTK20__
if (win->m_imData)
gtk_im_context_focus_out(win->m_imData->context);
#endif
wxLogTrace( TRACE_FOCUS, wxLogTrace( TRACE_FOCUS,
_T("%s: focus out"), win->GetName().c_str() ); _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; win->m_oldVerticalPos = adjust->value;
#ifndef __WXGTK20__
GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(win->m_widget); GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(win->m_widget);
#endif
wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->vscrollbar)); wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->vscrollbar));
int value = (int)(adjust->value+0.5); 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; float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return; if (fabs(diff) < 0.2) return;
#ifndef __WXGTK20__
GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(win->m_widget); GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(win->m_widget);
#endif
wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->hscrollbar)); wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->hscrollbar));
win->m_oldHorizontalPos = adjust->value; win->m_oldHorizontalPos = adjust->value;
@@ -2372,9 +2072,7 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget,
g_blockEventsOnScroll = true; g_blockEventsOnScroll = true;
// FIXME: there is no 'slider' field in GTK+ 2.0 any more // FIXME: there is no 'slider' field in GTK+ 2.0 any more
#ifndef __WXGTK20__
win->m_isScrolling = (gdk_event->window == widget->slider); win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
return FALSE; return FALSE;
} }
@@ -2454,15 +2152,6 @@ gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win )
if (g_isIdle) if (g_isIdle)
wxapp_install_idle_handler(); 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 ); wxWindowCreateEvent event( win );
event.SetEventObject( win ); event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );
@@ -2751,15 +2440,10 @@ void wxWindowGTK::Init()
m_cursor = *wxSTANDARD_CURSOR; m_cursor = *wxSTANDARD_CURSOR;
#ifdef __WXGTK20__
m_imData = NULL;
m_dirtyTabOrder = false;
#else
#ifdef HAVE_XIM #ifdef HAVE_XIM
m_ic = (GdkIC*) NULL; m_ic = (GdkIC*) NULL;
m_icattr = (GdkICAttr*) NULL; m_icattr = (GdkICAttr*) NULL;
#endif #endif
#endif
} }
wxWindowGTK::wxWindowGTK() wxWindowGTK::wxWindowGTK()
@@ -2925,11 +2609,6 @@ wxWindowGTK::~wxWindowGTK()
gdk_ic_attr_destroy (m_icattr); gdk_ic_attr_destroy (m_icattr);
#endif #endif
#ifdef __WXGTK20__
// delete before the widgets to avoid a crash on solaris
delete m_imData;
#endif
if (m_wxwindow) if (m_wxwindow)
{ {
gtk_widget_destroy( 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_connect( GTK_OBJECT(m_wxwindow), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
#ifndef __WXGTK20__
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); 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_connect( GTK_OBJECT(m_wxwindow), "event",
GTK_SIGNAL_FUNC(gtk_window_event_event_callback), (gpointer)this ); 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 // these are called when the "sunken" or "raised" borders are drawn
gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event", gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );
#ifndef __WXGTK20__
gtk_signal_connect( GTK_OBJECT(m_widget), "draw", gtk_signal_connect( GTK_OBJECT(m_widget), "draw",
GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this );
#endif
} }
// focus handling // focus handling
@@ -3094,13 +2756,6 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget )
gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event", gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event",
GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); 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_connect( GTK_OBJECT(widget), "enter_notify_event",
GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); 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 */ /* the default button has a border around it */
if (GTK_WIDGET_CAN_DEFAULT(m_widget)) 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; left_border = 6;
right_border = 6; right_border = 6;
top_border = 6; top_border = 6;
bottom_border = 5; bottom_border = 5;
#endif
} }
DoMoveWindow( m_x-top_border, 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() void wxWindowGTK::OnInternalIdle()
{ {
#ifdef __WXGTK20__
if ( m_dirtyTabOrder )
RealizeTabOrder();
#endif
// Update style if the window was not yet realized // Update style if the window was not yet realized
// and SetBackgroundStyle(wxBG_STYLE_CUSTOM) was called // and SetBackgroundStyle(wxBG_STYLE_CUSTOM) was called
if (m_needsStyleChange) if (m_needsStyleChange)
@@ -3590,31 +3228,9 @@ int wxWindowGTK::GetCharHeight() const
wxFont font = GetFont(); wxFont font = GetFont();
wxCHECK_MSG( font.Ok(), 12, wxT("invalid font") ); 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 ); GdkFont *gfont = font.GetInternalFont( 1.0 );
return gfont->ascent + gfont->descent; return gfont->ascent + gfont->descent;
#endif
} }
int wxWindowGTK::GetCharWidth() const int wxWindowGTK::GetCharWidth() const
@@ -3624,31 +3240,9 @@ int wxWindowGTK::GetCharWidth() const
wxFont font = GetFont(); wxFont font = GetFont();
wxCHECK_MSG( font.Ok(), 8, wxT("invalid font") ); 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 ); GdkFont *gfont = font.GetInternalFont( 1.0 );
return gdk_string_width( gfont, "g" ); return gdk_string_width( gfont, "g" );
#endif
} }
void wxWindowGTK::GetTextExtent( const wxString& string, void wxWindowGTK::GetTextExtent( const wxString& string,
@@ -3669,54 +3263,11 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
return; 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 ); GdkFont *font = fontToUse.GetInternalFont( 1.0 );
if (x) (*x) = gdk_string_width( font, wxGTK_CONV( string ) ); if (x) (*x) = gdk_string_width( font, wxGTK_CONV( string ) );
if (y) (*y) = font->ascent + font->descent; if (y) (*y) = font->ascent + font->descent;
if (descent) (*descent) = font->descent; if (descent) (*descent) = font->descent;
if (externalLeading) (*externalLeading) = 0; // ?? if (externalLeading) (*externalLeading) = 0; // ??
#endif
} }
void wxWindowGTK::SetFocus() void wxWindowGTK::SetFocus()
@@ -3737,13 +3288,6 @@ void wxWindowGTK::SetFocus()
} }
else if (m_widget) 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) ) if (GTK_WIDGET_CAN_FOCUS(m_widget) && !GTK_WIDGET_HAS_FOCUS (m_widget) )
{ {
@@ -3768,13 +3312,11 @@ void wxWindowGTK::SetFocus()
} }
} }
else else
#ifndef __WXGTK20__
if (GTK_IS_CONTAINER(m_widget)) if (GTK_IS_CONTAINER(m_widget))
{ {
gtk_container_focus( GTK_CONTAINER(m_widget), GTK_DIR_TAB_FORWARD ); gtk_container_focus( GTK_CONTAINER(m_widget), GTK_DIR_TAB_FORWARD );
} }
else else
#endif
{ {
wxLogTrace(TRACE_FOCUS, wxLogTrace(TRACE_FOCUS,
_T("Can't set focus to %s(%s)"), _T("Can't set focus to %s(%s)"),
@@ -3839,62 +3381,6 @@ void wxWindowGTK::DoAddChild(wxWindowGTK *child)
(*m_insertCallback)(this, 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() void wxWindowGTK::Raise()
{ {
wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
@@ -3964,7 +3450,6 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
if (!m_widget->window) if (!m_widget->window)
return; return;
#ifndef __WXGTK20__
if (g_isIdle) if (g_isIdle)
wxapp_install_idle_handler(); wxapp_install_idle_handler();
@@ -4024,27 +3509,6 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
gtk_widget_draw( m_widget, (GdkRectangle*) NULL ); 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() void wxWindowGTK::Update()
@@ -4060,13 +3524,8 @@ void wxWindowGTK::Update()
void wxWindowGTK::GtkUpdate() 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()) if (!m_updateRegion.IsEmpty())
GtkSendPaintEvents(); GtkSendPaintEvents();
#endif
// for consistency with other platforms (and also because it's convenient // 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 // to be able to update an entire TLW by calling Update() only once), we
@@ -4083,9 +3542,7 @@ void wxWindowGTK::GtkSendPaintEvents()
{ {
if (!m_wxwindow) if (!m_wxwindow)
{ {
#ifndef __WXGTK20__
m_clearRegion.Clear(); m_clearRegion.Clear();
#endif
m_updateRegion.Clear(); m_updateRegion.Clear();
return; return;
} }
@@ -4129,17 +3586,6 @@ void wxWindowGTK::GtkSendPaintEvents()
} }
else 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 // if (!m_clearRegion.IsEmpty()) // Always send an erase event under GTK 1.2
{ {
wxWindowDC dc( (wxWindow*)this ); wxWindowDC dc( (wxWindow*)this );
@@ -4170,7 +3616,6 @@ void wxWindowGTK::GtkSendPaintEvents()
} }
m_clearRegion.Clear(); m_clearRegion.Clear();
} }
#endif
wxNcPaintEvent nc_paint_event( GetId() ); wxNcPaintEvent nc_paint_event( GetId() );
nc_paint_event.SetEventObject( this ); nc_paint_event.SetEventObject( this );
@@ -4182,7 +3627,7 @@ void wxWindowGTK::GtkSendPaintEvents()
m_clipPaintRegion = false; m_clipPaintRegion = false;
#if !defined(__WXUNIVERSAL__) && !defined(__WXGTK20__) #if !defined(__WXUNIVERSAL__)
// The following code will result in all window-less widgets // The following code will result in all window-less widgets
// being redrawn because the wxWidgets class is allowed to // being redrawn because the wxWidgets class is allowed to
// paint over the window-less widgets. // paint over the window-less widgets.
@@ -4232,7 +3677,6 @@ void wxWindowGTK::ClearBackground()
{ {
wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
#ifndef __WXGTK20__
if (m_wxwindow && m_wxwindow->window) if (m_wxwindow && m_wxwindow->window)
{ {
m_clearRegion.Clear(); m_clearRegion.Clear();
@@ -4242,7 +3686,6 @@ void wxWindowGTK::ClearBackground()
// Better do this in idle? // Better do this in idle?
GtkUpdate(); GtkUpdate();
} }
#endif
} }
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
@@ -4304,13 +3747,6 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour )
return true; return true;
} }
#ifdef __WXGTK20__
PangoContext *wxWindowGTK::GtkGetPangoDefaultContext()
{
return gtk_widget_get_pango_context( m_widget );
}
#endif
GtkRcStyle *wxWindowGTK::CreateWidgetStyle(bool forceStyle) GtkRcStyle *wxWindowGTK::CreateWidgetStyle(bool forceStyle)
{ {
// do we need to apply any changes at all? // do we need to apply any changes at all?
@@ -4325,13 +3761,8 @@ GtkRcStyle *wxWindowGTK::CreateWidgetStyle(bool forceStyle)
if ( m_font.Ok() ) if ( m_font.Ok() )
{ {
#ifdef __WXGTK20__
style->font_desc =
pango_font_description_copy( m_font.GetNativeFontInfo()->description );
#else
wxString xfontname = m_font.GetNativeFontInfo()->GetXFontName(); wxString xfontname = m_font.GetNativeFontInfo()->GetXFontName();
style->fontset_name = g_strdup(xfontname.c_str()); style->fontset_name = g_strdup(xfontname.c_str());
#endif
} }
if ( m_foregroundColour.Ok() ) if ( m_foregroundColour.Ok() )
@@ -4687,7 +4118,6 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
// No scrolling requested. // No scrolling requested.
if ((dx == 0) && (dy == 0)) return; if ((dx == 0) && (dy == 0)) return;
#ifndef __WXGTK20__
if (!m_updateRegion.IsEmpty()) if (!m_updateRegion.IsEmpty())
{ {
m_updateRegion.Offset( dx, dy ); m_updateRegion.Offset( dx, dy );
@@ -4707,7 +4137,6 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
GetClientSize( &cw, &ch ); GetClientSize( &cw, &ch );
m_clearRegion.Intersect( 0, 0, cw, ch ); m_clearRegion.Intersect( 0, 0, cw, ch );
} }
#endif
m_clipPaintRegion = true; m_clipPaintRegion = true;