/*
I have been asked several times about writing some documentation about
- the GTK port of wxWindows, especially its internal structures. Obviously,
+ the GTK port of wxWidgets, especially its internal structures. Obviously,
you cannot understand wxGTK without knowing a little about the GTK, but
some more information about what the wxWindow, which is the base class
for all other window classes, does seems required as well.
6) Display a border (sunken, raised, simple or none).
- Normally one might expect, that one wxWindows window would always correspond
+ Normally one might expect, that one wxWidgets window would always correspond
to one GTK widget. Under GTK, there is no such allround widget that has all
the functionality. Moreover, the GTK defines a client area as a different
widget from the actual widget you are handling. Last but not least some
special classes (e.g. wxFrame) handle different categories of widgets and
still have the possibility to draw something in the client area.
It was therefore required to write a special purpose GTK widget, that would
- represent a client area in the sense of wxWindows capable to do the jobs
+ represent a client area in the sense of wxWidgets capable to do the jobs
2), 3) and 4). I have written this class and it resides in win_gtk.c of
this directory.
one is (in the GTK sense) a child of the GtkScrolledWindow.
If the m_wxwindow field is set, then all input to this widget is inter-
- cepted and sent to the wxWindows class. If not, all input to the widget
+ cepted and sent to the wxWidgets class. If not, all input to the widget
that gets pointed to by m_widget gets intercepted and sent to the class.
II)
- The design of scrolling in wxWindows is markedly different from that offered
+ The design of scrolling in wxWidgets is markedly different from that offered
by the GTK itself and therefore we cannot simply take it as it is. In GTK,
clicking on a scrollbar belonging to scrolled window will inevitably move
- the window. In wxWindows, the scrollbar will only emit an event, send this
+ the window. In wxWidgets, the scrollbar will only emit an event, send this
to (normally) a wxScrolledWindow and that class will call ScrollWindow()
which actually moves the window and its subchildren. Note that GtkPizza
- memorizes how much it has been scrolled but that wxWindows forgets this
+ memorizes how much it has been scrolled but that wxWidgets forgets this
so that the two coordinates systems have to be kept in synch. This is done
in various places using the pizza->xoffset and pizza->yoffset values.
if (gdk_event->button == 1)
{
// note that GDK generates triple click events which are not supported
- // by wxWindows but still have to be passed to the app as otherwise
+ // by wxWidgets but still have to be passed to the app as otherwise
// clicks would simply go missing
switch (gdk_event->type)
{
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
// these handlers block mouse events to any window during scrolling such as
- // motion events and prevent GTK and wxWindows from fighting over where the
+ // motion events and prevent GTK and wxWidgets from fighting over where the
// slider should be
gtk_signal_connect( GTK_OBJECT(scrolledWindow->vscrollbar), "button_press_event",
m_x = (int)pos.x;
m_y = (int)pos.y;
- // some reasonable defaults
- if (!parent)
- {
- if (m_x == -1)
- {
- m_x = (gdk_screen_width () - m_width) / 2;
- if (m_x < 10) m_x = 10;
- }
- if (m_y == -1)
- {
- m_y = (gdk_screen_height () - m_height) / 2;
- if (m_y < 10) m_y = 10;
- }
- }
-
return TRUE;
}
void wxWindowGTK::PostCreation()
{
- wxCHECK_VALID_WIDGET_RET();
-
+ wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
+
if (m_wxwindow)
{
if (!m_noExpose)
{
- // these get reported to wxWindows -> wxPaintEvent
+ // these get reported to wxWidgets -> wxPaintEvent
gtk_pizza_set_external( GTK_PIZZA(m_wxwindow), TRUE );
bool wxWindowGTK::Destroy()
{
- wxCHECK_VALID_WIDGET(FALSE);
+ wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
m_hasVMT = FALSE;
void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{
- wxCHECK_VALID_WIDGET_RET();
+ wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
wxASSERT_MSG( (m_parent != NULL), wxT("wxWindowGTK::SetSize requires parent.\n") );
/*
void wxWindowGTK::DoGetSize( int *width, int *height ) const
{
- wxCHECK_VALID_WIDGET_RET();
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
if (width) (*width) = m_width;
if (height) (*height) = m_height;
void wxWindowGTK::DoSetClientSize( int width, int height )
{
- wxCHECK_VALID_WIDGET_RET();
-
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
+
if (!m_wxwindow)
{
SetSize( width, height );
void wxWindowGTK::DoGetClientSize( int *width, int *height ) const
{
- wxCHECK_VALID_WIDGET_RET();
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
if (!m_wxwindow)
{
void wxWindowGTK::DoGetPosition( int *x, int *y ) const
{
- wxCHECK_VALID_WIDGET_RET();
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
int dx = 0;
int dy = 0;
void wxWindowGTK::DoClientToScreen( int *x, int *y ) const
{
- wxCHECK_VALID_WIDGET_RET();
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
if (!m_widget->window) return;
void wxWindowGTK::DoScreenToClient( int *x, int *y ) const
{
- wxCHECK_VALID_WIDGET_RET();
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
if (!m_widget->window) return;
bool wxWindowGTK::Show( bool show )
{
- wxCHECK_VALID_WIDGET(FALSE);
+ wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") );
if (!wxWindowBase::Show(show))
{
bool wxWindowGTK::Enable( bool enable )
{
- wxCHECK_VALID_WIDGET(FALSE);
-
+ wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") );
+
if (!wxWindowBase::Enable(enable))
{
// nothing to do
int wxWindowGTK::GetCharHeight() const
{
- wxCHECK_VALID_WIDGET(12);
+ wxCHECK_MSG( (m_widget != NULL), 12, wxT("invalid window") );
wxFont font = GetFont();
wxCHECK_MSG( font.Ok(), 12, wxT("invalid font") );
int wxWindowGTK::GetCharWidth() const
{
- wxCHECK_VALID_WIDGET(8);
+ wxCHECK_MSG( (m_widget != NULL), 8, wxT("invalid window") );
wxFont font = GetFont();
wxCHECK_MSG( font.Ok(), 8, wxT("invalid font") );
void wxWindowGTK::SetFocus()
{
- wxCHECK_VALID_WIDGET_RET();
+ wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
if ( m_hasFocus )
{
bool wxWindowGTK::Reparent( wxWindowBase *newParentBase )
{
- wxCHECK_VALID_WIDGET(FALSE);
+ wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") );
wxWindowGTK *oldParent = m_parent,
*newParent = (wxWindowGTK *)newParentBase;
void wxWindowGTK::Raise()
{
- wxCHECK_VALID_WIDGET_RET();
-
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
+
if (!m_widget->window) return;
gdk_window_raise( m_widget->window );
void wxWindowGTK::Lower()
{
- wxCHECK_VALID_WIDGET_RET();
-
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
+
if (!m_widget->window) return;
gdk_window_lower( m_widget->window );
bool wxWindowGTK::SetCursor( const wxCursor &cursor )
{
- wxCHECK_VALID_WIDGET(FALSE);
+ wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") );
if (cursor == m_cursor)
return FALSE;
void wxWindowGTK::WarpPointer( int x, int y )
{
- wxCHECK_VALID_WIDGET_RET();
-
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
+
// We provide this function ourselves as it is
// missing in GDK (top of this file).
g_eraseGC = gdk_gc_new( pizza->bin_window );
gdk_gc_set_fill( g_eraseGC, GDK_SOLID );
}
- gdk_gc_set_foreground( g_eraseGC, m_backgroundColour.GetColor() );
+ gdk_gc_set_foreground( g_eraseGC, GetBackgroundColour().GetColor() );
wxRegionIterator upd( m_clearRegion );
while (upd)
#ifndef __WXUNIVERSAL__
#ifndef __WXGTK20__
// The following code will result in all window-less widgets
- // being redrawn because the wxWindows class is allowed to
+ // being redrawn because the wxWidgets class is allowed to
// paint over the window-less widgets.
GList *children = pizza->children;
void wxWindowGTK::ClearBackground()
{
- wxCHECK_VALID_WIDGET_RET();
-
+ wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
+
#ifndef __WXGTK20__
if (m_wxwindow && m_wxwindow->window)
{
bool wxWindowGTK::SetBackgroundColour( const wxColour &colour )
{
- wxCHECK_VALID_WIDGET(FALSE);
+ wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") );
if (!wxWindowBase::SetBackgroundColour(colour))
return FALSE;
bool wxWindowGTK::SetForegroundColour( const wxColour &colour )
{
- wxCHECK_VALID_WIDGET(FALSE);
+ wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") );
if (!wxWindowBase::SetForegroundColour(colour))
{
static bool s_warningPrinted = FALSE;
if (!s_warningPrinted)
{
- printf( "wxWindows warning: Widget styles disabled due to buggy GTK theme.\n" );
+ printf( "wxWidgets warning: Widget styles disabled due to buggy GTK theme.\n" );
s_warningPrinted = TRUE;
}
m_widgetStyle = m_widget->style;
bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
{
- wxCHECK_VALID_WIDGET(FALSE);
+ wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") );
wxCHECK_MSG( menu != NULL, FALSE, wxT("invalid popup-menu") );
void wxWindowGTK::SetDropTarget( wxDropTarget *dropTarget )
{
- wxCHECK_VALID_WIDGET_RET();
-
+ wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
+
GtkWidget *dnd_widget = GetConnectWidget();
if (m_dropTarget) m_dropTarget->UnregisterWidget( dnd_widget );
void wxWindowGTK::DoCaptureMouse()
{
- wxCHECK_VALID_WIDGET_RET();
-
+ wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
+
GdkWindow *window = (GdkWindow*) NULL;
if (m_wxwindow)
window = GTK_PIZZA(m_wxwindow)->bin_window;
void wxWindowGTK::DoReleaseMouse()
{
- wxCHECK_VALID_WIDGET_RET();
-
+ wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
+
wxCHECK_RET( g_captureWindow, wxT("can't release mouse - not captured") );
g_captureWindow = (wxWindowGTK*) NULL;
void wxWindowGTK::SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh )
{
- wxCHECK_VALID_WIDGET_RET();
-
+ wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
+
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
m_hasScrolling = TRUE;
void wxWindowGTK::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) )
{
- wxCHECK_VALID_WIDGET_RET();
+ wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
int wxWindowGTK::GetScrollThumb( int orient ) const
{
- wxCHECK_VALID_WIDGET(0);
-
+ wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") );
+
wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") );
if (orient == wxHORIZONTAL)
int wxWindowGTK::GetScrollPos( int orient ) const
{
- wxCHECK_VALID_WIDGET(0);
+ wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") );
wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") );
int wxWindowGTK::GetScrollRange( int orient ) const
{
- wxCHECK_VALID_WIDGET(0);
+ wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") );
wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") );
void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
{
- wxCHECK_VALID_WIDGET_RET();
-
+ wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
+
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
// No scrolling requested.