A Hildon::Banner is a small popup window at the top of the screen which can display text, either with or without markup. The window will be hidden automatically after a certain amount of time.
The Banner cannot be directly instantiated. Instead you should call the static methods, such as show_information() and show_information_with_markup() to show a Banner.
This example shows some of the functionality of Hildon::Banner, showing some simple text when a button is clicked.
File: examplewindow.h
#ifndef _MAEMOMM_EXAMPLEWINDOW_H
#define _MAEMOMM_EXAMPLEWINDOW_H
#include <hildonmm/window.h>
#include <hildonmm/button.h>
#include <hildonmm/banner.h>
#include <gtkmm/buttonbox.h>
class ExampleWindow : public Hildon::Window
{
public:
ExampleWindow();
virtual ~ExampleWindow();
private:
//Signal handlers:
void on_button_clicked();
// Child widgets:
Gtk::HButtonBox box_;
Hildon::Button button_;
};
#endif /* _MAEMOMM_EXAMPLEWINDOW_H */
File: examplewindow.cc
#include "examplewindow.h"
ExampleWindow::ExampleWindow() :
button_(Gtk::Hildon::SIZE_HALFSCREEN_WIDTH | Gtk::Hildon::SIZE_FINGER_HEIGHT,
Hildon::BUTTON_ARRANGEMENT_VERTICAL,
"Show Banner",
"By clicking this button")
{
set_title("Hildon::Banner Example");
// Attach the callback functions to the activate signal:
button_.signal_clicked().connect(
sigc::mem_fun(*this, &ExampleWindow::on_button_clicked));
add(box_);
box_.pack_start(button_);
// Make all menu widgets visible
show_all_children();
}
ExampleWindow::~ExampleWindow()
{
}
void ExampleWindow::on_button_clicked()
{
Hildon::Banner::show_information(*this, "Hi there");
}
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;
}