From e6527f9dd4ed313b3d651e977f8c1219114e38d4 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 4 Jan 2000 22:56:58 +0000 Subject: [PATCH] Removed crashes when not using themes. Removed much flicker form tree ctrl and list ctrl. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5245 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/filedlgg.cpp | 4 ++-- src/generic/listctrl.cpp | 2 ++ src/generic/treectrl.cpp | 6 ++++-- src/gtk/font.cpp | 13 +++++++++++-- src/gtk/settings.cpp | 32 +++++++++++++++++++------------- src/gtk/window.cpp | 7 ++++++- src/gtk1/font.cpp | 13 +++++++++++-- src/gtk1/settings.cpp | 32 +++++++++++++++++++------------- src/gtk1/window.cpp | 7 ++++++- 9 files changed, 80 insertions(+), 36 deletions(-) diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 909355ded6..c43b4f6428 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -347,7 +347,7 @@ void wxFileCtrl::Update() { InsertColumn( 0, _("Name"), wxLIST_FORMAT_LEFT, 130 ); InsertColumn( 1, _("Size"), wxLIST_FORMAT_LEFT, 60 ); - InsertColumn( 2, _("Date"), wxLIST_FORMAT_LEFT, 70 ); + InsertColumn( 2, _("Date"), wxLIST_FORMAT_LEFT, 65 ); InsertColumn( 3, _("Time"), wxLIST_FORMAT_LEFT, 50 ); InsertColumn( 4, _("Permissions"), wxLIST_FORMAT_LEFT, 120 ); } @@ -397,9 +397,9 @@ void wxFileCtrl::Update() SortItems( ListCompare, 0 ); + SetColumnWidth( 1, wxLIST_AUTOSIZE ); SetColumnWidth( 2, wxLIST_AUTOSIZE ); SetColumnWidth( 3, wxLIST_AUTOSIZE ); - SetColumnWidth( 4, wxLIST_AUTOSIZE ); } void wxFileCtrl::SetWild( const wxString &wild ) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 3ea0fdc49a..0eb186d165 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -1168,6 +1168,8 @@ wxListMainWindow::~wxListMainWindow() void wxListMainWindow::RefreshLine( wxListLineData *line ) { + if (m_dirty) return; + int x = 0; int y = 0; int w = 0; diff --git a/src/generic/treectrl.cpp b/src/generic/treectrl.cpp index dfe2222291..a85aa6fd8d 100644 --- a/src/generic/treectrl.cpp +++ b/src/generic/treectrl.cpp @@ -589,14 +589,12 @@ void wxTreeCtrl::SetIndent(unsigned int indent) { m_indent = indent; m_dirty = TRUE; - Refresh(); } void wxTreeCtrl::SetSpacing(unsigned int spacing) { m_spacing = spacing; m_dirty = TRUE; - Refresh(); } size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item, bool recursively) @@ -2160,6 +2158,8 @@ void wxTreeCtrl::CalculatePositions() void wxTreeCtrl::RefreshSubtree(wxGenericTreeItem *item) { + if (m_dirty) return; + wxClientDC dc(this); PrepareDC(dc); @@ -2180,6 +2180,8 @@ void wxTreeCtrl::RefreshSubtree(wxGenericTreeItem *item) void wxTreeCtrl::RefreshLine( wxGenericTreeItem *item ) { + if (m_dirty) return; + wxClientDC dc(this); PrepareDC( dc ); diff --git a/src/gtk/font.cpp b/src/gtk/font.cpp index a486103090..5e9d1ce629 100644 --- a/src/gtk/font.cpp +++ b/src/gtk/font.cpp @@ -398,7 +398,16 @@ static GdkFont *GtkGetDefaultGuiFont() { GtkWidget *widget = gtk_button_new(); GtkStyle *def = gtk_rc_get_style( widget ); - g_systemDefaultGuiFont = gdk_font_ref( def->font ); + if (def) + { + g_systemDefaultGuiFont = gdk_font_ref( def->font ); + } + else + { + def = gtk_widget_get_default_style(); + if (def) + g_systemDefaultGuiFont = gdk_font_ref( def->font ); + } gtk_widget_destroy( widget ); } return g_systemDefaultGuiFont; @@ -428,7 +437,7 @@ GdkFont *wxFont::GetInternalFont( float scale ) const { font = GtkGetDefaultGuiFont(); } - else + if (!font) { font = wxLoadQueryNearestFont( point_scale, M_FONTDATA->m_family, diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index db8fbc1bb6..ca5965f55d 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -128,23 +128,29 @@ wxColour wxSystemSettings::GetSystemColour( int index ) { if (!g_systemHighlightColour) { -/* - g_systemHighlightColour = - new wxColour( 0 >> SHIFT, - 0 >> SHIFT, - 0x9c40 >> SHIFT ); -*/ GtkWidget *widget = gtk_button_new(); GtkStyle *def = gtk_rc_get_style( widget ); - int red = def->bg[GTK_STATE_SELECTED].red; - int green = def->bg[GTK_STATE_SELECTED].green; - int blue = def->bg[GTK_STATE_SELECTED].blue; + if (!def) + def = gtk_widget_get_default_style(); + if (def) + { + int red = def->bg[GTK_STATE_SELECTED].red; + int green = def->bg[GTK_STATE_SELECTED].green; + int blue = def->bg[GTK_STATE_SELECTED].blue; + g_systemHighlightColour = + new wxColour( red >> SHIFT, + green >> SHIFT, + blue >> SHIFT ); + } + else + { + g_systemHighlightColour = + new wxColour( 0 >> SHIFT, + 0 >> SHIFT, + 0x9c40 >> SHIFT ); + } gtk_widget_destroy( widget ); - g_systemHighlightColour = - new wxColour( red >> SHIFT, - green >> SHIFT, - blue >> SHIFT ); } return *g_systemHighlightColour; } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 6c749174f2..cc3a5b7c45 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2962,7 +2962,12 @@ GtkStyle *wxWindow::GetWidgetStyle() { if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); - m_widgetStyle = gtk_style_copy( gtk_rc_get_style( m_widget ) ); + GtkStyle *def = gtk_rc_get_style( m_widget ); + + if (!def) + def = gtk_widget_get_default_style(); + + m_widgetStyle = gtk_style_copy( def ); return m_widgetStyle; } diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index a486103090..5e9d1ce629 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -398,7 +398,16 @@ static GdkFont *GtkGetDefaultGuiFont() { GtkWidget *widget = gtk_button_new(); GtkStyle *def = gtk_rc_get_style( widget ); - g_systemDefaultGuiFont = gdk_font_ref( def->font ); + if (def) + { + g_systemDefaultGuiFont = gdk_font_ref( def->font ); + } + else + { + def = gtk_widget_get_default_style(); + if (def) + g_systemDefaultGuiFont = gdk_font_ref( def->font ); + } gtk_widget_destroy( widget ); } return g_systemDefaultGuiFont; @@ -428,7 +437,7 @@ GdkFont *wxFont::GetInternalFont( float scale ) const { font = GtkGetDefaultGuiFont(); } - else + if (!font) { font = wxLoadQueryNearestFont( point_scale, M_FONTDATA->m_family, diff --git a/src/gtk1/settings.cpp b/src/gtk1/settings.cpp index db8fbc1bb6..ca5965f55d 100644 --- a/src/gtk1/settings.cpp +++ b/src/gtk1/settings.cpp @@ -128,23 +128,29 @@ wxColour wxSystemSettings::GetSystemColour( int index ) { if (!g_systemHighlightColour) { -/* - g_systemHighlightColour = - new wxColour( 0 >> SHIFT, - 0 >> SHIFT, - 0x9c40 >> SHIFT ); -*/ GtkWidget *widget = gtk_button_new(); GtkStyle *def = gtk_rc_get_style( widget ); - int red = def->bg[GTK_STATE_SELECTED].red; - int green = def->bg[GTK_STATE_SELECTED].green; - int blue = def->bg[GTK_STATE_SELECTED].blue; + if (!def) + def = gtk_widget_get_default_style(); + if (def) + { + int red = def->bg[GTK_STATE_SELECTED].red; + int green = def->bg[GTK_STATE_SELECTED].green; + int blue = def->bg[GTK_STATE_SELECTED].blue; + g_systemHighlightColour = + new wxColour( red >> SHIFT, + green >> SHIFT, + blue >> SHIFT ); + } + else + { + g_systemHighlightColour = + new wxColour( 0 >> SHIFT, + 0 >> SHIFT, + 0x9c40 >> SHIFT ); + } gtk_widget_destroy( widget ); - g_systemHighlightColour = - new wxColour( red >> SHIFT, - green >> SHIFT, - blue >> SHIFT ); } return *g_systemHighlightColour; } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 6c749174f2..cc3a5b7c45 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2962,7 +2962,12 @@ GtkStyle *wxWindow::GetWidgetStyle() { if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); - m_widgetStyle = gtk_style_copy( gtk_rc_get_style( m_widget ) ); + GtkStyle *def = gtk_rc_get_style( m_widget ); + + if (!def) + def = gtk_widget_get_default_style(); + + m_widgetStyle = gtk_style_copy( def ); return m_widgetStyle; } -- 2.47.2