// Name: window.cpp
// Purpose:
// Author: Robert Roebling
-// Created: 01/02/97
-// Id:
-// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
+// Id: $Id$
+// Copyright: (c) 1998 Robert Roebling, Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
if (gdk_event->count > 0) return;
/*
- printf( "OnExpose from " );
+ printf( "OnExpose from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" );
// "drop_data_available_event"
//-----------------------------------------------------------------------------
-static void gtk_window_drop_callback( GtkWidget *widget, GdkEvent *event, wxWindow *win )
+static void gtk_window_drop_callback( GtkWidget *widget, GdkEventDropDataAvailable *event, wxWindow *win )
{
if (!win->HasVMT()) return;
int x = 0;
int y = 0;
gdk_window_get_pointer( widget->window, &x, &y, (GdkModifierType *) NULL );
+ win->GetDropTarget()->m_size = event->data_numbytes;
win->GetDropTarget()->Drop( event, x, y );
}
m_isEnabled = TRUE;
m_pDropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
- m_hasOwnStyle = FALSE;
+ m_scrollGC = (GdkGC*) NULL;
+ m_widgetStyle = (GtkStyle*) NULL;
}
bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_wxwindow = gtk_myfixed_new();
- if (m_wxwindow) GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
+ GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
if (m_windowStyle & wxTAB_TRAVERSAL == wxTAB_TRAVERSAL)
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
gtk_widget_show( m_wxwindow );
PostCreation();
-
+
Show( TRUE );
return TRUE;
}
-wxWindow::~wxWindow(void)
+wxWindow::~wxWindow()
{
m_hasVMT = FALSE;
DestroyChildren();
+ if (m_widgetStyle) gtk_style_unref( m_widgetStyle );
+
+ if (m_scrollGC) gdk_gc_unref( m_scrollGC );
+
if (m_wxwindow) gtk_widget_destroy( m_wxwindow );
if (m_widget) gtk_widget_destroy( m_widget );
if (m_cursor == NULL)
m_cursor = new wxCursor( wxCURSOR_ARROW );
m_font = *wxSWISS_FONT;
- m_backgroundColour = wxWHITE;
- m_foregroundColour = wxBLACK;
+// m_backgroundColour = wxWHITE;
+// m_foregroundColour = wxBLACK;
m_windowStyle = style;
m_windowName = name;
m_constraints = (wxLayoutConstraints *) NULL;
m_pDropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL;
- m_hasOwnStyle = FALSE;
+ m_scrollGC = (GdkGC*) NULL;
+ m_widgetStyle = (GtkStyle*) NULL;
}
-void wxWindow::PostCreation(void)
+void wxWindow::PostCreation()
{
if (m_parent) m_parent->AddChild( this );
if (m_widget && m_parent) gtk_widget_realize( m_widget );
- if (m_wxwindow)
- {
- gtk_widget_realize( m_wxwindow );
- gdk_gc_set_exposures( m_wxwindow->style->fg_gc[0], TRUE );
- }
+ if (m_wxwindow) gtk_widget_realize( m_wxwindow );
SetCursor( *wxSTANDARD_CURSOR );
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
}
-bool wxWindow::HasVMT(void)
+bool wxWindow::HasVMT()
{
return m_hasVMT;
}
return GetEventHandler()->ProcessEvent(event);
}
-bool wxWindow::Destroy(void)
+bool wxWindow::Destroy()
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
return TRUE;
}
-bool wxWindow::DestroyChildren(void)
+bool wxWindow::DestroyChildren()
{
if (GetChildren())
{
// are we to set fonts here ?
}
-void wxWindow::ImplementSetSize(void)
+void wxWindow::ImplementSetSize()
{
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
gtk_widget_set_usize( m_widget, m_width, m_height );
}
-void wxWindow::ImplementSetPosition(void)
+void wxWindow::ImplementSetPosition()
{
if (IS_KIND_OF(this,wxFrame) || IS_KIND_OF(this,wxDialog))
{
}
}
-void wxWindow::Fit(void)
+void wxWindow::Fit()
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable );
}
-int wxWindow::GetCharHeight(void) const
+int wxWindow::GetCharHeight() const
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
return font->ascent + font->descent;
}
-int wxWindow::GetCharWidth(void) const
+int wxWindow::GetCharWidth() const
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
}
}
-void wxWindow::SetFocus(void)
+void wxWindow::SetFocus()
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
}
}
-bool wxWindow::OnClose(void)
+bool wxWindow::OnClose()
{
return TRUE;
}
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
}
-wxList *wxWindow::GetChildren(void)
+wxList *wxWindow::GetChildren()
{
return (&m_children);
}
m_retCode = retCode;
}
-int wxWindow::GetReturnCode(void)
+int wxWindow::GetReturnCode()
{
return m_retCode;
}
-void wxWindow::Raise(void)
+void wxWindow::Raise()
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_widget) gdk_window_raise( m_widget->window );
}
-void wxWindow::Lower(void)
+void wxWindow::Lower()
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_widget) gdk_window_lower( m_widget->window );
}
-wxEvtHandler *wxWindow::GetEventHandler(void)
+wxEvtHandler *wxWindow::GetEventHandler()
{
return m_eventHandler;
}
return (wxEvtHandler *) NULL;
}
-wxValidator *wxWindow::GetValidator(void)
+wxValidator *wxWindow::GetValidator()
{
return m_windowValidator;
}
if (m_windowValidator) m_windowValidator->SetWindow(this);
}
-bool wxWindow::IsBeingDeleted(void)
+bool wxWindow::IsBeingDeleted()
{
return FALSE;
}
m_windowId = id;
}
-wxWindowID wxWindow::GetId(void)
+wxWindowID wxWindow::GetId()
{
return m_windowId;
}
return (m_updateRegion.Contains( rect.x, rect.y, rect.width, rect.height ) != wxOutRegion );
}
-void wxWindow::Clear(void)
+void wxWindow::Clear()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
}
-wxColour wxWindow::GetBackgroundColour(void) const
+wxColour wxWindow::GetBackgroundColour() const
{
return m_backgroundColour;
}
void wxWindow::SetBackgroundColour( const wxColour &colour )
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
m_backgroundColour = colour;
+ if (!m_backgroundColour.Ok()) return;
+
if (m_wxwindow)
{
- m_backgroundColour.CalcPixel( m_wxwindow->style->colormap );
- gdk_window_set_background( m_wxwindow->window, m_backgroundColour.GetColor() );
- gdk_window_clear( m_wxwindow->window );
+ GdkWindow *window = m_wxwindow->window;
+ m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
+ gdk_window_set_background( window, m_backgroundColour.GetColor() );
+ gdk_window_clear( window );
}
- // do something ?
+
+ ApplyWidgetStyle();
}
-wxColour wxWindow::GetForegroundColour(void) const
+wxColour wxWindow::GetForegroundColour() const
{
return m_foregroundColour;
}
void wxWindow::SetForegroundColour( const wxColour &colour )
{
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
+
m_foregroundColour = colour;
+ if (!m_foregroundColour.Ok()) return;
+
+ ApplyWidgetStyle();
}
-bool wxWindow::Validate(void)
+GtkStyle *wxWindow::GetWidgetStyle()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ if (m_widgetStyle) gtk_style_unref( m_widgetStyle );
+
+ m_widgetStyle =
+ gtk_style_copy(
+ gtk_widget_get_style( m_widget ) );
+
+ return m_widgetStyle;
+}
+
+void wxWindow::SetWidgetStyle()
+{
+ GtkStyle *style = GetWidgetStyle();
+
+ gdk_font_unref( style->font );
+ style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
+
+ if (m_foregroundColour.Ok())
+ {
+ m_foregroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) );
+ style->fg[GTK_STATE_NORMAL] = *m_foregroundColour.GetColor();
+ style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor();
+ style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor();
+ }
+
+ if (m_backgroundColour.Ok())
+ {
+ m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) );
+ style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+ style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+ style->bg[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
+ style->base[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
+ style->bg[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
+ style->base[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
+ style->bg[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
+ style->base[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
+ }
+}
+
+void wxWindow::ApplyWidgetStyle()
+{
+}
+
+bool wxWindow::Validate()
+{
+ wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
wxNode *node = GetChildren()->First();
while (node)
return TRUE;
}
-bool wxWindow::TransferDataToWindow(void)
+bool wxWindow::TransferDataToWindow()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
wxNode *node = GetChildren()->First();
while (node)
return TRUE;
}
-bool wxWindow::TransferDataFromWindow(void)
+bool wxWindow::TransferDataFromWindow()
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
TransferDataToWindow();
}
-void wxWindow::InitDialog(void)
+void wxWindow::InitDialog()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
wxInitDialogEvent event(GetId());
event.SetEventObject( this );
bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) )
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
+ wxCHECK_MSG( menu != NULL, FALSE, "invalid popup-menu" );
+
SetInvokingWindow( menu, this );
gtk_menu_popup(
GTK_MENU(menu->m_menu),
void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
GtkWidget *dnd_widget = GetConnectWidget();
m_pDropTarget->UnregisterWidget( widget );
}
-GtkWidget* wxWindow::GetConnectWidget(void)
+GtkWidget* wxWindow::GetConnectWidget()
{
GtkWidget *connect_widget = m_widget;
if (m_wxwindow) connect_widget = m_wxwindow;
void wxWindow::SetFont( const wxFont &font )
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
-
- GtkStyle *style = (GtkStyle*) NULL;
- if (!m_hasOwnStyle)
- {
- m_hasOwnStyle = TRUE;
- style = gtk_style_copy( gtk_widget_get_style( m_widget ) );
- }
- else
- {
- style = gtk_widget_get_style( m_widget );
- }
-
- gdk_font_unref( style->font );
- style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
-
- gtk_widget_set_style( m_widget, style );
+
+ ApplyWidgetStyle();
}
-wxFont *wxWindow::GetFont(void)
+wxFont *wxWindow::GetFont()
{
return &m_font;
}
m_windowStyle = flag;
}
-long wxWindow::GetWindowStyleFlag(void) const
+long wxWindow::GetWindowStyleFlag() const
{
return m_windowStyle;
}
-void wxWindow::CaptureMouse(void)
+void wxWindow::CaptureMouse()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
- wxASSERT_MSG( (g_capturing == FALSE), "CaptureMouse called twice" );
+ wxCHECK_RET( g_capturing == FALSE, "CaptureMouse called twice" );
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_add( connect_widget );
g_capturing = TRUE;
}
-void wxWindow::ReleaseMouse(void)
+void wxWindow::ReleaseMouse()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
- wxASSERT_MSG( (g_capturing == TRUE), "ReleaseMouse called twice" );
+ wxCHECK_RET( g_capturing == TRUE, "ReleaseMouse called twice" );
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_remove( connect_widget );
{
}
-wxString wxWindow::GetTitle(void) const
+wxString wxWindow::GetTitle() const
{
return (wxString&)m_windowName;
}
-wxString wxWindow::GetLabel(void) const
+wxString wxWindow::GetLabel() const
{
return GetTitle();
}
m_windowName = name;
}
-wxString wxWindow::GetName(void) const
+wxString wxWindow::GetName() const
{
return (wxString&)m_windowName;
}
-bool wxWindow::IsShown(void) const
+bool wxWindow::IsShown() const
{
return m_isShown;
}
-bool wxWindow::IsRetained(void)
+bool wxWindow::IsRetained()
{
return FALSE;
}
int d_y = 0;
if (dx > 0) d_x = dx;
if (dy > 0) d_y = dy;
- gdk_window_copy_area( m_wxwindow->window, m_wxwindow->style->fg_gc[0], d_x, d_y,
+
+ if (!m_scrollGC)
+ {
+ m_scrollGC = gdk_gc_new( m_wxwindow->window );
+ gdk_gc_set_exposures( m_scrollGC, TRUE );
+ }
+
+ gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y,
m_wxwindow->window, s_x, s_y, w, h );
wxRect rect;
// Layout
//-------------------------------------------------------------------------------------
-wxLayoutConstraints *wxWindow::GetConstraints(void) const
+wxLayoutConstraints *wxWindow::GetConstraints() const
{
return m_constraints;
}
m_autoLayout = autoLayout;
}
-bool wxWindow::GetAutoLayout(void) const
+bool wxWindow::GetAutoLayout() const
{
return m_autoLayout;
}
-wxSizer *wxWindow::GetSizer(void) const
+wxSizer *wxWindow::GetSizer() const
{
return m_windowSizer;
}
m_sizerParent = win;
}
-wxWindow *wxWindow::GetSizerParent(void) const
+wxWindow *wxWindow::GetSizerParent() const
{
return m_sizerParent;
}
}
// Reset any constraints that mention this window
-void wxWindow::DeleteRelatedConstraints(void)
+void wxWindow::DeleteRelatedConstraints()
{
if (m_constraintsInvolvedIn)
{
* New version
*/
-bool wxWindow::Layout(void)
+bool wxWindow::Layout()
{
if (GetConstraints())
{
return TRUE;
}
-void wxWindow::ResetConstraints(void)
+void wxWindow::ResetConstraints()
{
wxLayoutConstraints *constr = GetConstraints();
if (constr)