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
This commit is contained in:
Paul Cornett
2012-07-10 17:17:53 +00:00
parent 4e621d2471
commit c49ba2113c
8 changed files with 291 additions and 331 deletions

View File

@@ -134,111 +134,109 @@ static void wxGtkAboutDialogOnLink(GtkAboutDialog*, const char* link, void*)
void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* WXUNUSED(parent)) 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__ #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 #else
// NB: must be called before gtk_about_dialog_set_website() as // NB: must be called before gtk_about_dialog_set_website() as
// otherwise it has no effect (although GTK+ docs don't mention // otherwise it has no effect (although GTK+ docs don't mention
// this...) // this...)
gtk_about_dialog_set_url_hook(wxGtkAboutDialogOnLink, NULL, NULL); gtk_about_dialog_set_url_hook(wxGtkAboutDialogOnLink, NULL, NULL);
#endif #endif
gtk_about_dialog_set_website(dlg, wxGTK_CONV_SYS(info.GetWebSiteURL())); gtk_about_dialog_set_website(dlg, wxGTK_CONV_SYS(info.GetWebSiteURL()));
gtk_about_dialog_set_website_label gtk_about_dialog_set_website_label
( (
dlg, dlg,
wxGTK_CONV_SYS(info.GetWebSiteDescription()) 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);
#else
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
{
// 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);
g_signal_connect(dlg, "response",
G_CALLBACK(wxGtkAboutDialogOnClose), NULL);
gtk_window_present(GTK_WINDOW(dlg));
} }
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);
#else
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
{
// 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);
g_signal_connect(dlg, "response",
G_CALLBACK(wxGtkAboutDialogOnClose), NULL);
gtk_window_present(GTK_WINDOW(dlg));
} }
#endif // wxUSE_ABOUTDLG #endif // wxUSE_ABOUTDLG

View File

@@ -178,9 +178,7 @@ void wxAnyButton::GTKDoShowBitmap(const wxBitmap& bitmap)
} }
else // have both label and 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" ); wxCHECK_RET( image && GTK_IS_IMAGE(image), "must have image widget" );

View File

@@ -327,27 +327,25 @@ wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
} }
// otherwise try icon themes // otherwise try icon themes
{ gint *sizes = gtk_icon_theme_get_icon_sizes
gint *sizes = gtk_icon_theme_get_icon_sizes (
( gtk_icon_theme_get_default(),
gtk_icon_theme_get_default(), stockid.utf8_str()
stockid.utf8_str() );
); if ( !sizes )
if ( !sizes ) return bundle;
return bundle;
gint *last = sizes; gint *last = sizes;
while ( *last ) while ( *last )
last++; last++;
bundle = DoCreateIconBundle bundle = DoCreateIconBundle
( (
stockid.utf8_str(), stockid.utf8_str(),
sizes, last, sizes, last,
&CreateThemeIcon &CreateThemeIcon
); );
g_free(sizes); g_free(sizes);
}
return bundle; return bundle;
} }

View File

