Table of Contents
This section explains the additional widgets provided by the Maemo framework. Of course, most gtkmm widgets are also available.
Windows in maemomm are derived from Gtk::Window, with extra features provided, specific to the Hildon framework. For example, it is possible to set a Gtk::Menu for a Hildon::Window with the set_main_menu() method.
Hildon::Window represents a top-level window of an application running in the Hildon framework. You can attach a menu to the window, either with the set_app_menu() or the set_main_menu() methods, for use with Hildon::AppMenu or Gtk::Menu respectively. The Maemo Human Interface Guidelines recommend to use only Hildon::AppMenu in Maemo 5.
This example shows a simple window with a title, containing a gtk::Label.
File: examplewindow.h
#ifndef _MAEMOMM_EXAMPLEWINDOW_H
#define _MAEMOMM_EXAMPLEWINDOW_H
#include <hildonmm/window.h>
#include <gtkmm/label.h>
class ExampleWindow : public Hildon::Window
{
public:
ExampleWindow();
virtual ~ExampleWindow();
private:
// Child widgets.
Gtk::Label label_;
};
#endif /* _MAEMOMM_EXAMPLEWINDOW_H */
File: main.cc
#include <hildonmm.h>
#include "examplewindow.h"
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
Hildon::init();
ExampleWindow window;
kit.run(window); //Shows the window and returns when it is closed.
return 0;
}
File: examplewindow.cc
#include "examplewindow.h"
#include <iostream>
ExampleWindow::ExampleWindow() :
label_("Click the close button to quit.")
{
set_title("Hildon::Window example");
add(label_);
show_all();
}
ExampleWindow::~ExampleWindow()
{
}
A Hildon::StackableWindow represents a stackable top-level window in the Hildon framework, and is derived from Hildon::Window. Every application has a default Hildon::WindowStack to which each window is pushed when the show() method is called. Although with the default stack it is possible to use the show() and hide() methods from Gtk::Widget on each Hildon::StackableWindow, other Hildon::WindowStacks may be created, and individual Hildon::StackableWindows must be pushed and popped onto these user-created stacks with push() and pop() respectively.
This example shows a stack of three windows with different titles. As each window is closed, the next window on the stack is made visible.
File: examplewindow.h
#ifndef _MAEMOMM_EXAMPLEWINDOW_H
#define _MAEMOMM_EXAMPLEWINDOW_H
#include <hildonmm/stackable-window.h>
#include <gtkmm/buttonbox.h>
#include <hildonmm/button.h>
class ExampleWindow : public Hildon::StackableWindow
{
public:
ExampleWindow();
virtual ~ExampleWindow();
private:
// Signal handlers:
void on_button_clicked();
// Child widgets:
Gtk::HButtonBox box;
Hildon::Button button;
};
#endif /* _MAEMOMM_EXAMPLEWINDOW_H */
File: main.cc
#include <hildonmm.h>
#include "examplewindow.h"
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
Hildon::init();
ExampleWindow window;
kit.run(window); //Shows the window and returns when it is closed.
return 0;
}
File: examplewindow.cc
#include "examplewindow.h"
#include <hildonmm/stackable-window.h>
#include <hildonmm/window-stack.h>
#include <iostream>
ExampleWindow::ExampleWindow() :
button_(Gtk::Hildon::SIZE_HALFSCREEN_WIDTH | Gtk::Hildon::SIZE_FINGER_HEIGHT,
Hildon::BUTTON_ARRANGEMENT_VERTICAL,
"Click me!",
"to show a new StackableWindow")
{
set_title("Hildon::StackableWindow example");
button_.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_button_clicked));
box_.add(button_);
add(box);
button_.show();
box_.show();
show_all();
}
ExampleWindow::~ExampleWindow()
{
}
void ExampleWindow::on_button_clicked()
{
Hildon::StackableWindow stackable;
stackable.set_title("Hildon::StackableWindow example");
Gtk::Label stackable_label("This is a stackable window, above the root window.");
stackable.add(stackable_label);
stackable_label.show();
Glib::RefPtr<Hildon::WindowStack> stack = get_stack();
stack->push(stackable);
std::cout << "Button clicked." << std::endl;
}