Application Interface



The following program produces a yellow window.
I want to change its color to Red, Black, or Green while the program is running.

How do I change the color while the window is displayed?

------------------------------------------------------------------------------
#include <gtkmm.h>


class Example : public Gtk::Window
{
public:
       Example();
       virtual ~Example();

protected:
       virtual void on_button_quit();

       Gtk::VBox mc_VBox;

       Gtk::HBox mc_HBox;

Gdk::Color m_Color_Black, m_Color_Red, m_Color_Green, m_Color_Yellow;

       Gtk::EventBox m_Light1, m_Light2, m_Light3;

};


Example::Example()
{
       m_Color_Red.set_rgb_p(0.99, 0.00, 0.00);
       m_Color_Yellow.set_rgb_p(0.99, 0.99, 0.00);
       m_Color_Green.set_rgb_p(0.00, 0.99, 0.00);
       m_Color_Black.set_rgb_p(0.00, 0.00, 0.00);


       add(mc_HBox);

       mc_HBox.pack_start(mc_VBox, Gtk::PACK_SHRINK, 0);

       m_Light1.modify_bg(Gtk::STATE_NORMAL, m_Color_Yellow);

       m_Light1.set_size_request(400, 300);

       mc_HBox.add(m_Light1);

       show_all_children();
}


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

       Example window;

       Gtk::Main::run(window);

 return 0;
}


Example::~Example()
{
}


void Example::on_button_quit()
{
 hide();
}

------------------------------------------------------------------------------



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