re: re: tuning widgets base size
A pointer to the context's default font description. This value must not be modified or freed Well, yes. I interpreted this as meaning that I shouldn't modify the pointer itself. And yes -- the solution I gave was gtkmm. Glad you found the gtk solution. I should point out that one thing that tripped me up for a bit was figuring out where the Gtk::Label object was for arbitrary controls -- i.e. you have to dig into the control to get to the label. Happy programming! -- Garth Upshaw Garth's KidStuff ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
re: tuning widgets base size
But this doesn't work. What is the right solution of my problem? Finaly I want make widgets smaller than default widgets, like toolbox widgets in The GIMP. void LXDialog::ShrinkWidgetFont( Gtk::Widget* pCtrl, // [in] Control to shrink the text of real scale) // [in] scale factor (should be 1.0 to shrink control) { // Different kinds of controls need different sub-objects' font resized Gtk::Frame* pFrame = dynamic_castGtk::Frame*(pCtrl); if (NULL != pFrame) // e.g. Frames have label widgets they use to display their text pCtrl = pFrame-get_label_widget(); else { // ...and radio buttons and check buttons are simply containers with a single label child Gtk::Bin* pBin = dynamic_castGtk::Bin*(pCtrl); if (NULL != pBin) pCtrl = pBin-get_child(); } Gtk::Label* pLabel = dynamic_castGtk::Label*(pCtrl); if (NULL != pLabel) { // Other controls might not have a label whose font we need to set Glib::RefPtrPango::Context pPangoContext = pLabel-get_pango_context(); Pango::FontDescription fontD = pPangoContext-get_font_description(); fontD.set_size((int)(scale * fontD.get_size())); pLabel-modify_font(fontD); } -- Garth Upshaw Garth's KidStuff ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: tuning widgets base size
On Monday 02 March 2009, Garth's KidStuff wrote: But this doesn't work. What is the right solution of my problem? Finaly I want make widgets smaller than default widgets, like toolbox widgets in The GIMP. void LXDialog::ShrinkWidgetFont( Gtk::Widget* pCtrl, // [in] Control to shrink the text of real scale) // [in] scale factor (should be 1.0 to shrink control) { // Different kinds of controls need different sub-objects' font resized Gtk::Frame* pFrame = dynamic_castGtk::Frame*(pCtrl); if (NULL != pFrame) // e.g. Frames have label widgets they use to display their text pCtrl = pFrame-get_label_widget(); else { // ...and radio buttons and check buttons are simply containers with a single label child Gtk::Bin* pBin = dynamic_castGtk::Bin*(pCtrl); if (NULL != pBin) pCtrl = pBin-get_child(); } Gtk::Label* pLabel = dynamic_castGtk::Label*(pCtrl); if (NULL != pLabel) { // Other controls might not have a label whose font we need to set Glib::RefPtrPango::Context pPangoContext = pLabel-get_pango_context(); Pango::FontDescription fontD = pPangoContext-get_font_description(); fontD.set_size((int)(scale * fontD.get_size())); pLabel-modify_font(fontD); } Thanks, I've already found similar solution for gtk - gtk_widget_modify_font(); BTW, manual gives about get_font_description(): A pointer to the context's default font description. This value must not be modified or freed According to this words object fontD shouldn't be mofified. Am I right? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
tuning widgets base size
Hi, list. I've noticed many widgets calculate its base size relying on font sizes (font size, ascent, descent...) of its pango context. Thus I've tried to change PangoFontDescription of widgets in this way just after widget creation: context = gtk_widget_get_pango_context ( wg ); descr1 = pango_context_get_font_description ( context ); descr2 = pango_font_description_copy(descr1) ; int size = pango_font_description_get_size(descr2); size = ( size * 2 ) / 3; pango_font_description_set_size(descr2, size); pango_context_set_font_description(context, descr2); But this doesn't work. What is the right solution of my problem? Finaly I want make widgets smaller than default widgets, like toolbox widgets in The GIMP. Thanks. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list