merged 2.4 branch into the trunk

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18040 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-12-04 14:11:26 +00:00
parent 59a944cb63
commit 2b5f62a0b2
1057 changed files with 37805 additions and 24034 deletions

View File

@@ -26,6 +26,7 @@
#include "wx/dialog.h"
#include "wx/msgdlg.h"
#include "wx/file.h"
#include "wx/filename.h"
#if wxUSE_WX_RESOURCES
#include "wx/resource.h"
@@ -44,13 +45,32 @@
#endif
#include <unistd.h>
#if defined(__DARWIN__)
# warning "FIXME: select must be used instead of poll (GD)"
#elif defined(__VMS)
# include <poll.h>
#else
# include <sys/poll.h>
#endif
#ifdef HAVE_POLL
#if defined(__VMS)
#include <poll.h>
#else
// bug in the OpenBSD headers: at least in 3.1 there is no extern "C"
// in neither poll.h nor sys/poll.h which results in link errors later
#ifdef __OPENBSD__
extern "C"
{
#endif
#include <sys/poll.h>
#ifdef __OPENBSD__
};
#endif
#endif // platform
#else // !HAVE_POLL
// we implement poll() ourselves using select() which is supposed exist in
// all modern Unices
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#endif // HAVE_POLL/!HAVE_POLL
#include "wx/gtk/win_gtk.h"
#include <gtk/gtk.h>
@@ -250,22 +270,82 @@ static gint wxapp_idle_callback( gpointer WXUNUSED(data) )
#if wxUSE_THREADS
#ifdef HAVE_POLL
#define wxPoll poll
#define wxPollFd pollfd
#else // !HAVE_POLL
typedef GPollFD wxPollFd;
int wxPoll(wxPollFd *ufds, unsigned int nfds, int timeout)
{
// convert timeout from ms to struct timeval (s/us)
timeval tv_timeout;
tv_timeout.tv_sec = timeout/1000;
tv_timeout.tv_usec = (timeout%1000)*1000;
// remember the highest fd used here
int fdMax = -1;
// and fill the sets for select()
fd_set readfds;
fd_set writefds;
fd_set exceptfds;
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
unsigned int i;
for ( i = 0; i < nfds; i++ )
{
wxASSERT_MSG( ufds[i].fd < FD_SETSIZE, _T("fd out of range") );
if ( ufds[i].events & G_IO_IN )
FD_SET(ufds[i].fd, &readfds);
if ( ufds[i].events & G_IO_PRI )
FD_SET(ufds[i].fd, &exceptfds);
if ( ufds[i].events & G_IO_OUT )
FD_SET(ufds[i].fd, &writefds);
if ( ufds[i].fd > fdMax )
fdMax = ufds[i].fd;
}
fdMax++;
int res = select(fdMax, &readfds, &writefds, &exceptfds, &tv_timeout);
// translate the results back
for ( i = 0; i < nfds; i++ )
{
ufds[i].revents = 0;
if ( FD_ISSET(ufds[i].fd, &readfds ) )
ufds[i].revents |= G_IO_IN;
if ( FD_ISSET(ufds[i].fd, &exceptfds ) )
ufds[i].revents |= G_IO_PRI;
if ( FD_ISSET(ufds[i].fd, &writefds ) )
ufds[i].revents |= G_IO_OUT;
}
return res;
}
#endif // HAVE_POLL/!HAVE_POLL
static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout )
{
gint res;
gdk_threads_enter();
wxMutexGuiLeave();
g_mainThreadLocked = TRUE;
#ifdef __DARWIN__
// FIXME: poll is not available under Darwin/Mac OS X and this needs
// to be implemented using select instead (GD)
// what about other BSD derived systems?
res = -1;
#else
res = poll( (struct pollfd*) ufds, nfds, timeout );
#endif
// we rely on the fact that glib GPollFD struct is really just pollfd but
// I wonder how wise is this in the long term (VZ)
gint res = wxPoll( (wxPollFd *) ufds, nfds, timeout );
wxMutexGuiEnter();
g_mainThreadLocked = FALSE;
@@ -463,6 +543,16 @@ GdkVisual *wxApp::GetGdkVisual()
bool wxApp::ProcessIdle()
{
wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
node = wxTopLevelWindows.GetFirst();
while (node)
{
wxWindow* win = node->GetData();
CallInternalIdle( win );
node = node->GetNext();
}
wxIdleEvent event;
event.SetEventObject( this );
ProcessEvent( event );
@@ -510,14 +600,6 @@ bool wxApp::SendIdleEvents()
node = node->GetNext();
}
node = wxTopLevelWindows.GetFirst();
while (node)
{
wxWindow* win = node->GetData();
CallInternalIdle( win );
node = node->GetNext();
}
return needMore;
}
@@ -545,7 +627,7 @@ bool wxApp::SendIdleEvents( wxWindow* win )
event.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event);
if (event.MoreRequested())
needMore = TRUE;
@@ -609,10 +691,6 @@ bool wxApp::Initialize()
{
wxClassInfo::InitializeClasses();
#if wxUSE_INTL
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
#endif
// GL: I'm annoyed ... I don't know where to put this and I don't want to
// create a module for that as it's part of the core.
#if wxUSE_THREADS
@@ -631,7 +709,12 @@ bool wxApp::Initialize()
#endif
wxModule::RegisterModules();
if (!wxModule::InitializeModules()) return FALSE;
if (!wxModule::InitializeModules())
return FALSE;
#if wxUSE_INTL
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
#endif
return TRUE;
}
@@ -810,9 +893,11 @@ int wxEntry( int argc, char *argv[] )
wxTheApp->argv = argv;
#endif
wxString name(wxFileNameFromPath(argv[0]));
wxStripExtension( name );
wxTheApp->SetAppName( name );
if (wxTheApp->argc > 0)
{
wxFileName fname( wxTheApp->argv[0] );
wxTheApp->SetAppName( fname.GetName() );
}
int retValue;
retValue = wxEntryInitGui();

View File

