RE: Gtk value types



>> how can I add property to my widget with value of type 'GdkColor'?

>> class MyWidet : public Gtk::EventBox
>> {
>>        Gllib::Property<GdkColor> my_color;
>>        MyWidget() : my_color(*this, "my-color") {}
>>       ~MyWidget();
>> };

>> This works, but i get property of type 'glibmm__CustomBoxed_9_GdkColor'
>> Is there any solution?

Use the property_ paradigm, as follows:

#include <gtkmm.h>

class MyWidget : public Gtk::EventBox
{
  public:
    MyWidget () : my_color (this, "my-color") {}
    ~MyWidget () {}

  public:
    Glib::PropertyProxy<GdkColor> property_color ()
    {
      return Glib::PropertyProxy<GdkColor>(this, "my-color");
    }

  private:
   
Glib::PropertyProxy<GdkColor> my_color;
};

int main (int argc, char** argv)
{
  Gtk::Main main(argc, argv);

  MyWidget widget;

  /* get/set your color:
  widget.property_color() = ...
  GdkColor color = widget.property_color();
  */
}

Phil


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