From c49ba2113c3788115ec7134d2a5f37d0f4776c88 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Tue, 10 Jul 2012 17:17:53 +0000 Subject: [PATCH] no real changes, just remove unnecessary indentation and scoping after r72001 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72002 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/aboutdlg.cpp | 180 +++++++++++++++++++++--------------------- src/gtk/anybutton.cpp | 4 +- src/gtk/artgtk.cpp | 38 +++++---- src/gtk/dataview.cpp | 153 ++++++++++++++++------------------- src/gtk/dcclient.cpp | 132 +++++++++++++++---------------- src/gtk/stattext.cpp | 26 +++--- src/gtk/toplevel.cpp | 9 +-- src/gtk/utilsgtk.cpp | 48 ++++++----- 8 files changed, 275 insertions(+), 315 deletions(-) diff --git a/src/gtk/aboutdlg.cpp b/src/gtk/aboutdlg.cpp index cc9c4080c3..f17a837de9 100644 --- a/src/gtk/aboutdlg.cpp +++ b/src/gtk/aboutdlg.cpp @@ -134,111 +134,109 @@ static void wxGtkAboutDialogOnLink(GtkAboutDialog*, const char* link, void*) void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* WXUNUSED(parent)) { + // don't create another dialog if one is already present + if ( !gs_aboutDialog ) + gs_aboutDialog = GTK_ABOUT_DIALOG(gtk_about_dialog_new()); + + GtkAboutDialog * const dlg = gs_aboutDialog; + gtk_about_dialog_set_program_name(dlg, wxGTK_CONV_SYS(info.GetName())); + if ( info.HasVersion() ) + gtk_about_dialog_set_version(dlg, wxGTK_CONV_SYS(info.GetVersion())); + else + gtk_about_dialog_set_version(dlg, NULL); + if ( info.HasCopyright() ) + gtk_about_dialog_set_copyright(dlg, wxGTK_CONV_SYS(info.GetCopyrightToDisplay())); + else + gtk_about_dialog_set_copyright(dlg, NULL); + if ( info.HasDescription() ) + gtk_about_dialog_set_comments(dlg, wxGTK_CONV_SYS(info.GetDescription())); + else + gtk_about_dialog_set_comments(dlg, NULL); + if ( info.HasLicence() ) + gtk_about_dialog_set_license(dlg, wxGTK_CONV_SYS(info.GetLicence())); + else + gtk_about_dialog_set_license(dlg, NULL); + + wxIcon icon = info.GetIcon(); + if ( icon.IsOk() ) + gtk_about_dialog_set_logo(dlg, info.GetIcon().GetPixbuf()); + + if ( info.HasWebSite() ) { - // don't create another dialog if one is already present - if ( !gs_aboutDialog ) - gs_aboutDialog = GTK_ABOUT_DIALOG(gtk_about_dialog_new()); - - GtkAboutDialog * const dlg = gs_aboutDialog; - gtk_about_dialog_set_program_name(dlg, wxGTK_CONV_SYS(info.GetName())); - if ( info.HasVersion() ) - gtk_about_dialog_set_version(dlg, wxGTK_CONV_SYS(info.GetVersion())); - else - gtk_about_dialog_set_version(dlg, NULL); - if ( info.HasCopyright() ) - gtk_about_dialog_set_copyright(dlg, wxGTK_CONV_SYS(info.GetCopyrightToDisplay())); - else - gtk_about_dialog_set_copyright(dlg, NULL); - if ( info.HasDescription() ) - gtk_about_dialog_set_comments(dlg, wxGTK_CONV_SYS(info.GetDescription())); - else - gtk_about_dialog_set_comments(dlg, NULL); - if ( info.HasLicence() ) - gtk_about_dialog_set_license(dlg, wxGTK_CONV_SYS(info.GetLicence())); - else - gtk_about_dialog_set_license(dlg, NULL); - - wxIcon icon = info.GetIcon(); - if ( icon.IsOk() ) - gtk_about_dialog_set_logo(dlg, info.GetIcon().GetPixbuf()); - - if ( info.HasWebSite() ) - { #ifdef __WXGTK3__ - g_signal_connect(dlg, "activate-link", G_CALLBACK(activate_link), dlg); + g_signal_connect(dlg, "activate-link", G_CALLBACK(activate_link), dlg); #else - // NB: must be called before gtk_about_dialog_set_website() as - // otherwise it has no effect (although GTK+ docs don't mention - // this...) - gtk_about_dialog_set_url_hook(wxGtkAboutDialogOnLink, NULL, NULL); + // NB: must be called before gtk_about_dialog_set_website() as + // otherwise it has no effect (although GTK+ docs don't mention + // this...) + gtk_about_dialog_set_url_hook(wxGtkAboutDialogOnLink, NULL, NULL); #endif - gtk_about_dialog_set_website(dlg, wxGTK_CONV_SYS(info.GetWebSiteURL())); - gtk_about_dialog_set_website_label - ( - dlg, - wxGTK_CONV_SYS(info.GetWebSiteDescription()) - ); - } - else - { - gtk_about_dialog_set_website(dlg, NULL); - gtk_about_dialog_set_website_label(dlg, NULL); + gtk_about_dialog_set_website(dlg, wxGTK_CONV_SYS(info.GetWebSiteURL())); + gtk_about_dialog_set_website_label + ( + dlg, + wxGTK_CONV_SYS(info.GetWebSiteDescription()) + ); + } + else + { + gtk_about_dialog_set_website(dlg, NULL); + gtk_about_dialog_set_website_label(dlg, NULL); #ifdef __WXGTK3__ - g_signal_connect(dlg, "activate-link", G_CALLBACK(activate_link), NULL); + g_signal_connect(dlg, "activate-link", G_CALLBACK(activate_link), NULL); #else - gtk_about_dialog_set_url_hook(NULL, NULL, NULL); + gtk_about_dialog_set_url_hook(NULL, NULL, NULL); #endif - } + } - if ( info.HasDevelopers() ) - gtk_about_dialog_set_authors(dlg, GtkArray(info.GetDevelopers())); - else - gtk_about_dialog_set_authors(dlg, GtkArray()); - if ( info.HasDocWriters() ) - gtk_about_dialog_set_documenters(dlg, GtkArray(info.GetDocWriters())); - else - gtk_about_dialog_set_documenters(dlg, GtkArray()); - if ( info.HasArtists() ) - gtk_about_dialog_set_artists(dlg, GtkArray(info.GetArtists())); - else - gtk_about_dialog_set_artists(dlg, GtkArray()); - - wxString transCredits; - if ( info.HasTranslators() ) - { - const wxArrayString& translators = info.GetTranslators(); - const size_t count = translators.size(); - for ( size_t n = 0; n < count; n++ ) - { - transCredits << translators[n] << wxT('\n'); - } - } - else // no translators explicitly specified + if ( info.HasDevelopers() ) + gtk_about_dialog_set_authors(dlg, GtkArray(info.GetDevelopers())); + else + gtk_about_dialog_set_authors(dlg, GtkArray()); + if ( info.HasDocWriters() ) + gtk_about_dialog_set_documenters(dlg, GtkArray(info.GetDocWriters())); + else + gtk_about_dialog_set_documenters(dlg, GtkArray()); + if ( info.HasArtists() ) + gtk_about_dialog_set_artists(dlg, GtkArray(info.GetArtists())); + else + gtk_about_dialog_set_artists(dlg, GtkArray()); + + wxString transCredits; + if ( info.HasTranslators() ) + { + const wxArrayString& translators = info.GetTranslators(); + const size_t count = translators.size(); + for ( size_t n = 0; n < count; n++ ) { - // maybe we have translator credits in the message catalog? - wxString translator = _("translator-credits"); - - // gtk_about_dialog_set_translator_credits() is smart enough to - // detect if "translator-credits" is untranslated and hide the - // translators tab in that case, however it will still show the - // "credits" button, (at least GTK 2.10.6) even if there are no - // credits informations at all, so we still need to do the check - // ourselves - if ( translator != wxT("translator-credits") ) // untranslated! - transCredits = translator; + transCredits << translators[n] << wxT('\n'); } + } + else // no translators explicitly specified + { + // maybe we have translator credits in the message catalog? + wxString translator = _("translator-credits"); + + // gtk_about_dialog_set_translator_credits() is smart enough to + // detect if "translator-credits" is untranslated and hide the + // translators tab in that case, however it will still show the + // "credits" button, (at least GTK 2.10.6) even if there are no + // credits informations at all, so we still need to do the check + // ourselves + if ( translator != wxT("translator-credits") ) // untranslated! + transCredits = translator; + } - if ( !transCredits.empty() ) - gtk_about_dialog_set_translator_credits(dlg, wxGTK_CONV_SYS(transCredits)); - else - gtk_about_dialog_set_translator_credits(dlg, NULL); + if ( !transCredits.empty() ) + gtk_about_dialog_set_translator_credits(dlg, wxGTK_CONV_SYS(transCredits)); + else + gtk_about_dialog_set_translator_credits(dlg, NULL); - g_signal_connect(dlg, "response", - G_CALLBACK(wxGtkAboutDialogOnClose), NULL); + g_signal_connect(dlg, "response", + G_CALLBACK(wxGtkAboutDialogOnClose), NULL); - gtk_window_present(GTK_WINDOW(dlg)); - } + gtk_window_present(GTK_WINDOW(dlg)); } #endif // wxUSE_ABOUTDLG diff --git a/src/gtk/anybutton.cpp b/src/gtk/anybutton.cpp index 169bd1a415..9036b2a7ed 100644 --- a/src/gtk/anybutton.cpp +++ b/src/gtk/anybutton.cpp @@ -178,9 +178,7 @@ void wxAnyButton::GTKDoShowBitmap(const wxBitmap& bitmap) } else // have both label and bitmap { - { - image = gtk_button_get_image(GTK_BUTTON(m_widget)); - } + image = gtk_button_get_image(GTK_BUTTON(m_widget)); } wxCHECK_RET( image && GTK_IS_IMAGE(image), "must have image widget" ); diff --git a/src/gtk/artgtk.cpp b/src/gtk/artgtk.cpp index f7c8f53af2..533eab7619 100644 --- a/src/gtk/artgtk.cpp +++ b/src/gtk/artgtk.cpp @@ -327,27 +327,25 @@ wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id, } // otherwise try icon themes - { - gint *sizes = gtk_icon_theme_get_icon_sizes - ( - gtk_icon_theme_get_default(), - stockid.utf8_str() - ); - if ( !sizes ) - return bundle; - - gint *last = sizes; - while ( *last ) - last++; + gint *sizes = gtk_icon_theme_get_icon_sizes + ( + gtk_icon_theme_get_default(), + stockid.utf8_str() + ); + if ( !sizes ) + return bundle; - bundle = DoCreateIconBundle - ( - stockid.utf8_str(), - sizes, last, - &CreateThemeIcon - ); - g_free(sizes); - } + gint *last = sizes; + while ( *last ) + last++; + + bundle = DoCreateIconBundle + ( + stockid.utf8_str(), + sizes, last, + &CreateThemeIcon + ); + g_free(sizes); return bundle; } diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 26ff81c8f1..ab6ad3f1ff 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -2534,26 +2534,23 @@ wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString &label, { m_label = label; m_value = 0; + m_renderer = (GtkCellRenderer*) gtk_cell_renderer_progress_new(); - { - m_renderer = (GtkCellRenderer*) gtk_cell_renderer_progress_new(); - - SetMode(mode); - SetAlignment(align); + SetMode(mode); + SetAlignment(align); #if !wxUSE_UNICODE - // We can't initialize the renderer just yet because we don't have the - // pointer to the column that uses this renderer yet and so attempt to - // dereference GetOwner() to get the font that is used as a source of - // encoding in multibyte-to-Unicode conversion in GTKSetLabel() in - // non-Unicode builds would crash. So simply remember to do it later. - if ( !m_label.empty() ) - m_needsToSetLabel = true; - else + // We can't initialize the renderer just yet because we don't have the + // pointer to the column that uses this renderer yet and so attempt to + // dereference GetOwner() to get the font that is used as a source of + // encoding in multibyte-to-Unicode conversion in GTKSetLabel() in + // non-Unicode builds would crash. So simply remember to do it later. + if ( !m_label.empty() ) + m_needsToSetLabel = true; + else #endif // !wxUSE_UNICODE - { - GTKSetLabel(); - } + { + GTKSetLabel(); } } @@ -2585,19 +2582,17 @@ void wxDataViewProgressRenderer::GTKSetLabel() bool wxDataViewProgressRenderer::SetValue( const wxVariant &value ) { - { #if !wxUSE_UNICODE - if ( m_needsToSetLabel ) - GTKSetLabel(); + if ( m_needsToSetLabel ) + GTKSetLabel(); #endif // !wxUSE_UNICODE - gint tmp = (long) value; - GValue gvalue = { 0, }; - g_value_init( &gvalue, G_TYPE_INT ); - g_value_set_int( &gvalue, tmp ); - g_object_set_property( G_OBJECT(m_renderer), "value", &gvalue ); - g_value_unset( &gvalue ); - } + gint tmp = (long) value; + GValue gvalue = { 0, }; + g_value_init( &gvalue, G_TYPE_INT ); + g_value_set_int( &gvalue, tmp ); + g_object_set_property( G_OBJECT(m_renderer), "value", &gvalue ); + g_value_unset( &gvalue ); return true; } @@ -2636,34 +2631,30 @@ wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString &choices wxDataViewCellMode mode, int alignment ) : wxDataViewCustomRenderer( "string", mode, alignment, true ) { - m_choices = choices; - + m_choices = choices; + m_renderer = (GtkCellRenderer*) gtk_cell_renderer_combo_new(); + GtkListStore *store = gtk_list_store_new( 1, G_TYPE_STRING ); + for (size_t n = 0; n < m_choices.GetCount(); n++) { - m_renderer = (GtkCellRenderer*) gtk_cell_renderer_combo_new(); - - GtkListStore *store = gtk_list_store_new( 1, G_TYPE_STRING ); - for (size_t n = 0; n < m_choices.GetCount(); n++) - { - gtk_list_store_insert_with_values( - store, NULL, n, 0, - static_cast(m_choices[n].utf8_str()), -1 ); - } + gtk_list_store_insert_with_values( + store, NULL, n, 0, + static_cast(m_choices[n].utf8_str()), -1 ); + } - g_object_set (m_renderer, - "model", store, - "text-column", 0, - "has-entry", FALSE, - NULL); + g_object_set (m_renderer, + "model", store, + "text-column", 0, + "has-entry", FALSE, + NULL); - bool editable = (mode & wxDATAVIEW_CELL_EDITABLE) != 0; - g_object_set (m_renderer, "editable", editable, NULL); + bool editable = (mode & wxDATAVIEW_CELL_EDITABLE) != 0; + g_object_set (m_renderer, "editable", editable, NULL); - SetAlignment(alignment); + SetAlignment(alignment); - g_signal_connect_after( m_renderer, "edited", G_CALLBACK(wxGtkTextRendererEditedCallback), this ); + g_signal_connect_after( m_renderer, "edited", G_CALLBACK(wxGtkTextRendererEditedCallback), this ); - GtkInitHandlers(); - } + GtkInitHandlers(); } bool wxDataViewChoiceRenderer::Render( wxRect rect, wxDC *dc, int state ) @@ -2679,34 +2670,26 @@ wxSize wxDataViewChoiceRenderer::GetSize() const bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value ) { - - { - GValue gvalue = { 0, }; - g_value_init( &gvalue, G_TYPE_STRING ); - g_value_set_string(&gvalue, - wxGTK_CONV_FONT(value.GetString(), - GetOwner()->GetOwner()->GetFont())); - g_object_set_property( G_OBJECT(m_renderer), "text", &gvalue ); - g_value_unset( &gvalue ); - } + GValue gvalue = { 0, }; + g_value_init( &gvalue, G_TYPE_STRING ); + g_value_set_string(&gvalue, + wxGTK_CONV_FONT(value.GetString(), + GetOwner()->GetOwner()->GetFont())); + g_object_set_property( G_OBJECT(m_renderer), "text", &gvalue ); + g_value_unset( &gvalue ); return true; } bool wxDataViewChoiceRenderer::GetValue( wxVariant &value ) const { - { - GValue gvalue = { 0, }; - g_value_init( &gvalue, G_TYPE_STRING ); - g_object_get_property( G_OBJECT(m_renderer), "text", &gvalue ); - wxString temp = wxGTK_CONV_BACK_FONT(g_value_get_string(&gvalue), - GetOwner()->GetOwner()->GetFont()); - g_value_unset( &gvalue ); - value = temp; - - //wxPrintf( "temp %s\n", temp ); - // TODO: remove this code - } + GValue gvalue = { 0, }; + g_value_init( &gvalue, G_TYPE_STRING ); + g_object_get_property( G_OBJECT(m_renderer), "text", &gvalue ); + wxString temp = wxGTK_CONV_BACK_FONT(g_value_get_string(&gvalue), + GetOwner()->GetOwner()->GetFont()); + g_value_unset( &gvalue ); + value = temp; return true; } @@ -4524,10 +4507,8 @@ bool wxDataViewCtrl::Create(wxWindow *parent, g_signal_connect (m_treeview, "size_allocate", G_CALLBACK (gtk_dataviewctrl_size_callback), this); - { - bool fixed = (style & wxDV_VARIABLE_LINE_HEIGHT) == 0; - gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), fixed ); - } + bool fixed = (style & wxDV_VARIABLE_LINE_HEIGHT) == 0; + gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), fixed ); if (style & wxDV_MULTIPLE) { @@ -4633,10 +4614,8 @@ bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model ) if (!wxDataViewCtrlBase::AssociateModel( model )) return false; - { - bool fixed = (((GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) == 0) || (model->IsVirtualListModel())); - gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), fixed ); - } + bool fixed = (((GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) == 0) || (model->IsVirtualListModel())); + gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), fixed ); m_internal = new wxDataViewCtrlInternal( this, model ); @@ -4660,10 +4639,10 @@ bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col ) m_cols.Append( col ); + if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) != + GTK_TREE_VIEW_COLUMN_FIXED) { - if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) != - GTK_TREE_VIEW_COLUMN_FIXED) - gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE ); + gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE ); } gtk_tree_view_append_column( GTK_TREE_VIEW(m_treeview), @@ -4679,10 +4658,10 @@ bool wxDataViewCtrl::PrependColumn( wxDataViewColumn *col ) m_cols.Insert( col ); + if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) != + GTK_TREE_VIEW_COLUMN_FIXED) { - if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) != - GTK_TREE_VIEW_COLUMN_FIXED) - gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE ); + gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE ); } gtk_tree_view_insert_column( GTK_TREE_VIEW(m_treeview), @@ -4698,10 +4677,10 @@ bool wxDataViewCtrl::InsertColumn( unsigned int pos, wxDataViewColumn *col ) m_cols.Insert( pos, col ); + if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) != + GTK_TREE_VIEW_COLUMN_FIXED) { - if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) != - GTK_TREE_VIEW_COLUMN_FIXED) - gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE ); + gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE ); } gtk_tree_view_insert_column( GTK_TREE_VIEW(m_treeview), diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 3c87064d7c..680ab2c6cd 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -1451,82 +1451,80 @@ void wxWindowDCImpl::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord wxCHECK_RET( IsOk(), wxT("invalid window dc") ); + x = XLOG2DEV(x); + y = YLOG2DEV(y); + + pango_layout_set_text(m_layout, wxGTK_CONV(text), -1); + const bool setAttrs = m_font.GTKSetPangoAttrs(m_layout); + int oldSize = 0; + const bool isScaled = fabs(m_scaleY - 1.0) > 0.00001; + if (isScaled) { - x = XLOG2DEV(x); - y = YLOG2DEV(y); + //TODO: when Pango >= 1.6 is required, use pango_matrix_scale() + // If there is a user or actually any scale applied to + // the device context, scale the font. - pango_layout_set_text(m_layout, wxGTK_CONV(text), -1); - const bool setAttrs = m_font.GTKSetPangoAttrs(m_layout); - int oldSize = 0; - const bool isScaled = fabs(m_scaleY - 1.0) > 0.00001; - if (isScaled) - { - //TODO: when Pango >= 1.6 is required, use pango_matrix_scale() - // If there is a user or actually any scale applied to - // the device context, scale the font. + // scale font description + oldSize = pango_font_description_get_size(m_fontdesc); + pango_font_description_set_size(m_fontdesc, int(oldSize * m_scaleY)); - // scale font description - oldSize = pango_font_description_get_size(m_fontdesc); - pango_font_description_set_size(m_fontdesc, int(oldSize * m_scaleY)); + // actually apply scaled font + pango_layout_set_font_description( m_layout, m_fontdesc ); + } - // actually apply scaled font - pango_layout_set_font_description( m_layout, m_fontdesc ); - } + int w, h; + pango_layout_get_pixel_size(m_layout, &w, &h); - int w, h; - pango_layout_get_pixel_size(m_layout, &w, &h); - - const GdkColor* bg_col = NULL; - if (m_backgroundMode == wxBRUSHSTYLE_SOLID) - bg_col = m_textBackgroundColour.GetColor(); - - // rotate the text - PangoMatrix matrix = PANGO_MATRIX_INIT; - pango_matrix_rotate (&matrix, angle); - pango_context_set_matrix (m_context, &matrix); - pango_layout_context_changed (m_layout); - - // To be compatible with MSW, the rotation axis must be in the old - // top-left corner. - // Calculate the vertices of the rotated rectangle containing the text, - // relative to the old top-left vertex. - // We could use the matrix for this, but it's simpler with trignonometry. - double rad = DegToRad(angle); - // the rectangle vertices are counted clockwise with the first one - // being at (0, 0) - double x2 = w * cos(rad); - double y2 = -w * sin(rad); // y axis points to the bottom, hence minus - double x4 = h * sin(rad); - double y4 = h * cos(rad); - double x3 = x4 + x2; - double y3 = y4 + y2; - // Then we calculate max and min of the rotated rectangle. - wxCoord maxX = (wxCoord)(dmax(dmax(0, x2), dmax(x3, x4)) + 0.5), - maxY = (wxCoord)(dmax(dmax(0, y2), dmax(y3, y4)) + 0.5), - minX = (wxCoord)(dmin(dmin(0, x2), dmin(x3, x4)) - 0.5), - minY = (wxCoord)(dmin(dmin(0, y2), dmin(y3, y4)) - 0.5); - - gdk_draw_layout_with_colors(m_gdkwindow, m_textGC, x+minX, y+minY, - m_layout, NULL, bg_col); - - if (setAttrs) - pango_layout_set_attributes(m_layout, NULL); - - // clean up the transformation matrix - pango_context_set_matrix(m_context, NULL); + const GdkColor* bg_col = NULL; + if (m_backgroundMode == wxBRUSHSTYLE_SOLID) + bg_col = m_textBackgroundColour.GetColor(); - if (isScaled) - { - // reset unscaled size - pango_font_description_set_size( m_fontdesc, oldSize ); + // rotate the text + PangoMatrix matrix = PANGO_MATRIX_INIT; + pango_matrix_rotate (&matrix, angle); + pango_context_set_matrix (m_context, &matrix); + pango_layout_context_changed (m_layout); + + // To be compatible with MSW, the rotation axis must be in the old + // top-left corner. + // Calculate the vertices of the rotated rectangle containing the text, + // relative to the old top-left vertex. + // We could use the matrix for this, but it's simpler with trignonometry. + double rad = DegToRad(angle); + // the rectangle vertices are counted clockwise with the first one + // being at (0, 0) + double x2 = w * cos(rad); + double y2 = -w * sin(rad); // y axis points to the bottom, hence minus + double x4 = h * sin(rad); + double y4 = h * cos(rad); + double x3 = x4 + x2; + double y3 = y4 + y2; + // Then we calculate max and min of the rotated rectangle. + wxCoord maxX = (wxCoord)(dmax(dmax(0, x2), dmax(x3, x4)) + 0.5), + maxY = (wxCoord)(dmax(dmax(0, y2), dmax(y3, y4)) + 0.5), + minX = (wxCoord)(dmin(dmin(0, x2), dmin(x3, x4)) - 0.5), + minY = (wxCoord)(dmin(dmin(0, y2), dmin(y3, y4)) - 0.5); + + gdk_draw_layout_with_colors(m_gdkwindow, m_textGC, x+minX, y+minY, + m_layout, NULL, bg_col); - // actually apply unscaled font - pango_layout_set_font_description( m_layout, m_fontdesc ); - } + if (setAttrs) + pango_layout_set_attributes(m_layout, NULL); + + // clean up the transformation matrix + pango_context_set_matrix(m_context, NULL); - CalcBoundingBox(x+minX, y+minY); - CalcBoundingBox(x+maxX, y+maxY); + if (isScaled) + { + // reset unscaled size + pango_font_description_set_size( m_fontdesc, oldSize ); + + // actually apply unscaled font + pango_layout_set_font_description( m_layout, m_fontdesc ); } + + CalcBoundingBox(x+minX, y+minY); + CalcBoundingBox(x+maxX, y+maxY); } void wxWindowDCImpl::DoGetTextExtent(const wxString &string, diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index 8c25111fbe..33ddcd095a 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -72,18 +72,16 @@ bool wxStaticText::Create(wxWindow *parent, gtk_label_set_justify(GTK_LABEL(m_widget), justify); - { - // set ellipsize mode - PangoEllipsizeMode ellipsizeMode = PANGO_ELLIPSIZE_NONE; - if ( style & wxST_ELLIPSIZE_START ) - ellipsizeMode = PANGO_ELLIPSIZE_START; - else if ( style & wxST_ELLIPSIZE_MIDDLE ) - ellipsizeMode = PANGO_ELLIPSIZE_MIDDLE; - else if ( style & wxST_ELLIPSIZE_END ) - ellipsizeMode = PANGO_ELLIPSIZE_END; - - gtk_label_set_ellipsize( GTK_LABEL(m_widget), ellipsizeMode ); - } + // set ellipsize mode + PangoEllipsizeMode ellipsizeMode = PANGO_ELLIPSIZE_NONE; + if ( style & wxST_ELLIPSIZE_START ) + ellipsizeMode = PANGO_ELLIPSIZE_START; + else if ( style & wxST_ELLIPSIZE_MIDDLE ) + ellipsizeMode = PANGO_ELLIPSIZE_MIDDLE; + else if ( style & wxST_ELLIPSIZE_END ) + ellipsizeMode = PANGO_ELLIPSIZE_END; + + gtk_label_set_ellipsize( GTK_LABEL(m_widget), ellipsizeMode ); // GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2 static const float labelAlignments[] = { 0.0, 1.0, 0.5 }; @@ -106,9 +104,7 @@ void wxStaticText::GTKDoSetLabel(GTKLabelSetter setter, const wxString& label) InvalidateBestSize(); - { - (this->*setter)(GTK_LABEL(m_widget), label); - } + (this->*setter)(GTK_LABEL(m_widget), label); // adjust the label size to the new label unless disabled if ( !HasFlag(wxST_NO_AUTORESIZE) && diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 6e05104689..57709a5eb0 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -354,10 +354,8 @@ gtk_frame_map_callback( GtkWidget*, win->GetEventHandler()->ProcessEvent(eventShow); } - { - // restore focus-on-map setting in case ShowWithoutActivating() was called - gtk_window_set_focus_on_map(GTK_WINDOW(win->m_widget), true); - } + // restore focus-on-map setting in case ShowWithoutActivating() was called + gtk_window_set_focus_on_map(GTK_WINDOW(win->m_widget), true); return false; } @@ -972,8 +970,7 @@ void wxTopLevelWindowGTK::ShowWithoutActivating() { if (!m_isShown) { - gtk_window_set_focus_on_map(GTK_WINDOW(m_widget), false); - + gtk_window_set_focus_on_map(GTK_WINDOW(m_widget), false); Show(true); } } diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index f3d469f67d..f68fddcbf0 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -469,39 +469,35 @@ wxGUIAppTraits::GetStandardCmdLineOptions(wxArrayString& names, { wxString usage; + // check whether GLib version is greater than 2.6 but also lower than 2.33 + // because, as we use the undocumented _GOptionGroup struct, we don't want + // to run this code with future versions which might change it (2.32 is the + // latest one at the time of this writing) + if (glib_check_version(2,33,0)) { - // since GTK>=2.6, we can use the glib_check_version() symbol... + usage << _("The following standard GTK+ options are also supported:\n"); - // check whether GLib version is greater than 2.6 but also lower than 2.33 - // because, as we use the undocumented _GOptionGroup struct, we don't want - // to run this code with future versions which might change it (2.32 is the - // latest one at the time of this writing) - if (glib_check_version(2,33,0)) - { - usage << _("The following standard GTK+ options are also supported:\n"); - - // passing true here means that the function can open the default - // display while parsing (not really used here anyhow) - GOptionGroup *gtkOpts = gtk_get_option_group(true); - - // WARNING: here we access the internals of GOptionGroup: - GOptionEntry *entries = ((_GOptionGroup*)gtkOpts)->entries; - unsigned int n_entries = ((_GOptionGroup*)gtkOpts)->n_entries; - wxArrayString namesOptions, descOptions; + // passing true here means that the function can open the default + // display while parsing (not really used here anyhow) + GOptionGroup *gtkOpts = gtk_get_option_group(true); - for ( size_t n = 0; n < n_entries; n++ ) - { - if ( entries[n].flags & G_OPTION_FLAG_HIDDEN ) - continue; // skip + // WARNING: here we access the internals of GOptionGroup: + GOptionEntry *entries = ((_GOptionGroup*)gtkOpts)->entries; + unsigned int n_entries = ((_GOptionGroup*)gtkOpts)->n_entries; + wxArrayString namesOptions, descOptions; - names.push_back(wxGetNameFromGtkOptionEntry(&entries[n])); + for ( size_t n = 0; n < n_entries; n++ ) + { + if ( entries[n].flags & G_OPTION_FLAG_HIDDEN ) + continue; // skip - const gchar * const entryDesc = entries[n].description; - desc.push_back(wxString(entryDesc)); - } + names.push_back(wxGetNameFromGtkOptionEntry(&entries[n])); - g_option_group_free (gtkOpts); + const gchar * const entryDesc = entries[n].description; + desc.push_back(wxString(entryDesc)); } + + g_option_group_free (gtkOpts); } return usage; -- 2.45.2