Re: Gtk::Style usage help needed



On Fri, 2010-10-29 at 11:08 -0700, siagogam wrote:
> Ok, I'll try to explain what I want to do, so you can tell me if I'm doing it
> the way is supposed to be done. 
> 
> As you said, I want to modify how widgets are drawn (by using cairo inside
> the style virtual functions), and I have no intention of creating a new
> complete theme engine. If all applications should share the same look is a
> point of view quite extended , but what I want to do is just the opposite
> (define my own look and feel in my application) 
> 
> I'm trying to do it just the way you mentioned, by calling set_style in the
> affected widgets. But if we recover the example code, I'm getting some pango
> errors and a segfault when trying to use an overloaded Gtk::Style in a label
> widget (other widgets I have tested works fine with this approach). 
> 
> I've been looking to the Gtk::Style code in style.cc and the create()
> function does nothing but create the Glib::RefPtr, so I'm quite confused
> write now. ¿what can it be wrong? 

I suppose that if you want to derive from Gtk::Style you should follow
the same "structure" as the original Gtk::Style class.

Since Gtk::Style is reference counted, it is normally accessed using
Gli::RefPtr<>.  Its constructors are protected and the create() method
constructs the style and returns a Glib::RefPtr<> to the style.  You
might follow a similar structure for your class (I think).

As far as drawing widgets with cairo, there is good docs in the
programming book:
http://library.gnome.org/devel/gtkmm-tutorial/unstable/chapter-drawingarea.html

There's also a section on creating custom widgets that might be helpful:
http://library.gnome.org/devel/gtkmm-tutorial/unstable/chapter-customwidgets.html

Finally, I think it may be necessary to call the Glib::ObjectBase(const
char*) constructor from the derived style class (I don't know for sure).
See the following bug in case it is relevant:
https://bugzilla.gnome.org/show_bug.cgi?id=523043

> 
> TIA
> 
> 
> José Alburquerque wrote:
> > 
> > On Fri, 2010-10-29 at 00:40 -0700, siagogam wrote: 
> >> Yes I've already tried in my test example the Gtk::Style::create() and
> >> works
> >> fine, but what I want to do is overload the style drawing functions in
> >> order
> >> to perform some changes in the way some widgets are drawn. I can not do
> >> that
> >> using the create static method.
> > 
> > As Paul said, users normally determine the look of applications on their
> > desktop by selecting themes themselves.  If you should still want to
> > modify how widgets are drawn for some reason, the best way to do it, I
> > think, is by using the various style manipulating methods in the
> > Gtk::Widget API[1] such as get_style()[2], set_style()[3] and
> > modify_style()[4] among others.
> > 
> > [1] http://library.gnome.org/devel/gtkmm/stable/classGtk_1_1Widget.html
> > [2]
> > http://library.gnome.org/devel/gtkmm/stable/classGtk_1_1Widget.html#a3a3c08d5fcb8a134fff5e3f3a11f4f7f
> > [3]
> > http://library.gnome.org/devel/gtkmm/stable/classGtk_1_1Widget.html#a50ef706c909b415894aab77663447af3
> > [4]
> > http://library.gnome.org/devel/gtkmm/stable/classGtk_1_1Widget.html#a8fe55b3cc4342ae1242b384b2de813bd
> > 
> >> 
> >> I'm not sure of whats rcstyle for, but I think its for defining the
> >> system
> >> apearance through an rc style file. is this true? Anyway, thats not what
> >> I'm
> >> looking for.
> >> 
> >> Gtk::Style offers lots of protected virtual methods, so its' designed to
> >> be
> >> inherited, but in the other hand the label style seems to depend on the
> >> code
> >> executed in the create() method, that can not be overloaded. Is this a
> >> bug?
> >> 
> >> TIA
> > 
> > -- 
> > José
> > 
> > 
> > 
> > _______________________________________________
> > gtkmm-list mailing list
> > gtkmm-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtkmm-list
> > 
> > 
> 

-- 
José



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]