extern wxList wxPendingDelete;
extern wxList wxTopLevelWindows;
extern bool g_blockEventsOnDrag;
+ bool g_capturing = FALSE;
//-----------------------------------------------------------------------------
// "expose_event" (of m_wxwindow, not of m_widget)
if (gdk_event->count > 0) return;
+/*
+ printf( "OnExpose from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
// Some control don't have their own X window and thus cannot get
// any events.
- wxNode *node = win->GetChildren()->First();
- while (node)
+ if (!g_capturing)
{
- wxWindow *child = (wxWindow*)node->Data();
- if ((child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ wxNode *node = win->GetChildren()->First();
+ while (node)
{
- win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
- break;
+ wxWindow *child = (wxWindow*)node->Data();
+ if ((child->m_x <= event.m_x) &&
+ (child->m_y <= event.m_y) &&
+ (child->m_x+child->m_width >= event.m_x) &&
+ (child->m_y+child->m_height >= event.m_y))
+ {
+ win = child;
+ event.m_x -= child->m_x;
+ event.m_y -= child->m_y;
+ break;
+ }
+ node = node->Next();
}
- node = node->Next();
}
event.SetEventObject( win );
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return TRUE;
// Some control don't have their own X window and thus cannot get
// any events.
- wxNode *node = win->GetChildren()->First();
- while (node)
+ if (!g_capturing)
{
- wxWindow *child = (wxWindow*)node->Data();
- if ((child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ wxNode *node = win->GetChildren()->First();
+ while (node)
{
- win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
- break;
+ wxWindow *child = (wxWindow*)node->Data();
+ if ((child->m_x <= event.m_x) &&
+ (child->m_y <= event.m_y) &&
+ (child->m_x+child->m_width >= event.m_x) &&
+ (child->m_y+child->m_height >= event.m_y))
+ {
+ win = child;
+ event.m_x -= child->m_x;
+ event.m_y -= child->m_y;
+ break;
+ }
+ node = node->Next();
}
- node = node->Next();
}
event.SetEventObject( win );
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return TRUE;
// Some control don't have their own X window and thus cannot get
// any events.
- wxNode *node = win->GetChildren()->First();
- while (node)
+ if (!g_capturing)
{
- wxWindow *child = (wxWindow*)node->Data();
- if ((child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ wxNode *node = win->GetChildren()->First();
+ while (node)
{
- win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
- break;
+ wxWindow *child = (wxWindow*)node->Data();
+ if ((child->m_x <= event.m_x) &&
+ (child->m_y <= event.m_y) &&
+ (child->m_x+child->m_width >= event.m_x) &&
+ (child->m_y+child->m_height >= event.m_y))
+ {
+ win = child;
+ event.m_x -= child->m_x;
+ event.m_y -= child->m_y;
+ break;
+ }
+ node = node->Next();
}
- node = node->Next();
}
event.SetEventObject( win );
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
if (widget->window != gdk_event->window) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
+
if (!win->HasVMT()) return TRUE;
- if (widget->window)
+/*
+ printf( "OnEnter from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
+ if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() );
wxMouseEvent event( wxEVT_ENTER_WINDOW );
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
if (widget->window != gdk_event->window) return TRUE;
- if (!win->HasVMT()) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
- if (widget->window)
+ if (!win->HasVMT()) return TRUE;
+
+/*
+ printf( "OnLeave from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
+ if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
wxMouseEvent event( wxEVT_LEAVE_WINDOW );
win->GetEventHandler()->ProcessEvent( event );
}
+//-----------------------------------------------------------------------------
+// "button_press_event" from scrollbar
+//-----------------------------------------------------------------------------
+
+static gint gtk_scrollbar_button_press_callback( GtkRange *widget, GdkEventButton *gdk_event, wxWindow *win )
+{
+ if (gdk_event->window != widget->slider) return FALSE;
+
+ win->m_isScrolling = TRUE;
+
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// "button_release_event" from scrollbar
+//-----------------------------------------------------------------------------
+
+static gint gtk_scrollbar_button_release_callback( GtkRange *widget, GdkEventButton *gdk_event, wxWindow *win )
+{
+ if (gdk_event->window != widget->slider) return FALSE;
+
+ GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(win->m_widget);
+
+ if (widget == GTK_RANGE(s_window->vscrollbar))
+ gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" );
+ else
+ gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" );
+
+ win->m_isScrolling = FALSE;
+
+ return FALSE;
+}
+
//-----------------------------------------------------------------------------
// "drop_data_available_event"
//-----------------------------------------------------------------------------
m_eventHandler = this;
m_windowValidator = (wxValidator *) NULL;
m_windowId = -1;
- m_cursor = new wxCursor( wxCURSOR_ARROW );
+ m_cursor = (wxCursor *) NULL;
m_font = *wxSWISS_FONT;
m_windowStyle = 0;
m_windowName = "noname";
m_hasVMT = FALSE;
m_needParent = TRUE;
m_hasScrolling = FALSE;
+ m_isScrolling = FALSE;
m_hAdjust = (GtkAdjustment *) NULL;
m_vAdjust = (GtkAdjustment *) NULL;
m_oldHorizontalPos = 0.0;
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
m_hasScrolling = TRUE;
- GtkScrolledWindow *s_window;
- s_window = GTK_SCROLLED_WINDOW(m_widget);
-
+ GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
+
+ gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_press_event",
+ (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_press_event",
+ (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_release_event",
+ (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_release_event",
+ (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
+
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
scroll_class->scrollbar_spacing = 0;
m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->hscrollbar) );
m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->vscrollbar) );
- gtk_signal_connect (GTK_OBJECT (m_hAdjust), "value_changed",
+ gtk_signal_connect( GTK_OBJECT(m_hAdjust), "value_changed",
(GtkSignalFunc) gtk_window_hscroll_callback, (gpointer) this );
- gtk_signal_connect (GTK_OBJECT (m_vAdjust), "value_changed",
+ gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed",
(GtkSignalFunc) gtk_window_vscroll_callback, (gpointer) this );
- gtk_signal_connect (GTK_OBJECT (m_hAdjust), "changed",
+ gtk_signal_connect( GTK_OBJECT(m_hAdjust), "changed",
(GtkSignalFunc) gtk_window_hscroll_change_callback, (gpointer) this );
- gtk_signal_connect (GTK_OBJECT (m_vAdjust), "changed",
+ gtk_signal_connect(GTK_OBJECT(m_vAdjust), "changed",
(GtkSignalFunc) gtk_window_vscroll_change_callback, (gpointer) this );
- GtkViewport *viewport;
- viewport = GTK_VIEWPORT(s_window->viewport);
+ GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
if (m_windowStyle & wxRAISED_BORDER)
{
m_windowSizer = (wxSizer *) NULL;
m_sizerParent = (wxWindow *) NULL;
m_autoLayout = FALSE;
+ m_hasScrolling = FALSE;
+ m_isScrolling = FALSE;
m_pDropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL;
gdk_gc_set_exposures( m_wxwindow->style->fg_gc[0], TRUE );
}
- SetCursor( wxSTANDARD_CURSOR );
+ SetCursor( *wxSTANDARD_CURSOR );
m_hasVMT = TRUE;
}
bool wxWindow::Close( bool force )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
event.SetEventObject(this);
event.SetForce(force);
bool wxWindow::Destroy(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
m_hasVMT = FALSE;
delete this;
return TRUE;
void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (m_resizing) return; // I don't like recursions
m_resizing = TRUE;
void wxWindow::GetSize( int *width, int *height ) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (width) (*width) = m_width;
if (height) (*height) = m_height;
}
void wxWindow::SetClientSize( int width, int height )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (!m_wxwindow)
{
SetSize( width, height );
void wxWindow::GetClientSize( int *width, int *height ) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (!m_wxwindow)
{
if (width) (*width) = m_width;
void wxWindow::GetPosition( int *x, int *y ) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (x) (*x) = m_x;
if (y) (*y) = m_y;
}
void wxWindow::ClientToScreen( int *x, int *y )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
void wxWindow::ScreenToClient( int *x, int *y )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
void wxWindow::Centre( int direction )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (IS_KIND_OF(this,wxDialog) || IS_KIND_OF(this,wxFrame))
{
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
void wxWindow::Fit(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
int maxX = 0;
int maxY = 0;
wxNode *node = GetChildren()->First();
void wxWindow::SetSizeHints( int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH) )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
m_minWidth = minW;
m_minHeight = minH;
m_maxWidth = maxW;
bool wxWindow::Show( bool show )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (show)
gtk_widget_show( m_widget );
else
void wxWindow::Enable( bool enable )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
m_isEnabled = enable;
gtk_widget_set_sensitive( m_widget, enable );
if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable );
int wxWindow::GetCharHeight(void) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ if (!m_font.Ok())
+ {
+ wxFAIL_MSG( "invalid font" );
+ return -1;
+ }
+
GdkFont *font = m_font.GetInternalFont( 1.0 );
return font->ascent + font->descent;
}
int wxWindow::GetCharWidth(void) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ if (!m_font.Ok())
+ {
+ wxFAIL_MSG( "invalid font" );
+ return -1;
+ }
+
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
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxFont fontToUse = m_font;
if (theFont) fontToUse = *theFont;
+ if (!fontToUse.Ok())
+ {
+ wxFAIL_MSG( "invalid font" );
+ return;
+ }
+ wxASSERT_MSG( (m_font.Ok()), "invalid font" );
+
GdkFont *font = fontToUse.GetInternalFont( 1.0 );
if (x) (*x) = gdk_string_width( font, string );
if (y) (*y) = font->ascent + font->descent;
void wxWindow::SetFocus(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
GtkWidget *connect_widget = GetConnectWidget();
if (connect_widget)
{
void wxWindow::AddChild( wxWindow *child )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxASSERT_MSG( (m_wxwindow != NULL), "window need client area" );
+ wxASSERT_MSG( (child != NULL), "invalid child" );
+ wxASSERT_MSG( (child->m_widget != NULL), "invalid child" );
+
// Addchild is (often) called before the program
// has left the parents constructor so that no
// virtual tables work yet. The approach below
void wxWindow::RemoveChild( wxWindow *child )
{
if (GetChildren())
- GetChildren()->DeleteObject( child );
+ GetChildren()->DeleteObject( child );
child->m_parent = (wxWindow *) NULL;
}
void wxWindow::Raise(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (m_widget) gdk_window_raise( m_widget->window );
}
void wxWindow::Lower(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (m_widget) gdk_window_lower( m_widget->window );
}
void wxWindow::PushEventHandler(wxEvtHandler *handler)
{
- handler->SetNextHandler(GetEventHandler());
- SetEventHandler(handler);
+ handler->SetNextHandler(GetEventHandler());
+ SetEventHandler(handler);
}
wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
{
- if ( GetEventHandler() )
- {
- wxEvtHandler *handlerA = GetEventHandler();
- wxEvtHandler *handlerB = handlerA->GetNextHandler();
- handlerA->SetNextHandler((wxEvtHandler *) NULL);
- SetEventHandler(handlerB);
- if ( deleteHandler )
- {
- delete handlerA;
- return (wxEvtHandler *) NULL;
- }
- else
- return handlerA;
- }
- else
- return (wxEvtHandler *) NULL;
+ if (GetEventHandler())
+ {
+ wxEvtHandler *handlerA = GetEventHandler();
+ wxEvtHandler *handlerB = handlerA->GetNextHandler();
+ handlerA->SetNextHandler((wxEvtHandler *) NULL);
+ SetEventHandler(handlerB);
+ if (deleteHandler)
+ {
+ delete handlerA;
+ return (wxEvtHandler*) NULL;
+ }
+ else
+ return handlerA;
+ }
+ else
+ return (wxEvtHandler *) NULL;
}
wxValidator *wxWindow::GetValidator(void)
void wxWindow::SetCursor( const wxCursor &cursor )
{
- wxASSERT(m_cursor != NULL);
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ if (m_cursor == NULL)
+ {
+ wxFAIL_MSG( "wxWindow::SetCursor m_cursor == NULL" );
+ m_cursor = new wxCursor( wxCURSOR_ARROW );
+ }
+
+ if (cursor.Ok())
+ {
+ if (*((wxCursor*)&cursor) == m_cursor) return;
+ *m_cursor = cursor;
+ }
+ else
+ {
+ *m_cursor = *wxSTANDARD_CURSOR;
+ }
- if (m_cursor != NULL)
- if (*m_cursor == cursor)
- return;
- (*m_cursor) = cursor;
- if (m_widget->window)
+ if ((m_widget) && (m_widget->window))
gdk_window_set_cursor( m_widget->window, m_cursor->GetCursor() );
- if (m_wxwindow && m_wxwindow->window)
+
+ if ((m_wxwindow) && (m_wxwindow->window))
gdk_window_set_cursor( m_wxwindow->window, m_cursor->GetCursor() );
}
void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (eraseBackground && m_wxwindow && m_wxwindow->window)
{
if (rect)
void wxWindow::Clear(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
}
void wxWindow::SetBackgroundColour( const wxColour &colour )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
m_backgroundColour = colour;
if (m_wxwindow)
{
bool wxWindow::Validate(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxNode *node = GetChildren()->First();
while (node)
{
bool wxWindow::TransferDataToWindow(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxNode *node = GetChildren()->First();
while (node)
{
bool wxWindow::TransferDataFromWindow(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxNode *node = GetChildren()->First();
while (node)
{
void wxWindow::InitDialog(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxInitDialogEvent event(GetId());
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
SetInvokingWindow( menu, this );
gtk_menu_popup( GTK_MENU(menu->m_menu), (GtkWidget *) NULL, (GtkWidget *) NULL, (GtkMenuPositionFunc) NULL, NULL, 0, 0 );
return TRUE;
void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
GtkWidget *dnd_widget = GetConnectWidget();
DisconnectDnDWidget( dnd_widget );
void wxWindow::SetFont( const wxFont &font )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (((wxFont*)&font)->Ok())
m_font = font;
else
void wxWindow::CaptureMouse(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ wxASSERT_MSG( (g_capturing == FALSE), "CaptureMouse called twice" );
+
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_add( connect_widget );
gdk_pointer_grab ( connect_widget->window, FALSE,
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK),
(GdkWindow *) NULL, (GdkCursor *) NULL, GDK_CURRENT_TIME );
+ g_capturing = TRUE;
}
void wxWindow::ReleaseMouse(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ wxASSERT_MSG( (g_capturing == TRUE), "ReleaseMouse called twice" );
+
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_remove( connect_widget );
gdk_pointer_ungrab ( GDK_CURRENT_TIME );
+ g_capturing = FALSE;
}
void wxWindow::SetTitle( const wxString &WXUNUSED(title) )
}
void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
- int range, bool WXUNUSED(refresh) )
+ int range, bool refresh )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
+
if (!m_wxwindow) return;
if (orient == wxHORIZONTAL)
{
float fpos = (float)pos;
- m_oldHorizontalPos = fpos;
float frange = (float)range;
float fthumb = (float)thumbVisible;
- if ((fabs(fpos-m_hAdjust->value) < 0.2) &&
- (fabs(frange-m_hAdjust->upper) < 0.2) &&
- (fabs(fthumb-m_hAdjust->page_size) < 0.2))
+ if ((fabs(frange-m_hAdjust->upper) < 0.2) &&
+ (fabs(fthumb-m_hAdjust->page_size) < 0.2))
+ {
+ SetScrollPos( orient, pos, refresh );
return;
+ }
+ m_oldHorizontalPos = fpos;
+
m_hAdjust->lower = 0.0;
m_hAdjust->upper = frange;
m_hAdjust->value = fpos;
m_hAdjust->step_increment = 1.0;
- m_hAdjust->page_increment = (float)(wxMax(fthumb-2,0));
+ m_hAdjust->page_increment = (float)(wxMax(fthumb,0));
m_hAdjust->page_size = fthumb;
}
else
{
float fpos = (float)pos;
- m_oldVerticalPos = fpos;
float frange = (float)range;
float fthumb = (float)thumbVisible;
- if ((fabs(fpos-m_vAdjust->value) < 0.2) &&
- (fabs(frange-m_vAdjust->upper) < 0.2) &&
- (fabs(fthumb-m_vAdjust->page_size) < 0.2))
+ if ((fabs(frange-m_vAdjust->upper) < 0.2) &&
+ (fabs(fthumb-m_vAdjust->page_size) < 0.2))
+ {
+ SetScrollPos( orient, pos, refresh );
return;
+ }
+
+ m_oldVerticalPos = fpos;
m_vAdjust->lower = 0.0;
m_vAdjust->upper = frange;
m_vAdjust->value = fpos;
m_vAdjust->step_increment = 1.0;
- m_vAdjust->page_increment = (float)(wxMax(fthumb-2,0));
+ m_vAdjust->page_increment = (float)(wxMax(fthumb,0));
m_vAdjust->page_size = fthumb;
}
void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
+
if (!m_wxwindow) return;
if (orient == wxHORIZONTAL)
m_vAdjust->value = fpos;
}
- if (m_wxwindow->window)
- {
- if (orient == wxHORIZONTAL)
- gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" );
- else
- gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" );
+ if (!m_isScrolling)
+ {
+ if (m_wxwindow->window)
+ {
+ if (orient == wxHORIZONTAL)
+ gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" );
+ else
+ gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" );
+ }
}
}
int wxWindow::GetScrollThumb( int orient ) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
+
if (!m_wxwindow) return 0;
if (orient == wxHORIZONTAL)
int wxWindow::GetScrollPos( int orient ) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
+
if (!m_wxwindow) return 0;
if (orient == wxHORIZONTAL)
int wxWindow::GetScrollRange( int orient ) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
+
if (!m_wxwindow) return 0;
if (orient == wxHORIZONTAL)
void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
{
- if (!m_wxwindow) return;
-
-/*
- bool refresh = FALSE;
-
- if ((m_drawingOffsetX == 0) && (m_drawingOffsetY == 0))
- {
- m_drawingOffsetX = -16000;
- m_drawingOffsetY = -16000;
- refresh = TRUE;
- }
- else
- {
- m_drawingOffsetX += dx;
- m_drawingOffsetY += dy;
- }
-
-// printf( "X: %d Y: %d \n", (int)m_drawingOffsetX, (int)m_drawingOffsetY );
-
- gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- if (refresh) Refresh();
+ wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
- The code here is very nifty, but it doesn't work with
- overlapping windows...
-*/
+ if (!m_wxwindow) return;
int cw = 0;
int ch = 0;