@@ -344,7 +344,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
m_refData = new wxBitmapRefData();
// ------
// convertion to mono bitmap:
// conversion to mono bitmap:
// ------
if (depth == 1)
{
@@ -440,7 +440,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
}
// ------
// convertion to colour bitmap:
// conversion to colour bitmap:
// ------
else
{

View File

@@ -188,6 +188,15 @@ bool wxButton::Enable( bool enable )
return TRUE;
}
bool wxButton::IsOwnGtkWindow( GdkWindow *window )
{
#ifdef __WXGTK20__
return GTK_BUTTON(m_widget)->event_window;
#else
return (window == m_widget->window);
#endif
}
void wxButton::ApplyWidgetStyle()
{
SetWidgetStyle();

View File

@@ -13,6 +13,7 @@
#endif
#include "wx/gdicmn.h"
#include "wx/gtk/private.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
@@ -167,7 +168,7 @@ void wxColour::InitFromName( const wxString &colourName )
{
m_refData = new wxColourRefData();
if (!gdk_color_parse( colourName.mb_str(), &M_COLDATA->m_color ))
if (!gdk_color_parse( wxGTK_CONV( colourName ), &M_COLDATA->m_color ))
{
// VZ: asserts are good in general but this one is triggered by
// calling wxColourDatabase::FindColour() with an
@@ -217,11 +218,13 @@ void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue )
{
AllocExclusive();
m_refData = new wxColourRefData();
M_COLDATA->m_color.red = ((unsigned short)red) << SHIFT;
M_COLDATA->m_color.green = ((unsigned short)green) << SHIFT;
M_COLDATA->m_color.blue = ((unsigned short)blue) << SHIFT;
M_COLDATA->m_color.pixel = 0;
M_COLDATA->m_colormap = (GdkColormap*) NULL;
M_COLDATA->m_hasPixel = FALSE;
}
unsigned char wxColour::Red() const

View File

@@ -209,6 +209,17 @@ wxComboBox::~wxComboBox()
m_clientDataList.Clear();
}
void wxComboBox::SetFocus()
{
if ( m_hasFocus )
{
// don't do anything if we already have focus
return;
}
gtk_widget_grab_focus( m_focusWidget );
}
void wxComboBox::AppendCommon( const wxString &item )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
@@ -364,8 +375,14 @@ int wxComboBox::FindString( const wxString &item )
{
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
if (item == wxString(label->label,*wxConvCurrent))
#ifdef __WXGTK20__
wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
#else
wxString str( label->label );
#endif
if (item == str)
return count;
count++;
child = child->next;
}
@@ -408,7 +425,7 @@ wxString wxComboBox::GetString( int n ) const
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
#ifdef __WXGTK20__
str = wxGTK_CONV_BACK( gtk_label_get_text( label) );
str = wxGTK_CONV_BACK( gtk_label_get_text(label) );
#else
str = wxString( label->label );
#endif
@@ -431,7 +448,12 @@ wxString wxComboBox::GetStringSelection() const
if (selection)
{
GtkBin *bin = GTK_BIN( selection->data );
wxString tmp = wxString(GTK_LABEL( bin->child )->label,*wxConvCurrent);
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;
}

View File

@@ -158,6 +158,11 @@ wxDataObject::wxDataObject()
{
}
wxDataObject::~wxDataObject()
{
// dtor is empty but needed for Darwin and AIX -- otherwise it doesn't link
}
bool wxDataObject::IsSupportedFormat(const wxDataFormat& format, Direction dir) const
{
size_t nFormatCount = GetFormatCount(dir);

View File

@@ -330,12 +330,7 @@ wxWindowDC::wxWindowDC( wxWindow *window )
wxASSERT_MSG( widget, wxT("DC needs a widget") );
#ifdef __WXGTK20__
m_context = gtk_widget_get_pango_context( widget );
// Always take Xft context to get matching fonts
// for display and printing.
// m_context = pango_xft_get_context (GDK_DISPLAY (), DefaultScreen (GDK_DISPLAY ()));
m_context = window->GtkGetPangoDefaultContext();
m_fontdesc = widget->style->font_desc;
#endif
@@ -1414,19 +1409,23 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
wxCHECK_RET( Ok(), wxT("invalid window dc") );
if (!m_window) return;
if (text.empty()) return;
#ifndef __WXGTK20__
GdkFont *font = m_font.GetInternalFont( m_scaleY );
wxCHECK_RET( font, wxT("invalid font") );
#endif
#if defined(__WXGTK20__)
#ifdef __WXGTK20__
wxCHECK_RET( m_context, wxT("no Pango context") );
#endif
x = XLOG2DEV(x);
y = YLOG2DEV(y);
#if defined(__WXGTK20__)
#ifdef __WXGTK20__
// TODO: the layout engine should be abstracted at a higher level!
PangoLayout *layout = pango_layout_new(m_context);
pango_layout_set_font_description(layout, m_fontdesc);
@@ -1440,12 +1439,17 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data ));
#endif
}
PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
PangoRectangle rect;
pango_layout_line_get_extents(line, NULL, &rect);
wxCoord width = rect.width;
wxCoord height = rect.height;
// Measure layout.
int w,h;
pango_layout_get_pixel_size(layout, &w, &h);
wxCoord width = w;
wxCoord height = h;
// Draw layout.
gdk_draw_layout( m_window, m_textGC, x, y, layout );
g_object_unref( G_OBJECT( layout ) );
#else // GTK+ 1.x
wxCoord width = gdk_string_width( font, text.mbc_str() );
wxCoord height = font->ascent + font->descent;
@@ -1469,9 +1473,6 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
}
#endif // GTK+ 2.0/1.x
#if defined(__WXGTK20__)
g_object_unref( G_OBJECT( layout ) );
#endif
width = wxCoord(width / m_scaleX);
height = wxCoord(height / m_scaleY);
@@ -1596,8 +1597,6 @@ void wxWindowDC::DoGetTextExtent(const wxString &string,
wxCoord *descent, wxCoord *externalLeading,
wxFont *theFont) const
{
wxFont fontToUse = m_font;
if (theFont) fontToUse = *theFont;
if (string.IsEmpty())
{
if (width) (*width) = 0;
@@ -1606,9 +1605,14 @@ void wxWindowDC::DoGetTextExtent(const wxString &string,
}
#ifdef __WXGTK20__
PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description;
// Create layout and set font description
PangoLayout *layout = pango_layout_new(m_context);
pango_layout_set_font_description(layout, desc);
if (theFont)
pango_layout_set_font_description( layout, theFont->GetNativeFontInfo()->description );
else
pango_layout_set_font_description(layout, m_fontdesc);
// Set layout's text
#if wxUSE_UNICODE
const wxCharBuffer data = wxConvUTF8.cWC2MB( string );
pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data ));
@@ -1617,23 +1621,25 @@ void wxWindowDC::DoGetTextExtent(const wxString &string,
const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data ));
#endif
PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
PangoRectangle rect;
pango_layout_line_get_extents(line, NULL, &rect);
// Measure text.
int w,h;
pango_layout_get_pixel_size(layout, &w, &h);
if (width) (*width) = (wxCoord) (rect.width / PANGO_SCALE);
if (height) (*height) = (wxCoord) (rect.height / PANGO_SCALE);
if (width) (*width) = (wxCoord) w;
if (height) (*height) = (wxCoord) h;
if (descent)
{
// Do something about metrics here
// Do something about metrics here. TODO.
(*descent) = 0;
}
if (externalLeading) (*externalLeading) = 0; // ??
g_object_unref( G_OBJECT( layout ) );
#else
wxFont fontToUse = m_font;
if (theFont) fontToUse = *theFont;
GdkFont *font = fontToUse.GetInternalFont( m_scaleY );
if (width) (*width) = wxCoord(gdk_string_width( font, string.mbc_str() ) / m_scaleX);
if (height) (*height) = wxCoord((font->ascent + font->descent) / m_scaleY);
@@ -1644,18 +1650,40 @@ void wxWindowDC::DoGetTextExtent(const wxString &string,
wxCoord wxWindowDC::GetCharWidth() const
{
#ifdef __WXGTK20__
// There should be an easier way.
PangoLayout *layout = pango_layout_new(m_context);
pango_layout_set_font_description(layout, m_fontdesc);
pango_layout_set_text(layout, "H", 1 );
int w,h;
pango_layout_get_pixel_size(layout, &w, &h);
g_object_unref( G_OBJECT( layout ) );
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__
// There should be an easier way.
PangoLayout *layout = pango_layout_new(m_context);
pango_layout_set_font_description(layout, m_fontdesc);
pango_layout_set_text(layout, "H", 1 );
int w,h;
pango_layout_get_pixel_size(layout, &w, &h);
g_object_unref( G_OBJECT( layout ) );
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()
@@ -1705,6 +1733,14 @@ void wxWindowDC::SetFont( const wxFont &font )
m_font = font;
#ifdef __WXGTK20__
m_fontdesc = m_font.GetNativeFontInfo()->description;
if (m_owner)
{
if (m_font.GetNoAntiAliasing())
m_context = m_owner->GtkGetPangoX11Context();
else
m_context = m_owner->GtkGetPangoDefaultContext();
}
#endif
}
@@ -1816,7 +1852,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
gdk_gc_set_dashes( m_penGC, 0, (wxGTKDash*)req_dash, req_nb_dash );
}
}
#endif
#endif // GTK+ > 1.0
GdkCapStyle capStyle = GDK_CAP_ROUND;
switch (m_pen.GetCap())
@@ -1955,12 +1991,12 @@ void wxWindowDC::SetLogicalFunction( int function )
if (!m_window)
return;
GdkFunction mode = GDK_COPY;
GdkFunction mode;
switch (function)
{
case wxXOR: mode = GDK_XOR; break;
case wxINVERT: mode = GDK_INVERT; break;
#if (GTK_MINOR_VERSION > 0)
#if (GTK_MINOR_VERSION > 0) || (GTK_MAJOR_VERSION > 1)
case wxOR_REVERSE: mode = GDK_OR_REVERSE; break;
case wxAND_REVERSE: mode = GDK_AND_REVERSE; break;
case wxCLEAR: mode = GDK_CLEAR; break;
@@ -1977,12 +2013,10 @@ void wxWindowDC::SetLogicalFunction( int function )
// unsupported by GTK
case wxNOR: mode = GDK_COPY; break;
#endif
#endif // GTK+ > 1.0
default:
{
wxFAIL_MSG( wxT("unsupported logical function") );
break;
}
mode = GDK_COPY;
}
m_logicalFunction = function;

View File

@@ -30,8 +30,6 @@ extern void wxapp_install_idle_handler();
extern bool g_isIdle;
extern int g_openDialogs;
//-----------------------------------------------------------------------------
// wxDialog
//-----------------------------------------------------------------------------
@@ -209,9 +207,11 @@ int wxDialog::ShowModal()
}
wxBusyCursorSuspender cs; // temporarily suppress the busy cursor
Show( TRUE );
SetFocus();
m_modalShowing = TRUE;
g_openDialogs++;

View File

@@ -265,7 +265,6 @@ ALL_SOURCES = \
html/m_layout.cpp \
html/m_links.cpp \
html/m_list.cpp \
html/m_meta.cpp \
html/m_pre.cpp \
html/m_style.cpp \
html/m_tables.cpp \
@@ -636,7 +635,6 @@ ALL_HEADERS = \
protocol/protocol.h
COMMONOBJS = \
parser.o \
appcmn.o \
artprov.o \
artstd.o \
@@ -984,7 +982,6 @@ HTMLOBJS = \
m_layout.o \
m_links.o \
m_list.o \
m_meta.o \
m_pre.o \
m_style.o \
m_tables.o \

View File

@@ -93,6 +93,9 @@ public:
void SetFaceName(const wxString& facename);
void SetEncoding(wxFontEncoding encoding);
void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; }
bool GetNoAntiAliasing() { return m_noAA; }
// and this one also modifies all the other font data fields
void SetNativeFontInfo(const wxNativeFontInfo& info);
@@ -130,17 +133,14 @@ protected:
void InitFromNative();
private:
#ifdef __WXGTK20__
void ClearGdkFonts() { }
#else // GTK 1.x
// clear m_scaled_xfonts
// 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
// the broken down font parameters
int m_pointSize;
int m_family,
m_style,
@@ -148,6 +148,7 @@ private:
bool m_underlined;
wxString m_faceName;
wxFontEncoding m_encoding; // Unused under GTK 2.0
bool m_noAA; // No anti-aliasing
// The native font info, basicly an XFLD under GTK 1.2 and
// the pango font description under GTK 2.0.
@@ -156,12 +157,8 @@ private:
friend class wxFont;
};
// ============================================================================
// wxFontRefData implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxFontRefData creation
// wxFontRefData
// ----------------------------------------------------------------------------
void wxFontRefData::Init(int pointSize,
@@ -188,25 +185,37 @@ void wxFontRefData::Init(int pointSize,
m_underlined = underlined;
m_encoding = encoding;
m_noAA = FALSE;
#ifdef __WXGTK20__
// Create native font info
m_nativeFontInfo.description = pango_font_description_new();
// And set its values
switch (m_family)
if (!m_faceName.empty())
{
case wxFONTFAMILY_MODERN:
case wxFONTFAMILY_TELETYPE:
pango_font_description_set_family( m_nativeFontInfo.description, "monospace" );
break;
case wxFONTFAMILY_SWISS:
pango_font_description_set_family( m_nativeFontInfo.description, "serif" );
break;
default:
pango_font_description_set_family( m_nativeFontInfo.description, "sans" );
break;
pango_font_description_set_family( m_nativeFontInfo.description, wxGTK_CONV(m_faceName) );
}
else
{
switch (m_family)
{
case wxFONTFAMILY_MODERN:
case wxFONTFAMILY_TELETYPE:
pango_font_description_set_family( m_nativeFontInfo.description, "monospace" );
break;
case wxFONTFAMILY_ROMAN:
pango_font_description_set_family( m_nativeFontInfo.description, "serif" );
break;
case wxFONTFAMILY_SWISS:
// SWISS = sans serif
default:
pango_font_description_set_family( m_nativeFontInfo.description, "sans" );
break;
}
}
SetStyle( m_style );
SetPointSize( m_pointSize );
SetWeight( m_weight );
@@ -215,6 +224,8 @@ void wxFontRefData::Init(int pointSize,
void wxFontRefData::InitFromNative()
{
m_noAA = FALSE;
#ifdef __WXGTK20__
// Get native info
PangoFontDescription *desc = m_nativeFontInfo.description;
@@ -267,6 +278,10 @@ void wxFontRefData::InitFromNative()
{
m_family = wxFONTFAMILY_SWISS;
}
else if (m_faceName == wxT("serif"))
{
m_family = wxFONTFAMILY_ROMAN;
}
else
{
m_family = wxFONTFAMILY_UNKNOWN;
@@ -391,6 +406,8 @@ wxFontRefData::wxFontRefData( const wxFontRefData& data )
m_faceName = data.m_faceName;
m_encoding = data.m_encoding;
m_noAA = data.m_noAA;
m_nativeFontInfo = data.m_nativeFontInfo;
}
@@ -414,9 +431,9 @@ wxFontRefData::wxFontRefData(const wxString& fontname)
InitFromNative();
}
#ifndef __WXGTK20__
void wxFontRefData::ClearGdkFonts()
{
#ifndef __WXGTK20__
for ( wxScaledFontList::iterator i = m_scaled_xfonts.begin();
i != m_scaled_xfonts.end();
++i )
@@ -426,8 +443,8 @@ void wxFontRefData::ClearGdkFonts()
}
m_scaled_xfonts.clear();
}
#endif // GTK 1.x
}
wxFontRefData::~wxFontRefData()
{
@@ -522,7 +539,27 @@ void wxFontRefData::SetWeight(int weight)
{
m_weight = weight;
#ifndef __WXGTK20__
#ifdef __WXGTK20__
PangoFontDescription *desc = m_nativeFontInfo.description;
switch ( weight )
{
case wxFONTWEIGHT_BOLD:
pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
break;
case wxFONTWEIGHT_LIGHT:
pango_font_description_set_weight(desc, PANGO_WEIGHT_LIGHT);
break;
default:
wxFAIL_MSG( _T("unknown font weight") );
// fall through
case wxFONTWEIGHT_NORMAL:
// unspecified
pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL);
}
#else //!__WXGTK20__
if ( HasNativeFont() )
{
wxString boldness;
@@ -597,10 +634,6 @@ void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info)
InitFromNative();
}
// ============================================================================
// wxFont implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxFont creation
// ----------------------------------------------------------------------------
@@ -624,7 +657,7 @@ wxFont::wxFont(const wxNativeFontInfo& info)
info.GetFaceName(),
info.GetEncoding() );
#else
Create(info.GetXFontName());
(void) Create(info.GetXFontName());
#endif
}
@@ -636,6 +669,8 @@ bool wxFont::Create( int pointSize,
const wxString& face,
wxFontEncoding encoding)
{
UnRef();
m_refData = new wxFontRefData(pointSize, family, style, weight,
underlined, face, encoding);
@@ -679,9 +714,6 @@ wxFont::~wxFont()
// accessors
// ----------------------------------------------------------------------------
// all accessors are just forwarded to wxFontRefData which has everything we
// need
int wxFont::GetPointSize() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
@@ -731,6 +763,13 @@ wxFontEncoding wxFont::GetEncoding() const
return M_FONTDATA->m_encoding;
}
bool wxFont::GetNoAntiAliasing()
{
wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
return M_FONTDATA->m_noAA;
}
wxNativeFontInfo *wxFont::GetNativeFontInfo() const
{
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
@@ -814,11 +853,18 @@ void wxFont::SetEncoding(wxFontEncoding encoding)
M_FONTDATA->SetEncoding(encoding);
}
void wxFont::SetNativeFontInfo(const wxNativeFontInfo& info)
void wxFont::SetNativeFontInfo( const wxNativeFontInfo& info )
{
Unshare();
M_FONTDATA->SetNativeFontInfo(info);
M_FONTDATA->SetNativeFontInfo( info );
}
void wxFont::SetNoAntiAliasing( bool no )
{
Unshare();
M_FONTDATA->SetNoAntiAliasing( no );
}
// ----------------------------------------------------------------------------

