The Hildon::ColorSelector is the Maemo equivalent for the Gtk::ColorSelector but optimized for embedded devices. There is also a Hildon::ColorButton which can be used to launch a Hildon::ColorSelector and show the selected color on the button.
The interface is quite self explaining, here is an example
examplewindow.h
//$Id: examplewindow.h,v 1.1 2003/11/03 09:29:56 murrayc Exp $ -*- c++ -*-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GTKMM_EXAMPLEWINDOW_H
#define GTKMM_EXAMPLEWINDOW_H
#include <hildon-libsmm/window.h>
#include <hildon-libsmm/color-button.h>
#include <gtkmm.h>
class ExampleWindow : public Hildon::Window
{
public:
ExampleWindow();
virtual ~ExampleWindow();
protected:
//Signal handlers:
virtual void on_quit();
virtual void on_clicked();
Gtk::Menu main;
Gtk::MenuItem item_quit;
Gtk::VBox vbox;
Hildon::ColorButton color_button;
Gtk::Button button;
};
#endif //GTKMM_EXAMPLEWINDOW_H
examplewindow.cc
//$Id: examplewindow.cc,v 1.5 2004/03/25 14:35:34 murrayc Exp $ -*- c++ -*-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "examplewindow.h"
#include <gtkmm.h>
#include <hildon-libsmm/color-selector.h>
ExampleWindow::ExampleWindow() :
item_quit("Quit"),
button("Choose color"),
vbox(true, 5)
{
/* Add menu items to right menus */
main.append(item_quit);
main.show_all();
set_menu(main);
/* Attach the callback functions to the activate signal */
item_quit.signal_activate().connect( sigc::mem_fun(*this, &ExampleWindow::on_quit) );
button.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_clicked));
add(vbox);
vbox.pack_start(color_button);
vbox.pack_start(button);
/* Make all menu widgets visible */
show_all();
}
ExampleWindow::~ExampleWindow()
{
}
void ExampleWindow::on_quit()
{
Gtk::Main::quit();
}
void ExampleWindow::on_clicked()
{
Hildon::ColorSelector selector(*this);
switch(selector.run())
{
case Gtk::RESPONSE_OK:
{
Gdk::Color color;
selector.get_property("color", color);
}
default:
selector.hide();
}
}
main.cc
//$Id: main.cc,v 1.1 2003/11/03 09:29:56 murrayc Exp $ -*- c++ -*-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <hildon-libsmm/program.h>
#include <gtkmm/main.h>
#include "examplewindow.h"
/* This is the C++ version of the example in the tutorial */
int main(int argc, char *argv[])
{
/* Initialize the GTKmm. */
Gtk::Main kit(&argc, &argv);
/* Create the hildon program and setup the title */
Hildon::Program program;
Glib::set_application_name("Color example");
/* Create Window and set it to Program */
ExampleWindow window;
program.add_window(window);
/* Begin the main application */
window.show_all();
kit.run(window);
/* Exit */
return 0;
}
The documentation for the standard GTKmm ColorSelectionDialog can be found in the GTKmm tutorial.