// wxWakeUpIdle
//-----------------------------------------------------------------------------
-// RR/KH: The wxMutexGui calls are not needed on GTK2 according to
-// the GTK faq, http://www.gtk.org/faq/#AEN500
-// The calls to gdk_threads_enter() and leave() are specifically noted
-// as not being necessary. The MutexGui calls are still left in for GTK1.
-// Eliminating the MutexGui calls fixes the long-standing "random" lockup
-// when using wxPostEvent (which calls WakeUpIdle) from a thread.
+// RR/KH: No wxMutexGui calls are needed here according to the GTK faq,
+// http://www.gtk.org/faq/#AEN500 - this caused problems for wxPostEvent.
void wxApp::WakeUpIdle()
{
-#ifndef __WXGTK20__
-#if wxUSE_THREADS
- if (!wxThread::IsMain())
- wxMutexGuiEnter();
-#endif // wxUSE_THREADS_
-#endif // __WXGTK2__
-
wxapp_install_idle_handler();
-
-#ifndef __WXGTK20__
-#if wxUSE_THREADS
- if (!wxThread::IsMain())
- wxMutexGuiLeave();
-#endif // wxUSE_THREADS_
-#endif // __WXGTK2__
}
//-----------------------------------------------------------------------------
if (wxTopLevelWindows.GetCount() > 0)
{
wxWindow* win = (wxWindow*) wxTopLevelWindows.GetLast()->GetData();
-#ifdef __WXGTK20__
if (win->IsKindOf(CLASSINFO(wxMessageDialog)))
-#else
- if (win->IsKindOf(CLASSINFO(wxGenericMessageDialog)))
-#endif
win->OnInternalIdle();
}
return TRUE;
// chosen a specific visual, then derive the GdkVisual from that
if (m_glVisualInfo != NULL)
{
-#ifdef __WXGTK20__
// seems gtk_widget_set_default_visual no longer exists?
GdkVisual* vis = gtk_widget_get_default_visual();
-#else
- GdkVisual* vis = gdkx_visual_get(
- ((XVisualInfo *) m_glVisualInfo) ->visualid );
- gtk_widget_set_default_visual( vis );
-#endif
GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
gtk_widget_set_default_colormap( colormap );
else
if ((gdk_visual_get_best() != gdk_visual_get_system()) && (m_useBestVisual))
{
-#ifdef __WXGTK20__
/* seems gtk_widget_set_default_visual no longer exists? */
GdkVisual* vis = gtk_widget_get_default_visual();
-#else
- GdkVisual* vis = gdk_visual_get_best();
- gtk_widget_set_default_visual( vis );
-#endif
GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
gtk_widget_set_default_colormap( colormap );
bool wxApp::Initialize(int& argc, wxChar **argv)
{
bool init_result;
-
+
#if wxUSE_THREADS
// GTK 1.2 up to version 1.2.3 has broken threads
if ((gtk_major_version == 1) &&
// We should have the wxUSE_WCHAR_T test on the _outside_
#if wxUSE_WCHAR_T
- #if defined(__WXGTK20__)
- // gtk+ 2.0 supports Unicode through UTF-8 strings
- wxConvCurrent = &wxConvUTF8;
- #else // GTK 1.x
- if (!wxOKlibc())
- wxConvCurrent = &wxConvLocal;
- #endif
+ // gtk+ 2.0 supports Unicode through UTF-8 strings
+ wxConvCurrent = &wxConvUTF8;
#else // !wxUSE_WCHAR_T
if (!wxOKlibc())
wxConvCurrent = (wxMBConv*) NULL;
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
-#ifdef __WXGTK20__
// decide which conversion to use for the file names
// (1) this variable exists for the sole purpose of specifying the encoding
if (encName == _T("@locale"))
encName.clear();
encName.MakeUpper();
-#if wxUSE_INTL
+#if wxUSE_INTL
if (encName.empty())
{
// (2) if a non default locale is set, assume that the user wants his
#endif // wxUSE_INTL
static wxConvBrokenFileNames fileconv(encName);
wxConvFileName = &fileconv;
-#endif // __WXGTK20__
#if wxUSE_UNICODE
// gtk_init() wants UTF-8, not wchar_t, so convert
argvGTK[argc] = NULL;
int argcGTK = argc;
-
+
#ifdef __WXGPE__
init_result = true; // is there a _check() version of this?
gpe_application_init( &argcGTK, &argvGTK );
wxLogError(wxT("Unable to initialize gtk, is DISPLAY set properly?"));
return false;
}
-
+
// we can not enter threads before gtk_init is done
gdk_threads_enter();
#include "wx/dcmemory.h"
#include "wx/app.h"
-#ifdef __WXGTK20__
#include "wx/rawbmp.h"
// need this to get gdk_image_new_bitmap()
#define GDK_ENABLE_BROKEN
-#endif
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
-#ifdef __WXGTK20__
- #include <gdk/gdkimage.h>
-#else // GTK+ 1.2
- #include <gdk/gdkrgb.h>
-#endif // GTK+ 2.0/1.2
+#include <gdk/gdkimage.h>
#include "wx/math.h"
GdkPixmap *m_pixmap;
GdkBitmap *m_bitmap;
-#ifdef __WXGTK20__
GdkPixbuf *m_pixbuf;
-#endif
wxMask *m_mask;
int m_width;
int m_height;
{
m_pixmap = (GdkPixmap *) NULL;
m_bitmap = (GdkBitmap *) NULL;
-#ifdef __WXGTK20__
m_pixbuf = (GdkPixbuf *) NULL;
-#endif
m_mask = (wxMask *) NULL;
m_width = 0;
m_height = 0;
gdk_pixmap_unref( m_pixmap );
if (m_bitmap)
gdk_bitmap_unref( m_bitmap );
-#ifdef __WXGTK20__
if (m_pixbuf)
gdk_pixbuf_unref( m_pixbuf );
-#endif
delete m_mask;
#if wxUSE_PALETTE
delete m_palette;
M_BMPDATA->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
M_BMPDATA->m_bpp = 1;
}
-#ifdef __WXGTK20__
else if (depth == 32)
{
M_BMPDATA->m_pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, true,
8, width, height);
M_BMPDATA->m_bpp = 32;
}
-#endif
else
{
M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth );
wxBitmap bmp;
-#ifdef __WXGTK20__
if (HasPixbuf())
{
bmp.SetWidth(width);
GDK_INTERP_BILINEAR);
}
else
-#endif // __WXGTK20__
{
GdkImage *img = (GdkImage*) NULL;
if (GetPixmap())
}
else
{
-#ifdef __WXGTK20__
if (image.HasAlpha())
return CreateFromImageAsPixbuf(image);
-#endif
+
return CreateFromImageAsPixmap(image);
}
}
return true;
}
-#ifdef __WXGTK20__
bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image)
{
int width = image.GetWidth();
return true;
}
-#endif // __WXGTK20__
wxImage wxBitmap::ConvertToImage() const
{
return wxNullImage;
}
-#ifdef __WXGTK20__
if (HasPixbuf())
{
GdkPixbuf *pixbuf = GetPixbuf();
}
}
else
-#endif // __WXGTK20__
{
// the colour used as transparent one in wxImage and the one it is
// replaced with when it really occurs in the bitmap
{
return (m_refData != NULL) &&
(
-#ifdef __WXGTK20__
M_BMPDATA->m_pixbuf ||
-#endif
M_BMPDATA->m_bitmap || M_BMPDATA->m_pixmap
);
}
wxBitmap ret( rect.width, rect.height, M_BMPDATA->m_bpp );
wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") );
-#ifdef __WXGTK20__
if (HasPixbuf())
{
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
pixbuf, 0, 0);
}
else
-#endif // __WXGTK20__
{
if (ret.GetPixmap())
{
m_refData = new wxBitmapRefData();
M_BMPDATA->m_pixmap = pixmap;
-#ifdef __WXGTK20__
PurgeOtherRepresentations(Pixmap);
-#endif
}
void wxBitmap::SetBitmap( GdkPixmap *bitmap )
m_refData = new wxBitmapRefData();
M_BMPDATA->m_bitmap = bitmap;
-#ifdef __WXGTK20__
PurgeOtherRepresentations(Pixmap);
-#endif
}
GdkPixmap *wxBitmap::GetPixmap() const
{
wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, wxT("invalid bitmap") );
-#ifdef __WXGTK20__
// create the pixmap on the fly if we use Pixbuf representation:
if (HasPixbuf() && !HasPixmap())
{
&M_BMPDATA->m_mask->m_bitmap,
128 /*threshold*/);
}
-#endif // __WXGTK20__
return M_BMPDATA->m_pixmap;
}
return M_BMPDATA->m_bitmap;
}
-#ifdef __WXGTK20__
GdkPixbuf *wxBitmap::GetPixbuf() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
}
}
-#endif // __WXGTK20__
-
void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
{
-#ifdef __WXGTK20__
if (bpp != 32)
return NULL;
data.m_stride = gdk_pixbuf_get_rowstride( pixbuf );
return gdk_pixbuf_get_pixels( pixbuf );
-#else
- return NULL;
-#endif
}
void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data))
bool wxBitmap::HasAlpha() const
{
-#ifdef __WXGTK20__
return HasPixbuf();
-#else
- return false;
-#endif
}
void wxBitmap::UseAlpha()
{
-#ifdef __WXGTK20__
GetPixbuf();
-#endif
}
//-----------------------------------------------------------------------------
{
// initial bitmap
GtkWidget *pixmap;
-#ifdef __WXGTK20__
+
if (the_one.HasPixbuf())
pixmap = gtk_image_new_from_pixbuf(the_one.GetPixbuf());
else
pixmap = gtk_image_new_from_pixmap(the_one.GetPixmap(), mask);
-#else
- pixmap = gtk_pixmap_new(the_one.GetPixmap(), mask);
-#endif
+
gtk_widget_show(pixmap);
gtk_container_add(GTK_CONTAINER(m_widget), pixmap);
}
else
{ // subsequent bitmaps
-#ifdef __WXGTK20__
GtkImage *pixmap = GTK_IMAGE(child);
if (the_one.HasPixbuf())
gtk_image_set_from_pixbuf(pixmap, the_one.GetPixbuf());
else
gtk_image_set_from_pixmap(pixmap, the_one.GetPixmap(), mask);
-#else
- GtkPixmap *pixmap = GTK_PIXMAP(child);
- gtk_pixmap_set(pixmap, the_one.GetPixmap(), mask);
-#endif
}
}
/* the default button has a border around it */
if (GTK_WIDGET_CAN_DEFAULT(m_widget))
{
-#ifdef __WXGTK20__
GtkBorder *default_border = NULL;
gtk_widget_style_get( m_widget, "default_border", &default_border, NULL );
if (default_border)
bottom_border += default_border->bottom;
g_free( default_border );
}
-#else
- left_border = 6;
- right_border = 6;
- top_border = 6;
- bottom_border = 5;
-#endif
win->DoMoveWindow( win->m_x-top_border,
win->m_y-left_border,
win->m_width+left_border+right_border,
return FALSE;
}
-#ifdef __WXGTK20__
m_widget = gtk_button_new_with_mnemonic("");
-#else
- m_widget = gtk_button_new_with_label("");
-#endif
float x_alignment = 0.5;
if (HasFlag(wxBU_LEFT))
/* static */
wxSize wxButtonBase::GetDefaultSize()
{
-#ifdef __WXGTK20__
static wxSize size = wxDefaultSize;
if (size == wxDefaultSize)
{
gtk_widget_destroy(wnd);
}
return size;
-#else
- return wxSize(80,26);
-#endif
}
void wxButton::SetLabel( const wxString &lbl )
const wxString labelGTK = GTKConvertMnemonics(label);
-#ifdef __WXGTK20__
if (wxIsStockID(m_windowId) && wxIsStockLabel(m_windowId, label))
{
const char *stock = wxGetStockGtkID(m_windowId);
gtk_button_set_use_stock(GTK_BUTTON(m_widget), FALSE);
ApplyWidgetStyle( false );
-#else // GTK+ 1
- gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), wxGTK_CONV(labelGTK));
-#endif // GTK+ 2/1
}
bool wxButton::Enable( bool enable )
bool wxButton::IsOwnGtkWindow( GdkWindow *window )
{
-#ifdef __WXGTK20__
return GTK_BUTTON(m_widget)->event_window;
-#else
- return (window == m_widget->window);
-#endif
}
void wxButton::DoApplyWidgetStyle(GtkRcStyle *style)
GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT );
}
-#ifndef __WXGTK20__
- ret.x += 10; // add a few pixels for sloppy (but common) themes
-#endif
-
if (!HasFlag(wxBU_EXACTFIT))
{
wxSize defaultSize = GetDefaultSize();
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:
gtk_toggle_button_set_inconsistent(toggle, false);
}
}
-#endif
wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId());
-#ifdef __WXGTK20__
event.SetInt(cb->Get3StateValue());
-#else
- event.SetInt(cb->GetValue());
-#endif
event.SetEventObject(cb);
cb->GetEventHandler()->ProcessEvent(event);
}
{
wxCHECK_MSG( m_widgetCheckbox != NULL, FALSE, wxT("invalid checkbox") );
-#ifdef __WXGTK20__
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_widgetCheckbox));
-#else
- return GTK_TOGGLE_BUTTON(m_widgetCheckbox)->active;
-#endif
}
-#ifdef __WXGTK20__
void wxCheckBox::DoSet3StateValue(wxCheckBoxState state)
{
SetValue(state != wxCHK_UNCHECKED);
return GetValue() ? wxCHK_CHECKED : wxCHK_UNCHECKED;
}
}
-#endif
void wxCheckBox::SetLabel( const wxString& label )
{
int selection = wxNOT_FOUND;
-#ifdef __WXGTK20__
selection = gtk_option_menu_get_history( GTK_OPTION_MENU(choice->GetHandle()) );
-#else
- GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(choice->GetHandle()) ) );
- int count = 0;
- GList *child = menu_shell->children;
- while (child)
- {
- GtkBin *bin = GTK_BIN( child->data );
- if (!bin->child)
- {
- selection = count;
- break;
- }
- child = child->next;
- count++;
- }
-#endif
choice->m_selection_hack = selection;
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() );
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
-#ifdef __WXGTK20__
wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text( label) ) );
-#else
- wxString tmp( label->label );
-#endif
if (string.IsSameAs( tmp, bCase ))
return count;
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
-#ifdef __WXGTK20__
return wxString( wxGTK_CONV_BACK( gtk_label_get_text( label) ) );
-#else
- return wxString( label->label );
-#endif
}
child = child->next;
count++;
bool wxChoice::IsOwnGtkWindow( GdkWindow *window )
{
-#ifdef __WXGTK20__
return GTK_BUTTON(m_widget)->event_window;
-#else
- return (window == m_widget->window);
-#endif
}
// static
// Text data will be in UTF8 in Unicode mode.
data->GetDataHere( selection_data->target, d );
-#ifdef __WXGTK20__
// NB: GTK+ requires special treatment of UTF8_STRING data, the text
// would show as UTF-8 data interpreted as latin1 (?) in other
// GTK+ apps if we used gtk_selection_data_set()
size-1 );
}
else
-#endif
{
gtk_selection_data_set(
selection_data,
{
if (m_colormap)
{
-#ifdef __WXGTK20__
if ((m_colormap->visual->type == GDK_VISUAL_GRAYSCALE) ||
(m_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR))
-#else
- GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) m_colormap;
- if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) ||
- (private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR))
-#endif
{
int idx = m_color.pixel;
colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] - 1;
FreeColour();
-#ifdef __WXGTK20__
if ( (cmap->visual->type == GDK_VISUAL_GRAYSCALE) ||
(cmap->visual->type == GDK_VISUAL_PSEUDO_COLOR) )
-#else
- GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) cmap;
- if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) ||
- (private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR))
-#endif
{
m_hasPixel = gdk_colormap_alloc_color( cmap, &m_color, FALSE, TRUE );
int idx = m_color.pixel;
// and case-sensitive
gtk_combo_set_case_sensitive( GTK_COMBO(m_widget), TRUE );
-#ifdef __WXGTK20__
if (style & wxNO_BORDER)
g_object_set( GTK_ENTRY( combo->entry ), "has-frame", FALSE, NULL );
-#endif
GtkWidget *list = GTK_COMBO(m_widget)->list;
-#ifndef __WXGTK20__
- // gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE );
-#endif
-
for (int i = 0; i < n; i++)
{
GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( choices[i] ) );
{
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
-#ifdef __WXGTK20__
wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
-#else
- wxString str( label->label );
-#endif
+
if (item.IsSameAs( str , bCase ) )
return count;
{
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
-#ifdef __WXGTK20__
str = wxGTK_CONV_BACK( gtk_label_get_text(label) );
-#else
- str = wxString( label->label );
-#endif
}
else
{
{
GtkBin *bin = GTK_BIN( selection->data );
GtkLabel *label = GTK_LABEL( bin->child );
-#ifdef __WXGTK20__
wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
-#else
- wxString tmp( label->label );
-#endif
return tmp;
}
if (IsEditable())
{
GtkEditable *editable = GTK_EDITABLE(GTK_COMBO(m_widget)->entry);
-#ifdef __WXGTK20__
gint start, end;
gtk_editable_get_selection_bounds(editable, & start, & end);
*from = start;
*to = end;
-#else
- *from = (long) editable->selection_start_pos;
- *to = (long) editable->selection_end_pos;
-#endif
}
}
const wxString labelGTK = GTKConvertMnemonics(label);
-#ifdef __WXGTK20__
gtk_label_set_text_with_mnemonic(w, wxGTK_CONV(labelGTK));
-#else
- gtk_label_set(w, wxGTK_CONV(labelGTK));
-#endif
}
void wxControl::GTKSetLabelForFrame(GtkFrame *w, const wxString& label)
/* static */
wxString wxControl::GTKConvertMnemonics(const wxString& label)
{
-#ifdef __WXGTK20__
return GTKProcessMnemonics(label, MNEMONICS_CONVERT);
-#else
- return GTKRemoveMnemonics(label);
-#endif
}
// ----------------------------------------------------------------------------
style->bg[state].blue >> SHIFT);
// get the style's font
-#ifdef __WXGTK20__
if ( !style->font_desc )
style = gtk_widget_get_default_style();
if ( style && style->font_desc )
attr.font = wxFont(wxString::FromAscii(font_name));
g_free (font_name);
}
-#else
- // TODO: isn't there a way to get a standard gtk 1.2 font?
- attr.font = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
-#endif
return attr;
}
wxCHECK_RET( src, _T("NULL src in gdk_wx_draw_bitmap") );
wxCHECK_RET( gc, _T("NULL gc in gdk_wx_draw_bitmap") );
-#ifdef __WXGTK20__
gint src_width, src_height;
gdk_drawable_get_size(src, &src_width, &src_height);
if (width == -1) width = src_width;
width, height,
0, 0,
1 );
-#else
- GdkWindowPrivate *drawable_private;
- GdkWindowPrivate *src_private;
- GdkGCPrivate *gc_private;
-
- drawable_private = (GdkWindowPrivate*) drawable;
- src_private = (GdkWindowPrivate*) src;
- if (drawable_private->destroyed || src_private->destroyed)
- return;
-
- gint src_width = src_private->width;
- gint src_height = src_private->height;
-
- gc_private = (GdkGCPrivate*) gc;
-
- if (width == -1) width = src_width;
- if (height == -1) height = src_height;
-
- XCopyPlane( drawable_private->xdisplay,
- src_private->xwindow,
- drawable_private->xwindow,
- gc_private->xgc,
- xsrc, ysrc,
- width, height,
- xdest, ydest,
- 1 );
-#endif
}
//-----------------------------------------------------------------------------
m_isMemDC = false;
m_isScreenDC = false;
m_owner = (wxWindow *)NULL;
-#ifdef __WXGTK20__
m_context = (PangoContext *)NULL;
m_layout = (PangoLayout *)NULL;
m_fontdesc = (PangoFontDescription *)NULL;
-#endif
}
wxWindowDC::wxWindowDC( wxWindow *window )
wxASSERT_MSG( widget, wxT("DC needs a widget") );
-#ifdef __WXGTK20__
m_context = window->GtkGetPangoDefaultContext();
m_layout = pango_layout_new( m_context );
m_fontdesc = pango_font_description_copy( widget->style->font_desc );
-#endif
GtkPizza *pizza = GTK_PIZZA( widget );
m_window = pizza->bin_window;
{
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()
// drawing a mono-bitmap (XBitmap) we use the current text GC
if (is_mono)
{
-#ifdef __WXGTK20__
GdkPixmap *bitmap2 = gdk_pixmap_new( wxGetRootWindow()->window, ww, hh, -1 );
GdkGC *gc = gdk_gc_new( bitmap2 );
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_bitmap_unref( bitmap2 );
gdk_gc_unref( gc );
-#else
- gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), 0, 0, xx, yy, -1, -1 );
-#endif
}
else
{
if (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_bitmap_unref( bitmap );
gdk_gc_unref( gc );
-#else
- // was: gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, xx, yy, ww, hh );
- gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, cx, cy, cw, ch );
-#endif
}
else
{
if (text.empty()) return;
-#ifndef __WXGTK20__
- GdkFont *font = m_font.GetInternalFont( m_scaleY );
-
- wxCHECK_RET( font, wxT("invalid font") );
-#endif
-
x = XLOG2DEV(x);
y = YLOG2DEV(y);
-#ifdef __WXGTK20__
wxCHECK_RET( m_context, wxT("no Pango context") );
wxCHECK_RET( m_layout, wxT("no Pango layout") );
wxCHECK_RET( m_fontdesc, wxT("no Pango font description") );
wxCoord width = w;
wxCoord height = h;
-#else // GTK+ 1.x
- wxCoord width = gdk_string_width( font, text.mbc_str() );
- wxCoord height = font->ascent + font->descent;
-
- if ( m_backgroundMode == wxSOLID )
- {
- gdk_gc_set_foreground( m_textGC, m_textBackgroundColour.GetColor() );
- gdk_draw_rectangle( m_window, m_textGC, TRUE, x, y, width, height );
- gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() );
- }
- gdk_draw_string( m_window, font, m_textGC, x, y + font->ascent, text.mbc_str() );
-
- /* CMB 17/7/98: simple underline: ignores scaling and underlying
- X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS
- properties (see wxXt implementation) */
- if (m_font.GetUnderlined())
- {
- wxCoord ul_y = y + font->ascent;
- if (font->descent > 0) ul_y++;
- gdk_draw_line( m_window, m_textGC, x, ul_y, x + width, ul_y);
- }
-#endif // GTK+ 2.0/1.x
-
width = wxCoord(width / m_scaleX);
height = wxCoord(height / m_scaleY);
CalcBoundingBox (x + width, y + height);
wxCoord w;
wxCoord h;
-#ifdef __WXGTK20__
- // implement later without GdkFont for GTK 2.0
+ // TODO: implement later without GdkFont for GTK 2.0
GetTextExtent(text, &w, &h, NULL,NULL, &m_font);
-#else
- GdkFont *font = m_font.GetInternalFont( m_scaleY );
-
- wxCHECK_RET( font, wxT("invalid font") );
-
- // the size of the text
- w = gdk_string_width( font, text.mbc_str() );
- h = font->ascent + font->descent;
-#endif
// draw the string normally
wxBitmap src(w, h);
wxMemoryDC dc;
return;
}
-#ifdef __WXGTK20__
// Set new font description
if (theFont)
pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description );
// Reset old font description
if (theFont)
pango_layout_set_font_description( m_layout, m_fontdesc );
-#else // GTK+ 1.x
- wxFont fontToUse = m_font;
- if (theFont)
- fontToUse = *theFont;
-
- GdkFont *font = fontToUse.GetInternalFont( m_scaleY );
- if ( !font )
- return;
-
- if (width)
- *width = wxCoord(gdk_string_width( font, string.mbc_str() ) / m_scaleX);
- if (height)
- *height = wxCoord((font->ascent + font->descent) / m_scaleY);
- if (descent)
- *descent = wxCoord(font->descent / m_scaleY);
-#endif // GTK+ 2/1
}
wxCoord wxWindowDC::GetCharWidth() const
{
-#ifdef __WXGTK20__
pango_layout_set_text( m_layout, "H", 1 );
int w;
pango_layout_get_pixel_size( m_layout, &w, NULL );
return w;
-#else
- GdkFont *font = m_font.GetInternalFont( m_scaleY );
- wxCHECK_MSG( font, -1, wxT("invalid font") );
-
- return wxCoord(gdk_string_width( font, "H" ) / m_scaleX);
-#endif
}
wxCoord wxWindowDC::GetCharHeight() const
{
-#ifdef __WXGTK20__
pango_layout_set_text( m_layout, "H", 1 );
int h;
pango_layout_get_pixel_size( m_layout, NULL, &h );
return h;
-#else
- GdkFont *font = m_font.GetInternalFont( m_scaleY );
- wxCHECK_MSG( font, -1, wxT("invalid font") );
-
- return wxCoord((font->ascent + font->descent) / m_scaleY);
-#endif
}
void wxWindowDC::Clear()
{
m_font = font;
-#ifdef __WXGTK20__
if (m_font.Ok())
{
if (m_fontdesc)
pango_layout_set_font_description( m_layout, m_fontdesc );
}
-#endif
}
void wxWindowDC::SetPen( const wxPen &pen )
int wxWindowDC::GetDepth() const
{
-#ifdef __WXGTK20__
return gdk_drawable_get_depth(m_window);
-#else
- wxFAIL_MSG(wxT("not implemented"));
-
- return -1;
-#endif
}
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) )
m_cmap = gtk_widget_get_default_colormap();
-#ifdef __WXGTK20__
m_context = gdk_pango_context_get();
pango_context_set_language( m_context, gtk_get_default_language() );
m_layout = pango_layout_new( m_context );
m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
-#endif
}
wxMemoryDC::~wxMemoryDC()
{
-#ifdef __WXGTK20__
g_object_unref(m_context);
-#endif
}
void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
m_window = m_selected.GetBitmap();
}
-#ifdef __WXGTK20__
m_selected.PurgeOtherRepresentations(wxBitmap::Pixmap);
-#endif
m_isMemDC = TRUE;
m_cmap = gdk_colormap_get_system();
m_window = GDK_ROOT_PARENT();
-#ifdef __WXGTK20__
m_context = gdk_pango_context_get();
// Note: The Sun customised version of Pango shipping with Solaris 10
// crashes if the language is left NULL (see bug 1374114)
pango_context_set_language( m_context, gtk_get_default_language() );
m_layout = pango_layout_new( m_context );
// m_fontdesc = pango_font_description_copy( widget->style->font_desc );
-#endif
m_isScreenDC = TRUE;
GList *child = m_dragContext->targets;
while (child)
{
- // in GTK+ 1.x GdkAtom was a gulong, but now it's a pointer
- GdkAtom formatAtom =
-#ifdef __WXGTK20__
- (GdkAtom)(child->data);
-#else
- GPOINTER_TO_INT(child->data);
-#endif
+ GdkAtom formatAtom = (GdkAtom)(child->data);
wxDataFormat format( formatAtom );
#ifdef __WXDEBUG__
gdk_window_get_size (pixmap, &width, &height);
GdkColormap *colormap = gtk_widget_get_colormap( m_widget );
-#ifndef __WXGTK20__
- gtk_widget_push_visual (gdk_colormap_get_visual (colormap));
-#endif
gtk_widget_push_colormap (colormap);
m_iconWindow = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_events (m_iconWindow, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
gtk_widget_set_app_paintable (GTK_WIDGET (m_iconWindow), TRUE);
-#ifndef __WXGTK20__
- gtk_widget_pop_visual ();
-#endif
gtk_widget_pop_colormap ();
gtk_widget_set_usize (m_iconWindow, width, height);
// do we have the native font info?
bool HasNativeFont() const
{
-#ifdef __WXGTK20__
// we always have a Pango font description
return TRUE;
-#else // GTK 1.x
- // only use m_nativeFontInfo if it had been initialized
- return !m_nativeFontInfo.IsDefault();
-#endif // GTK 2.0/1.x
}
// setters: all of them also take care to modify m_nativeFontInfo if we
// and this one also modifies all the other font data fields
void SetNativeFontInfo(const wxNativeFontInfo& info);
- // debugger helper: shows what the font really is
- //
- // VZ: I need this as my gdb either shows wildly wrong values or crashes
- // when I ask it to "p fontRefData" :-(
-#if defined(__WXDEBUG__) && !defined(__WXGTK20__)
- void Dump() const
- {
- wxPrintf(_T("%s-%s-%s-%d-%d\n"),
- m_faceName.c_str(),
- m_weight == wxFONTWEIGHT_NORMAL
- ? _T("normal")
- : m_weight == wxFONTWEIGHT_BOLD
- ? _T("bold")
- : _T("light"),
- m_style == wxFONTSTYLE_NORMAL ? _T("regular") : _T("italic"),
- m_pointSize,
- m_encoding);
- }
-#endif // Debug
-
protected:
// common part of all ctors
void Init(int pointSize,
// clear m_scaled_xfonts if any
void ClearGdkFonts();
-#ifndef __WXGTK20__
- // the map of font sizes to "GdkFont *"
- wxScaledFontList m_scaled_xfonts;
-#endif // GTK 2.0/1.x
-
int m_pointSize;
int m_family,
m_style,
m_noAA = FALSE;
-#ifdef __WXGTK20__
// Create native font info
m_nativeFontInfo.description = pango_font_description_new();
SetStyle( m_style );
SetPointSize( m_pointSize );
SetWeight( m_weight );
-#endif // GTK 2.0
}
void wxFontRefData::InitFromNative()
{
m_noAA = FALSE;
-#ifdef __WXGTK20__
// Get native info
PangoFontDescription *desc = m_nativeFontInfo.description;
// Cannot we choose that
m_encoding = wxFONTENCODING_SYSTEM;
-#else // GTK 1.x
- // get the font parameters from the XLFD
- // -------------------------------------
-
- m_faceName = m_nativeFontInfo.GetXFontComponent(wxXLFD_FAMILY);
-
- m_weight = wxFONTWEIGHT_NORMAL;
-
- wxString w = m_nativeFontInfo.GetXFontComponent(wxXLFD_WEIGHT).Upper();
- if ( !w.empty() && w != _T('*') )
- {
- // the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD
- // and BLACK
- if ( ((w[0u] == _T('B') && (!wxStrcmp(w.c_str() + 1, wxT("OLD")) ||
- !wxStrcmp(w.c_str() + 1, wxT("LACK"))))) ||
- wxStrstr(w.c_str() + 1, _T("BOLD")) )
- {
- m_weight = wxFONTWEIGHT_BOLD;
- }
- else if ( w == _T("LIGHT") || w == _T("THIN") )
- {
- m_weight = wxFONTWEIGHT_LIGHT;
- }
- }
-
- switch ( wxToupper(*m_nativeFontInfo.
- GetXFontComponent(wxXLFD_SLANT).c_str()) )
- {
- case _T('I'): // italique
- m_style = wxFONTSTYLE_ITALIC;
- break;
-
- case _T('O'): // oblique
- m_style = wxFONTSTYLE_SLANT;
- break;
-
- default:
- m_style = wxFONTSTYLE_NORMAL;
- }
-
- long ptSize;
- if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_POINTSIZE).ToLong(&ptSize) )
- {
- // size in XLFD is in 10 point units
- m_pointSize = (int)(ptSize / 10);
- }
- else
- {
- m_pointSize = wxDEFAULT_FONT_SIZE;
- }
-
- // examine the spacing: if the font is monospaced, assume wxTELETYPE
- // family for compatibility with the old code which used it instead of
- // IsFixedWidth()
- if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == _T('M') )
- {
- m_family = wxFONTFAMILY_TELETYPE;
- }
- else // not monospaceed
- {
- // don't even try guessing it, it doesn't work for too many fonts
- // anyhow
- m_family = wxFONTFAMILY_UNKNOWN;
- }
-
- // X fonts are never underlined...
- m_underlined = FALSE;
-
- // deal with font encoding
- wxString
- registry = m_nativeFontInfo.GetXFontComponent(wxXLFD_REGISTRY).Upper(),
- encoding = m_nativeFontInfo.GetXFontComponent(wxXLFD_ENCODING).Upper();
-
- if ( registry == _T("ISO8859") )
- {
- int cp;
- if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 )
- {
- m_encoding = (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1);
- }
- }
- else if ( registry == _T("MICROSOFT") )
- {
- int cp;
- if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 )
- {
- m_encoding = (wxFontEncoding)(wxFONTENCODING_CP1250 + cp);
- }
- }
- else if ( registry == _T("KOI8") )
- {
- m_encoding = wxFONTENCODING_KOI8;
- }
- else // unknown encoding
- {
- // may be give a warning here? or use wxFontMapper?
- m_encoding = wxFONTENCODING_SYSTEM;
- }
-#endif // GTK 2.0/1.x
}
wxFontRefData::wxFontRefData( const wxFontRefData& data )
wxFontRefData::wxFontRefData(const wxString& fontname)
{
- // VZ: FromString() should really work in both cases, doesn't it?
-#ifdef __WXGTK20__
m_nativeFontInfo.FromString( fontname );
-#else // GTK 1.x
- m_nativeFontInfo.SetXFontName(fontname);
-#endif // GTK 2.0/1.x
InitFromNative();
}
void wxFontRefData::ClearGdkFonts()
{
-#ifndef __WXGTK20__
- for ( wxScaledFontList::iterator i = m_scaled_xfonts.begin();
- i != m_scaled_xfonts.end();
- ++i )
- {
- GdkFont *font = i->second;
- gdk_font_unref( font );
- }
-
- m_scaled_xfonts.clear();
-#endif // GTK 1.x
}
wxFontRefData::~wxFontRefData()
{
m_pointSize = pointSize;
-#ifdef __WXGTK20__
m_nativeFontInfo.SetPointSize(pointSize);
-#else
- if ( HasNativeFont() )
- {
- wxString size;
- if ( pointSize == -1 )
- size = _T('*');
- else
- size.Printf(_T("%d"), 10*pointSize);
-
- m_nativeFontInfo.SetXFontComponent(wxXLFD_POINTSIZE, size);
- }
-#endif
}
void wxFontRefData::SetFamily(int family)
{
m_style = style;
-#ifdef __WXGTK20__
m_nativeFontInfo.SetStyle((wxFontStyle)style);
-#else
- if ( HasNativeFont() )
- {
- wxString slant;
- switch ( style )
- {
- case wxFONTSTYLE_ITALIC:
- slant = _T('i');
- break;
-
- case wxFONTSTYLE_SLANT:
- slant = _T('o');
- break;
-
- default:
- wxFAIL_MSG( _T("unknown font style") );
- // fall through
-
- case wxFONTSTYLE_NORMAL:
- slant = _T('r');
- }
-
- m_nativeFontInfo.SetXFontComponent(wxXLFD_SLANT, slant);
- }
-#endif
}
void wxFontRefData::SetWeight(int weight)
{
m_weight = weight;
-#ifdef __WXGTK20__
m_nativeFontInfo.SetWeight((wxFontWeight)weight);
-#else //!__WXGTK20__
- if ( HasNativeFont() )
- {
- wxString boldness;
- switch ( weight )
- {
- case wxFONTWEIGHT_BOLD:
- boldness = _T("bold");
- break;
-
- case wxFONTWEIGHT_LIGHT:
- boldness = _T("light");
- break;
-
- default:
- wxFAIL_MSG( _T("unknown font weight") );
- // fall through
-
- case wxFONTWEIGHT_NORMAL:
- // unspecified
- boldness = _T("medium");
- }
-
- m_nativeFontInfo.SetXFontComponent(wxXLFD_WEIGHT, boldness);
- }
-#endif
}
void wxFontRefData::SetUnderlined(bool underlined)
{
m_faceName = facename;
-#ifdef __WXGTK20__
m_nativeFontInfo.SetFaceName(facename);
-#else
- if ( HasNativeFont() )
- {
- m_nativeFontInfo.SetXFontComponent(wxXLFD_FAMILY, facename);
- }
-#endif
}
void wxFontRefData::SetEncoding(wxFontEncoding encoding)
{
m_encoding = encoding;
-
-#ifndef __WXGTK20__
- if ( HasNativeFont() )
- {
- wxNativeEncodingInfo info;
- if ( wxGetNativeFontEncoding(encoding, &info) )
- {
- m_nativeFontInfo.SetXFontComponent(wxXLFD_REGISTRY, info.xregistry);
- m_nativeFontInfo.SetXFontComponent(wxXLFD_ENCODING, info.xencoding);
- }
- }
-#endif
}
void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info)
{
Init();
-#ifdef __WXGTK20__
Create( info.GetPointSize(),
info.GetFamily(),
info.GetStyle(),
info.GetUnderlined(),
info.GetFaceName(),
info.GetEncoding() );
-#else
- (void) Create(info.GetXFontName());
-#endif
}
bool wxFont::Create( int pointSize,
{
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
-#ifndef __WXGTK20__
- if ( !M_FONTDATA->HasNativeFont() )
- {
- // NB: this call has important side-effect: it not only finds
- // GdkFont representation, it also initializes m_nativeFontInfo
- // by calling its SetXFontName method
- GetInternalFont();
- }
-#endif
-
return &(M_FONTDATA->m_nativeFontInfo);
}
{
wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") );
-#ifndef __WXGTK20__
- if ( M_FONTDATA->HasNativeFont() )
- {
- // the monospace fonts are supposed to have "M" in the spacing field
- wxString spacing = M_FONTDATA->
- m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING);
-
- return spacing.Upper() == _T('M');
- }
-#endif
-
return wxFontBase::IsFixedWidth();
}
M_FONTDATA->SetNoAntiAliasing( no );
}
-
-// ----------------------------------------------------------------------------
-// get internal representation of font
-// ----------------------------------------------------------------------------
-
-#ifndef __WXGTK20__
-static GdkFont *g_systemDefaultGuiFont = (GdkFont*) NULL;
-
-// this is also used from tbargtk.cpp and tooltip.cpp, hence extern
-extern GdkFont *GtkGetDefaultGuiFont()
-{
- if (!g_systemDefaultGuiFont)
- {
- GtkWidget *widget = gtk_button_new();
- GtkStyle *def = gtk_rc_get_style( widget );
- if (def)
- {
- g_systemDefaultGuiFont = gdk_font_ref( def->font );
- }
- else
- {
- def = gtk_widget_get_default_style();
- if (def)
- g_systemDefaultGuiFont = gdk_font_ref( def->font );
- }
- gtk_widget_destroy( widget );
- }
- else
- {
- // already have it, but ref it once more before returning
- gdk_font_ref(g_systemDefaultGuiFont);
- }
-
- return g_systemDefaultGuiFont;
-}
-
-GdkFont *wxFont::GetInternalFont( float scale ) const
-{
- GdkFont *font = (GdkFont *) NULL;
-
- wxCHECK_MSG( Ok(), font, wxT("invalid font") )
-
- long int_scale = long(scale * 100.0 + 0.5); // key for fontlist
- int point_scale = (int)((M_FONTDATA->m_pointSize * 10 * int_scale) / 100);
-
- wxScaledFontList& list = M_FONTDATA->m_scaled_xfonts;
- wxScaledFontList::iterator i = list.find(int_scale);
- if ( i != list.end() )
- {
- font = i->second;
- }
- else // we don't have this font in this size yet
- {
- if (*this == wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT))
- {
- font = GtkGetDefaultGuiFont();
- }
-
- if ( !font )
- {
- // do we have the XLFD?
- if ( int_scale == 100 && M_FONTDATA->HasNativeFont() )
- {
- font = wxLoadFont(M_FONTDATA->m_nativeFontInfo.GetXFontName());
- }
-
- // no XLFD of no exact match - try the approximate one now
- if ( !font )
- {
- wxString xfontname;
- font = wxLoadQueryNearestFont( point_scale,
- M_FONTDATA->m_family,
- M_FONTDATA->m_style,
- M_FONTDATA->m_weight,
- M_FONTDATA->m_underlined,
- M_FONTDATA->m_faceName,
- M_FONTDATA->m_encoding,
- &xfontname);
- // NB: wxFont::GetNativeFontInfo relies on this
- // side-effect of GetInternalFont
- if ( int_scale == 100 )
- M_FONTDATA->m_nativeFontInfo.SetXFontName(xfontname);
- }
- }
-
- if ( font )
- {
- list[int_scale] = font;
- }
- }
-
- // it's quite useless to make it a wxCHECK because we're going to crash
- // anyhow...
- wxASSERT_MSG( font, wxT("could not load any font?") );
-
- return font;
-}
-#endif // not GTK 2.0
-
GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget);
-#ifndef __WXGTK20__
- GdkFont *gfont = gtk_font_selection_dialog_get_font(fontdlg);
-
- if (!gfont)
- {
- wxMessageBox(_("Please choose a valid font."), _("Error"),
- wxOK | wxICON_ERROR);
- return;
- }
-#endif
-
gchar *fontname = gtk_font_selection_dialog_get_font_name(fontdlg);
dialog->SetChosenFont( fontname);
gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked",
GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this );
-#ifndef __WXGTK20__
- // strange way to internationalize
- gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), _("OK") );
-#endif
-
gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked",
GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this );
-#ifndef __WXGTK20__
- // strange way to internationalize
- gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), _("Cancel") );
-#endif
-
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this );
if ( info )
{
-#ifdef __WXGTK20__
const wxString& fontname = info->ToString();
-#else
- const wxString& fontname = info->GetXFontName();
- if ( !fontname )
- font.GetInternalFont();
-#endif
gtk_font_selection_dialog_set_font_name(sel, wxGTK_CONV(fontname));
}
else
}
}
-//-----------------------------------------------------------------------------
-// "draw" of m_wxwindow
-//-----------------------------------------------------------------------------
-
-#ifndef __WXGTK20__
-extern "C" {
-static void
-gtk_glwindow_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxGLCanvas *win )
-{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
- win->m_exposed = TRUE;
-
- win->GetUpdateRegion().Union( rect->x, rect->y,
- rect->width, rect->height );
-}
-}
-#endif
-
//-----------------------------------------------------------------------------
// "size_allocate" of 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_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
GTK_SIGNAL_FUNC(gtk_glwindow_expose_callback), (gpointer)this );
-#ifndef __WXGTK20__
- gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
- GTK_SIGNAL_FUNC(gtk_glwindow_draw_callback), (gpointer)this );
-#endif
-
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_glcanvas_size_callback), (gpointer)this );
-#ifdef __WXGTK20__
if (gtk_check_version(2,2,0) != NULL)
-#endif
{
gtk_widget_pop_visual();
gtk_widget_pop_colormap();
wxString str;
-#ifdef __WXGTK20__
str = wxGTK_CONV_BACK( gtk_label_get_text( label ) );
-#else
- str = wxString( label->label );
-#endif
#if wxUSE_CHECKLISTBOX
// checklistboxes have "[±] " prepended to their lables, remove it
// we use normal item but with a special id for the menu title
static const int wxGTK_TITLE_ID = -3;
-// defined in window.cpp
-#ifndef __WXGTK20__
- extern guint32 wxGtkTimeLastClick;
-#endif
-
//-----------------------------------------------------------------------------
// idle system
//-----------------------------------------------------------------------------
}
m_menubar = gtk_menu_bar_new();
-#ifndef __WXGTK20__
- m_accel = gtk_accel_group_new();
-#endif
if (style & wxMB_DOCKABLE)
{
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
-#ifndef __WXGTK20__
- // support for native hot keys
- gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
-#endif
-
wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
while (node)
{
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
-#ifndef __WXGTK20__
- // support for native key accelerators indicated by underscroes
- ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget);
- if ( !g_slist_find( ACCEL_OBJECTS(m_accel), obj ) )
- gtk_accel_group_attach( m_accel, obj );
-#endif
-
wxMenuList::compatibility_iterator node = m_menus.GetFirst();
while (node)
{
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
-#ifndef __WXGTK20__
- // support for native key accelerators indicated by underscroes
- gtk_accel_group_detach( m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
-#endif
-
wxMenuList::compatibility_iterator node = m_menus.GetFirst();
while (node)
{
menu->SetTitle( str );
// The "m_owner" is the "menu item"
-#ifdef __WXGTK20__
menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) );
-#else
- menu->m_owner = gtk_menu_item_new_with_label( wxGTK_CONV( str ) );
- GtkLabel *label = GTK_LABEL( GTK_BIN(menu->m_owner)->child );
- // set new text
- gtk_label_set_text( label, wxGTK_CONV( str ) );
- // reparse key accel
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( str ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menu->m_owner,
- "activate_item",
- m_accel, //gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menubar)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
-#endif
gtk_widget_show( menu->m_owner );
continue;
}
-#ifdef __WXGTK20__
if ( *pc == wxT('\\') )
{
// GTK 2.0 escapes "xxx/xxx" to "xxx\/xxx"
label += *pc;
continue;
}
-#endif
if ( (*pc == wxT('&')) && (*(pc+1) != wxT('&')) )
{
else
label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
-#ifdef __WXGTK20__
gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV(m_text) );
-#else
- // set new text
- gtk_label_set( label, wxGTK_CONV( m_text ) );
-
- // reparse key accel
- (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) );
- gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
-#endif
}
guint accel_key;
GtkWidget *menuItem;
wxString text;
-#ifndef __WXGTK20__
- GtkLabel* label;
-#endif
if ( mitem->IsSeparator() )
{
-#ifdef __WXGTK20__
menuItem = gtk_separator_menu_item_new();
-#else
- // TODO
- menuItem = gtk_menu_item_new();
-#endif
}
else if (mitem->GetBitmap().Ok())
{
text = mitem->GetText();
const wxBitmap *bitmap = &mitem->GetBitmap();
-#ifdef __WXGTK20__
menuItem = gtk_image_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
GtkWidget *image;
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menuItem), image );
-#else
- // TODO
- wxUnusedVar(bitmap);
- menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
- label = GTK_LABEL( GTK_BIN(menuItem)->child );
-#endif
-
m_prevRadio = NULL;
}
else // a normal item
{
case wxITEM_CHECK:
{
-#ifdef __WXGTK20__
menuItem = gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
-#else
- menuItem = gtk_check_menu_item_new_with_label( wxGTK_CONV( text ) );
- label = GTK_LABEL( GTK_BIN(menuItem)->child );
- // set new text
- gtk_label_set_text( label, wxGTK_CONV( text ) );
-#endif
m_prevRadio = NULL;
break;
}
if ( m_prevRadio == NULL )
{
// start of a new radio group
-#ifdef __WXGTK20__
m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) );
-#else
- m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
- label = GTK_LABEL( GTK_BIN(menuItem)->child );
- // set new text
- gtk_label_set_text( label, wxGTK_CONV( text ) );
-#endif
}
else // continue the radio group
{
-#ifdef __WXGTK20__
group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (m_prevRadio));
m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) );
-#else
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (m_prevRadio));
- m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
- label = GTK_LABEL( GTK_BIN(menuItem)->child );
-#endif
}
break;
}
case wxITEM_NORMAL:
{
-#ifdef __WXGTK20__
menuItem = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
-#else
- menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
- label = GTK_LABEL( GTK_BIN(menuItem)->child );
-#endif
m_prevRadio = NULL;
break;
}
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
(gpointer)this );
}
-
-#ifndef __WXGTK20__
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
-#endif
}
mitem->SetMenuItem(menuItem);
extern "C"
void wxPopupMenuPositionCallback( GtkMenu *menu,
gint *x, gint *y,
-#ifdef __WXGTK20__
gboolean * WXUNUSED(whatever),
-#endif
gpointer user_data )
{
// ensure that the menu appears entirely on screen
posfunc, // function to position it
userdata, // client data
0, // button used to activate it
-#ifdef __WXGTK20__
gtk_get_current_event_time()
-#else
- wxGtkTimeLastClick // the time of activation
-#endif
);
while (is_waiting)
}
}
-//-----------------------------------------------------------------------------
-// "draw" of m_mainWidget
-//-----------------------------------------------------------------------------
-
-#ifndef __WXGTK20__
-extern "C" {
-static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxFrame *win )
-{
- if (g_isIdle) wxapp_install_idle_handler();
-
- if (!win->m_hasVMT) return;
-
- GtkPizza *pizza = GTK_PIZZA(widget);
-
- gtk_draw_shadow( widget->style,
- pizza->bin_window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- 0, 0,
- win->m_width, win->m_height );
-
- if (!win->GetTitle().empty() &&
- ((win->GetWindowStyle() & wxCAPTION) ||
- (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) ||
- (win->GetWindowStyle() & wxTINY_CAPTION_VERT)))
- {
- wxClientDC dc(win);
- dc.SetFont( *wxSMALL_FONT );
- int height = dc.GetCharHeight();
-
- GdkGC *gc = gdk_gc_new( pizza->bin_window );
- gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] );
- gdk_draw_rectangle( pizza->bin_window, gc, TRUE,
- 3,
- 3,
- win->m_width - 7,
- height+1 );
- gdk_gc_unref( gc );
-
- // Hack alert
- dc.m_window = pizza->bin_window;
- dc.SetTextForeground( *wxWHITE );
- dc.DrawText( win->GetTitle(), 6, 3 );
- }
-}
-}
-#endif
-
//-----------------------------------------------------------------------------
// "button_press_event" of m_mainWidget
//-----------------------------------------------------------------------------
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );
-#ifndef __WXGTK20__
- gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
- GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this );
-#endif
-
/* these are required for dragging the mini frame around */
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event",
GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this );
{
wxFrame::SetTitle( title );
-#ifdef __WXGTK20__
gdk_window_invalidate_rect( GTK_PIZZA(m_mainWidget)->bin_window, NULL, true );
-#else
- gtk_widget_draw( m_mainWidget, (GdkRectangle*) NULL );
-#endif
}
#endif
const size_t count = GetPageCount();
size_t i = 0;
-#ifdef __WXGTK20__
GtkNotebook * notebook = GTK_NOTEBOOK(m_widget);
if (gtk_notebook_get_scrollable(notebook));
i = g_list_position( notebook->children, notebook->first_tab );
-#endif
for ( ; i < count; i++ )
{
wxGtkNotebookPage* nb_page = GetNotebookPage(i);
GtkWidget *box = nb_page->m_box;
- // VZ: don't know how to find the border width in GTK+ 1.2
-#ifdef __WXGTK20__
const gint border = gtk_container_get_border_width(GTK_CONTAINER(box));
-#else // !GTK+ 2.x
- const gint border = 0;
-#endif
+
if ( IsPointInsideWidget(pt, box, x, y, border) )
{
// ok, we're inside this tab -- now find out where, if needed
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) );
-#ifdef __WXGTK20__
wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
-#else
- wxString str( label->label );
-#endif
return str;
}
void wxRadioBox::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style( m_widget, style );
-
-#ifdef __WXGTK20__
gtk_widget_modify_style(GTK_FRAME(m_widget)->label_widget, style);
-#endif
wxList::compatibility_iterator node = m_boxes.GetFirst();
while (node)
#include "wx/log.h"
#include "wx/gtk/private.h"
-#ifndef __WXGTK20__
-
-// ----------------------------------------------------------------------------
-// wxGdkRegion: creates a new region in ctor and destroys in dtor
-// ----------------------------------------------------------------------------
-
-class wxGdkRegion
-{
-public:
- wxGdkRegion() { m_region = gdk_region_new(); }
- ~wxGdkRegion() { gdk_region_destroy(m_region); }
-
- operator GdkRegion *() const { return m_region; }
-
-private:
- GdkRegion *m_region;
-};
-
-#endif // __WXGTK20__
// ----------------------------------------------------------------------------
// wxRegionRefData: private class containing the information about the region
wxRegionRefData(const wxRegionRefData& refData)
: wxObjectRefData()
{
-#ifdef __WXGTK20__
m_region = gdk_region_copy(refData.m_region);
-#else
- m_region = gdk_regions_union(wxGdkRegion(), refData.m_region);
-#endif
}
~wxRegionRefData()
m_refData = new wxRegionRefData();
-#ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
-#else
- M_REGIONDATA->m_region = gdk_region_union_with_rect( wxGdkRegion(), &rect );
-#endif
}
wxRegion::wxRegion( GdkRegion *region )
{
m_refData = new wxRegionRefData();
-#ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_copy( region );
-#else
- M_REGIONDATA->m_region = gdk_regions_union(wxGdkRegion(), region);
-#endif
}
wxRegion::wxRegion( size_t n, const wxPoint *points, int fillStyle )
rect.width = width;
rect.height = height;
-#ifdef __WXGTK20__
gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
-#else
- GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
-#endif
}
return TRUE;
AllocExclusive();
}
-#ifdef __WXGTK20__
gdk_region_union( M_REGIONDATA->m_region, region.GetRegion() );
-#else
- GdkRegion *reg = gdk_regions_union( M_REGIONDATA->m_region, region.GetRegion() );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
-#endif
return TRUE;
}
AllocExclusive();
-#ifdef __WXGTK20__
gdk_region_intersect( M_REGIONDATA->m_region, region.GetRegion() );
-#else
- GdkRegion *reg = gdk_regions_intersect( M_REGIONDATA->m_region, region.GetRegion() );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
-#endif
return TRUE;
}
AllocExclusive();
-#ifdef __WXGTK20__
gdk_region_subtract( M_REGIONDATA->m_region, region.GetRegion() );
-#else
- GdkRegion *reg = gdk_regions_subtract( M_REGIONDATA->m_region, region.GetRegion() );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
-#endif
return TRUE;
}
AllocExclusive();
-#ifdef __WXGTK20__
gdk_region_xor( M_REGIONDATA->m_region, region.GetRegion() );
-#else
- GdkRegion *reg = gdk_regions_xor( M_REGIONDATA->m_region, region.GetRegion() );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
-#endif
return TRUE;
}
// wxRegionIterator
// ----------------------------------------------------------------------------
-#ifndef __WXGTK20__
-
-// the following structures must match the private structures
-// in X11 region code ( xc/lib/X11/region.h )
-
-// this makes the Region type transparent
-// and we have access to the region rectangles
-
-#include <gdk/gdkprivate.h>
-
-struct _XBox {
- short x1, x2, y1, y2;
-};
-
-struct _XRegion {
- long size , numRects;
- _XBox *rects, extents;
-};
-
-#endif // GTK+ 1.x
-
class wxRIRefData: public wxObjectRefData
{
public:
if (!gdkregion)
return;
-#ifdef __WXGTK20__
GdkRectangle *gdkrects = NULL;
gint numRects = 0;
gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects );
}
}
g_free( gdkrects );
-#else // GTK+ 1.x
- Region r = ((GdkRegionPrivate *)gdkregion)->xregion;
- if (r)
- {
- m_numRects = r->numRects;
- if (m_numRects)
- {
- m_rects = new wxRect[m_numRects];
- for (size_t i=0; i < m_numRects; ++i)
- {
- _XBox &xr = r->rects[i];
- wxRect &wr = m_rects[i];
- wr.x = xr.x1;
- wr.y = xr.y1;
- wr.width = xr.x2-xr.x1;
- wr.height = xr.y2-xr.y1;
- }
- }
- }
-#endif // GTK+ 2.0/1.x
}
wxRegionIterator::wxRegionIterator()
#include "wx/window.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
-
-#ifdef __WXGTK20__
- #include "wx/settings.h"
-#endif // GTK 2.0
-
-#ifdef __WXGTK20__
- #define WXUNUSED_IN_GTK1(arg) arg
-#else
- #define WXUNUSED_IN_GTK1(arg)
-#endif
+#include "wx/settings.h"
// RR: After a correction to the orientation of the sash
// this doesn't seem to be required anymore and it
const wxRect& rect,
int flags = 0);
-#ifdef __WXGTK20__
// draw the expanded/collapsed icon for a tree control item
virtual void DrawTreeItemButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0);
-#endif // GTK+ 2.0
virtual void DrawSplitterBorder(wxWindow *win,
wxDC& dc,
// used by DrawHeaderButton and DrawComboBoxDropButton
static GtkWidget *GetButtonWidget();
-#ifdef __WXGTK20__
// used by DrawTreeItemButton()
static GtkWidget *GetTreeWidget();
-#endif // GTK+ 2.0
};
// ============================================================================
return s_button;
}
-#ifdef __WXGTK20__
-
GtkWidget *
wxRendererGTK::GetTreeWidget()
{
return s_tree;
}
-#endif // GTK+ 2.0
-
// ----------------------------------------------------------------------------
// list/tree controls drawing
// ----------------------------------------------------------------------------
);
}
-#ifdef __WXGTK20__
-
// draw a ">" or "v" button
void
wxRendererGTK::DrawTreeItemButton(wxWindow* win,
);
}
-#endif // GTK+ 2.0
// ----------------------------------------------------------------------------
// splitter sash drawing
// ----------------------------------------------------------------------------
-#ifndef __WXGTK20__
- // the full sash width (should be even)
- static const wxCoord SASH_SIZE = 8;
-
- // margin around the sash
- static const wxCoord SASH_MARGIN = 2;
-#endif // GTK+ 2.x/1.x
-
static int GetGtkSplitterFullSize()
{
-#ifdef __WXGTK20__
static GtkWidget *s_paned = NULL;
if (s_paned == NULL)
s_paned = gtk_vpaned_new();
gtk_widget_style_get (s_paned, "handle_size", &handle_size, NULL);
return handle_size;
-#else
- return SASH_SIZE + SASH_MARGIN;
-#endif
}
wxSplitterRenderParams
(
GetGtkSplitterFullSize(),
0,
-#ifdef __WXGTK20__
true // hot sensitive
-#else // GTK+ 1.x
- false // not
-#endif // GTK+ 2.x/1.x
);
}
const wxSize& size,
wxCoord position,
wxOrientation orient,
- int WXUNUSED_IN_GTK1(flags))
+ int flags)
{
if ( !win->m_wxwindow->window )
{
);
#endif
-#ifdef __WXGTK20__
gtk_paint_handle
(
win->m_wxwindow->style,
rect.height,
isVert ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
);
-#else // GTK+ 1.x
-
- // leave some margin before sash itself
- position += SASH_MARGIN / 2;
-
- // and finally draw it using GTK paint functions
- typedef void (*GtkPaintLineFunc)(GtkStyle *, GdkWindow *,
- GtkStateType,
- GdkRectangle *, GtkWidget *,
- gchar *,
- gint, gint, gint);
-
- GtkPaintLineFunc func = isVert ? gtk_paint_vline : gtk_paint_hline;
-
- (*func)
- (
- win->m_wxwindow->style,
- GTK_PIZZA(win->m_wxwindow)->bin_window,
- GTK_STATE_NORMAL,
- NULL,
- win->m_wxwindow,
- (char *)"paned", // const_cast
- 0, isVert ? size.y : size.x, position + SASH_SIZE / 2 - 1
- );
-
- gtk_paint_box
- (
- win->m_wxwindow->style,
- GTK_PIZZA(win->m_wxwindow)->bin_window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- (GdkRectangle*) NULL,
- win->m_wxwindow,
- (char *)"paned", // const_cast
- isVert ? position : size.x - 2*SASH_SIZE,
- isVert ? size.y - 2*SASH_SIZE : position,
- SASH_SIZE, SASH_SIZE
- );
-#endif // GTK+ 2.x/1.x
}
void
g_currentUpDownEvent = wxEVT_SCROLL_LINEUP;
}
-#ifndef __WXGTK20__
- // There is no slider field any more
- win->m_isScrolling = (gdk_event->window == widget->slider);
-#endif
-
return FALSE;
}
}
bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window )
{
GtkRange *range = GTK_RANGE(m_widget);
- return ( (window == GTK_WIDGET(range)->window)
-#ifndef __WXGTK20__
- || (window == range->trough)
- || (window == range->slider)
- || (window == range->step_forw)
- || (window == range->step_back)
-#endif // GTK+ 1.x
- );
+ return ( (window == GTK_WIDGET(range)->window) );
}
wxSize wxScrollBar::DoGetBestSize() const
{
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 )
g_free (font_name);
}
gtk_widget_destroy( widget );
-#else
- gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
-#endif
}
return gs_objects.m_fontSystem;
}
int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
{
-#ifdef __WXGTK20__
bool success = false;
guchar *data = NULL;
GdkWindow *window = NULL;
if(win && GTK_WIDGET_REALIZED(win->GetHandle()))
window = win->GetHandle()->window;
-#endif
switch (index)
{
-#ifdef __WXGTK20__
case wxSYS_BORDER_X:
case wxSYS_BORDER_Y:
case wxSYS_EDGE_X:
}
return -1; // no window specified
-#endif // gtk2
case wxSYS_CURSOR_X:
case wxSYS_CURSOR_Y:
#endif
return 16;
-#ifdef __WXGTK20__
case wxSYS_DCLICK_X:
case wxSYS_DCLICK_Y:
gint dclick_distance;
"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;
}
return drag_threshold * 2;
-#endif
// MBN: ditto for icons
case wxSYS_ICON_X: return 32;
case wxSYS_HSCROLL_Y: return 15;
case wxSYS_VSCROLL_X: return 15;
-// a gtk1 implementation should be possible too if gtk2 efficiency/convenience functions aren't used
-#ifdef __WXGTK20__
case wxSYS_CAPTION_Y:
if (!window)
// No realized window specified, and no implementation for that case yet.
// ...
return -1;
-#endif // gtk2
case wxSYS_PENWINDOWS_PRESENT:
// No MS Windows for Pen computing extension available in X11 based gtk+.
return;
wxEventType evtType;
-#ifdef __WXGTK20__
if ( win->m_isScrolling )
evtType = wxEVT_SCROLL_THUMBTRACK;
// it could seem that UP/DOWN are inversed but this is what wxMSW does
evtType = wxEVT_SCROLL_TOP;
else if ( AreSameAdjustValues(adjust->value, adjust->upper) )
evtType = wxEVT_SCROLL_BOTTOM;
-#else
- evtType = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));
-#endif
ProcessScrollEvent(win, evtType, dvalue);
m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) );
-#ifdef __WXGTK20__
if (style & wxSL_INVERSE)
gtk_range_set_inverted( GTK_RANGE(m_widget), TRUE );
-#endif
GtkEnableEvents();
gtk_signal_connect( GTK_OBJECT(m_widget),
bool wxSlider::IsOwnGtkWindow( GdkWindow *window )
{
GtkRange *range = GTK_RANGE(m_widget);
-#ifdef __WXGTK20__
return (range->event_window == window);
-#else
- return ( (window == GTK_WIDGET(range)->window)
- || (window == range->trough)
- || (window == range->slider)
- || (window == range->step_forw)
- || (window == range->step_back) );
-#endif
}
void wxSlider::GtkDisableEvents()
Create( parent, id, bitmap, pos, size, style, name );
}
-#ifndef __WXGTK20__
-// empty bitmap, so that we can create GtkPixmap widget:
-static char * bogus_xpm[] = {
-"2 2 1 1",
-" c None",
-" ",
-" "};
-#endif
-
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
m_bitmap = bitmap;
-#ifdef __WXGTK20__
m_widget = gtk_image_new();
-#else
- wxBitmap bmp(bitmap.Ok() ? bitmap : wxBitmap(bogus_xpm));
- m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL);
-#endif
if (bitmap.Ok())
SetBitmap(bitmap);
if (m_bitmap.GetMask())
mask = m_bitmap.GetMask()->GetBitmap();
-#ifdef __WXGTK20__
if (m_bitmap.HasPixbuf())
{
gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget),
else
gtk_image_set_from_pixmap(GTK_IMAGE(m_widget),
m_bitmap.GetPixmap(), mask);
-#else
- gtk_pixmap_set(GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask);
-#endif
InvalidateBestSize();
SetSize(GetBestSize());
void wxStaticBox::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
-#ifdef __WXGTK20__
gtk_widget_modify_style(GTK_FRAME(m_widget)->label_widget, style);
-#endif
}
// static
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
(gpointer) this
);
}
-#endif // __WXGTK20__
return TRUE;
}
wxString wxStaticText::GetLabel() const
{
GtkLabel *label = GTK_LABEL(m_widget);
-
-#ifdef __WXGTK20__
wxString str = wxGTK_CONV_BACK( gtk_label_get_text( label ) );
-#else
- wxString str = wxString( label->label );
-#endif
return wxString(str);
}
{
wxControl::SetLabel(label);
-#ifdef __WXGTK20__
// Build the colorized version of the label (markup only allowed
// under GTK2):
if (m_foregroundColour.Ok())
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
// Do not return any arbitrary default value...
wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") );
-#ifndef __WXGTK20__
- // This resets the internal GTK1 size calculation, which
- // otherwise would be cashed (incorrectly)
- gtk_label_set_pattern( GTK_LABEL(m_widget), NULL );
-#endif
-
// GetBestSize is supposed to return unwrapped size
gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
*gtkStyle = style & wxTB_NOICONS
? GTK_TOOLBAR_TEXT
: (
-#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?
{
GdkBitmap *mask = bitmap.GetMask() ? bitmap.GetMask()->GetBitmap()
: (GdkBitmap *)NULL;
-#ifdef __WXGTK20__
if (bitmap.HasPixbuf())
gtk_image_set_from_pixbuf( GTK_IMAGE(m_pixmap), bitmap.GetPixbuf() );
else
-#endif // !__WXGTK20__
gtk_pixmap_set( GTK_PIXMAP(m_pixmap), bitmap.GetPixmap(), mask );
}
}
return false;
}
-#ifdef __WXGTK20__
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
GtkSetStyle();
// Doesn't work this way.
// GtkToolbarSpaceStyle space_style = GTK_TOOLBAR_SPACE_EMPTY;
// gtk_widget_style_set (GTK_WIDGET (m_toolbar), "space_style", &space_style, NULL);
-#else
- GtkOrientation orient;
- GtkToolbarStyle gtkStyle;
- GetGtkStyle(style, &orient, >kStyle);
-
- m_toolbar = GTK_TOOLBAR( gtk_toolbar_new(orient, gtkStyle) );
-#endif
SetToolSeparation(7);
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
// FIXME: there is no such function for toolbars in 2.0
-#ifndef __WXGTK20__
+#if 0
if (style & wxTB_FLAT)
gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );
#endif
{
wxToolBarTool *tool = (wxToolBarTool *)toolBase;
-#ifndef __WXGTK20__
- // if we have inserted a space before all the tools we must change the GTK
- // index by 1
- size_t posGtk = m_xMargin > 1 ? pos + 1 : pos;
-#else
size_t posGtk = pos;
-#endif
if ( tool->IsButton() )
{
GtkWidget *tool_pixmap = (GtkWidget *)NULL;
-#ifdef __WXGTK20__
if (bitmap.HasPixbuf())
{
tool_pixmap = gtk_image_new();
tool->SetPixmap(bitmap);
}
else
-#endif
{
GdkPixmap *pixmap = bitmap.GetPixmap();
gtk_widget_destroy( tool->m_item );
break;
-#ifdef __WXGTK20__
case wxTOOL_STYLE_SEPARATOR:
gtk_toolbar_remove_space( m_toolbar, pos );
break;
-#endif
}
InvalidateBestSize();
wxCHECK_RET( GetToolsCount() == 0,
wxT("wxToolBar::SetMargins must be called before adding tools.") );
-#ifndef __WXGTK20__
- if (x > 1)
- gtk_toolbar_append_space( m_toolbar ); // oh well
-#endif
-
m_xMargin = x;
m_yMargin = y;
}
void wxToolBar::SetToolSeparation( int separation )
{
// FIXME: this function disappeared
-#ifndef __WXGTK20__
+#if 0
gtk_toolbar_set_space_size( m_toolbar, separation );
#endif
wxVisualAttributes
wxToolBar::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
{
-#ifdef __WXGTK20__
return GetDefaultAttributesFromGTKWidget(gtk_toolbar_new);
-#else
- wxVisualAttributes attr;
- GtkWidget* widget = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
- attr = GetDefaultAttributesFromGTKWidget(widget);
- gtk_widget_destroy(widget);
- return attr;
-#endif
}
#endif // wxUSE_TOOLBAR_NATIVE
// helpers
// ----------------------------------------------------------------------------
-#ifdef __WXGTK20__
extern "C" {
static void wxGtkOnRemoveTag(GtkTextBuffer *buffer,
GtkTextTag *tag,
wxGtkTextApplyTagsFromAttr(text_buffer, attr, &start, &iter);
}
}
-#else
-extern "C" {
-static void wxGtkTextInsert(GtkWidget *text,
- const wxTextAttr& attr,
- const char *txt,
- size_t len)
-{
- GdkFont *font = attr.HasFont() ? attr.GetFont().GetInternalFont()
- : NULL;
-
- GdkColor *colFg = attr.HasTextColour() ? attr.GetTextColour().GetColor()
- : NULL;
-
- GdkColor *colBg = attr.HasBackgroundColour()
- ? attr.GetBackgroundColour().GetColor()
- : NULL;
-
- gtk_text_insert( GTK_TEXT(text), font, colFg, colBg, txt, len );
-}
-}
-#endif // GTK 1.x
// ----------------------------------------------------------------------------
// "insert_text" for GtkEntry
}
}
-#ifdef __WXGTK20__
// Implementation of wxTE_AUTO_URL for wxGTK2 by Mart Raudsepp,
extern "C" {
}
-#endif
-
//-----------------------------------------------------------------------------
// "changed"
//-----------------------------------------------------------------------------
wxapp_install_idle_handler();
win->SetModified();
-#ifndef __WXGTK20__
- win->UpdateFontIfNeeded();
-#endif // !__WXGTK20__
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
event.SetEventObject( win );
// "expose_event" from scrolled window and textview
//-----------------------------------------------------------------------------
-#ifdef __WXGTK20__
extern "C" {
static gboolean
gtk_text_exposed_callback( GtkWidget *widget, GdkEventExpose *event, wxTextCtrl *win )
return TRUE;
}
}
-#endif
-
-//-----------------------------------------------------------------------------
-// "changed" from vertical scrollbar
-//-----------------------------------------------------------------------------
-
-#ifndef __WXGTK20__
-extern "C" {
-static void
-gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
-{
- if (!win->m_hasVMT) return;
-
- if (g_isIdle)
- wxapp_install_idle_handler();
-
- win->CalculateScrollbar();
-}
-}
-#endif
-
-// ----------------------------------------------------------------------------
-// redraw callback for multiline text
-// ----------------------------------------------------------------------------
-
-#ifndef __WXGTK20__
-
-// redrawing a GtkText from inside a wxYield() call results in crashes (the
-// text sample shows it in its "Add lines" command which shows wxProgressDialog
-// which implicitly calls wxYield()) so we override GtkText::draw() and simply
-// don't do anything if we're inside wxYield()
-
-extern bool wxIsInsideYield;
-
-extern "C" {
- typedef void (*GtkDrawCallback)(GtkWidget *widget, GdkRectangle *rect);
-}
-
-static GtkDrawCallback gs_gtk_text_draw = NULL;
-
-extern "C" {
-static void wxgtk_text_draw( GtkWidget *widget, GdkRectangle *rect)
-{
- if ( !wxIsInsideYield )
- {
- wxCHECK_RET( gs_gtk_text_draw != wxgtk_text_draw,
- _T("infinite recursion in wxgtk_text_draw aborted") );
-
- gs_gtk_text_draw(widget, rect);
- }
-}
-}
-#endif // __WXGTK20__
//-----------------------------------------------------------------------------
// wxTextCtrl
EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
-#ifdef __WXGTK20__
// wxTE_AUTO_URL wxTextUrl support. Currently only creates
// wxTextUrlEvent in the same cases as wxMSW, more can be added here.
EVT_MOTION (wxTextCtrl::OnUrlMouseEvent)
EVT_RIGHT_DOWN (wxTextCtrl::OnUrlMouseEvent)
EVT_RIGHT_UP (wxTextCtrl::OnUrlMouseEvent)
EVT_RIGHT_DCLICK(wxTextCtrl::OnUrlMouseEvent)
-#endif
END_EVENT_TABLE()
void wxTextCtrl::Init()
SetUpdateFont(false);
m_text =
m_vScrollbar = (GtkWidget *)NULL;
-#ifdef __WXGTK20__
m_frozenness = 0;
m_gdkHandCursor = NULL;
m_gdkXTermCursor = NULL;
-#endif
}
wxTextCtrl::~wxTextCtrl()
{
-#ifdef __WXGTK20__
if(m_gdkHandCursor)
gdk_cursor_unref(m_gdkHandCursor);
if(m_gdkXTermCursor)
gdk_cursor_unref(m_gdkXTermCursor);
-#endif
}
wxTextCtrl::wxTextCtrl( wxWindow *parent,
if (multi_line)
{
-#ifdef __WXGTK20__
// Create view
m_text = gtk_text_view_new();
gtk_widget_add_events( GTK_WIDGET(m_text), GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
-#else // GTK+ 1
- // create our control ...
- m_text = gtk_text_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
-
- // ... and put into the upper left hand corner of the table
- bool bHasHScrollbar = false;
- m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE);
- GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
- gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1,
- (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
- (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
- 0, 0);
-
- // always wrap words
- gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE );
-
- // finally, put the vertical scrollbar in the upper right corner
- m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj );
- GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS );
- gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1,
- GTK_FILL,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
- 0, 0);
-#endif // GTK+ 2/1
}
else
{
m_widget =
m_text = gtk_entry_new();
-#ifdef __WXGTK20__
if (style & wxNO_BORDER)
g_object_set( GTK_ENTRY(m_text), "has-frame", FALSE, NULL );
-#endif
}
m_parent->DoAddChild( this );
if (multi_line)
gtk_widget_show(m_text);
-#ifndef __WXGTK20__
- if (multi_line)
- {
- gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed",
- (GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this );
-
- // only initialize gs_gtk_text_draw once, starting from the next the
- // klass::draw will already be wxgtk_text_draw
- if ( !gs_gtk_text_draw )
- {
- GtkDrawCallback&
- draw = GTK_WIDGET_CLASS(GTK_OBJECT(m_text)->klass)->draw;
-
- gs_gtk_text_draw = draw;
-
- draw = wxgtk_text_draw;
- }
- }
-#endif // GTK+ 1.x
-
if (!value.empty())
{
-#ifdef __WXGTK20__
SetValue( value );
-#else
-
-#if !GTK_CHECK_VERSION(1, 2, 0)
- // if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in
- // gtk_editable_insert_text()
- gtk_widget_realize(m_text);
-#endif // GTK 1.0
-
- gint tmp = 0;
-#if wxUSE_UNICODE
- wxWX2MBbuf val = value.mbc_str();
- gtk_editable_insert_text( GTK_EDITABLE(m_text), val, strlen(val), &tmp );
-#else
- gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp );
-#endif
-
- if (multi_line)
- {
- // Bring editable's cursor uptodate. Bug in GTK.
- SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
- }
-
-#endif
}
if (style & wxTE_PASSWORD)
{
if (!multi_line)
gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE );
-#ifdef __WXGTK20__
else
gtk_text_view_set_editable( GTK_TEXT_VIEW( m_text), FALSE);
-#else
- }
- else
- {
- if (multi_line)
- gtk_text_set_editable( GTK_TEXT(m_text), 1 );
-#endif
}
-#ifdef __WXGTK20__
if (multi_line)
{
if (style & wxTE_RIGHT)
}
#endif
}
-#endif // __WXGTK20__
// We want to be notified about text changes.
-#ifdef __WXGTK20__
if (multi_line)
{
g_signal_connect( G_OBJECT(m_buffer), "changed",
}
}
else
-#endif
-
{
gtk_signal_connect( GTK_OBJECT(m_text), "changed",
GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
void wxTextCtrl::CalculateScrollbar()
{
-#ifndef __WXGTK20__
- if ((m_windowStyle & wxTE_MULTILINE) == 0) return;
-
- GtkAdjustment *adj = GTK_TEXT(m_text)->vadj;
-
- if (adj->upper - adj->page_size < 0.8)
- {
- if (m_vScrollbarVisible)
- {
- gtk_widget_hide( m_vScrollbar );
- m_vScrollbarVisible = false;
- }
- }
- else
- {
- if (!m_vScrollbarVisible)
- {
- gtk_widget_show( m_vScrollbar );
- m_vScrollbarVisible = true;
- }
- }
-#endif
}
wxString wxTextCtrl::GetValue() const
wxString tmp;
if (m_windowStyle & wxTE_MULTILINE)
{
-#ifdef __WXGTK20__
GtkTextIter start;
gtk_text_buffer_get_start_iter( m_buffer, &start );
GtkTextIter end;
tmp = buffer;
g_free( text );
-#else
- gint len = gtk_text_get_length( GTK_TEXT(m_text) );
- char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
- tmp = text;
- g_free( text );
-#endif
}
else
{
if (m_windowStyle & wxTE_MULTILINE)
{
-#ifdef __WXGTK20__
-
#if wxUSE_UNICODE
wxCharBuffer buffer( wxConvUTF8.cWX2MB( value) );
#else
}
gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
-
-#else
- gint len = gtk_text_get_length( GTK_TEXT(m_text) );
- gtk_editable_delete_text( GTK_EDITABLE(m_text), 0, len );
- len = 0;
- gtk_editable_insert_text( GTK_EDITABLE(m_text), value.mbc_str(), value.Length(), &len );
-#endif
}
else
{
if ( m_windowStyle & wxTE_MULTILINE )
{
-#ifdef __WXGTK20__
-
#if wxUSE_UNICODE
wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) );
#else
gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text),
gtk_text_buffer_get_insert( m_buffer ), 0.0, FALSE, 0.0, 1.0 );
}
-#else // GTK 1.x
- // After cursor movements, gtk_text_get_point() is wrong by one.
- gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) );
-
- // always use m_defaultStyle, even if it is empty as otherwise
- // resetting the style and appending some more text wouldn't work: if
- // we don't specify the style explicitly, the old style would be used
- gtk_editable_delete_selection( GTK_EDITABLE(m_text) );
- wxGtkTextInsert(m_text, m_defaultStyle, text.c_str(), text.Len());
-
- // we called wxGtkTextInsert with correct font, no need to do anything
- // in UpdateFontIfNeeded() any longer
- if ( !text.empty() )
- {
- SetUpdateFont(false);
- }
-
- // Bring editable's cursor back uptodate.
- SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
-#endif // GTK 1.x/2.0
}
else // single line
{
// This moves the cursor pos to behind the inserted text.
gint len = GET_EDITABLE_POS(m_text);
-#ifdef __WXGTK20__
-
#if wxUSE_UNICODE
wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) );
#else
gtk_editable_insert_text( GTK_EDITABLE(m_text), buffer, strlen(buffer), &len );
-#else
- gtk_editable_insert_text( GTK_EDITABLE(m_text), text.c_str(), text.Len(), &len );
-#endif
-
// Bring entry's cursor uptodate.
gtk_entry_set_position( GTK_ENTRY(m_text), len );
}
{
if (m_windowStyle & wxTE_MULTILINE)
{
-#ifndef __WXGTK20__
- gint len = gtk_text_get_length( GTK_TEXT(m_text) );
- char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
-
- if (text)
- {
- wxString buf;
- long i;
- int currentLine = 0;
- for (i = 0; currentLine != lineNo && text[i]; i++ )
- if (text[i] == '\n')
- currentLine++;
- // Now get the text
- int j;
- for (j = 0; text[i] && text[i] != '\n'; i++, j++ )
- buf += text[i];
-
- g_free( text );
- return buf;
- }
- else
- {
- return wxEmptyString;
- }
-#else
GtkTextIter line;
gtk_text_buffer_get_iter_at_line(m_buffer,&line,lineNo);
GtkTextIter end = line;
wxString result(wxGTK_CONV_BACK(text));
g_free(text);
return result;
-#endif
}
else
{
{
if ( m_windowStyle & wxTE_MULTILINE )
{
-#ifdef __WXGTK20__
GtkTextIter iter;
gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, pos);
if (gtk_text_iter_is_end(&iter))
*y = gtk_text_iter_get_line(&iter);
*x = gtk_text_iter_get_line_offset(&iter);
-#else
- wxString text = GetValue();
-
- // cast to prevent warning. But pos really should've been unsigned.
- if( (unsigned long)pos > text.Len() )
- return false;
-
- *x=0; // First Col
- *y=0; // First Line
-
- const wxChar* stop = text.c_str() + pos;
- for ( const wxChar *p = text.c_str(); p < stop; p++ )
- {
- if (*p == wxT('\n'))
- {
- (*y)++;
- *x=0;
- }
- else
- (*x)++;
- }
-#endif
}
else // single line control
{
{
if (!(m_windowStyle & wxTE_MULTILINE)) return 0;
-#ifdef __WXGTK20__
GtkTextIter iter;
if (y >= gtk_text_buffer_get_line_count (m_buffer))
return -1;
return -1;
return gtk_text_iter_get_offset(&iter) + x;
-#else
- long pos=0;
- for( int i=0; i<y; i++ ) pos += GetLineLength(i) + 1; // one for '\n'
-
- pos += x;
- return pos;
-#endif
}
int wxTextCtrl::GetLineLength(long lineNo) const
{
-#ifdef __WXGTK20__
if (m_windowStyle & wxTE_MULTILINE)
{
int last_line = gtk_text_buffer_get_line_count( m_buffer ) - 1;
return gtk_text_iter_get_chars_in_line(&iter) - ((lineNo == last_line) ? 0 : 1);
}
else
-#endif
{
wxString str = GetLineText (lineNo);
return (int) str.Length();
int wxTextCtrl::GetNumberOfLines() const
{
if (m_windowStyle & wxTE_MULTILINE)
- {
-#ifdef __WXGTK20__
return gtk_text_buffer_get_line_count( m_buffer );
-#else
- gint len = gtk_text_get_length( GTK_TEXT(m_text) );
- char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
-
- if (text)
- {
- int currentLine = 0;
- for (int i = 0; i < len; i++ )
- {
- if (text[i] == '\n')
- currentLine++;
- }
- g_free( text );
-
- // currentLine is 0 based, add 1 to get number of lines
- return currentLine + 1;
- }
- else
- {
- return 0;
- }
-#endif
- }
else
- {
return 1;
- }
}
void wxTextCtrl::SetInsertionPoint( long pos )
if ( IsMultiLine() )
{
-#ifdef __WXGTK20__
GtkTextIter iter;
gtk_text_buffer_get_iter_at_offset( m_buffer, &iter, pos );
gtk_text_buffer_place_cursor( m_buffer, &iter );
GTK_TEXT_VIEW(m_text),
gtk_text_buffer_get_insert( m_buffer )
);
-#else // GTK+ 1.x
- gtk_signal_disconnect_by_func( GTK_OBJECT(m_text),
- GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
-
- /* we fake a set_point by inserting and deleting. as the user
- isn't supposed to get to know about this non-sense, we
- disconnect so that no events are sent to the user program. */
-
- gint tmp = (gint)pos;
- gtk_editable_insert_text( GTK_EDITABLE(m_text), " ", 1, &tmp );
- gtk_editable_delete_text( GTK_EDITABLE(m_text), tmp-1, tmp );
-
- gtk_signal_connect( GTK_OBJECT(m_text), "changed",
- GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
-
- // bring editable's cursor uptodate. Bug in GTK.
- SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
-#endif // GTK+ 2/1
}
else
{
if (m_windowStyle & wxTE_MULTILINE)
{
-#ifdef __WXGTK20__
GtkTextIter end;
gtk_text_buffer_get_end_iter( m_buffer, &end );
gtk_text_buffer_place_cursor( m_buffer, &end );
-#else
- SetInsertionPoint(gtk_text_get_length(GTK_TEXT(m_text)));
-#endif
}
else
{
if (m_windowStyle & wxTE_MULTILINE)
{
-#ifdef __WXGTK20__
gtk_text_view_set_editable( GTK_TEXT_VIEW(m_text), editable );
-#else
- gtk_text_set_editable( GTK_TEXT(m_text), editable );
-#endif
}
else
{
if (m_windowStyle & wxTE_MULTILINE)
{
-#ifdef __WXGTK20__
SetEditable( enable );
-#else
- gtk_text_set_editable( GTK_TEXT(m_text), enable );
- OnParentEnable(enable);
-#endif
}
else
{
to = GetValue().Length();
}
-#ifndef __WXGTK20__
- if ( (m_windowStyle & wxTE_MULTILINE) &&
- !GTK_TEXT(m_text)->line_start_cache )
- {
- // tell the programmer that it didn't work
- wxLogDebug(_T("Can't call SetSelection() before realizing the control"));
- return;
- }
-#endif
-
if (m_windowStyle & wxTE_MULTILINE)
{
-#ifdef __WXGTK20__
GtkTextIter fromi, toi;
gtk_text_buffer_get_iter_at_offset( m_buffer, &fromi, from );
gtk_text_buffer_get_iter_at_offset( m_buffer, &toi, to );
gtk_text_buffer_place_cursor( m_buffer, &toi );
gtk_text_buffer_move_mark_by_name( m_buffer, "selection_bound", &fromi );
-#else
- gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
-#endif
}
else
{
{
if (m_windowStyle & wxTE_MULTILINE)
{
-#ifdef __WXGTK20__
GtkTextIter iter;
gtk_text_buffer_get_start_iter( m_buffer, &iter );
gtk_text_iter_set_offset( &iter, pos );
GtkTextMark *mark = gtk_text_buffer_create_mark( m_buffer, NULL, &iter, TRUE );
gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text), mark, 0.0, FALSE, 0.0, 0.0 );
-#else // GTK 1.x
- GtkAdjustment *vp = GTK_TEXT(m_text)->vadj;
- float totalLines = (float) GetNumberOfLines();
- long posX;
- long posY;
- PositionToXY(pos, &posX, &posY);
- float posLine = (float) posY;
- float p = (posLine/totalLines)*(vp->upper - vp->lower) + vp->lower;
- gtk_adjustment_set_value(GTK_TEXT(m_text)->vadj, p);
-#endif // GTK 1.x/2.x
}
}
-#ifdef __WXGTK20__
-
wxTextCtrlHitTestResult
wxTextCtrl::HitTest(const wxPoint& pt, long *pos) const
{
return wxTE_HT_ON_TEXT;
}
-#endif // __WXGTK20__
-
long wxTextCtrl::GetInsertionPoint() const
{
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
-#ifdef __WXGTK20__
if (m_windowStyle & wxTE_MULTILINE)
{
// There is no direct accessor for the cursor, but
return gtk_text_iter_get_offset( &cursor );
}
else
-#endif
{
return (long) GET_EDITABLE_POS(m_text);
}
if (m_windowStyle & wxTE_MULTILINE)
{
-#ifdef __WXGTK20__
GtkTextIter end;
gtk_text_buffer_get_end_iter( m_buffer, &end );
pos = gtk_text_iter_get_offset( &end );
-#else
- pos = gtk_text_get_length( GTK_TEXT(m_text) );
-#endif
}
else
{
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
-#ifdef __WXGTK20__
if (m_windowStyle & wxTE_MULTILINE)
{
GtkTextIter fromi, toi;
gtk_text_buffer_delete( m_buffer, &fromi, &toi );
}
else // single line
-#endif
- gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
+ gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
}
void wxTextCtrl::Replace( long from, long to, const wxString &value )
if (!value.empty())
{
-#ifdef __WXGTK20__
SetInsertionPoint( from );
WriteText( value );
-#else // GTK 1.x
- gint pos = (gint)from;
-#if wxUSE_UNICODE
- wxWX2MBbuf buf = value.mbc_str();
- gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &pos );
-#else
- gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos );
-#endif // wxUSE_UNICODE
-#endif // GTK 1.x/2.x
}
}
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
-#ifdef __WXGTK20__
if (m_windowStyle & wxTE_MULTILINE)
g_signal_emit_by_name(m_text, "cut-clipboard");
else
-#endif
gtk_editable_cut_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
}
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
-#ifdef __WXGTK20__
if (m_windowStyle & wxTE_MULTILINE)
g_signal_emit_by_name(m_text, "copy-clipboard");
else
-#endif
gtk_editable_copy_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
}
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
-#ifdef __WXGTK20__
if (m_windowStyle & wxTE_MULTILINE)
g_signal_emit_by_name(m_text, "paste-clipboard");
else
-#endif
gtk_editable_paste_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
}
gint to = -1;
bool haveSelection = false;
-#ifdef __WXGTK20__
if (m_windowStyle & wxTE_MULTILINE)
{
GtkTextIter ifrom, ito;
haveSelection = true;
}
}
-#else // not GTK2
- if ( (GTK_EDITABLE(m_text)->has_selection) )
- {
- haveSelection = true;
- from = (long) GTK_EDITABLE(m_text)->selection_start_pos;
- to = (long) GTK_EDITABLE(m_text)->selection_end_pos;
- }
-#endif
if (! haveSelection )
from = to = GetInsertionPoint();
{
wxCHECK_MSG( m_text != NULL, false, wxT("invalid text ctrl") );
-#ifdef __WXGTK20__
if (m_windowStyle & wxTE_MULTILINE)
{
return gtk_text_view_get_editable(GTK_TEXT_VIEW(m_text));
{
return gtk_editable_get_editable(GTK_EDITABLE(m_text));
}
-#else
- return GTK_EDITABLE(m_text)->editable;
-#endif
}
bool wxTextCtrl::IsModified() const
{
if (m_windowStyle & wxTE_MULTILINE)
{
-#ifdef __WXGTK20__
return window == gtk_text_view_get_window( GTK_TEXT_VIEW( m_text ), GTK_TEXT_WINDOW_TEXT ); // pure guesswork
-#else
- return (window == GTK_TEXT(m_text)->text_area);
-#endif
}
else
{
// possible!
//
// TODO: it can be implemented much more efficiently for GTK2
-#ifndef __WXGTK20__
- wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE) && m_updateFont,
-
- _T("shouldn't be called for single line controls") );
-#else
wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE),
_T("shouldn't be called for single line controls") );
-#endif
wxString value = GetValue();
if ( !value.empty() )
}
}
-#ifndef __WXGTK20__
-
-void wxTextCtrl::UpdateFontIfNeeded()
-{
- if ( m_updateFont )
- ChangeFontGlobally();
-}
-
-#endif // GTK+ 1.x
-
bool wxTextCtrl::SetForegroundColour(const wxColour& colour)
{
if ( !wxControl::SetForegroundColour(colour) )
if ( !wxControl::SetBackgroundColour( colour ) )
return false;
-#ifndef __WXGTK20__
- if (!m_widget->window)
- return false;
-#endif
-
if (!m_backgroundColour.Ok())
return false;
- if (m_windowStyle & wxTE_MULTILINE)
- {
-#ifndef __WXGTK20__
- GdkWindow *window = GTK_TEXT(m_text)->text_area;
- if (!window)
- return false;
- m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
- gdk_window_set_background( window, m_backgroundColour.GetColor() );
- gdk_window_clear( window );
-#endif
- }
-
// change active background color too
m_defaultStyle.SetBackgroundColour( colour );
return true;
}
-#ifdef __WXGTK20__
gint l = gtk_text_buffer_get_char_count( m_buffer );
wxCHECK_MSG( start >= 0 && end <= l, false,
wxTextAttr attr = wxTextAttr::Combine(style, m_defaultStyle, this);
wxGtkTextApplyTagsFromAttr( m_buffer, attr, &starti, &endi );
-#else
- // VERY dirty way to do that - removes the required text and re-adds it
- // with styling (FIXME)
-
- gint l = gtk_text_get_length( GTK_TEXT(m_text) );
-
- wxCHECK_MSG( start >= 0 && end <= l, false,
- _T("invalid range in wxTextCtrl::SetStyle") );
-
- gint old_pos = gtk_editable_get_position( GTK_EDITABLE(m_text) );
- char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), start, end );
- wxString tmp(text,*wxConvCurrent);
- g_free( text );
-
- gtk_editable_delete_text( GTK_EDITABLE(m_text), start, end );
- gtk_editable_set_position( GTK_EDITABLE(m_text), start );
-
- #if wxUSE_UNICODE
- wxWX2MBbuf buf = tmp.mbc_str();
- const char *txt = buf;
- size_t txtlen = strlen(buf);
- #else
- const char *txt = tmp;
- size_t txtlen = tmp.length();
- #endif
-
- // use the attributes from style which are set in it and fall back
- // first to the default style and then to the text control default
- // colours for the others
- wxGtkTextInsert(m_text,
- wxTextAttr::Combine(style, m_defaultStyle, this),
- txt,
- txtlen);
-
- /* does not seem to help under GTK+ 1.2 !!!
- gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */
- SetInsertionPoint( old_pos );
-#endif
return true;
}
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
- if (cursor.Ok())
- {
-#ifndef __WXGTK20__
- GdkWindow *window = (GdkWindow*) NULL;
- if (HasFlag(wxTE_MULTILINE))
- window = GTK_TEXT(m_text)->text_area;
- else
- window = GTK_ENTRY(m_text)->text_area;
-
- if (window)
- gdk_window_set_cursor( window, cursor.GetCursor() );
-
- if (!g_globalCursor.Ok())
- cursor = *wxSTANDARD_CURSOR;
-
- window = m_widget->window;
- if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget)))
- gdk_window_set_cursor( window, cursor.GetCursor() );
-#endif
- }
-
if (g_delayedFocus == this)
{
if (GTK_WIDGET_REALIZED(m_widget))
{
if ( HasFlag(wxTE_MULTILINE) )
{
-#ifdef __WXGTK20__
if ( !m_frozenness++ )
{
// freeze textview updates and remove buffer
g_object_ref(m_buffer);
gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), gtk_text_buffer_new(NULL));
}
-#else
- gtk_text_freeze(GTK_TEXT(m_text));
-#endif
}
}
{
if ( HasFlag(wxTE_MULTILINE) )
{
-#ifdef __WXGTK20__
wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") );
if ( !--m_frozenness )
g_signal_handlers_disconnect_by_func(m_widget, (gpointer)gtk_text_exposed_callback, this);
g_signal_handlers_disconnect_by_func(m_text, (gpointer)gtk_text_exposed_callback, this);
}
-#else
- GTK_TEXT(m_text)->vadj->value = 0.0;
-
- gtk_text_thaw(GTK_TEXT(m_text));
-#endif
}
}
// wxTextUrlEvent passing if style & wxTE_AUTO_URL
// ----------------------------------------------------------------------------
-#ifdef __WXGTK20__
-
// FIXME: when dragging on a link the sample gets an "Unknown event".
// This might be an excessive event from us or a buggy wxMouseEvent::Moving() or
// a buggy sample, or something else
//event.Skip(!GetEventHandler()->ProcessEvent(url_event));
GetEventHandler()->ProcessEvent(url_event);
}
-#endif // gtk2
// ----------------------------------------------------------------------------
// scrolling
if ( !IsMultiLine() )
return NULL;
-#ifdef __WXGTK20__
return gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(m_widget));
-#else
- return GTK_TEXT(m_text)->vadj;
-#endif
}
bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
adj->value = value;
-#ifdef __WXGTK20__
gtk_adjustment_value_changed(GTK_ADJUSTMENT(adj));
-#else
- gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed");
-#endif
return true;
}
if ( !adj )
return false;
-#ifdef __WXGTK20__
int diff = (int)ceil(lines*adj->step_increment);
-#else
- // this is hardcoded to 10 in GTK+ 1.2 (great idea)
- int diff = 10*lines;
-#endif
return DoScroll(adj, diff);
}
}
}
-//-----------------------------------------------------------------------------
-// "draw" of m_client
-//-----------------------------------------------------------------------------
-
-#ifndef __WXGTK20__
-
-extern "C" {
-static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win )
-{
- GtkPizza *pizza = GTK_PIZZA(widget);
-
- gtk_paint_flat_box (win->m_widget->style,
- pizza->bin_window, GTK_STATE_NORMAL,
- GTK_SHADOW_NONE,
- rect,
- win->m_widget,
- (char *)"base",
- 0, 0, -1, -1);
-}
-}
-
-#endif // GTK+ 1.x
-
// ----------------------------------------------------------------------------
// wxTopLevelWindowGTK itself
// ----------------------------------------------------------------------------
{
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):
GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_position(GTK_WINDOW(m_widget),
GTK_WIN_POS_CENTER_ON_PARENT);
-#else
- m_widget = gtk_window_new(GTK_WINDOW_DIALOG);
-#endif
}
else
{
// For m_mainWidget themes
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
-#ifndef __WXGTK20__
- gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
- GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
-#endif
}
// m_wxwindow only represents the client area without toolbar and menubar
void wxTopLevelWindowGTK::Raise()
{
-#ifdef __WXGTK20__
gtk_window_present( GTK_WINDOW( m_widget ) );
-#else
- wxWindow::Raise();
-#endif
}
void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
wxTopLevelWindowBase::SetIcons( icons );
-#ifdef __WXGTK20__
GList *list = NULL;
size_t max = icons.m_icons.GetCount();
}
gtk_window_set_icon_list(GTK_WINDOW(m_widget), list);
g_list_free(list);
-
-#else // !__WXGTK20__
- GdkWindow* window = m_widget->window;
- if (!window)
- return;
-
- wxIcon icon = icons.GetIcon(-1);
- if (icon.Ok())
- {
- wxMask *mask = icon.GetMask();
- GdkBitmap *bm = (GdkBitmap *) NULL;
- if (mask) bm = mask->GetBitmap();
-
- gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
- }
-
- wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ),
- (WXWindow)GDK_WINDOW_XWINDOW( window ), icons );
-#endif // !__WXGTK20__
}
// ----------------------------------------------------------------------------
void wxTopLevelWindowGTK::Maximize(bool maximize)
{
-#ifdef __WXGTK20__
if (maximize)
gtk_window_maximize( GTK_WINDOW( m_widget ) );
else
gtk_window_unmaximize( GTK_WINDOW( m_widget ) );
-#else
- wxFAIL_MSG( _T("not implemented") );
-#endif
}
bool wxTopLevelWindowGTK::IsMaximized() const
{
-#ifdef __WXGTK20__
if(!m_widget->window)
return false;
return gdk_window_get_state(m_widget->window) & GDK_WINDOW_STATE_MAXIMIZED;
-#else
- // wxFAIL_MSG( _T("not implemented") );
-
- // This is an approximation
- return false;
-#endif
}
void wxTopLevelWindowGTK::Restore()
{
-#ifdef __WXGTK20__
// "Present" seems similar enough to "restore"
gtk_window_present( GTK_WINDOW( m_widget ) );
-#else
- wxFAIL_MSG( _T("not implemented") );
-#endif
}
void wxTopLevelWindowGTK::Iconize( bool iconize )
{
-#ifdef __WXGTK20__
if (iconize)
gtk_window_iconify( GTK_WINDOW( m_widget ) );
else
gtk_window_deiconify( GTK_WINDOW( m_widget ) );
-#else
- if (iconize)
- {
- GdkWindow *window = m_widget->window;
-
- // you should do it later, for example from OnCreate() handler
- wxCHECK_RET( window, _T("frame not created yet - can't iconize") );
-
- XIconifyWindow( GDK_WINDOW_XDISPLAY( window ),
- GDK_WINDOW_XWINDOW( window ),
- DefaultScreen( GDK_DISPLAY() ) );
- }
-#endif
}
bool wxTopLevelWindowGTK::IsIconized() const
}
else
{
-#ifdef __WXGTK20__
gdk_window_shape_combine_region(window, region.GetRegion(), 0, 0);
-#else
- wxBitmap bmp = region.ConvertToBitmap();
- bmp.SetMask(new wxMask(bmp, *wxBLACK));
- GdkBitmap* mask = bmp.GetMask()->GetBitmap();
- gdk_window_shape_combine_mask(window, mask, 0, 0);
-#endif
return true;
}
}
void wxTopLevelWindowGTK::SetWindowStyleFlag( long style )
{
-#ifdef __WXGTK20__
// Store which styles were changed
long styleChanges = style ^ m_windowStyle;
-#endif
// Process wxWindow styles. This also updates the internal variable
// Therefore m_windowStyle bits carry now the _new_ style values
wxWindow::SetWindowStyleFlag(style);
-#ifdef __WXGTK20__
// just return for now if widget does not exist yet
if (!m_widget)
return;
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), m_windowStyle & wxFRAME_NO_TASKBAR);
}
#endif // GTK+ 2.2
-#endif // GTK+ 2.0
}
#include "glib.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
-#ifndef __WXGTK20__
-#include "gtk/gtkfeatures.h"
-#endif
#include "gdk/gdkx.h"
#ifdef HAVE_X11_XKBLIB_H
}
#endif
-#ifdef __WXGTK20__
// Escapes string so that it is valid Pango markup XML string:
wxString wxEscapeStringForPangoMarkup(const wxString& str)
{
}
return out;
}
-#endif
// ----------------------------------------------------------------------------
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
{
static wxToolkitInfo info;
-#ifdef __WXGTK20__
info.shortName = _T("gtk2");
-#else
- info.shortName = _T("gtk");
-#endif
info.name = _T("wxGTK");
#ifdef __WXUNIVERSAL__
info.shortName << _T("univ");
extern "C" {
#endif /* __cplusplus */
-#ifndef __WXGTK20__
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>
-
-#define IS_ONSCREEN(x,y) ((x >= G_MINSHORT) && (x <= G_MAXSHORT) && \
- (y >= G_MINSHORT) && (y <= G_MAXSHORT))
-
-#endif
-
typedef struct _GtkPizzaAdjData GtkPizzaAdjData;
struct _GtkPizzaAdjData
GtkRequisition *requisition);
static void gtk_pizza_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-#ifndef __WXGTK20__
-static void gtk_pizza_draw (GtkWidget *widget,
- GdkRectangle *area);
-#endif /* __WXGTK20__ */
static gint gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_pizza_style_set (GtkWidget *widget,
static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
gpointer cb_data);
-#ifndef __WXGTK20__
-static void gtk_pizza_position_child (GtkPizza *pizza,
- GtkPizzaChild *child);
-static void gtk_pizza_position_children (GtkPizza *pizza);
-
-static GdkFilterReturn gtk_pizza_filter (GdkXEvent *gdk_xevent,
- GdkEvent *event,
- gpointer data);
-static GdkFilterReturn gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
- GdkEvent *event,
- gpointer data);
-#endif /* __WXGTK20__ */
-
static GtkType gtk_pizza_child_type (GtkContainer *container);
static void gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
GtkAdjustment *hadj,
GtkAdjustment *vadj);
-
-#ifdef __WXGTK20__
- GtkContainerClass *pizza_parent_class = NULL;
-#else
-static GtkContainerClass *pizza_parent_class = NULL;
-#endif
-
-#ifndef __WXGTK20__
-static gboolean gravity_works;
-#endif
+/* static */
+GtkContainerClass *pizza_parent_class = NULL;
GtkType
gtk_pizza_get_type ()
if (!pizza_type)
{
-
-#ifdef __WXGTK20__
static const GTypeInfo pizza_info =
{
sizeof (GtkPizzaClass),
(GInstanceInitFunc) gtk_pizza_init,
};
pizza_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkPizza", &pizza_info, (GTypeFlags)0);
-#else
- GtkTypeInfo pizza_info =
- {
- "GtkPizza",
- sizeof (GtkPizza),
- sizeof (GtkPizzaClass),
- (GtkClassInitFunc) gtk_pizza_class_init,
- (GtkObjectInitFunc) gtk_pizza_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
- pizza_type = gtk_type_unique (gtk_container_get_type (), &pizza_info);
-#endif
}
return pizza_type;
}
-#ifdef __WXGTK20__
/* Marshaller needed for set_scroll_adjustments signal,
generated with GLib-2.4.6 glib-genmarshal */
#define g_marshal_value_peek_object(v) g_value_get_object (v)
g_marshal_value_peek_object (param_values + 2),
data2);
}
-#endif /* __WXGTK20__ */
static void
gtk_pizza_class_init (GtkPizzaClass *klass)
widget_class->unrealize = gtk_pizza_unrealize;
widget_class->size_request = gtk_pizza_size_request;
widget_class->size_allocate = gtk_pizza_size_allocate;
-#ifndef __WXGTK20__
- widget_class->draw = gtk_pizza_draw;
-#endif
widget_class->expose_event = gtk_pizza_expose;
widget_class->style_set = gtk_pizza_style_set;
klass->set_scroll_adjustments = gtk_pizza_scroll_set_adjustments;
widget_class->set_scroll_adjustments_signal =
-#ifdef __WXGTK20__
g_signal_new(
"set_scroll_adjustments",
G_TYPE_FROM_CLASS(object_class),
2,
GTK_TYPE_ADJUSTMENT,
GTK_TYPE_ADJUSTMENT);
-#else
- gtk_signal_new ("set_scroll_adjustments",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (GtkPizzaClass, set_scroll_adjustments),
- gtk_marshal_NONE__POINTER_POINTER,
- GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
-#endif /* __WXGTK20__ */
}
static GtkType
gtk_widget_set_parent (widget, GTK_WIDGET (pizza));
-#ifndef __WXGTK20__ /* FIXME? */
- if (!IS_ONSCREEN (x, y))
- GTK_PRIVATE_SET_FLAG (widget, GTK_IS_OFFSCREEN);
-#endif
-
gtk_widget_set_usize (widget, width, height);
}
if ( GTK_WIDGET_VISIBLE (child->widget) &&
!GTK_WIDGET_MAPPED (child->widget) &&
-#ifdef __WXGTK20__
TRUE)
-#else
- !GTK_WIDGET_IS_OFFSCREEN (child->widget))
-#endif
{
gtk_widget_map (child->widget);
}
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= GDK_EXPOSURE_MASK |
-#ifdef __WXGTK20__
GDK_SCROLL_MASK |
-#endif
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_MOTION_MASK |
gdk_window_set_back_pixmap( pizza->bin_window, NULL, FALSE );
*/
-#ifndef __WXGTK20__
- /* add filters for intercepting visibility and expose events */
- gdk_window_add_filter (widget->window, gtk_pizza_main_filter, pizza);
- gdk_window_add_filter (pizza->bin_window, gtk_pizza_filter, pizza);
-
- /* we NEED gravity or we'll give up */
- gravity_works = gdk_window_set_static_gravities (pizza->bin_window, TRUE);
-#endif // !__WXGTK20__
-
/* cannot be done before realisation */
children = pizza->children;
while (children)
child = children->data;
children = children->next;
-#ifndef __WXGTK20__
- gtk_pizza_position_child (pizza, child);
-#endif
gtk_pizza_allocate_child (pizza, child);
}
}
-#ifndef __WXGTK20__
-
-static void
-gtk_pizza_draw (GtkWidget *widget,
- GdkRectangle *area)
-{
- GtkPizza *pizza;
- GtkPizzaChild *child;
- GdkRectangle child_area;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_PIZZA (widget));
-
- pizza = GTK_PIZZA (widget);
-
- /* Sometimes, We handle all expose events in window.cpp now. */
- if (pizza->external_expose)
- return;
-
- children = pizza->children;
- if ( !(GTK_WIDGET_APP_PAINTABLE (widget)) &&
- (pizza->clear_on_draw))
- {
- gdk_window_clear_area( pizza->bin_window,
- area->x, area->y, area->width, area->height);
- }
-
- while (children)
- {
- child = children->data;
- children = children->next;
-
- if (gtk_widget_intersect (child->widget, area, &child_area))
- gtk_widget_draw (child->widget, &child_area);
- }
-}
-
-#endif /* __WXGTK20__ */
-
static gint
gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkPizza *pizza;
-#ifndef __WXGTK20__
- GtkPizzaChild *child;
- GdkEventExpose child_event;
- GList *children;
-#endif
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PIZZA (widget), FALSE);
if (pizza->external_expose)
return FALSE;
-#ifdef __WXGTK20__
-
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, event);
return FALSE;
-
-#else
-
- children = pizza->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- child_event = *event;
-
- if (GTK_WIDGET_NO_WINDOW (child->widget) &&
- GTK_WIDGET_DRAWABLE (child->widget) &&
- gtk_widget_intersect (child->widget, &event->area, &child_event.area))
- {
- gtk_widget_event (child->widget, (GdkEvent*) &child_event);
- }
- }
-
- return TRUE;
-
-#endif
}
static void
/* security checks */
g_return_if_fail (GTK_IS_WIDGET (widget));
-#ifndef __WXGTK20__
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_IS_OFFSCREEN);
-#endif
-
break;
}
}
}
-#ifndef __WXGTK20__
-static void
-gtk_pizza_position_child (GtkPizza *pizza,
- GtkPizzaChild *child)
-{
- gint x;
- gint y;
-
- x = child->x - pizza->xoffset;
- y = child->y - pizza->yoffset;
-
- if (IS_ONSCREEN (x,y))
- {
- if (GTK_WIDGET_MAPPED (pizza) &&
- GTK_WIDGET_VISIBLE (child->widget))
- {
- if (!GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_map (child->widget);
- }
-
- if (GTK_WIDGET_IS_OFFSCREEN (child->widget))
- GTK_PRIVATE_UNSET_FLAG (child->widget, GTK_IS_OFFSCREEN);
- }
- else
- {
- if (!GTK_WIDGET_IS_OFFSCREEN (child->widget))
- GTK_PRIVATE_SET_FLAG (child->widget, GTK_IS_OFFSCREEN);
-
- if (GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_unmap (child->widget);
- }
-}
-
-static void
-gtk_pizza_position_children (GtkPizza *pizza)
-{
- GList *tmp_list;
-
- tmp_list = pizza->children;
- while (tmp_list)
- {
- GtkPizzaChild *child = tmp_list->data;
- tmp_list = tmp_list->next;
-
- gtk_pizza_position_child (pizza, child);
- }
-}
-
-/* This function is used to find events to process while scrolling */
-static Bool
-gtk_pizza_expose_predicate (Display *display,
- XEvent *xevent,
- XPointer arg)
-{
- if ((xevent->type == Expose) ||
- ((xevent->xany.window == *(Window *)arg) &&
- (xevent->type == ConfigureNotify)))
- return True;
- else
- return False;
-}
-#endif /* __WXGTK20__ */
/* This is the main routine to do the scrolling. Scrolling is
* done by "Guffaw" scrolling, as in the Mozilla XFE, with
void
gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
{
-#ifdef __WXGTK20__
pizza->xoffset += dx;
pizza->yoffset += dy;
if (pizza->bin_window)
gdk_window_scroll( pizza->bin_window, -dx, -dy );
-#else // !__WXGTK20__
- GtkWidget *widget;
- XEvent xevent;
- XID win;
-
- gint x,y,w,h,border;
-
- widget = GTK_WIDGET (pizza);
-
- pizza->xoffset += dx;
- pizza->yoffset += dy;
-
- if (!GTK_WIDGET_MAPPED (pizza))
- {
- gtk_pizza_position_children (pizza);
- return;
- }
-
- gtk_pizza_adjust_allocations (pizza, -dx, -dy);
-
- if (pizza->shadow_type == GTK_MYSHADOW_NONE)
- border = 0;
- else
- if (pizza->shadow_type == GTK_MYSHADOW_THIN)
- border = 1;
- else
- border = 2;
-
- x = 0;
- y = 0;
- w = widget->allocation.width - 2*border;
- h = widget->allocation.height - 2*border;
-
- if (dx > 0)
- {
- if (gravity_works)
- {
- gdk_window_resize (pizza->bin_window,
- w + dx,
- h);
- gdk_window_move (pizza->bin_window, x-dx, y);
- gdk_window_move_resize (pizza->bin_window, x, y, w, h );
- }
- else
- {
- /* FIXME */
- }
- }
- else if (dx < 0)
- {
- if (gravity_works)
- {
- gdk_window_move_resize (pizza->bin_window,
- x + dx,
- y,
- w - dx,
- h);
- gdk_window_move (pizza->bin_window, x, y);
- gdk_window_resize (pizza->bin_window, w, h );
- }
- else
- {
- /* FIXME */
- }
- }
-
- if (dy > 0)
- {
- if (gravity_works)
- {
- gdk_window_resize (pizza->bin_window, w, h + dy);
- gdk_window_move (pizza->bin_window, x, y-dy);
- gdk_window_move_resize (pizza->bin_window,
- x, y, w, h );
- }
- else
- {
- /* FIXME */
- }
- }
- else if (dy < 0)
- {
- if (gravity_works)
- {
- gdk_window_move_resize (pizza->bin_window,
- x, y+dy, w, h - dy );
- gdk_window_move (pizza->bin_window, x, y);
- gdk_window_resize (pizza->bin_window, w, h );
- }
- else
- {
- /* FIXME */
- }
- }
-
- gtk_pizza_position_children (pizza);
-
- gdk_flush();
-
- win = GDK_WINDOW_XWINDOW (pizza->bin_window);
- while (XCheckIfEvent(GDK_WINDOW_XDISPLAY (pizza->bin_window),
- &xevent,
- gtk_pizza_expose_predicate,
- (XPointer)&win))
- {
- GdkEvent event;
- GtkWidget *event_widget;
-
- if ((xevent.xany.window == GDK_WINDOW_XWINDOW (pizza->bin_window)) )
- gtk_pizza_filter (&xevent, &event, pizza);
-
- if (xevent.type == Expose)
- {
- event.expose.window = gdk_window_lookup (xevent.xany.window);
- gdk_window_get_user_data (event.expose.window,
- (gpointer *)&event_widget);
-
- if (event_widget)
- {
- event.expose.type = GDK_EXPOSE;
- event.expose.area.x = xevent.xexpose.x;
- event.expose.area.y = xevent.xexpose.y;
- event.expose.area.width = xevent.xexpose.width;
- event.expose.area.height = xevent.xexpose.height;
- event.expose.count = xevent.xexpose.count;
-
- gdk_window_ref (event.expose.window);
- gtk_widget_event (event_widget, &event);
- gdk_window_unref (event.expose.window);
- }
- }
- }
-#endif /* __WXGTK20__/!__WXGTK20__ */
}
-
-#ifndef __WXGTK20__
-/* The main event filter. Actually, we probably don't really need
- * to install this as a filter at all, since we are calling it
- * directly above in the expose-handling hack. But in case scrollbars
- * are fixed up in some manner...
- *
- * This routine identifies expose events that are generated when
- * we've temporarily moved the bin_window_origin, and translates
- * them or discards them, depending on whether we are obscured
- * or not.
- */
-static GdkFilterReturn
-gtk_pizza_filter (GdkXEvent *gdk_xevent,
- GdkEvent *event,
- gpointer data)
-{
- XEvent *xevent;
- GtkPizza *pizza;
-
- xevent = (XEvent *)gdk_xevent;
-
- pizza = GTK_PIZZA (data);
-
- if (!pizza->use_filter)
- return GDK_FILTER_CONTINUE;
-
- switch (xevent->type)
- {
- case Expose:
- if (xevent->xexpose.serial == pizza->configure_serial)
- {
- xevent->xexpose.x += pizza->scroll_x;
- xevent->xexpose.y += pizza->scroll_y;
- }
- break;
-
- case ConfigureNotify:
- {
- pizza->configure_serial = xevent->xconfigure.serial;
- pizza->scroll_x = xevent->xconfigure.x;
- pizza->scroll_y = xevent->xconfigure.y;
- }
- break;
- }
-
- return GDK_FILTER_CONTINUE;
-}
-
-/* Although GDK does have a GDK_VISIBILITY_NOTIFY event,
- * there is no corresponding event in GTK, so we have
- * to get the events from a filter
- */
-static GdkFilterReturn
-gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
- GdkEvent *event,
- gpointer data)
-{
- XEvent *xevent;
- GtkPizza *pizza;
-
- xevent = (XEvent *)gdk_xevent;
- pizza = GTK_PIZZA (data);
-
- if (!pizza->use_filter)
- return GDK_FILTER_CONTINUE;
-
- if (xevent->type == VisibilityNotify)
- {
- switch (xevent->xvisibility.state)
- {
- case VisibilityFullyObscured:
- pizza->visibility = GDK_VISIBILITY_FULLY_OBSCURED;
- break;
-
- case VisibilityPartiallyObscured:
- pizza->visibility = GDK_VISIBILITY_PARTIAL;
- break;
-
- case VisibilityUnobscured:
- pizza->visibility = GDK_VISIBILITY_UNOBSCURED;
- break;
- }
-
- return GDK_FILTER_REMOVE;
- }
-
- return GDK_FILTER_CONTINUE;
-}
-#endif /* __WXGTK20__ */
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
#include "wx/gtk/win_gtk.h"
-#ifdef __WXGTK20__
#include <pango/pangox.h>
-#endif
-
-#ifdef __WXGTK20__
- #ifdef HAVE_XIM
- #undef HAVE_XIM
- #endif
+#ifdef HAVE_XIM
+ #undef HAVE_XIM
#endif
-#ifdef __WXGTK20__
extern GtkContainerClass *pizza_parent_class;
-#endif
//-----------------------------------------------------------------------------
// documentation on internals
// yet, defer setting the focus to idle time.
wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL;
-// hack: we need something to pass to gtk_menu_popup, so we store the time of
-// the last click here (extern: used from gtk/menu.cpp)
-#ifndef __WXGTK20__
-guint32 wxGtkTimeLastClick = 0;
-#endif
-
extern bool g_mainThreadLocked;
//-----------------------------------------------------------------------------
gint x,
gint y)
{
-#ifndef __WXGTK20__
- GdkWindowPrivate *priv;
-#endif
-
if (!window)
window = GDK_ROOT_PARENT();
-#ifdef __WXGTK20__
if (!GDK_WINDOW_DESTROYED(window))
{
XWarpPointer (GDK_WINDOW_XDISPLAY(window),
0, 0, 0, 0, /* not source window -> move from anywhere */
x, y );
}
-#else
- priv = (GdkWindowPrivate*) window;
-
- if (!priv->destroyed)
- {
- XWarpPointer (priv->xdisplay,
- None, /* not source window -> move from anywhere */
- priv->xwindow, /* dest window */
- 0, 0, 0, 0, /* not source window -> move from anywhere */
- x, y );
- }
-#endif
}
//-----------------------------------------------------------------------------
draw_frame( widget, win );
-#ifdef __WXGTK20__
-
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event);
-#endif
return TRUE;
}
}
-//-----------------------------------------------------------------------------
-// "draw" of m_widget
-//-----------------------------------------------------------------------------
-
-#ifndef __WXGTK20__
-
-extern "C" {
-static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindowGTK *win )
-{
- draw_frame( widget, win );
-}
-}
-
-#endif // GTK+ < 2.0
-
//-----------------------------------------------------------------------------
// "size_request" of m_widget
//-----------------------------------------------------------------------------
if (g_isIdle)
wxapp_install_idle_handler();
-#ifdef __WXGTK20__
// This callback gets called in drawing-idle time under
// GTK 2.0, so we don't need to defer anything to idle
// time anymore.
// Let parent window draw window-less widgets
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event);
-#else
- // This gets called immediately after an expose event
- // under GTK 1.2 so we collect the calls and wait for
- // the idle handler to pick things up.
-
- win->GetUpdateRegion().Union( gdk_event->area.x,
- gdk_event->area.y,
- gdk_event->area.width,
- gdk_event->area.height );
- win->m_clearRegion.Union( gdk_event->area.x,
- gdk_event->area.y,
- gdk_event->area.width,
- gdk_event->area.height );
-
- // Actual redrawing takes place in idle time.
- // win->GtkUpdate();
-#endif
return FALSE;
}
}
-//-----------------------------------------------------------------------------
-// "event" of m_wxwindow
-//-----------------------------------------------------------------------------
-
-#ifndef __WXGTK20__
-
-// GTK thinks it is clever and filters out a certain amount of "unneeded"
-// expose events. We need them, of course, so we override the main event
-// procedure in GtkWidget by giving our own handler for all system events.
-// There, we look for expose events ourselves whereas all other events are
-// handled normally.
-
-extern "C" {
-static
-gint gtk_window_event_event_callback( GtkWidget *widget,
- GdkEventExpose *event,
- wxWindow *win )
-{
- if (event->type == GDK_EXPOSE)
- {
- gint ret = gtk_window_expose_callback( widget, event, win );
- return ret;
- }
-
- return FALSE;
-}
-}
-
-#endif // !GTK+ 2
-
-//-----------------------------------------------------------------------------
-// "draw" of m_wxwindow
-//-----------------------------------------------------------------------------
-
-#ifndef __WXGTK20__
-
-// This callback is a complete replacement of the gtk_pizza_draw() function,
-// which is disabled.
-
-extern "C" {
-static void gtk_window_draw_callback( GtkWidget *widget,
- GdkRectangle *rect,
- wxWindow *win )
-{
- DEBUG_MAIN_THREAD
-
- if (g_isIdle)
- wxapp_install_idle_handler();
-
- // if there are any children we must refresh everything
- //
- // VZ: why?
- if ( !win->HasFlag(wxFULL_REPAINT_ON_RESIZE) &&
- win->GetChildren().IsEmpty() )
- {
- return;
- }
-
-#if 0
- if (win->GetName())
- {
- wxPrintf( wxT("OnDraw from ") );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( wxT(" %d %d %d %d\n"), (int)rect->x,
- (int)rect->y,
- (int)rect->width,
- (int)rect->height );
- }
-#endif
-
-#ifndef __WXUNIVERSAL__
- GtkPizza *pizza = GTK_PIZZA (widget);
-
- if (win->GetThemeEnabled() && win->GetBackgroundStyle() == wxBG_STYLE_SYSTEM)
- {
- wxWindow *parent = win->GetParent();
- while (parent && !parent->IsTopLevel())
- parent = parent->GetParent();
- if (!parent)
- parent = win;
-
- gtk_paint_flat_box (parent->m_widget->style,
- pizza->bin_window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_NONE,
- rect,
- parent->m_widget,
- (char *)"base",
- 0, 0, -1, -1);
- }
-#endif
-
- win->m_clearRegion.Union( rect->x, rect->y, rect->width, rect->height );
- win->GetUpdateRegion().Union( rect->x, rect->y, rect->width, rect->height );
-
- // Update immediately, not in idle time.
- win->GtkUpdate();
-
-#ifndef __WXUNIVERSAL__
- // Redraw child widgets
- GList *children = pizza->children;
- while (children)
- {
- GtkPizzaChild *child = (GtkPizzaChild*) children->data;
- children = children->next;
-
- GdkRectangle child_area;
- if (gtk_widget_intersect (child->widget, rect, &child_area))
- {
- gtk_widget_draw (child->widget, &child_area /* (GdkRectangle*) NULL*/ );
- }
- }
-#endif
-}
-}
-
-#endif
-
//-----------------------------------------------------------------------------
// "key_press_event" from any window
//-----------------------------------------------------------------------------
}
-#ifdef __WXGTK20__
struct wxGtkIMData
{
GtkIMContext *context;
g_object_unref(context);
}
};
-#endif
extern "C" {
static gint gtk_window_key_press_callback( GtkWidget *widget,
return_after_IM = true;
}
-#ifdef __WXGTK20__
// 2005.01.26 modified by Hong Jen Yee (hzysoft@sina.com.tw):
// When we get a key_press event here, it could be originate
// from the current widget or its child widgets. However, only the widget
return true;
}
}
-#endif
+
if (return_after_IM)
return false;
-
+
// Emit KEY_DOWN event
ret = win->GetEventHandler()->ProcessEvent( event );
-#ifndef __WXGTK20__
- // This is for GTK+ 1.2 only. The char event generatation for GTK+ 2.0 is done
- // in the "commit" handler.
-
- // 2005.02.02 modified by Hong Jen Yee (hzysoft@sina.com.tw).
- // In GTK+ 1.2, strings sent by IMs are also regarded as key_press events whose
- // keyCodes cannot be recognized by wxWidgets. These MBCS strings, however, are
- // composed of more than one character, which means gdk_event->length will always
- // greater than one. When gtk_event->length == 1, this may be an ASCII character
- // and can be translated by wx. However, when MBCS characters are sent by IM,
- // gdk_event->length will >= 2. So neither should we pass it to accelerator table,
- // nor should we pass it to controls. The following explanation was excerpted
- // from GDK documentation.
- // gint length : the length of string.
- // gchar *string : a null-terminated multi-byte string containing the composed
- // characters resulting from the key press. When text is being input, in a GtkEntry
- // for example, it is these characters which should be added to the input buffer.
- // When using Input Methods to support internationalized text input, the composed
- // characters appear here after the pre-editing has been completed.
-
- if ( (!ret) && (gdk_event->length > 1) ) // If this event contains a pre-edited string from IM.
- {
- // We should translate this key event into wxEVT_CHAR not wxEVT_KEY_DOWN.
- #if wxUSE_UNICODE // GTK+ 1.2 is not UTF-8 based.
- const wxWCharBuffer string = wxConvLocal.cMB2WC( gdk_event->string );
- if( !string )
- return false;
- #else
- const char* string = gdk_event->string;
- #endif
-
- // Implement OnCharHook by checking ancestor top level windows
- wxWindow *parent = win;
- while (parent && !parent->IsTopLevel())
- parent = parent->GetParent();
-
- for( const wxChar* pstr = string; *pstr; pstr++ )
- {
- #if wxUSE_UNICODE
- event.m_uniChar = *pstr;
- // Backward compatible for ISO-8859-1
- event.m_keyCode = *pstr < 256 ? event.m_uniChar : 0;
- #else
- event.m_keyCode = *pstr;
- #endif
- if (parent)
- {
- event.SetEventType( wxEVT_CHAR_HOOK );
- ret = parent->GetEventHandler()->ProcessEvent( event );
- }
- if (!ret)
- {
- event.SetEventType(wxEVT_CHAR);
- win->GetEventHandler()->ProcessEvent( event );
- }
- }
- return true;
- }
-
-#endif // #ifndef __WXGTK20__
-
#if wxUSE_ACCEL
if (!ret)
{
}
}
-#ifdef __WXGTK20__
extern "C" {
static void gtk_wxwindow_commit_cb (GtkIMContext *context,
const gchar *str,
}
}
}
-#endif
//-----------------------------------------------------------------------------
if ( !g_captureWindow )
win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
-#ifndef __WXGTK20__
- wxGtkTimeLastClick = gdk_event->time;
-
- if (event_type == wxEVT_LEFT_DCLICK)
- {
- // GTK 1.2 crashes when intercepting double
- // click events from both wxSpinButton and
- // wxSpinCtrl
- if (GTK_IS_SPIN_BUTTON(win->m_widget))
- {
- // Just disable this event for now.
- return FALSE;
- }
- }
-#endif // !__WXGTK20__
-
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
}
}
-#ifdef __WXGTK20__
//-----------------------------------------------------------------------------
// "mouse_wheel_event"
//-----------------------------------------------------------------------------
return win->GetEventHandler()->ProcessEvent(event);
}
}
-#endif // __WXGTK20__
//-----------------------------------------------------------------------------
// "focus_in_event"
if (g_isIdle)
wxapp_install_idle_handler();
-#ifdef __WXGTK20__
if (win->m_imData)
gtk_im_context_focus_in(win->m_imData->context);
-#endif
g_focusWindowLast =
g_focusWindow = win;
if (g_isIdle)
wxapp_install_idle_handler();
-#ifdef __WXGTK20__
if (win->m_imData)
gtk_im_context_focus_out(win->m_imData->context);
-#endif
wxLogTrace( TRACE_FOCUS,
_T("%s: focus out"), win->GetName().c_str() );
win->m_oldVerticalPos = adjust->value;
-#ifndef __WXGTK20__
- GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(win->m_widget);
-#endif
wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->vscrollbar));
int value = (int)(adjust->value+0.5);
float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return;
-#ifndef __WXGTK20__
- GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(win->m_widget);
-#endif
wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->hscrollbar));
win->m_oldHorizontalPos = adjust->value;
g_blockEventsOnScroll = true;
- // FIXME: there is no 'slider' field in GTK+ 2.0 any more
-#ifndef __WXGTK20__
+// FIXME: there is no 'slider' field in GTK+ 2.0 any more
+#if 0
win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
if (g_isIdle)
wxapp_install_idle_handler();
-#ifdef __WXGTK20__
if (win->m_imData)
{
GtkPizza *pizza = GTK_PIZZA( m_widget );
gtk_im_context_set_client_window( win->m_imData->context,
pizza->bin_window );
}
-#endif
wxWindowCreateEvent event( win );
event.SetEventObject( win );
m_cursor = *wxSTANDARD_CURSOR;
-#ifdef __WXGTK20__
m_imData = NULL;
m_dirtyTabOrder = false;
-#else
-#ifdef HAVE_XIM
- m_ic = (GdkIC*) NULL;
- m_icattr = (GdkICAttr*) NULL;
-#endif
-#endif
}
wxWindowGTK::wxWindowGTK()
gdk_ic_attr_destroy (m_icattr);
#endif
-#ifdef __WXGTK20__
// delete before the widgets to avoid a crash on solaris
delete m_imData;
-#endif
if (m_wxwindow)
{
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
-#ifndef __WXGTK20__
- gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
- GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
-
- if (!HasFlag(wxFULL_REPAINT_ON_RESIZE))
- {
- gtk_signal_connect( GTK_OBJECT(m_wxwindow), "event",
- GTK_SIGNAL_FUNC(gtk_window_event_event_callback), (gpointer)this );
- }
-#else
// gtk_widget_set_redraw_on_allocate( GTK_WIDGET(m_wxwindow), !HasFlag( wxFULL_REPAINT_ON_RESIZE ) );
-#endif
}
-#ifdef __WXGTK20__
// Create input method handler
m_imData = new wxGtkIMData;
g_signal_connect (G_OBJECT (m_imData->context), "commit",
G_CALLBACK (gtk_wxwindow_commit_cb), this);
-#endif
// these are called when the "sunken" or "raised" borders are drawn
gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );
-#ifndef __WXGTK20__
- gtk_signal_connect( GTK_OBJECT(m_widget), "draw",
- GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this );
-#endif
}
// focus handling
gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event",
GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this );
-#ifdef __WXGTK20__
gtk_signal_connect( GTK_OBJECT(widget), "scroll_event",
GTK_SIGNAL_FUNC(gtk_window_wheel_callback), (gpointer)this );
g_signal_connect(widget, "popup_menu",
G_CALLBACK(wxgtk_window_popup_menu_callback), this);
-#endif
gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event",
GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this );
/* the default button has a border around it */
if (GTK_WIDGET_CAN_DEFAULT(m_widget))
{
-#ifdef __WXGTK20__
GtkBorder *default_border = NULL;
gtk_widget_style_get( m_widget, "default_border", &default_border, NULL );
if (default_border)
bottom_border += default_border->bottom;
g_free( default_border );
}
-#else
- left_border = 6;
- right_border = 6;
- top_border = 6;
- bottom_border = 5;
-#endif
}
DoMoveWindow( m_x-top_border,
void wxWindowGTK::OnInternalIdle()
{
-#ifdef __WXGTK20__
if ( m_dirtyTabOrder )
RealizeTabOrder();
-#endif
+
// Update style if the window was not yet realized
// and SetBackgroundStyle(wxBG_STYLE_CUSTOM) was called
if (m_needsStyleChange)
wxFont font = GetFont();
wxCHECK_MSG( font.Ok(), 12, wxT("invalid font") );
-#ifdef __WXGTK20__
PangoContext *context = NULL;
if (m_widget)
context = gtk_widget_get_pango_context( m_widget );
g_object_unref( G_OBJECT( layout ) );
return (int) PANGO_PIXELS(rect.height);
-#else
- GdkFont *gfont = font.GetInternalFont( 1.0 );
-
- return gfont->ascent + gfont->descent;
-#endif
}
int wxWindowGTK::GetCharWidth() const
wxFont font = GetFont();
wxCHECK_MSG( font.Ok(), 8, wxT("invalid font") );
-#ifdef __WXGTK20__
PangoContext *context = NULL;
if (m_widget)
context = gtk_widget_get_pango_context( m_widget );
g_object_unref( G_OBJECT( layout ) );
return (int) PANGO_PIXELS(rect.width);
-#else
- GdkFont *gfont = font.GetInternalFont( 1.0 );
-
- return gdk_string_width( gfont, "g" );
-#endif
}
void wxWindowGTK::GetTextExtent( const wxString& string,
return;
}
-#ifdef __WXGTK20__
PangoContext *context = NULL;
if (m_widget)
context = gtk_widget_get_pango_context( m_widget );
if (externalLeading) (*externalLeading) = 0; // ??
g_object_unref( G_OBJECT( layout ) );
-#else
- GdkFont *font = fontToUse.GetInternalFont( 1.0 );
- if (x) (*x) = gdk_string_width( font, wxGTK_CONV( string ) );
- if (y) (*y) = font->ascent + font->descent;
- if (descent) (*descent) = font->descent;
- if (externalLeading) (*externalLeading) = 0; // ??
-#endif
}
void wxWindowGTK::SetFocus()
}
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) )
{
}
}
else
-#ifndef __WXGTK20__
- if (GTK_IS_CONTAINER(m_widget))
- {
- gtk_container_focus( GTK_CONTAINER(m_widget), GTK_DIR_TAB_FORWARD );
- }
- else
-#endif
{
wxLogTrace(TRACE_FOCUS,
_T("Can't set focus to %s(%s)"),
(*m_insertCallback)(this, child);
}
-#ifdef __WXGTK20__
-
void wxWindowGTK::AddChild(wxWindowBase *child)
{
wxWindowBase::AddChild(child);
m_dirtyTabOrder = false;
}
-#endif // __WXGTK20__
-
void wxWindowGTK::Raise()
{
wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
if (!m_widget->window)
return;
-#ifndef __WXGTK20__
- if (g_isIdle)
- wxapp_install_idle_handler();
-
- wxRect myRect;
- if (m_wxwindow && rect)
- {
- myRect.SetSize(wxSize( m_wxwindow->allocation.width,
- m_wxwindow->allocation.height));
- if ( myRect.Intersect(*rect).IsEmpty() )
- {
- // nothing to do, rectangle is empty
- return;
- }
-
- rect = &myRect;
- }
-
- // schedule the area for later updating in GtkUpdate()
- if (eraseBackground && m_wxwindow && m_wxwindow->window)
- {
- if (rect)
- {
- m_clearRegion.Union( rect->x, rect->y, rect->width, rect->height );
- }
- else
- {
- m_clearRegion.Clear();
- m_clearRegion.Union( 0, 0, m_wxwindow->allocation.width, m_wxwindow->allocation.height );
- }
- }
-
- if (rect)
- {
- if (m_wxwindow)
- {
- m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
- }
- else
- {
- GdkRectangle gdk_rect;
- gdk_rect.x = rect->x;
- gdk_rect.y = rect->y;
- gdk_rect.width = rect->width;
- gdk_rect.height = rect->height;
- gtk_widget_draw( m_widget, &gdk_rect );
- }
- }
- else
- {
- if (m_wxwindow)
- {
- m_updateRegion.Clear();
- m_updateRegion.Union( 0, 0, m_wxwindow->allocation.width, m_wxwindow->allocation.height );
- }
- else
- {
- gtk_widget_draw( m_widget, (GdkRectangle*) NULL );
- }
- }
-#else // GTK+ 2
if (m_wxwindow)
{
GdkRectangle gdk_rect,
gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, p, TRUE );
}
-#endif // GTK+ 1/2
}
void wxWindowGTK::Update()
void wxWindowGTK::GtkUpdate()
{
-#ifdef __WXGTK20__
if (m_wxwindow && GTK_PIZZA(m_wxwindow)->bin_window)
gdk_window_process_updates( GTK_PIZZA(m_wxwindow)->bin_window, FALSE );
-#else
- if (!m_updateRegion.IsEmpty())
- GtkSendPaintEvents();
-#endif
// for consistency with other platforms (and also because it's convenient
// to be able to update an entire TLW by calling Update() only once), we
{
if (!m_wxwindow)
{
-#ifndef __WXGTK20__
- m_clearRegion.Clear();
-#endif
m_updateRegion.Clear();
return;
}
}
else
-#ifdef __WXGTK20__
{
wxWindowDC dc( (wxWindow*)this );
dc.SetClippingRegion( m_updateRegion );
GetEventHandler()->ProcessEvent(erase_event);
}
-#else
- // if (!m_clearRegion.IsEmpty()) // Always send an erase event under GTK 1.2
- {
- wxWindowDC dc( (wxWindow*)this );
- if (m_clearRegion.IsEmpty())
- dc.SetClippingRegion( m_updateRegion );
- else
- dc.SetClippingRegion( m_clearRegion );
-
- wxEraseEvent erase_event( GetId(), &dc );
- erase_event.SetEventObject( this );
-
- if (!GetEventHandler()->ProcessEvent(erase_event) && GetBackgroundStyle() != wxBG_STYLE_CUSTOM)
- {
- if (!g_eraseGC)
- {
- g_eraseGC = gdk_gc_new( pizza->bin_window );
- gdk_gc_set_fill( g_eraseGC, GDK_SOLID );
- }
- gdk_gc_set_foreground( g_eraseGC, GetBackgroundColour().GetColor() );
-
- wxRegionIterator upd( m_clearRegion );
- while (upd)
- {
- gdk_draw_rectangle( pizza->bin_window, g_eraseGC, 1,
- upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() );
- upd ++;
- }
- }
- m_clearRegion.Clear();
- }
-#endif
wxNcPaintEvent nc_paint_event( GetId() );
nc_paint_event.SetEventObject( this );
m_clipPaintRegion = false;
-#if !defined(__WXUNIVERSAL__) && !defined(__WXGTK20__)
- // The following code will result in all window-less widgets
- // being redrawn because the wxWidgets class is allowed to
- // paint over the window-less widgets.
-
- GList *children = pizza->children;
- while (children)
- {
- GtkPizzaChild *child = (GtkPizzaChild*) children->data;
- children = children->next;
-
- if (GTK_WIDGET_NO_WINDOW (child->widget) &&
- GTK_WIDGET_DRAWABLE (child->widget))
- {
- // Get intersection of widget area and update region
- wxRegion region( m_updateRegion );
-
- GdkEventExpose gdk_event;
- gdk_event.type = GDK_EXPOSE;
- gdk_event.window = pizza->bin_window;
- gdk_event.count = 0;
- gdk_event.send_event = TRUE;
-
- wxRegionIterator upd( m_updateRegion );
- while (upd)
- {
- GdkRectangle rect;
- rect.x = upd.GetX();
- rect.y = upd.GetY();
- rect.width = upd.GetWidth();
- rect.height = upd.GetHeight();
-
- if (gtk_widget_intersect (child->widget, &rect, &gdk_event.area))
- {
- gtk_widget_event (child->widget, (GdkEvent*) &gdk_event);
- }
-
- upd ++;
- }
- }
- }
-#endif // native GTK 1
-
m_updateRegion.Clear();
}
void wxWindowGTK::ClearBackground()
{
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
-
-#ifndef __WXGTK20__
- if (m_wxwindow && m_wxwindow->window)
- {
- m_clearRegion.Clear();
- wxSize size( GetClientSize() );
- m_clearRegion.Union( 0,0,size.x,size.y );
-
- // Better do this in idle?
- GtkUpdate();
- }
-#endif
}
#if wxUSE_TOOLTIPS
return true;
}
-#ifdef __WXGTK20__
PangoContext *wxWindowGTK::GtkGetPangoDefaultContext()
{
return gtk_widget_get_pango_context( m_widget );
}
-#endif
GtkRcStyle *wxWindowGTK::CreateWidgetStyle(bool forceStyle)
{
if ( m_font.Ok() )
{
-#ifdef __WXGTK20__
style->font_desc =
pango_font_description_copy( m_font.GetNativeFontInfo()->description );
-#else
- wxString xfontname = m_font.GetNativeFontInfo()->GetXFontName();
- style->fontset_name = g_strdup(xfontname.c_str());
-#endif
}
if ( m_foregroundColour.Ok() )
// No scrolling requested.
if ((dx == 0) && (dy == 0)) return;
-#ifndef __WXGTK20__
- if (!m_updateRegion.IsEmpty())
- {
- m_updateRegion.Offset( dx, dy );
-
- int cw = 0;
- int ch = 0;
- GetClientSize( &cw, &ch );
- m_updateRegion.Intersect( 0, 0, cw, ch );
- }
-
- if (!m_clearRegion.IsEmpty())
- {
- m_clearRegion.Offset( dx, dy );
-
- int cw = 0;
- int ch = 0;
- GetClientSize( &cw, &ch );
- m_clearRegion.Intersect( 0, 0, cw, ch );
- }
-#endif
-
m_clipPaintRegion = true;
gtk_pizza_scroll( GTK_PIZZA(m_wxwindow), -dx, -dy );