@@ -2534,26 +2534,23 @@ wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString &label,
{ {
m_label = label; m_label = label;
m_value = 0; m_value = 0;
m_renderer = (GtkCellRenderer*) gtk_cell_renderer_progress_new();
{ SetMode(mode);
m_renderer = (GtkCellRenderer*) gtk_cell_renderer_progress_new(); SetAlignment(align);
SetMode(mode);
SetAlignment(align);
#if !wxUSE_UNICODE #if !wxUSE_UNICODE
// We can't initialize the renderer just yet because we don't have the // 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 // 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 // dereference GetOwner() to get the font that is used as a source of
// encoding in multibyte-to-Unicode conversion in GTKSetLabel() in // encoding in multibyte-to-Unicode conversion in GTKSetLabel() in
// non-Unicode builds would crash. So simply remember to do it later. // non-Unicode builds would crash. So simply remember to do it later.
if ( !m_label.empty() ) if ( !m_label.empty() )
m_needsToSetLabel = true; m_needsToSetLabel = true;
else else
#endif // !wxUSE_UNICODE #endif // !wxUSE_UNICODE
{ {
GTKSetLabel(); GTKSetLabel();
}
} }
} }
@@ -2585,19 +2582,17 @@ void wxDataViewProgressRenderer::GTKSetLabel()
bool wxDataViewProgressRenderer::SetValue( const wxVariant &value ) bool wxDataViewProgressRenderer::SetValue( const wxVariant &value )
{ {
{
#if !wxUSE_UNICODE #if !wxUSE_UNICODE
if ( m_needsToSetLabel ) if ( m_needsToSetLabel )
GTKSetLabel(); GTKSetLabel();
#endif // !wxUSE_UNICODE #endif // !wxUSE_UNICODE
gint tmp = (long) value; gint tmp = (long) value;
GValue gvalue = { 0, }; GValue gvalue = { 0, };
g_value_init( &gvalue, G_TYPE_INT ); g_value_init( &gvalue, G_TYPE_INT );
g_value_set_int( &gvalue, tmp ); g_value_set_int( &gvalue, tmp );
g_object_set_property( G_OBJECT(m_renderer), "value", &gvalue ); g_object_set_property( G_OBJECT(m_renderer), "value", &gvalue );
g_value_unset( &gvalue ); g_value_unset( &gvalue );
}
return true; return true;
} }
@@ -2636,34 +2631,30 @@ wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString &choices
wxDataViewCellMode mode, int alignment ) : wxDataViewCellMode mode, int alignment ) :
wxDataViewCustomRenderer( "string", mode, alignment, true ) 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(); gtk_list_store_insert_with_values(
store, NULL, n, 0,
GtkListStore *store = gtk_list_store_new( 1, G_TYPE_STRING ); static_cast<const char *>(m_choices[n].utf8_str()), -1 );
for (size_t n = 0; n < m_choices.GetCount(); n++)
{
gtk_list_store_insert_with_values(
store, NULL, n, 0,
static_cast<const char *>(m_choices[n].utf8_str()), -1 );
}
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);
SetAlignment(alignment);
g_signal_connect_after( m_renderer, "edited", G_CALLBACK(wxGtkTextRendererEditedCallback), this );
GtkInitHandlers();
} }
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);
SetAlignment(alignment);
g_signal_connect_after( m_renderer, "edited", G_CALLBACK(wxGtkTextRendererEditedCallback), this );
GtkInitHandlers();
} }
bool wxDataViewChoiceRenderer::Render( wxRect rect, wxDC *dc, int state ) bool wxDataViewChoiceRenderer::Render( wxRect rect, wxDC *dc, int state )
@@ -2679,34 +2670,26 @@ wxSize wxDataViewChoiceRenderer::GetSize() const
bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value ) bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value )
{ {
GValue gvalue = { 0, };
{ g_value_init( &gvalue, G_TYPE_STRING );
GValue gvalue = { 0, }; g_value_set_string(&gvalue,
g_value_init( &gvalue, G_TYPE_STRING ); wxGTK_CONV_FONT(value.GetString(),
g_value_set_string(&gvalue, GetOwner()->GetOwner()->GetFont()));
wxGTK_CONV_FONT(value.GetString(), g_object_set_property( G_OBJECT(m_renderer), "text", &gvalue );
GetOwner()->GetOwner()->GetFont())); g_value_unset( &gvalue );
g_object_set_property( G_OBJECT(m_renderer), "text", &gvalue );
g_value_unset( &gvalue );
}
return true; return true;
} }
bool wxDataViewChoiceRenderer::GetValue( wxVariant &value ) const bool wxDataViewChoiceRenderer::GetValue( wxVariant &value ) const
{ {
{ GValue gvalue = { 0, };
GValue gvalue = { 0, }; g_value_init( &gvalue, G_TYPE_STRING );
g_value_init( &gvalue, G_TYPE_STRING ); g_object_get_property( G_OBJECT(m_renderer), "text", &gvalue );
g_object_get_property( G_OBJECT(m_renderer), "text", &gvalue ); wxString temp = wxGTK_CONV_BACK_FONT(g_value_get_string(&gvalue),
wxString temp = wxGTK_CONV_BACK_FONT(g_value_get_string(&gvalue), GetOwner()->GetOwner()->GetFont());
GetOwner()->GetOwner()->GetFont()); g_value_unset( &gvalue );
g_value_unset( &gvalue ); value = temp;
value = temp;
//wxPrintf( "temp %s\n", temp );
// TODO: remove this code
}
return true; return true;
} }
@@ -4524,10 +4507,8 @@ bool wxDataViewCtrl::Create(wxWindow *parent,
g_signal_connect (m_treeview, "size_allocate", g_signal_connect (m_treeview, "size_allocate",
G_CALLBACK (gtk_dataviewctrl_size_callback), this); G_CALLBACK (gtk_dataviewctrl_size_callback), this);
{ bool fixed = (style & wxDV_VARIABLE_LINE_HEIGHT) == 0;
bool fixed = (style & wxDV_VARIABLE_LINE_HEIGHT) == 0; gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), fixed );
gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), fixed );
}
if (style & wxDV_MULTIPLE) if (style & wxDV_MULTIPLE)
{ {
@@ -4633,10 +4614,8 @@ bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model )
if (!wxDataViewCtrlBase::AssociateModel( model )) if (!wxDataViewCtrlBase::AssociateModel( model ))
return false; return false;
{ bool fixed = (((GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) == 0) || (model->IsVirtualListModel()));
bool fixed = (((GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) == 0) || (model->IsVirtualListModel())); gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), fixed );
gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), fixed );
}
m_internal = new wxDataViewCtrlInternal( this, model ); m_internal = new wxDataViewCtrlInternal( this, model );
@@ -4660,10 +4639,10 @@ bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
m_cols.Append( 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_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE );
GTK_TREE_VIEW_COLUMN_FIXED)
gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE );
} }
gtk_tree_view_append_column( GTK_TREE_VIEW(m_treeview), gtk_tree_view_append_column( GTK_TREE_VIEW(m_treeview),
@@ -4679,10 +4658,10 @@ bool wxDataViewCtrl::PrependColumn( wxDataViewColumn *col )
m_cols.Insert( 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_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE );
GTK_TREE_VIEW_COLUMN_FIXED)
gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE );
} }
gtk_tree_view_insert_column( GTK_TREE_VIEW(m_treeview), 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 ); 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_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE );
GTK_TREE_VIEW_COLUMN_FIXED)
gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE );
} }
gtk_tree_view_insert_column( GTK_TREE_VIEW(m_treeview), gtk_tree_view_insert_column( GTK_TREE_VIEW(m_treeview),

View File

@@ -1451,82 +1451,80 @@ void wxWindowDCImpl::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord
wxCHECK_RET( IsOk(), wxT("invalid window dc") ); 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); //TODO: when Pango >= 1.6 is required, use pango_matrix_scale()
y = YLOG2DEV(y); // 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); // scale font description
const bool setAttrs = m_font.GTKSetPangoAttrs(m_layout); oldSize = pango_font_description_get_size(m_fontdesc);
int oldSize = 0; pango_font_description_set_size(m_fontdesc, int(oldSize * m_scaleY));
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 // actually apply scaled font
oldSize = pango_font_description_get_size(m_fontdesc); pango_layout_set_font_description( m_layout, 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 );
}
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);
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);
} }
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);
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, void wxWindowDCImpl::DoGetTextExtent(const wxString &string,

View File

@@ -72,18 +72,16 @@ bool wxStaticText::Create(wxWindow *parent,
gtk_label_set_justify(GTK_LABEL(m_widget), justify); gtk_label_set_justify(GTK_LABEL(m_widget), justify);
{ // set ellipsize mode
// set ellipsize mode PangoEllipsizeMode ellipsizeMode = PANGO_ELLIPSIZE_NONE;
PangoEllipsizeMode ellipsizeMode = PANGO_ELLIPSIZE_NONE; if ( style & wxST_ELLIPSIZE_START )
if ( style & wxST_ELLIPSIZE_START ) ellipsizeMode = PANGO_ELLIPSIZE_START;
ellipsizeMode = PANGO_ELLIPSIZE_START; else if ( style & wxST_ELLIPSIZE_MIDDLE )
else if ( style & wxST_ELLIPSIZE_MIDDLE ) ellipsizeMode = PANGO_ELLIPSIZE_MIDDLE;
ellipsizeMode = PANGO_ELLIPSIZE_MIDDLE; else if ( style & wxST_ELLIPSIZE_END )
else if ( style & wxST_ELLIPSIZE_END ) ellipsizeMode = PANGO_ELLIPSIZE_END;
ellipsizeMode = PANGO_ELLIPSIZE_END;
gtk_label_set_ellipsize( GTK_LABEL(m_widget), ellipsizeMode ); gtk_label_set_ellipsize( GTK_LABEL(m_widget), ellipsizeMode );
}
// GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2 // GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2
static const float labelAlignments[] = { 0.0, 1.0, 0.5 }; static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
@@ -106,9 +104,7 @@ void wxStaticText::GTKDoSetLabel(GTKLabelSetter setter, const wxString& label)
InvalidateBestSize(); 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 // adjust the label size to the new label unless disabled
if ( !HasFlag(wxST_NO_AUTORESIZE) && if ( !HasFlag(wxST_NO_AUTORESIZE) &&

View File

@@ -354,10 +354,8 @@ gtk_frame_map_callback( GtkWidget*,
win->GetEventHandler()->ProcessEvent(eventShow); win->GetEventHandler()->ProcessEvent(eventShow);
} }
{ // restore focus-on-map setting in case ShowWithoutActivating() was called
// restore focus-on-map setting in case ShowWithoutActivating() was called gtk_window_set_focus_on_map(GTK_WINDOW(win->m_widget), true);
gtk_window_set_focus_on_map(GTK_WINDOW(win->m_widget), true);
}
return false; return false;
} }
@@ -972,8 +970,7 @@ void wxTopLevelWindowGTK::ShowWithoutActivating()
{ {
if (!m_isShown) 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); Show(true);
} }
} }