View File

@@ -77,7 +77,7 @@ void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dial
// printf( "font %s\n", fontname );
dialog->SetChosenFont(fontname);
dialog->SetChosenFont( fontname);
g_free( fontname );
@@ -181,7 +181,7 @@ wxFontDialog::~wxFontDialog()
void wxFontDialog::SetChosenFont(const char *fontname)
{
m_fontData.SetChosenFont(wxFont(fontname));
m_fontData.SetChosenFont(wxFont( wxString::FromAscii(fontname) ));
}
#endif // wxUSE_FONTDLG

View File

@@ -45,7 +45,6 @@
// constants
// ----------------------------------------------------------------------------
const int wxMENU_HEIGHT = 27;
const int wxSTATUS_HEIGHT = 25;
const int wxPLACE_HOLDER = 0;
@@ -165,7 +164,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
child->m_y,
child->m_width,
child->m_height );
#if wxUSE_TOOLBAR_NATIVE
// We connect to these events for recalculating the client area
// space when the toolbar is floating
@@ -193,7 +192,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
child->m_width,
child->m_height );
}
// Resize on OnInternalIdle
parent->GtkUpdateSize();
}
@@ -206,6 +205,7 @@ void wxFrame::Init()
{
m_menuBarDetached = FALSE;
m_toolBarDetached = FALSE;
m_menuBarHeight = 2;
}
bool wxFrame::Create( wxWindow *parent,
@@ -219,6 +219,7 @@ bool wxFrame::Create( wxWindow *parent,
bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig,
style, name);
m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
return rt;
}
@@ -245,7 +246,7 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const
if (m_frameMenuBar)
{
if (!m_menuBarDetached)
(*height) -= wxMENU_HEIGHT;
(*height) -= m_menuBarHeight;
else
(*height) -= wxPLACE_HOLDER;
}
@@ -292,7 +293,7 @@ void wxFrame::DoSetClientSize( int width, int height )
if (m_frameMenuBar)
{
if (!m_menuBarDetached)
height += wxMENU_HEIGHT;
height += m_menuBarHeight;
else
height += wxPLACE_HOLDER;
}
@@ -396,7 +397,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
int xx = m_miniEdge;
int yy = m_miniEdge + m_miniTitle;
int ww = m_width - 2*m_miniEdge;
int hh = wxMENU_HEIGHT;
int hh = m_menuBarHeight;
if (m_menuBarDetached) hh = wxPLACE_HOLDER;
m_frameMenuBar->m_x = xx;
m_frameMenuBar->m_y = yy;
@@ -419,7 +420,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
if (m_frameMenuBar)
{
if (!m_menuBarDetached)
yy += wxMENU_HEIGHT;
yy += m_menuBarHeight;
else
yy += wxPLACE_HOLDER;
}
@@ -576,11 +577,34 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached",
GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
}
m_frameMenuBar->Show( TRUE );
}
// resize window in OnInternalIdle
UpdateMenuBarSize();
}
else
{
m_menuBarHeight = 2;
GtkUpdateSize(); // resize window in OnInternalIdle
}
}
void wxFrame::UpdateMenuBarSize()
{
wxASSERT_MSG( m_frameMenuBar, _T("Updating non existant menubar?") );
GtkRequisition req;
req.width = 2;
req.height = 2;
(* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_frameMenuBar->m_widget) )->size_request )
(m_frameMenuBar->m_widget, &req );
m_menuBarHeight = req.height;
// resize window in OnInternalIdle
GtkUpdateSize();
}

View File

@@ -15,18 +15,22 @@
#if wxUSE_GAUGE
#include <gdk/gdk.h>
#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// wxGauge
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range,
const wxPoint& pos, const wxSize& size,
long style, const wxValidator& validator, const wxString& name )
bool wxGauge::Create( wxWindow *parent,
wxWindowID id,
int range,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name )
{
m_needParent = TRUE;
@@ -38,12 +42,13 @@ bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range,
}
m_rangeMax = range;
m_gaugePos = 0;
m_useProgressBar = TRUE;
m_widget = gtk_progress_bar_new();
if( style & wxGA_VERTICAL)
gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget) , GTK_PROGRESS_BOTTOM_TO_TOP );
if ( style & wxGA_VERTICAL )
{
gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget),
GTK_PROGRESS_BOTTOM_TO_TOP );
}
m_parent->DoAddChild( this );
@@ -54,20 +59,31 @@ bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range,
return TRUE;
}
void wxGauge::SetRange( int r )
void wxGauge::DoSetGauge()
{
m_rangeMax = r;
if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
wxASSERT_MSG( 0 <= m_gaugePos && m_gaugePos <= m_rangeMax,
_T("invalid gauge position in DoSetGauge()") );
gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget),
m_rangeMax ? ((float)m_gaugePos)/m_rangeMax : 0.);
}
void wxGauge::SetRange( int range )
{
m_rangeMax = range;
if (m_gaugePos > m_rangeMax)
m_gaugePos = m_rangeMax;
DoSetGauge();
}
void wxGauge::SetValue( int pos )
{
m_gaugePos = pos;
if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
wxCHECK_RET( pos <= m_rangeMax, _T("invalid value in wxGauge::SetValue()") );
gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
m_gaugePos = pos;
DoSetGauge();
}
int wxGauge::GetRange() const

View File

