Table of Contents
This section describes the additional dialogs provided by the Maemo framework.
A Hildon::Note
can display small pieces of information. Like a normal Gtk::Dialog
, it may contain buttons. This class has specific API to display a progress bar and a cancel button.
This example shows some ways of using a Hildon::Note
.
File: examplewindow.h
#ifndef _MAEMOMM_EXAMPLEWINDOW_H #define _MAEMOMM_EXAMPLEWINDOW_H #include <hildonmm/window.h> #include <hildonmm/button.h> #include <hildonmm/note.h> #include <gtkmm/buttonbox.h> #include <gtkmm/progressbar.h> class ExampleWindow : public Hildon::Window { public: ExampleWindow(); virtual ~ExampleWindow(); private: // Signal handlers: void on_button(); // Child widgets: Gtk::HButtonBox box_; Hildon::Button button_; Gtk::ProgressBar bar_; // Other variables: int type_; }; #endif /* _MAEMOMM_EXAMPLEWINDOW_H */
File: main.cc
#include <hildonmm.h> #include "examplewindow.h" int main(int argc, char *argv[]) { // Initialize gtkmm and maemomm: Gtk::Main kit(&argc, &argv); Hildon::init(); // Create Window and set it to Program ExampleWindow window; Hildon::Program::get_instance()->add_window(window); // Begin the main application kit.run(window); return 0; }
File: examplewindow.cc
#include "examplewindow.h" #include <gtkmm.h> #include <hildonmm/note.h> #include <iostream> ExampleWindow::ExampleWindow() : button_(Gtk::Hildon::SIZE_HALFSCREEN_WIDTH | Gtk::Hildon::SIZE_FINGER_HEIGHT, Hildon::BUTTON_ARRANGEMENT_VERTICAL, "Click Me (three times)", "to show notes"), type_(1) { set_title("Hildon::Note Example"); // Attach the callback functions to the clicked signal. button_.signal_clicked().connect( sigc::mem_fun(*this, &ExampleWindow::on_button)); box_.pack_start(button_); add(box_); // Make all widgets visible. show_all_children(); } ExampleWindow::~ExampleWindow() { } void ExampleWindow::on_button() { switch (type_) { case 1: { Hildon::Note note(Hildon::NOTE_TYPE_INFORMATION, "Very important information. (click to dismiss)"); note.run(); break; } case 2: { Hildon::Note note(Hildon::NOTE_TYPE_CONFIRMATION_BUTTON, *this, "Do you agree?"); note.add_button(Gtk::Stock::YES, Gtk::RESPONSE_YES); note.add_button(Gtk::Stock::NO, Gtk::RESPONSE_NO); note.run(); break; } case 3: { Hildon::Note* note = new Hildon::Note(bar_, *this, "Note with ProgressBar"); bar_.set_fraction(0.5); note->run(); delete note; } } ++type_; if(type_ > 3) type_ = 1; }