extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor;
static wxWindow *g_captureWindow = (wxWindow*) NULL;
-static wxWindow *g_focusWindow = (wxWindow*) NULL;
+ wxWindow *g_focusWindow = (wxWindow*) NULL;
/* hack: we need something to pass to gtk_menu_popup, so we store the time of
the last click here */
static gint gtk_debug_focus_in_callback( GtkWidget *WXUNUSED(widget),
GdkEvent *WXUNUSED(event),
- const wxChar *name )
+ const wxChar *WXUNUSED(name) )
{
/*
static bool s_done = FALSE;
win->m_width-dw, win->m_height-dh );
return;
}
+
+ if (win->HasFlag(wxSIMPLE_BORDER))
+ {
+ GdkGC *gc = gdk_gc_new( widget->window );
+ gdk_gc_set_foreground( gc, &widget->style->black );
+ gdk_draw_rectangle( widget->window, gc, FALSE,
+ dx, dy,
+ win->m_width-dw-1, win->m_height-dh-1 );
+ gdk_gc_unref( gc );
+ return;
+ }
}
//-----------------------------------------------------------------------------
ret = (ret || win->GetEventHandler()->ProcessEvent( event2 ));
}
-
/* win is a control: tab can be propagated up */
if ( (!ret) &&
((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
-
+
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
if (gdk_event->is_hint)
// "value_changed" from m_vAdjust
//-----------------------------------------------------------------------------
-static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
+static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win )
{
if (g_isIdle)
wxapp_install_idle_handler();
if (g_blockEventsOnDrag) return;
if (!win->m_hasVMT) return;
-
- float diff = win->m_vAdjust->value - win->m_oldVerticalPos;
+
+ float diff = adjust->value - win->m_oldVerticalPos;
if (fabs(diff) < 0.2) return;
- win->m_oldVerticalPos = win->m_vAdjust->value;
+
+ win->m_oldVerticalPos = adjust->value;
- wxEventType command = wxEVT_NULL;
-
- float line_step = win->m_vAdjust->step_increment;
- float page_step = win->m_vAdjust->page_increment;
-
- if (win->IsScrolling())
- {
- command = wxEVT_SCROLLWIN_THUMBTRACK;
- }
- else
- {
- if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM;
- else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP;
- else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEDOWN;
- else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEUP;
- else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEDOWN;
- else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEUP;
- else command = wxEVT_SCROLLWIN_THUMBTRACK;
- }
+ GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
+ GtkRange *range = GTK_RANGE( scrolledWindow->vscrollbar );
+
+ wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
+ if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
+ else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
+ else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
+ else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
+
+// if (fabs(adjust->value-adjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM;
+// if (fabs(adjust->value-adjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP;
- int value = (int)(win->m_vAdjust->value+0.5);
+ int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxVERTICAL );
event.SetEventObject( win );
// "value_changed" from m_hAdjust
//-----------------------------------------------------------------------------
-static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
+static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win )
{
if (g_isIdle)
wxapp_install_idle_handler();
if (g_blockEventsOnDrag) return;
if (!win->m_hasVMT) return;
- float diff = win->m_hAdjust->value - win->m_oldHorizontalPos;
+ float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return;
- win->m_oldHorizontalPos = win->m_hAdjust->value;
+
+ win->m_oldHorizontalPos = adjust->value;
- wxEventType command = wxEVT_NULL;
+ GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
+ GtkRange *range = GTK_RANGE( scrolledWindow->hscrollbar );
+
+ wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
+ if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
+ else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
+ else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
+ else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
+
+// if (fabs(adjust->value-adjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM;
+// if (fabs(adjust->value-adjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP;
- float line_step = win->m_hAdjust->step_increment;
- float page_step = win->m_hAdjust->page_increment;
-
- if (win->IsScrolling())
- {
- command = wxEVT_SCROLLWIN_THUMBTRACK;
- }
- else
- {
- if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM;
- else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP;
- else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEDOWN;
- else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEUP;
- else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEDOWN;
- else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEUP;
- else command = wxEVT_SCROLLWIN_THUMBTRACK;
- }
-
- int value = (int)(win->m_hAdjust->value+0.5);
+ int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxHORIZONTAL );
event.SetEventObject( win );
wxapp_install_idle_handler();
// don't test here as we can release the mouse while being over
-// a different window then the slider
+// a different window than the slider
//
// if (gdk_event->window != widget->slider) return FALSE;
{
// don't test here as we can release the mouse while being over
-// a different window then the slider
+// a different window than the slider
//
// if (gdk_event->window != widget->slider) return FALSE;
- GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
-
- if (widget == GTK_RANGE(scrolledWindow->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" );
+// GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
+//
+// if (widget == GTK_RANGE(scrolledWindow->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->SetScrolling( FALSE );
// "realize" from m_widget
//-----------------------------------------------------------------------------
-/* we cannot set colours, fonts and cursors before the widget has
+/* we cannot set colours and fonts before the widget has
been realized, so we do this directly after realization */
static gint
if (win->m_delayedForegroundColour)
win->SetForegroundColour( win->GetForegroundColour() );
- win->SetCursor( win->GetCursor() );
-
wxWindowCreateEvent event( win );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
m_insertCallback = (wxInsertChildFunction) NULL;
m_isStaticBox = FALSE;
+ m_isRadioButton = FALSE;
m_acceptsFocus = FALSE;
+
+ m_cursor = *wxSTANDARD_CURSOR;
}
wxWindow::wxWindow()
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
- PreCreation( parent, id, pos, size, style, name );
+ if (!PreCreation( parent, pos, size ) ||
+ !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
+ {
+ wxFAIL_MSG( _T("wxWindow creation failed") );
+ return FALSE;
+ }
m_insertCallback = wxInsertChildInWindow;
if (HasFlag(wxRAISED_BORDER))
{
- gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_OUT );
+ gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_OUT );
}
else if (HasFlag(wxSUNKEN_BORDER))
{
- gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_IN );
+ gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_IN );
+ }
+ else if (HasFlag(wxSIMPLE_BORDER))
+ {
+ gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_THIN );
}
else
{
- gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_NONE );
+ gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_NONE );
}
#else // GTK_MINOR_VERSION == 0
GtkViewport *viewport = GTK_VIEWPORT(scrolledWindow->viewport);
}
}
-void wxWindow::PreCreation( wxWindow *parent,
- wxWindowID id,
- const wxPoint &pos,
- const wxSize &size,
- long style,
- const wxString &name )
+bool wxWindow::PreCreation( wxWindow *parent, const wxPoint &pos, const wxSize &size )
{
- wxASSERT_MSG( !m_needParent || parent, _T("Need complete parent.") );
-
- if ( !CreateBase(parent, id, pos, size, style, name) )
- {
- wxFAIL_MSG(_T("window creation failed"));
- }
+ wxCHECK_MSG( !m_needParent || parent, FALSE, _T("Need complete parent.") );
+ /* this turns -1 into 20 so that a minimal window is
+ visible even although -1,-1 has been given as the
+ size of the window. the same trick is used in other
+ ports and should make debugging easier */
m_width = WidthDefault(size.x);
m_height = HeightDefault(size.y);
m_x = (int)pos.x;
m_y = (int)pos.y;
- if (!parent) /* some reasonable defaults */
+ /* some reasonable defaults */
+ if (!parent)
{
if (m_x == -1)
{
if (m_y < 10) m_y = 10;
}
}
+
+ return TRUE;
}
void wxWindow::PostCreation()
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
#if (GTK_MINOR_VERSION > 0)
- /* these are called when the "sunken" or "raised" borders are drawn */
+ /* these are called when the "sunken", "raised" or "simple" borders are drawn */
gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );
if (cursor.Ok() && m_currentGdkCursor != cursor)
{
+ m_currentGdkCursor = cursor;
+
if (m_wxwindow)
{
GdkWindow *window = m_wxwindow->window;
cursor = *wxSTANDARD_CURSOR;
window = m_widget->window;
- if (window)
+ if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget)))
gdk_window_set_cursor( window, cursor.GetCursor() );
+
}
else
{
+
GdkWindow *window = m_widget->window;
- if (window)
+ if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget)))
gdk_window_set_cursor( window, cursor.GetCursor() );
- }
- m_currentGdkCursor = cursor;
+ }
}
UpdateWindowUI();
int dw = 0;
int dh = 0;
- GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
- GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
-
#if (GTK_MINOR_VERSION == 0)
- GtkWidget *viewport = scroll_window->viewport;
- GtkStyleClass *viewport_class = viewport->style->klass;
-
if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
{
- dw += 2 * viewport_class->xthickness;
- dh += 2 * viewport_class->ythickness;
+ if (HasScrolling())
+ {
+ GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
+#if 0 // unused - if this is ok, just remove this line (VZ)
+ GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
+#endif // 0
+
+ GtkWidget *viewport = scroll_window->viewport;
+ GtkStyleClass *viewport_class = viewport->style->klass;
+
+ dw += 2 * viewport_class->xthickness;
+ dh += 2 * viewport_class->ythickness;
+ }
}
#else
if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
{
- /* when using GTK 1.2 we set the border size to 2 */
+ /* when using GTK 1.2 we set the shadow border size to 2 */
dw += 2 * 2;
dh += 2 * 2;
}
+ if (HasFlag(wxSIMPLE_BORDER))
+ {
+ /* when using GTK 1.2 we set the simple border size to 1 */
+ dw += 1 * 2;
+ dh += 1 * 2;
+ }
#endif
if (HasScrolling())
we use this instead: range.slider_width = 11 + 2*2pts edge
*/
+ GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
+ GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
+
if (scroll_window->vscrollbar_visible)
{
dw += 15; /* dw += vscrollbar->allocation.width; */
if (HasScrolling())
{
GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
+#if 0 // unused - if this is ok, just remove this line (VZ)
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
+#endif // 0
GtkWidget *viewport = scroll_window->viewport;
GtkStyleClass *viewport_class = viewport->style->klass;
#else
if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
{
- /* when using GTK 1.2 we set the border size to 2 */
+ /* when using GTK 1.2 we set the shadow border size to 2 */
dw += 2 * 2;
dh += 2 * 2;
}
+ if (HasFlag(wxSIMPLE_BORDER))
+ {
+ /* when using GTK 1.2 we set the simple border size to 1 */
+ dw += 1 * 2;
+ dh += 1 * 2;
+ }
#endif
if (HasScrolling())
{
return m_acceptsFocus && wxWindowBase::AcceptsFocus();
}
-bool wxWindow::Reparent( wxWindow *newParent )
+bool wxWindow::Reparent( wxWindowBase *newParentBase )
{
wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
- wxWindow *oldParent = m_parent;
+ wxWindow *oldParent = m_parent,
+ *newParent = (wxWindow *)newParentBase;
if ( !wxWindowBase::Reparent(newParent) )
return FALSE;
{
wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
- if (!wxWindowBase::SetCursor(cursor))
- {
- // don't leave if the GTK widget has just
- // been realized
- if (!m_delayedCursor) return FALSE;
- }
-
- GtkWidget *connect_widget = GetConnectWidget();
- if (!connect_widget->window)
- {
- // indicate that a new style has been set
- // but it couldn't get applied as the
- // widget hasn't been realized yet.
- m_delayedCursor = TRUE;
-
- // pretend we have done something
- return TRUE;
- }
-
-// gdk_window_set_cursor( connect_widget->window, GetCursor().GetCursor() );
-
- // cursor was set
- return TRUE;
+ return wxWindowBase::SetCursor( cursor );
}
void wxWindow::WarpPointer( int x, int y )
{
}
+//-----------------------------------------------------------------------------
+// Pop-up menu stuff
+//-----------------------------------------------------------------------------
+
+static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting )
+{
+ *is_waiting = FALSE;
+}
+
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
*y = gs_pop_y;
}
-bool wxWindow::PopupMenu( wxMenu *menu, int x, int y )
+bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y )
{
wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
gs_pop_x = x;
gs_pop_y = y;
+ bool is_waiting = TRUE;
+
+ gtk_signal_connect( GTK_OBJECT(menu->m_menu), "hide",
+ GTK_SIGNAL_FUNC(gtk_pop_hide_callback), (gpointer)&is_waiting );
+
gtk_menu_popup(
GTK_MENU(menu->m_menu),
(GtkWidget *) NULL, // parent menu shell
0, // button used to activate it
0 //gs_timeLastClick // the time of activation
);
+
+ while (is_waiting)
+ {
+ while (gtk_events_pending())
+ gtk_main_iteration();
+ }
+
return TRUE;
}
bool wxWindow::SetFont( const wxFont &font )
{
- wxCHECK_MSG( m_widget != NULL, FALSE, _T( "invalid window") );
+ wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
if (!wxWindowBase::SetFont(font))
{
m_vAdjust->value = fpos;
}
- if (!m_isScrolling) /* prevent recursion */
+/*
+ if (!m_isScrolling)
{
+*/
if (m_wxwindow->window)
{
if (orient == wxHORIZONTAL)
else
gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" );
}
+/*
}
+*/
}
int wxWindow::GetScrollThumb( int orient ) const