@@ -1,12 +1,12 @@
/////////////////////////////////////////////////////////////////////////////
// Name: glcanvas.cpp
// Name: gtk/glcanvas.cpp
// Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK
// Author: Robert Roebling
// Modified by:
// Created: 17/08/98
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -24,7 +24,8 @@
#include "wx/module.h"
#include "wx/app.h"
extern "C" {
extern "C"
{
#include "gtk/gtk.h"
#include "gdk/gdk.h"
#include "gdk/gdkx.h"
@@ -58,16 +59,16 @@ wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, const wxPalette&
wxGLCanvas *gc = (wxGLCanvas*) win;
XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
wxCHECK_RET( vi, "invalid visual for OpenGl" );
wxCHECK_RET( vi, _T("invalid visual for OpenGl") );
m_glContext = glXCreateContext( GDK_DISPLAY(), vi, None, GL_TRUE );
wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
wxCHECK_RET( m_glContext, _T("Couldn't create OpenGl context") );
}
wxGLContext::wxGLContext(
bool WXUNUSED(isRGB), wxWindow *win,
wxGLContext::wxGLContext(
bool WXUNUSED(isRGB), wxWindow *win,
const wxPalette& WXUNUSED(palette),
const wxGLContext *other /* for sharing display lists */
)
@@ -77,26 +78,28 @@ wxGLContext::wxGLContext(
wxGLCanvas *gc = (wxGLCanvas*) win;
XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
wxCHECK_RET( vi, "invalid visual for OpenGl" );
if( other != 0 )
m_glContext = glXCreateContext( GDK_DISPLAY(), vi, other->m_glContext, GL_TRUE );
else
m_glContext = glXCreateContext( GDK_DISPLAY(), vi, None, GL_TRUE );
wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
wxCHECK_RET( vi, _T("invalid visual for OpenGl") );
m_glContext = glXCreateContext( GDK_DISPLAY(), vi,
other ? other->m_glContext : None,
GL_TRUE );
if ( !m_glContext )
{
wxFAIL_MSG( _T("Couldn't create OpenGl context") );
}
}
wxGLContext::~wxGLContext()
{
if (!m_glContext) return;
if (m_glContext == glXGetCurrentContext())
{
glXMakeCurrent( GDK_DISPLAY(), None, NULL);
}
glXDestroyContext( GDK_DISPLAY(), m_glContext );
}
@@ -111,14 +114,14 @@ void wxGLContext::SwapBuffers()
void wxGLContext::SetCurrent()
{
if (m_glContext)
{
if (m_glContext)
{
GdkWindow *window = GTK_PIZZA(m_widget)->bin_window;
glXMakeCurrent( GDK_DISPLAY(), GDK_WINDOW_XWINDOW(window), m_glContext );
}
}
void wxGLContext::SetColour(const char *colour)
void wxGLContext::SetColour(const wxChar *colour)
{
float r = 0.0;
float g = 0.0;
@@ -185,10 +188,10 @@ gtk_glwindow_map_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win )
// "expose_event" of m_wxwindow
//-----------------------------------------------------------------------------
static void
static void
gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxGLCanvas *win )
{
if (g_isIdle)
if (g_isIdle)
wxapp_install_idle_handler();
win->m_exposed = TRUE;
@@ -203,10 +206,10 @@ gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_e
// "draw" of m_wxwindow
//-----------------------------------------------------------------------------
static void
static void
gtk_glwindow_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxGLCanvas *win )
{
if (g_isIdle)
if (g_isIdle)
wxapp_install_idle_handler();
win->m_exposed = TRUE;
@@ -219,7 +222,7 @@ gtk_glwindow_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxG
// "size_allocate" of m_wxwindow
//-----------------------------------------------------------------------------
static void
static void
gtk_glcanvas_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxGLCanvas *win )
{
if (g_isIdle)
@@ -244,77 +247,80 @@ BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow)
END_EVENT_TABLE()
wxGLCanvas::wxGLCanvas( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
{
Create( parent, NULL, NULL, id, pos, size, style, name, attribList, palette );
}
wxGLCanvas::wxGLCanvas( wxWindow *parent,
wxGLCanvas::wxGLCanvas( wxWindow *parent,
const wxGLContext *shared,
wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
{
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
{
Create( parent, shared, NULL, id, pos, size, style, name, attribList, palette );
}
wxGLCanvas::wxGLCanvas( wxWindow *parent,
wxGLCanvas::wxGLCanvas( wxWindow *parent,
const wxGLCanvas *shared,
wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
{
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
{
Create( parent, NULL, shared, id, pos, size, style, name, attribList, palette );
}
bool wxGLCanvas::Create( wxWindow *parent,
bool wxGLCanvas::Create( wxWindow *parent,
const wxGLContext *shared,
const wxGLCanvas *shared_context_of,
wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette)
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette)
{
m_sharedContext = (wxGLContext*)shared; // const_cast
m_sharedContextOf = (wxGLCanvas*)shared_context_of; // const_cast
m_glContext = (wxGLContext*) NULL;
m_exposed = FALSE;
m_noExpose = TRUE;
m_nativeSizeEvent = TRUE;
XVisualInfo *vi = NULL;
if (wxTheApp->m_glVisualInfo != NULL) {
vi = (XVisualInfo *) wxTheApp->m_glVisualInfo;
if (wxTheApp->m_glVisualInfo != NULL)
{
vi = (XVisualInfo *) wxTheApp->m_glVisualInfo;
m_canFreeVi = FALSE; // owned by wxTheApp - don't free upon destruction
} else {
}
else
{
vi = (XVisualInfo *) ChooseGLVisual(attribList);
m_canFreeVi = TRUE;
}
m_vi = vi; // save for later use
wxCHECK_MSG( m_vi, FALSE, "required visual couldn't be found" );
wxCHECK_MSG( m_vi, FALSE, _T("required visual couldn't be found") );
GdkVisual *visual = gdkx_visual_get( vi->visualid );
GdkColormap *colormap = gdk_colormap_new( gdkx_visual_get(vi->visualid), TRUE );
gtk_widget_push_colormap( colormap );
gtk_widget_push_visual( visual );
wxWindow::Create( parent, id, pos, size, style, name );
m_glWidget = m_wxwindow;
gtk_pizza_set_clear( GTK_PIZZA(m_wxwindow), FALSE );
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize",
GTK_SIGNAL_FUNC(gtk_glwindow_realized_callback), (gpointer) this );
@@ -326,26 +332,26 @@ bool wxGLCanvas::Create( wxWindow *parent,
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
GTK_SIGNAL_FUNC(gtk_glwindow_draw_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_glcanvas_size_callback), (gpointer)this );
gtk_widget_pop_visual();
gtk_widget_pop_colormap();
if (GTK_WIDGET_REALIZED(m_wxwindow))
gtk_glwindow_realized_callback( m_wxwindow, this );
if (GTK_WIDGET_MAPPED(m_wxwindow))
gtk_glwindow_map_callback( m_wxwindow, this );
return TRUE;
}
wxGLCanvas::~wxGLCanvas()
{
XVisualInfo *vi = (XVisualInfo *) m_vi;
if (vi && m_canFreeVi) XFree( vi );
if (m_glContext) delete m_glContext;
}
@@ -365,12 +371,12 @@ void* wxGLCanvas::ChooseGLVisual(int *attribList)
data[10] = GLX_ALPHA_SIZE; data[11] = 0;
data[12] = None;
attribList = (int*) data;
attribList = (int*) data;
}
else
{
int arg=0, p=0;
while( (attribList[arg]!=0) && (p<510) )
{
switch( attribList[arg++] )
@@ -392,9 +398,9 @@ void* wxGLCanvas::ChooseGLVisual(int *attribList)
data[p++]=GLX_BLUE_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ALPHA:
data[p++]=GLX_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_DEPTH_SIZE:
case WX_GL_DEPTH_SIZE:
data[p++]=GLX_DEPTH_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_STENCIL_SIZE:
case WX_GL_STENCIL_SIZE:
data[p++]=GLX_STENCIL_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ACCUM_RED:
data[p++]=GLX_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break;
@@ -407,21 +413,22 @@ void* wxGLCanvas::ChooseGLVisual(int *attribList)
default:
break;
}
}
data[p] = 0;
}
data[p] = 0;
attribList = (int*) data;
}
Display *dpy = GDK_DISPLAY();
return glXChooseVisual( dpy, DefaultScreen(dpy), attribList );
}
void wxGLCanvas::SwapBuffers()
{
if (m_glContext) m_glContext->SwapBuffers();
if (m_glContext)
m_glContext->SwapBuffers();
}
void wxGLCanvas::OnSize(wxSizeEvent& WXUNUSED(event))
@@ -430,12 +437,14 @@ void wxGLCanvas::OnSize(wxSizeEvent& WXUNUSED(event))
void wxGLCanvas::SetCurrent()
{
if (m_glContext) m_glContext->SetCurrent();
if (m_glContext)
m_glContext->SetCurrent();
}
void wxGLCanvas::SetColour( const char *colour )
void wxGLCanvas::SetColour( const wxChar *colour )
{
if (m_glContext) m_glContext->SetColour( colour );
if (m_glContext)
m_glContext->SetColour( colour );
}
void wxGLCanvas::OnInternalIdle()
@@ -449,7 +458,7 @@ void wxGLCanvas::OnInternalIdle()
m_exposed = FALSE;
GetUpdateRegion().Clear();
}
wxWindow::OnInternalIdle();
}
@@ -460,17 +469,21 @@ void wxGLCanvas::OnInternalIdle()
//---------------------------------------------------------------------------
IMPLEMENT_CLASS(wxGLApp, wxApp)
wxGLApp::~wxGLApp()
{
if (m_glVisualInfo) XFree(m_glVisualInfo);
if (m_glVisualInfo)
XFree(m_glVisualInfo);
}
bool wxGLApp::InitGLVisual(int *attribList)
{
if (m_glVisualInfo) XFree(m_glVisualInfo);
if (m_glVisualInfo)
XFree(m_glVisualInfo);
m_glVisualInfo = wxGLCanvas::ChooseGLVisual(attribList);
return (m_glVisualInfo != NULL);
return m_glVisualInfo != NULL;
}
#endif

View File

@@ -1057,7 +1057,7 @@ wxSize wxListBox::DoGetBestSize() const
// And just a bit more
int cx, cy;
GetTextExtent("X", &cx, &cy);
GetTextExtent( wxT("X"), &cx, &cy);
lbWidth += 3 * cx;
// don't make the listbox too tall (limit height to around 10 items) but don't

View File

@@ -113,9 +113,16 @@ static wxString wxReplaceUnderscore( const wxString& title )
/* GTK 1.2 wants to have "_" instead of "&" for accelerators */
wxString str;
for ( pc = title; *pc != wxT('\0'); pc++ )
pc = title;
while (*pc != wxT('\0'))
{
if (*pc == wxT('&'))
if ((*pc == wxT('&')) && (*(pc+1) == wxT('&')))
{
// "&" is doubled to indicate "&" instead of accelerator
++pc;
str << wxT('&');
}
else if (*pc == wxT('&'))
{
#if GTK_CHECK_VERSION(1, 2, 0)
str << wxT('_');
@@ -149,6 +156,7 @@ static wxString wxReplaceUnderscore( const wxString& title )
str << *pc;
}
++pc;
}
return str;
}
@@ -385,10 +393,23 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title)
#endif
// m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables
// adding menu later on.
// addings menu later on.
if (m_invokingWindow)
{
wxMenubarSetInvokingWindow( menu, m_invokingWindow );
// OPTIMISE ME: we should probably cache this, or pass it
// directly, but for now this is a minimal
// change to validate the new dynamic sizing.
// see (and refactor :) similar code in Remove
// below.
wxFrame *frame = wxDynamicCast( m_invokingWindow, wxFrame );
if( frame )
frame->UpdateMenuBarSize();
}
return TRUE;
}
@@ -452,6 +473,16 @@ wxMenu *wxMenuBar::Remove(size_t pos)
printf( "menu shell entries after %d\n", (int)g_list_length( menu_shell->children ) );
*/
if (m_invokingWindow)
{
// OPTIMISE ME: see comment in GtkAppend
wxFrame *frame = wxDynamicCast( m_invokingWindow, wxFrame );
if( frame )
frame->UpdateMenuBarSize();
}
return menu;
}
@@ -554,10 +585,9 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const
wxString text( menu->GetTitle() );
for ( const wxChar *pc = text.c_str(); *pc; pc++ )
{
if ( *pc == wxT('_') || *pc == wxT('&') )
if ( *pc == wxT('_') )
{
// '_' is the escape character for GTK+ and '&' is the one for
// wxWindows - skip both of them
// '_' is the escape character for GTK+
continue;
}
@@ -750,17 +780,21 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
{
if ( *pc == wxT('_') )
{
// wxGTK escapes "xxx_xxx" to "xxx__xxx"
// GTK 1.2 escapes "xxx_xxx" to "xxx__xxx"
pc++;
label += *pc;
continue;
}
if ( *pc == wxT('&') )
#if GTK_CHECK_VERSION(2, 0, 0)
if ( *pc == wxT('\\') )
{
// wxMSW escapes &
// GTK 2.0 escapes "xxx/xxx" to "xxx\/xxx"
pc++;
label += *pc;
continue;
}
#endif
label += *pc;
}
@@ -784,42 +818,54 @@ void wxMenuItem::SetText( const wxString& str )
{
GtkLabel *label;
if (m_labelWidget)
label = (GtkLabel*) m_labelWidget;
label = (GtkLabel*) m_labelWidget;
else
label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
/* set new text */
#if GTK_CHECK_VERSION(2, 0, 0)
// We have to imitate item_factory_unescape_label here
wxString tmp;
for (size_t n = 0; n < m_text.Len(); n++)
{
if (m_text[n] != wxT('\\'))
tmp += m_text[n];
}
gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV(tmp) );
#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 ) );
// reparse key accel
(void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
#endif
}
}
// it's valid for this function to be called even if m_menuItem == NULL
void wxMenuItem::DoSetText( const wxString& str )
{
/* '\t' is the deliminator indicating a hot key */
// '\t' is the deliminator indicating a hot key
m_text.Empty();
const wxChar *pc = str;
for (; (*pc != wxT('\0')) && (*pc != wxT('\t')); pc++ )
while ( (*pc != wxT('\0')) && (*pc != wxT('\t')) )
{
#if GTK_CHECK_VERSION(1, 2, 0)
if (*pc == wxT('&'))
if ((*pc == wxT('&')) && (*(pc+1) == wxT('&')))
{
// "&" is doubled to indicate "&" instead of accelerator
++pc;
m_text << wxT('&');
}
else if (*pc == wxT('&'))
{
m_text << wxT('_');
}
#if GTK_CHECK_VERSION(2, 0, 0)
else if ( *pc == wxT('_') ) // escape underscores
{
m_text << wxT("__");
// m_text << wxT("__"); doesn't work
}
#else // GTK+ < 1.2.0
if (*pc == wxT('&'))
{
}
#endif
#if GTK_CHECK_VERSION(2, 0, 0)
else if (*pc == wxT('/')) // we have to escape slashes
{
m_text << wxT("\\/");
@@ -828,16 +874,22 @@ void wxMenuItem::DoSetText( const wxString& str )
{
m_text << wxT("\\\\");
}
#elif GTK_CHECK_VERSION(1, 2, 0)
#else
else if ( *pc == wxT('_') ) // escape underscores
{
m_text << wxT("__");
}
else if (*pc == wxT('/')) /* we have to filter out slashes ... */
{
m_text << wxT('\\'); /* ... and replace them with back slashes */
}
#endif
else
else {
m_text << *pc;
}
++pc;
}
m_hotKey = wxT("");
if(*pc == wxT('\t'))
@@ -913,9 +965,9 @@ wxString wxMenuItem::GetFactoryPath() const
for ( const wxChar *pc = m_text.c_str(); *pc; pc++ )
{
if ( *pc == wxT('_') || *pc == wxT('&') )
if ( *pc == wxT('_') )
{
// remove '_' and '&' unconditionally
// remove '_' unconditionally
continue;
}
@@ -1042,7 +1094,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuItem);
if (accel_key != GDK_VoidSymbol)
{
{
gtk_widget_add_accelerator (menuItem,
"activate_item",
gtk_menu_ensure_uline_accel_group (GTK_MENU (m_menu)),
@@ -1060,6 +1112,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
(gpointer)this );
gtk_menu_append( GTK_MENU(m_menu), menuItem );
gtk_widget_show( menuItem );
@@ -1097,7 +1150,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
{
// start of a new radio group
item_type = "<RadioItem>";
m_pathLastRadio = bufPath + 1;
wxString tmp( wxGTK_CONV_BACK( bufPath ) );
tmp.Remove(0,1);
m_pathLastRadio = tmp;
}
else // continue the radio group
{
@@ -1143,10 +1198,15 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
wxString path( mitem->GetFactoryPath() );
menuItem = gtk_item_factory_get_widget( m_factory, wxGTK_CONV( path ) );
if (!menuItem)
wxLogError( wxT("Wrong menu path: %s\n"), path.c_str() );
}
if ( !mitem->IsSeparator() )
{
wxASSERT_MSG( menuItem, wxT("invalid menuitem") );
gtk_signal_connect( GTK_OBJECT(menuItem), "select",
GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
(gpointer)this );
@@ -1283,6 +1343,33 @@ static wxString GetHotKey( const wxMenuItem& item )
case WXK_DELETE:
hotkey << wxT("Delete" );
break;
case WXK_UP:
hotkey << wxT("Up" );
break;
case WXK_DOWN:
hotkey << wxT("Down" );
break;
case WXK_PAGEUP:
hotkey << wxT("Prior" );
break;
case WXK_PAGEDOWN:
hotkey << wxT("Next" );
break;
case WXK_LEFT:
hotkey << wxT("Left" );
break;
case WXK_RIGHT:
hotkey << wxT("Right" );
break;
case WXK_HOME:
hotkey << wxT("Home" );
break;
case WXK_END:
hotkey << wxT("End" );
break;
case WXK_RETURN:
hotkey << wxT("Return" );
break;
// if there are any other keys wxGetAccelFromString() may
// return, we should process them here
@@ -1290,7 +1377,7 @@ static wxString GetHotKey( const wxMenuItem& item )
default:
if ( code < 127 )
{
gchar *name = gdk_keyval_name((guint)code);
wxString name = wxGTK_CONV_BACK( gdk_keyval_name((guint)code) );
if ( name )
{
hotkey << name;

View File

@@ -86,14 +86,12 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
gint page,
wxNotebook *notebook )
{
static bool s_inPageChange = FALSE;
// are you trying to call SetSelection() from a notebook event handler?
// you shouldn't!
wxCHECK_RET( !s_inPageChange,
wxCHECK_RET( !notebook->m_inSwitchPage,
_T("gtk_notebook_page_change_callback reentered") );
s_inPageChange = TRUE;
notebook->m_inSwitchPage = TRUE;
if (g_isIdle)
wxapp_install_idle_handler();
@@ -123,7 +121,7 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
notebook->GetEventHandler()->ProcessEvent( eventChanged );
}
s_inPageChange = FALSE;
notebook->m_inSwitchPage = FALSE;
}
//-----------------------------------------------------------------------------
@@ -236,6 +234,8 @@ END_EVENT_TABLE()
void wxNotebook::Init()
{
m_padding = 0;
m_inSwitchPage = FALSE;
m_imageList = (wxImageList *) NULL;
m_pagesData.DeleteContents( TRUE );
m_selection = -1;

View File

@@ -160,7 +160,7 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
m_needParent = FALSE;
if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
!CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, "popup" ))
!CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("popup") ))
{
wxFAIL_MSG( wxT("wxPopupWindow creation failed") );
return FALSE;

View File

@@ -418,7 +418,7 @@ bool wxRadioBox::Show( bool show )
return TRUE;
}
int wxRadioBox::FindString( const wxString &s ) const
int wxRadioBox::FindString( const wxString &find ) const
{
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") );
@@ -428,7 +428,12 @@ int wxRadioBox::FindString( const wxString &s ) const
while (node)
{
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
if (s == label->label)
#ifdef __WXGTK20__
wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
#else
wxString str( label->label );
#endif
if (find == str)
return count;
count++;
@@ -505,7 +510,13 @@ wxString wxRadioBox::GetString( int n ) const
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
return wxString( label->label );
#ifdef __WXGTK20__
wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
#else
wxString str( label->label );
#endif
return str;
}
void wxRadioBox::SetLabel( const wxString& label )
@@ -592,7 +603,12 @@ wxString wxRadioBox::GetStringSelection() const
{
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
return label->label;
#ifdef __WXGTK20__
wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
#else
wxString str( label->label );
#endif
return str;
}
node = node->Next();
}

View File

@@ -191,25 +191,20 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
if ( !width || !height )
return TRUE;
GdkRectangle rect;
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
if (!m_refData)
if ( !m_refData )
{
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
InitRect(x, y, width, height);
}
else
{
AllocExclusive();
GdkRectangle rect;
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
#ifdef __WXGTK20__
gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
#else
@@ -274,16 +269,11 @@ bool wxRegion::Intersect( const wxRegion& region )
if (!m_refData)
{
m_refData = new wxRegionRefData();
M_REGIONDATA->m_region = gdk_region_new();
// intersecting with invalid region doesn't make sense
return FALSE;
}
// leave here
return TRUE;
}
else
{
AllocExclusive();
}
AllocExclusive();
#ifdef __WXGTK20__
gdk_region_intersect( M_REGIONDATA->m_region, region.GetRegion() );
@@ -315,14 +305,12 @@ bool wxRegion::Subtract( const wxRegion& region )
if (!m_refData)
{
m_refData = new wxRegionRefData();
M_REGIONDATA->m_region = gdk_region_new();
}
else
{
AllocExclusive();
// subtracting from an invalid region doesn't make sense
return FALSE;
}
AllocExclusive();
#ifdef __WXGTK20__
gdk_region_subtract( M_REGIONDATA->m_region, region.GetRegion() );
#else
@@ -353,14 +341,11 @@ bool wxRegion::Xor( const wxRegion& region )
if (!m_refData)
{
m_refData = new wxRegionRefData();
M_REGIONDATA->m_region = gdk_region_new();
}
else
{
AllocExclusive();
return FALSE;
}
AllocExclusive();
#ifdef __WXGTK20__
gdk_region_xor( M_REGIONDATA->m_region, region.GetRegion() );
#else
@@ -372,6 +357,18 @@ bool wxRegion::Xor( const wxRegion& region )
return TRUE;
}
bool wxRegion::Offset( wxCoord x, wxCoord y )
{
if (!m_refData)
return FALSE;
AllocExclusive();
gdk_region_offset( M_REGIONDATA->m_region, x, y );
return TRUE;
}
// ----------------------------------------------------------------------------
// wxRegion tests
// ----------------------------------------------------------------------------
@@ -403,18 +400,6 @@ wxRect wxRegion::GetBox() const
return wxRect( x, y, w, h );
}
bool wxRegion::Offset( wxCoord x, wxCoord y )
{
if (!m_refData)
return FALSE;
AllocExclusive();
gdk_region_offset( M_REGIONDATA->m_region, x, y );
return TRUE;
}
bool wxRegion::Empty() const
{
if (!m_refData)
@@ -495,7 +480,7 @@ struct _XRegion {
_XBox *rects, extents;
};
#endif
#endif // GTK+ 1.x
class wxRIRefData: public wxObjectRefData
{
@@ -592,42 +577,48 @@ bool wxRegionIterator::HaveRects() const
return m_current < ((wxRIRefData*)m_refData)->m_numRects;
}
wxRegionIterator::operator bool () const
wxRegionIterator& wxRegionIterator::operator ++ ()
{
return HaveRects();
if (HaveRects())
++m_current;
return *this;
}
void wxRegionIterator::operator ++ ()
wxRegionIterator wxRegionIterator::operator ++ (int)
{
if (HaveRects()) ++m_current;
}
wxRegionIterator tmp = *this;
if (HaveRects())
++m_current;
void wxRegionIterator::operator ++ (int)
{
if (HaveRects()) ++m_current;
return tmp;
}
wxCoord wxRegionIterator::GetX() const
{
if( !HaveRects() ) return 0;
wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") );
return ((wxRIRefData*)m_refData)->m_rects[m_current].x;
}
wxCoord wxRegionIterator::GetY() const
{
if( !HaveRects() ) return 0;
wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") );
return ((wxRIRefData*)m_refData)->m_rects[m_current].y;
}
wxCoord wxRegionIterator::GetW() const
{
if( !HaveRects() ) return -1;
wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") );
return ((wxRIRefData*)m_refData)->m_rects[m_current].width;
}
wxCoord wxRegionIterator::GetH() const
{
if( !HaveRects() ) return -1;
wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") );
return ((wxRIRefData*)m_refData)->m_rects[m_current].height;
}

View File

@@ -313,7 +313,7 @@ bool wxScrolledWindow::Create(wxWindow *parent,
PostCreation();
Show( TRUE );
return TRUE;
}
@@ -349,8 +349,12 @@ void wxScrolledWindow::SetScrollbars( int pixelsPerUnitX, int pixelsPerUnitY,
m_hAdjust->value = m_xScrollPosition = xPos;
m_vAdjust->value = m_yScrollPosition = yPos;
// Setting hints here should arguably be deprecated, but without it
// a sizer might override this manual scrollbar setting in old code.
m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
m_targetWindow->SetVirtualSize( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
if (!noRefresh)
{
int new_x = m_xScrollPixelsPerLine * m_xScrollPosition;
@@ -381,13 +385,16 @@ void wxScrolledWindow::AdjustScrollbars()
// If the scrollbar hits the right side, move the window
// right to keep it from over extending.
if( m_hAdjust->value + m_hAdjust->page_size > m_hAdjust->upper )
if ((m_hAdjust->value != 0.0) && (m_hAdjust->value + m_hAdjust->page_size > m_hAdjust->upper))
{
m_hAdjust->value = m_hAdjust->upper - m_hAdjust->page_size;
if (m_hAdjust->value < 0.0)
m_hAdjust->value = 0.0;
if (GetChildren().GetCount() == 0)
{
m_hAdjust->value = m_hAdjust->upper - m_hAdjust->page_size;
m_xScrollPosition = (int)m_hAdjust->value;
}
m_xScrollPosition = (int)m_hAdjust->value; // This is enough without child windows
else
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" ); // Actually scroll window
}
}
@@ -401,13 +408,16 @@ void wxScrolledWindow::AdjustScrollbars()
m_vAdjust->upper = vh / m_yScrollPixelsPerLine;
m_vAdjust->page_size = (h / m_yScrollPixelsPerLine);
if( m_vAdjust->value + m_vAdjust->page_size > m_vAdjust->upper )
if ((m_vAdjust->value != 0.0) && (m_vAdjust->value + m_vAdjust->page_size > m_vAdjust->upper))
{
m_vAdjust->value = m_vAdjust->upper - m_vAdjust->page_size;
if (m_vAdjust->value < 0.0)
m_vAdjust->value = 0.0;
if (GetChildren().GetCount() == 0)
{
m_vAdjust->value = m_vAdjust->upper - m_vAdjust->page_size;
m_yScrollPosition = (int)m_vAdjust->value;
}
m_yScrollPosition = (int)m_vAdjust->value;
else
gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" );
}
}
@@ -823,10 +833,17 @@ bool wxScrolledWindow::Layout()
// Default OnSize resets scrollbars, if any
void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
{
if( m_targetWindow != this )
m_targetWindow->SetVirtualSize( m_targetWindow->GetClientSize() );
if( GetAutoLayout() )
{
if( m_targetWindow != this )
m_targetWindow->FitInside();
SetVirtualSize( GetClientSize() );
FitInside();
}
else
{
AdjustScrollbars();
}
}
// This calls OnDraw, having adjusted the origin according to the current
@@ -849,7 +866,7 @@ void wxScrolledWindow::OnChar(wxKeyEvent& event)
szx, szy, // view size (total)
clix, cliy; // view size (on screen)
ViewStart(&stx, &sty);
GetViewStart(&stx, &sty);
GetClientSize(&clix, &cliy);
GetVirtualSize(&szx, &szy);

View File

@@ -16,6 +16,7 @@
#include "wx/debug.h"
#include "wx/module.h"
#include "wx/cmndata.h"
#include "wx/fontutil.h"
#include <gdk/gdk.h>
#include <gdk/gdkprivate.h>
@@ -326,8 +327,25 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
{
if (!g_systemFont)
{
#ifdef __WXGTK20__
GtkWidget *widget = gtk_button_new();
GtkStyle *def = gtk_rc_get_style( widget );
if (!def)
def = gtk_widget_get_default_style();
if (def)
{
wxNativeFontInfo info;
info.description = def->font_desc;
g_systemFont = new wxFont(info);
}
else
{
g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
}
gtk_widget_destroy( widget );
#else
g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
#endif
}
return *g_systemFont;
}

View File

@@ -255,14 +255,15 @@ int wxSlider::GetLineSize() const
bool wxSlider::IsOwnGtkWindow( GdkWindow *window )
{
GtkRange *range = GTK_RANGE(m_widget);
#ifdef __WXGTK20__
return (range->event_window == window);
#else
return ( (window == GTK_WIDGET(range)->window)
#ifndef __WXGTK20__
|| (window == range->trough)
|| (window == range->slider)
|| (window == range->step_forw)
|| (window == range->step_back)
#endif // GTK+ 1.x
);
|| (window == range->step_back) );
#endif
}
void wxSlider::ApplyWidgetStyle()

View File

@@ -278,6 +278,10 @@ bool wxToolBar::Create( wxWindow *parent,
#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;
@@ -374,37 +378,44 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
{
wxToolBarTool *tool = (wxToolBarTool *)toolBase;
#ifndef __WXGTK20__
// if we have inserted a space before all the tools we must change the GTK
// index by 1
size_t posGtk = m_xMargin > 1 ? pos + 1 : pos;
#else
size_t posGtk = pos;
#endif
if ( tool->IsButton() )
{
wxBitmap bitmap = tool->GetNormalBitmap();
if ( !HasFlag(wxTB_NOICONS) )
{
wxBitmap bitmap = tool->GetNormalBitmap();
wxCHECK_MSG( bitmap.Ok(), FALSE,
wxT("invalid bitmap for wxToolBar icon") );
wxCHECK_MSG( bitmap.Ok(), FALSE,
wxT("invalid bitmap for wxToolBar icon") );
wxCHECK_MSG( bitmap.GetBitmap() == NULL, FALSE,
wxT("wxToolBar doesn't support GdkBitmap") );
wxCHECK_MSG( bitmap.GetBitmap() == NULL, FALSE,
wxT("wxToolBar doesn't support GdkBitmap") );
wxCHECK_MSG( bitmap.GetPixmap() != NULL, FALSE,
wxT("wxToolBar::Add needs a wxBitmap") );
wxCHECK_MSG( bitmap.GetPixmap() != NULL, FALSE,
wxT("wxToolBar::Add needs a wxBitmap") );
GtkWidget *tool_pixmap = (GtkWidget *)NULL;
GtkWidget *tool_pixmap = (GtkWidget *)NULL;
GdkPixmap *pixmap = bitmap.GetPixmap();
GdkPixmap *pixmap = bitmap.GetPixmap();
GdkBitmap *mask = (GdkBitmap *)NULL;
if ( bitmap.GetMask() )
mask = bitmap.GetMask()->GetBitmap();
GdkBitmap *mask = (GdkBitmap *)NULL;
if ( bitmap.GetMask() )
mask = bitmap.GetMask()->GetBitmap();
tool_pixmap = gtk_pixmap_new( pixmap, mask );
gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE );
tool_pixmap = gtk_pixmap_new( pixmap, mask );
gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE );
gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 );
gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 );
tool->m_pixmap = tool_pixmap;
tool->m_pixmap = tool_pixmap;
}
}
switch ( tool->GetStyle() )
@@ -464,7 +475,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
return FALSE;
}
gtk_signal_connect( GTK_OBJECT(tool->m_item),
"enter_notify_event",
GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
@@ -587,8 +598,10 @@ void wxToolBar::SetMargins( int x, int y )
wxCHECK_RET( GetToolsCount() == 0,
wxT("wxToolBar::SetMargins must be called before adding tools.") );
#ifndef __WXGTK20__
if (x > 1)
gtk_toolbar_append_space( m_toolbar ); // oh well
#endif
m_xMargin = x;
m_yMargin = y;

View File

@@ -475,7 +475,7 @@ wxString wxTextCtrl::GetValue() const
GtkTextIter end;
gtk_text_buffer_get_end_iter( text_buffer, &end );
gchar *text = gtk_text_buffer_get_text( text_buffer, &start, &end, TRUE );
#if wxUSE_UNICODE
wxWCharBuffer buffer( wxConvUTF8.cMB2WX( text ) );
#else
@@ -552,6 +552,7 @@ void wxTextCtrl::WriteText( const wxString &text )
wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) );
#endif
GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
// TODO: call wahtever is needed to delete the selection
gtk_text_buffer_insert_at_cursor( text_buffer, buffer, strlen(buffer) );
#else // GTK 1.x
@@ -561,6 +562,7 @@ void wxTextCtrl::WriteText( const wxString &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());
// Bring editable's cursor back uptodate.
@@ -569,6 +571,9 @@ void wxTextCtrl::WriteText( const wxString &text )
}
else // single line
{
// First remove the selection if there is one
gtk_editable_delete_selection( GTK_EDITABLE(m_text) );
// This moves the cursor pos to behind the inserted text.
gint len = GET_EDITABLE_POS(m_text);
@@ -585,9 +590,6 @@ void wxTextCtrl::WriteText( const wxString &text )
gtk_editable_insert_text( GTK_EDITABLE(m_text), text.c_str(), text.Len(), &len );
#endif
// Bring editable's cursor uptodate.
len += text.Len();
// Bring entry's cursor uptodate.
gtk_entry_set_position( GTK_ENTRY(m_text), len );
}
@@ -928,6 +930,12 @@ void wxTextCtrl::SetSelection( long from, long to )
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
if (from == -1 && to == -1)
{
from = 0;
to = GetValue().Length();
}
#ifndef __WXGTK20__
if ( (m_windowStyle & wxTE_MULTILINE) &&
!GTK_TEXT(m_text)->line_start_cache )

