#include "wx/notebook.h"
#include "wx/statusbr.h"
#include <wx/intl.h>
-//#include "wx/treectrl.h"
#include "gdk/gdkkeysyms.h"
#include <math.h>
#include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
// button_press
-gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
-{
- if (widget->window != gdk_event->window) return TRUE;
+gint gtk_window_button_press_callback( GtkWidget *WXUNUSED(widget), GdkEventButton *gdk_event, wxWindow *win )
+{
+ if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
if (win->m_wxwindow)
//-----------------------------------------------------------------------------
// button_release
-gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
+gint gtk_window_button_release_callback( GtkWidget *WXUNUSED(widget), GdkEventButton *gdk_event, wxWindow *win )
{
- if (widget->window != gdk_event->window) return TRUE;
-
+ if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return TRUE;
//-----------------------------------------------------------------------------
// motion_notify
-gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
+gint gtk_window_motion_notify_callback( GtkWidget *WXUNUSED(widget), GdkEventMotion *gdk_event, wxWindow *win )
{
- if (widget->window != gdk_event->window) return TRUE;
-
+ if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return TRUE;
{
int x = 0;
int y = 0;
- gdk_window_get_pointer( widget->window, &x, &y, NULL );
+ gdk_window_get_pointer( widget->window, &x, &y, (GdkModifierType *) NULL );
win->GetDropTarget()->Drop( event, x, y );
}
wxWindow::wxWindow()
{
- m_widget = NULL;
- m_wxwindow = NULL;
- m_parent = NULL;
+ m_widget = (GtkWidget *) NULL;
+ m_wxwindow = (GtkWidget *) NULL;
+ m_parent = (wxWindow *) NULL;
m_children.DeleteContents( FALSE );
m_x = 0;
m_y = 0;
m_height = 0;
m_retCode = 0;
m_eventHandler = this;
- m_windowValidator = NULL;
+ m_windowValidator = (wxValidator *) NULL;
m_windowId = -1;
m_cursor = new wxCursor( wxCURSOR_ARROW );
m_font = *wxSWISS_FONT;
m_windowStyle = 0;
m_windowName = "noname";
- m_constraints = NULL;
- m_constraintsInvolvedIn = NULL;
- m_windowSizer = NULL;
- m_sizerParent = NULL;
+ m_constraints = (wxLayoutConstraints *) NULL;
+ m_constraintsInvolvedIn = (wxList *) NULL;
+ m_windowSizer = (wxSizer *) NULL;
+ m_sizerParent = (wxWindow *) NULL;
m_autoLayout = FALSE;
m_sizeSet = FALSE;
m_hasVMT = FALSE;
m_needParent = TRUE;
m_hasScrolling = FALSE;
- m_hAdjust = NULL;
- m_vAdjust = NULL;
+ m_hAdjust = (GtkAdjustment *) NULL;
+ m_vAdjust = (GtkAdjustment *) NULL;
m_oldHorizontalPos = 0.0;
m_oldVerticalPos = 0.0;
m_isShown = FALSE;
m_isEnabled = TRUE;
- m_drawingOffsetX = 0;
- m_drawingOffsetY = 0;
- m_pDropTarget = NULL;
+ m_pDropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
}
m_isEnabled = TRUE;
m_needParent = TRUE;
- m_cursor = NULL;
+ m_cursor = (wxCursor *) NULL;
PreCreation( parent, id, pos, size, style, name );
- m_widget = gtk_scrolled_window_new( NULL, NULL );
+ m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
m_hasScrolling = TRUE;
GtkScrolledWindow *s_window;
// in other windows' constraintsInvolvedIn lists.
UnsetConstraints(m_constraints);
delete m_constraints;
- m_constraints = NULL;
+ m_constraints = (wxLayoutConstraints *) NULL;
}
if (m_windowSizer)
{
delete m_windowSizer;
- m_windowSizer = NULL;
+ m_windowSizer = (wxSizer *) NULL;
}
// If this is a child of a sizer, remove self from parent
if (m_sizerParent) m_sizerParent->RemoveChild((wxWindow *)this);
if (m_needParent && (parent == NULL))
wxFatalError( _("Need complete parent."), name );
- m_widget = NULL;
+ m_widget = (GtkWidget *) NULL;
m_hasVMT = FALSE;
m_parent = parent;
m_children.DeleteContents( FALSE );
m_foregroundColour = wxBLACK;
m_windowStyle = style;
m_windowName = name;
- m_constraints = NULL;
- m_constraintsInvolvedIn = NULL;
- m_windowSizer = NULL;
- m_sizerParent = NULL;
+ m_constraints = (wxLayoutConstraints *) NULL;
+ m_constraintsInvolvedIn = (wxList *) NULL;
+ m_windowSizer = (wxSizer *) NULL;
+ m_sizerParent = (wxWindow *) NULL;
m_autoLayout = FALSE;
- m_drawingOffsetX = 0;
- m_drawingOffsetY = 0;
- m_pDropTarget = NULL;
+ m_pDropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
- m_windowValidator = NULL;
+ m_windowValidator = (wxValidator *) NULL;
}
void wxWindow::PostCreation(void)
*/
if (m_widget && m_parent) gtk_widget_realize( m_widget );
- if (m_wxwindow) gtk_widget_realize( m_wxwindow );
+
+ if (m_wxwindow)
+ {
+ gtk_widget_realize( m_wxwindow );
+ gdk_gc_set_exposures( m_wxwindow->style->fg_gc[0], TRUE );
+ }
SetCursor( wxSTANDARD_CURSOR );
if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL)
{
delete child;
- if (GetChildren()->Member(child)) delete node;
+ if (GetChildren()->Member(child)) delete node;
}
}
}
if (!m_parent)
{
- printf( _("wxWindow::SetSize error.\n") );
+ wxFAIL_MSG( _("wxWindow::SetSize error.\n") );
return;
}
{
// Does this look simple ?
- GdkWindow *source = NULL;
+ GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
else
void wxWindow::ScreenToClient( int *x, int *y )
{
- GdkWindow *source = NULL;
+ GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
else
if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable );
}
+int wxWindow::GetCharHeight(void) const
+{
+ GdkFont *font = m_font.GetInternalFont( 1.0 );
+ return font->ascent + font->descent;
+}
+
+int wxWindow::GetCharWidth(void) const
+{
+ GdkFont *font = m_font.GetInternalFont( 1.0 );
+ return gdk_string_width( font, "H" );
+}
+
+void wxWindow::GetTextExtent( const wxString& string, int *x, int *y,
+ int *descent, int *externalLeading, const wxFont *theFont, bool WXUNUSED(use16) ) const
+{
+ wxFont fontToUse = m_font;
+ if (theFont) fontToUse = *theFont;
+
+ GdkFont *font = fontToUse.GetInternalFont( 1.0 );
+ if (x) (*y) = gdk_string_width( font, string );
+ if (y) (*y) = font->ascent + font->descent;
+ if (descent) (*descent) = font->descent;
+ if (externalLeading) (*externalLeading) = 0; // ??
+}
+
void wxWindow::MakeModal( bool modal )
{
return;
{
if (GetChildren())
GetChildren()->DeleteObject( child );
- child->m_parent = NULL;
+ child->m_parent = (wxWindow *) NULL;
}
void wxWindow::SetReturnCode( int retCode )
return m_retCode;
}
-wxWindow *wxWindow::GetParent(void)
-{
- return m_parent;
-}
-
void wxWindow::Raise(void)
{
if (m_widget) gdk_window_raise( m_widget->window );
{
wxEvtHandler *handlerA = GetEventHandler();
wxEvtHandler *handlerB = handlerA->GetNextHandler();
- handlerA->SetNextHandler(NULL);
+ handlerA->SetNextHandler((wxEvtHandler *) NULL);
SetEventHandler(handlerB);
if ( deleteHandler )
{
delete handlerA;
- return NULL;
+ return (wxEvtHandler *) NULL;
}
else
return handlerA;
}
else
- return NULL;
+ return (wxEvtHandler *) NULL;
}
wxValidator *wxWindow::GetValidator(void)
{
if (m_wxwindow)
{
- wxClientDC dc(this);
- PrepareDC(dc);
- long x = 0;
- long y = 0;
- dc.GetInternalDeviceOrigin( &x, &y );
-
int w = 0;
int h = 0;
GetClientSize( &w, &h );
GdkRectangle gdk_rect;
- gdk_rect.x = x;
- gdk_rect.y = y;
+ gdk_rect.x = 0;
+ gdk_rect.y = 0;
gdk_rect.width = w;
gdk_rect.height = h;
gtk_widget_draw( m_wxwindow, &gdk_rect );
bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) )
{
SetInvokingWindow( menu, this );
- gtk_menu_popup( GTK_MENU(menu->m_menu), NULL, NULL, NULL, NULL, 0, 0 );
+ gtk_menu_popup( GTK_MENU(menu->m_menu), (GtkWidget *) NULL, (GtkWidget *) NULL, (GtkMenuPositionFunc) NULL, NULL, 0, 0 );
return TRUE;
}
return connect_widget;
}
+bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
+{
+ if (m_wxwindow) return (window == m_wxwindow->window);
+ return (window == m_widget->window);
+}
+
void wxWindow::SetFont( const wxFont &font )
{
m_font = font;
(GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK),
- NULL, NULL, GDK_CURRENT_TIME );
+ (GdkWindow *) NULL, (GdkCursor *) NULL, GDK_CURRENT_TIME );
}
void wxWindow::ReleaseMouse(void)
if (res) return res;
node = node->Next();
}
- return NULL;
+ return (wxWindow *) NULL;
}
wxWindow *wxWindow::FindWindow( const wxString& name )
if (res) return res;
node = node->Next();
}
- return NULL;
+ return (wxWindow *) NULL;
}
void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
if (m_wxwindow->window)
{
if (orient == wxHORIZONTAL)
- {
-/*
- m_drawingOffsetX = -16000;
-
- gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
-*/
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
- }
else
- {
-/*
- m_drawingOffsetY = -16000;
-
- gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
-*/
gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" );
- }
gtk_widget_set_usize( m_widget, m_width, m_height );
}
{
if (!m_wxwindow) return;
+/*
bool refresh = FALSE;
if ((m_drawingOffsetX == 0) && (m_drawingOffsetY == 0))
if (refresh) Refresh();
-/*
The code here is very nifty, but it doesn't work with
overlapping windows...
+*/
int cw = 0;
int ch = 0;
if (dx != 0) rect.height = ch; else rect.height = abs(dy);
Refresh( TRUE, &rect );
-*/
-}
-
-void wxWindow::GetDrawingOffset( long *x, long *y )
-{
- if (x) *x = m_drawingOffsetX;
- if (y) *y = m_drawingOffsetY;
}
//-------------------------------------------------------------------------------------
node = next;
}
delete m_constraintsInvolvedIn;
- m_constraintsInvolvedIn = NULL;
+ m_constraintsInvolvedIn = (wxList *) NULL;
}
}