View File

@@ -469,39 +469,35 @@ wxGUIAppTraits::GetStandardCmdLineOptions(wxArrayString& names,
{ {
wxString usage; 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 // passing true here means that the function can open the default
// because, as we use the undocumented _GOptionGroup struct, we don't want // display while parsing (not really used here anyhow)
// to run this code with future versions which might change it (2.32 is the GOptionGroup *gtkOpts = gtk_get_option_group(true);
// latest one at the time of this writing)
if (glib_check_version(2,33,0)) // WARNING: here we access the internals of GOptionGroup:
GOptionEntry *entries = ((_GOptionGroup*)gtkOpts)->entries;
unsigned int n_entries = ((_GOptionGroup*)gtkOpts)->n_entries;
wxArrayString namesOptions, descOptions;
for ( size_t n = 0; n < n_entries; n++ )
{ {
usage << _("The following standard GTK+ options are also supported:\n"); if ( entries[n].flags & G_OPTION_FLAG_HIDDEN )
continue; // skip
// passing true here means that the function can open the default names.push_back(wxGetNameFromGtkOptionEntry(&entries[n]));
// display while parsing (not really used here anyhow)
GOptionGroup *gtkOpts = gtk_get_option_group(true);
// WARNING: here we access the internals of GOptionGroup: const gchar * const entryDesc = entries[n].description;
GOptionEntry *entries = ((_GOptionGroup*)gtkOpts)->entries; desc.push_back(wxString(entryDesc));
unsigned int n_entries = ((_GOptionGroup*)gtkOpts)->n_entries;
wxArrayString namesOptions, descOptions;
for ( size_t n = 0; n < n_entries; n++ )
{
if ( entries[n].flags & G_OPTION_FLAG_HIDDEN )
continue; // skip
names.push_back(wxGetNameFromGtkOptionEntry(&entries[n]));
const gchar * const entryDesc = entries[n].description;
desc.push_back(wxString(entryDesc));
}
g_option_group_free (gtkOpts);
} }
g_option_group_free (gtkOpts);
} }
return usage; return usage;