View File

@@ -25,6 +25,7 @@
#include "wx/defs.h"
#include "wx/log.h"
#include "wx/dialog.h"
#include "wx/control.h"
#include "wx/app.h"
@@ -835,6 +836,11 @@ void wxTopLevelWindowGTK::OnInternalIdle()
if ( g_delayedFocus &&
wxGetTopLevelParent((wxWindow*)g_delayedFocus) == this )
{
wxLogTrace(_T("focus"),
_T("Setting focus from wxTLW::OnIdle() to %s(%s)"),
g_delayedFocus->GetClassInfo()->GetClassName(),
g_delayedFocus->GetLabel().c_str());
g_delayedFocus->SetFocus();
g_delayedFocus = NULL;
}

View File

@@ -310,11 +310,11 @@ gtk_pizza_put (GtkPizza *pizza,
pizza->children = g_list_append (pizza->children, child_info);
gtk_widget_set_parent (widget, GTK_WIDGET (pizza));
if (GTK_WIDGET_REALIZED (pizza))
gtk_widget_set_parent_window (widget, pizza->bin_window);
gtk_widget_set_parent (widget, GTK_WIDGET (pizza));
#ifndef __WXGTK20__ /* FIXME? */
if (!IS_ONSCREEN (x, y))
GTK_PRIVATE_SET_FLAG (widget, GTK_IS_OFFSCREEN);

View File

@@ -67,6 +67,10 @@
#include "wx/gtk/win_gtk.h"
#ifdef __WXGTK20__
#include <pango/pangox.h>
#endif
#ifdef __WXGTK20__
#define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d))
#else
@@ -262,7 +266,7 @@ extern bool g_mainThreadLocked;
//-----------------------------------------------------------------------------
#ifndef __WXGTK20__
#define DISABLE_STYLE_IF_BROKEN_THEME 1
#define DISABLE_STYLE_IF_BROKEN_THEME 0
#endif
#ifdef __WXDEBUG__
@@ -501,10 +505,10 @@ static int gtk_window_expose_callback( GtkWidget *widget,
// This callback gets called in drawing-idle time under
// GTK 2.0, so we don't need to defer anything to idle
// time anymore.
GtkPizza *pizza = GTK_PIZZA( widget );
if (gdk_event->window != pizza->bin_window) return FALSE;
#if 0
if (win->GetName())
{
@@ -522,13 +526,14 @@ static int gtk_window_expose_callback( GtkWidget *widget,
win->GtkSendPaintEvents();
// Let parent window draw window less widgets
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event);
#else
// This gets called immediately after an expose event
// under GTK 1.2 so we collect the calls and wait for
// the idle handler to pick things up.
win->GetUpdateRegion().Union( gdk_event->area.x,
gdk_event->area.y,
gdk_event->area.width,
@@ -1060,6 +1065,7 @@ wxTranslateGTKKeyEventToWx(wxKeyEvent& event,
return TRUE;
}
#ifndef __WXGTK20__
static gint gtk_window_key_press_callback( GtkWidget *widget,
GdkEventKey *gdk_event,
wxWindow *win )
@@ -1130,7 +1136,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
wxLogTrace(TRACE_KEYS, _T("Char event: %ld"), key_code);
event.m_keyCode = key_code;
// Implement OnCharHook by checking ancesteror top level windows
wxWindow *parent = win;
while (parent && !parent->IsTopLevel())
@@ -1207,45 +1213,184 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
}
}
// Doesn't work.
#if 0
// Pressing F10 will activate the menu bar of the top frame
if ( (!ret) &&
(gdk_event->keyval == GDK_F10) )
if (ret)
{
wxWindowGTK *ancestor = win;
while (ancestor)
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
return TRUE;
}
return FALSE;
}
#endif
#ifdef __WXGTK20__
static gint gtk_window_key_press_callback( GtkWidget *widget,
GdkEventKey *gdk_event,
wxWindow *win )
{
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT)
return FALSE;
if (g_blockEventsOnDrag)
return FALSE;
bool ret = FALSE;
bool dont_use_IM = FALSE;
wxKeyEvent event( wxEVT_KEY_DOWN );
long keycode = wxTranslateKeySymToWXKey( gdk_event->keyval, FALSE );
if (keycode)
{
// We were able to decode the key press without
// any input method, so don't use it.
dont_use_IM = TRUE;
// now fill all the other fields
int x = 0;
int y = 0;
GdkModifierType state;
if (gdk_event->window)
gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
event.SetTimestamp( gdk_event->time );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK) != 0;
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK) != 0;
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK) != 0;
event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK) != 0;
event.m_keyCode = keycode;
event.m_scanCode = gdk_event->keyval;
event.m_rawCode = (wxUint32) gdk_event->keyval;
event.m_rawFlags = 0;
event.m_x = x;
event.m_y = y;
event.SetEventObject( win );
// send key down event
ret = win->GetEventHandler()->ProcessEvent( event );
if (!ret)
{
if (wxIsKindOf(ancestor,wxFrame))
// Implement OnCharHook by checking ancesteror top level windows
wxWindow *parent = win;
while (parent && !parent->IsTopLevel())
parent = parent->GetParent();
if (parent)
{
wxFrame *frame = (wxFrame*) ancestor;
wxMenuBar *menubar = frame->GetMenuBar();
if (menubar)
{
wxNode *node = menubar->GetMenus().First();
if (node)
{
wxMenu *firstMenu = (wxMenu*) node->Data();
gtk_menu_item_select( GTK_MENU_ITEM(firstMenu->m_owner) );
ret = TRUE;
break;
}
}
event.SetEventType( wxEVT_CHAR_HOOK );
ret = parent->GetEventHandler()->ProcessEvent( event );
}
if (!ret)
{
event.SetEventType(wxEVT_CHAR);
ret = win->GetEventHandler()->ProcessEvent( event );
}
}
// win is a control: tab can be propagated up
if ( !ret &&
((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
win->GetParent() && (win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
{
wxNavigationKeyEvent new_event;
new_event.SetEventObject( win->GetParent() );
// GDK reports GDK_ISO_Left_Tab for SHIFT-TAB
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
// CTRL-TAB changes the (parent) window, i.e. switch notebook page
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
new_event.SetCurrentFocus( win );
ret = win->GetParent()->GetEventHandler()->ProcessEvent( new_event );
}
if ( !ret &&
(gdk_event->keyval == GDK_Escape) )
{
wxWindow *winForCancel = win, *btnCancel = NULL;
while ( winForCancel )
{
btnCancel = winForCancel->FindWindow(wxID_CANCEL);
if ( btnCancel ) break;
if ( winForCancel->IsTopLevel() ) break;
winForCancel = winForCancel->GetParent();
}
if ( btnCancel )
{
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
event.SetEventObject(btnCancel);
ret = btnCancel->GetEventHandler()->ProcessEvent(event);
}
ancestor = ancestor->GetParent();
}
}
#endif // 0
if (ret)
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
return TRUE;
}
if (!dont_use_IM && win->m_imContext)
{
// In GTK 2.0, we need to hand over the key
// event to an input method and the IM will
// emit a "commit" event containing the
// actual utf8 character.
gtk_im_context_filter_keypress ( (GtkIMContext*) win->m_imContext, gdk_event );
return TRUE;
}
return FALSE;
}
static void gtk_wxwindow_commit_cb (GtkIMContext *context,
const gchar *str,
wxWindow *window)
{
bool ret = FALSE;
wxKeyEvent event( wxEVT_KEY_DOWN );
#if wxUSE_UNICODE
event.m_uniChar = g_utf8_get_char( str );
// Backward compatible for ISO-8859
if (event.m_uniChar < 256)
event.m_keyCode = event.m_uniChar;
#else
gunichar uniChar = g_utf8_get_char( str );
// We cannot handle Unicode in non-Unicode mode
if (uniChar > 255) return;
event.m_keyCode = uniChar;
#endif
if (!ret)
{
// Implement OnCharHook by checking ancesteror top level windows
wxWindow *parent = window;
while (parent && !parent->IsTopLevel())
parent = parent->GetParent();
if (parent)
{
event.SetEventType( wxEVT_CHAR_HOOK );
ret = parent->GetEventHandler()->ProcessEvent( event );
}
if (!ret)
{
event.SetEventType(wxEVT_CHAR);
ret = window->GetEventHandler()->ProcessEvent( event );
}
}
}
#endif
//-----------------------------------------------------------------------------
// "key_release_event" from any window
//-----------------------------------------------------------------------------
@@ -1303,6 +1448,13 @@ static gint gtk_window_key_release_callback( GtkWidget *widget,
event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK); \
event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK); \
event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK); \
if (event.GetEventType()==wxEVT_MOUSEWHEEL) \
{ \
if (((GdkEventButton*)gdk_event)->button == 4) \
event.m_wheelRotation = 120; \
else if (((GdkEventButton*)gdk_event)->button == 5) \
event.m_wheelRotation = -120; \
} \
\
wxPoint pt = win->GetClientAreaOrigin(); \
event.m_x = (wxCoord)gdk_event->x - pt.x; \
@@ -1447,6 +1599,26 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
*/
}
// GDK sends surplus button down event
// before a double click event. We
// need to filter these out.
if (gdk_event->type == GDK_BUTTON_PRESS)
{
GdkEvent *peek_event = gdk_event_peek();
if (peek_event)
{
if (peek_event->type == GDK_2BUTTON_PRESS)
{
gdk_event_free( peek_event );
return TRUE;
}
else
{
gdk_event_free( peek_event );
}
}
}
wxEventType event_type = wxEVT_NULL;
if (gdk_event->button == 1)
@@ -1476,6 +1648,22 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
default: break;
}
}
else if (gdk_event->button == 4)
{
switch (gdk_event->type)
{
case GDK_BUTTON_PRESS: event_type = wxEVT_MOUSEWHEEL; break;
default: break;
}
}
else if (gdk_event->button == 5)
{
switch (gdk_event->type)
{
case GDK_BUTTON_PRESS: event_type = wxEVT_MOUSEWHEEL; break;
default: break;
}
}
if ( event_type == wxEVT_NULL )
{
@@ -1520,7 +1708,9 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
// "button_release_event"
//-----------------------------------------------------------------------------
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindowGTK *win )
static gint gtk_window_button_release_callback( GtkWidget *widget,
GdkEventButton *gdk_event,
wxWindowGTK *win )
{
DEBUG_MAIN_THREAD
@@ -1533,21 +1723,25 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
/*
printf( "OnButtonRelease from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" );
*/
wxEventType event_type = wxEVT_NULL;
switch (gdk_event->button)
{
case 1: event_type = wxEVT_LEFT_UP; break;
case 2: event_type = wxEVT_MIDDLE_UP; break;
case 3: event_type = wxEVT_RIGHT_UP; break;
default: return FALSE;
case 1:
event_type = wxEVT_LEFT_UP;
break;
case 2:
event_type = wxEVT_MIDDLE_UP;
break;
case 3:
event_type = wxEVT_RIGHT_UP;
break;
default:
// unknwon button, don't process
return FALSE;
}
wxMouseEvent event( event_type );
@@ -1558,6 +1752,20 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
// same wxListBox hack as above
win->FixUpMouseEvent(widget, event.m_x, event.m_y);
if ( event_type == wxEVT_RIGHT_UP )
{
// generate a "context menu" event: this is similar to wxEVT_RIGHT_UP
// except that:
//
// (a) it's a command event and so is propagated to the parent
// (b) under MSW it can be generated from kbd too
// (c) it uses screen coords (because of (a))
wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU,
win->GetId(),
win->ClientToScreen(event.GetPosition()));
(void)win->GetEventHandler()->ProcessEvent(evtCtx);
}
if ( !g_captureWindow )
win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
@@ -1706,7 +1914,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
#endif // wxUSE_CARET
g_activeFrameLostFocus = FALSE;
wxWindowGTK *active = wxGetTopLevelParent(win);
if ( active != g_activeFrame )
{
@@ -1723,7 +1931,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, g_activeFrame->GetId());
event.SetEventObject(g_activeFrame);
g_activeFrame->GetEventHandler()->ProcessEvent(event);
// Don't send focus events in addition to activate
// if (win == g_activeFrame)
// return TRUE;
@@ -2077,7 +2285,7 @@ static void gtk_window_destroy_callback( GtkWidget* widget, wxWindow *win )
been realized, so we do this directly after realization. */
static gint
gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win )
gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win )
{
DEBUG_MAIN_THREAD
@@ -2090,6 +2298,14 @@ gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win )
if (win->m_delayedForegroundColour)
win->GtkSetForegroundColour( win->GetForegroundColour() );
#ifdef __WXGTK20__
if (win->m_imContext)
{
GtkPizza *pizza = GTK_PIZZA( m_widget );
gtk_im_context_set_client_window( (GtkIMContext*) win->m_imContext, pizza->bin_window );
}
#endif
wxWindowCreateEvent event( win );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
@@ -2349,10 +2565,15 @@ void wxWindowGTK::Init()
m_delayedForegroundColour = FALSE;
m_delayedBackgroundColour = FALSE;
#ifdef __WXGTK20__
m_imContext = NULL;
m_x11Context = NULL;
#else
#ifdef HAVE_XIM
m_ic = (GdkIC*) NULL;
m_icattr = (GdkICAttr*) NULL;
#endif
#endif
}
wxWindowGTK::wxWindowGTK()
@@ -2387,9 +2608,9 @@ bool wxWindowGTK::Create( wxWindow *parent,
}
m_insertCallback = wxInsertChildInWindow;
// always needed for background clearing
m_delayedBackgroundColour = TRUE;
m_delayedBackgroundColour = TRUE;
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
@@ -2473,6 +2694,17 @@ bool wxWindowGTK::Create( wxWindow *parent,
gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed",
(GtkSignalFunc) gtk_window_vscroll_callback, (gpointer) this );
#ifdef __WXGTK20__
// Create input method handler
m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new ();
// Cannot handle drawing preedited text yet
gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE );
g_signal_connect (G_OBJECT (m_imContext), "commit",
G_CALLBACK (gtk_wxwindow_commit_cb), this);
#endif
gtk_widget_show( m_wxwindow );
if (m_parent)
@@ -2596,7 +2828,18 @@ void wxWindowGTK::PostCreation()
GTK_SIGNAL_FUNC(gtk_window_event_event_callback), (gpointer)this );
}
#else
gtk_widget_set_redraw_on_allocate( GTK_WIDGET(m_wxwindow), HasFlag( wxNO_FULL_REPAINT_ON_RESIZE ) );
// gtk_widget_set_redraw_on_allocate( GTK_WIDGET(m_wxwindow), HasFlag( wxNO_FULL_REPAINT_ON_RESIZE ) );
#endif
#ifdef __WXGTK20__
// Create input method handler
m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new ();
// Cannot handle drawing preedited text yet
gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE );
g_signal_connect (G_OBJECT (m_imContext), "commit",
G_CALLBACK (gtk_wxwindow_commit_cb), this);
#endif
}
@@ -2683,7 +2926,7 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget )
gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event",
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
// This keeps crashing on me. RR.
//
// gtk_signal_connect( GTK_OBJECT(widget), "destroy",
@@ -2842,7 +3085,7 @@ void wxWindowGTK::OnInternalIdle()
}
g_activeFrameLostFocus = FALSE;
}
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
@@ -3113,6 +3356,11 @@ bool wxWindowGTK::Show( bool show )
else
gtk_widget_hide( m_widget );
wxShowEvent eventShow(GetId(), show);
eventShow.m_eventObject = this;
GetEventHandler()->ProcessEvent(eventShow);
return TRUE;
}
@@ -3185,26 +3433,26 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
if (theFont) fontToUse = *theFont;
wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
if (string.IsEmpty())
{
if (x) (*x) = 0;
if (y) (*y) = 0;
return;
}
#ifdef __WXGTK20__
#ifdef __WXGTK20__
PangoContext *context = NULL;
if (m_widget)
gtk_widget_get_pango_context( m_widget );
context = gtk_widget_get_pango_context( m_widget );
if (!context)
{
if (x) (*x) = 0;
if (y) (*y) = 0;
return;
}
PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description;
PangoLayout *layout = pango_layout_new(context);
pango_layout_set_font_description(layout, desc);
@@ -3219,10 +3467,10 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
#endif
}
PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
PangoRectangle rect;
pango_layout_line_get_extents(line, NULL, &rect);
if (x) (*x) = (wxCoord) (rect.width / PANGO_SCALE);
if (y) (*y) = (wxCoord) (rect.height / PANGO_SCALE);
if (descent)
@@ -3231,7 +3479,7 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
(*descent) = 0;
}
if (externalLeading) (*externalLeading) = 0; // ??
g_object_unref( G_OBJECT( layout ) );
#else
GdkFont *font = fontToUse.GetInternalFont( 1.0 );
@@ -3408,11 +3656,11 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
{
if (!m_widget) return;
if (!m_widget->window) return;
#ifndef __WXGTK20__
if (g_isIdle)
wxapp_install_idle_handler();
if (eraseBackground && m_wxwindow && m_wxwindow->window)
{
if (rect)
@@ -3498,7 +3746,7 @@ void wxWindowGTK::GtkSendPaintEvents()
{
if (!m_wxwindow)
{
#ifndef __WXGTK20__
#ifndef __WXGTK20__
m_clearRegion.Clear();
#endif
m_updateRegion.Clear();
@@ -3511,7 +3759,7 @@ void wxWindowGTK::GtkSendPaintEvents()
#ifndef __WXGTK20__
// widget to draw on
GtkPizza *pizza = GTK_PIZZA (m_wxwindow);
// later for GTK 2.0, too.
if (GetThemeEnabled())
{
@@ -3521,7 +3769,7 @@ void wxWindowGTK::GtkSendPaintEvents()
parent = parent->GetParent();
if (!parent)
parent = (wxWindow*)this;
wxRegionIterator upd( m_updateRegion );
while (upd)
{
@@ -3530,7 +3778,7 @@ void wxWindowGTK::GtkSendPaintEvents()
rect.y = upd.GetY();
rect.width = upd.GetWidth();
rect.height = upd.GetHeight();
gtk_paint_flat_box( parent->m_widget->style,
pizza->bin_window,
GTK_STATE_NORMAL,
@@ -3539,7 +3787,7 @@ void wxWindowGTK::GtkSendPaintEvents()
parent->m_widget,
(char *)"base",
0, 0, -1, -1 );
upd ++;
}
}
@@ -3610,7 +3858,7 @@ void wxWindowGTK::GtkSendPaintEvents()
{
GtkPizzaChild *child = (GtkPizzaChild*) children->data;
children = children->next;
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
GTK_WIDGET_DRAWABLE (child->widget))
{
@@ -3656,7 +3904,7 @@ void wxWindowGTK::Clear()
m_clearRegion.Clear();
wxSize size( GetClientSize() );
m_clearRegion.Union( 0,0,size.x,size.y );
// Better do this in idle?
GtkUpdate();
}
@@ -3687,10 +3935,10 @@ void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour )
window = GetConnectWidget()->window;
wxASSERT( window );
// We need the pixel value e.g. for background clearing.
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
if (m_wxwindow)
{
// wxMSW doesn't clear the window here, either.
@@ -3774,6 +4022,21 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour )
return TRUE;
}
#ifdef __WXGTK20__
PangoContext *wxWindowGTK::GtkGetPangoDefaultContext()
{
return gtk_widget_get_pango_context( m_widget );
}
PangoContext *wxWindowGTK::GtkGetPangoX11Context()
{
if (!m_x11Context)
m_x11Context = pango_x_get_context( gdk_display );
return m_x11Context;
}
#endif
GtkStyle *wxWindowGTK::GetWidgetStyle()
{
if (m_widgetStyle)
@@ -4271,7 +4534,7 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
// No scrolling requested.
if ((dx == 0) && (dy == 0)) return;