FontSelectionDialog
The FontSelectionDialog allows the user to choose a font.
- 15.4.1. Beispiel
15.4.1. Beispiel
File: examplewindow.h (For use with gtkmm 2, not gtkmm 3)
#ifndef GTKMM_EXAMPLEWINDOW_H #define GTKMM_EXAMPLEWINDOW_H #include <gtkmm.h> class ExampleWindow : public Gtk::Window { public: ExampleWindow(); virtual ~ExampleWindow(); protected: //Signal handlers: void on_button_font_set(); //Child widgets: Gtk::FontButton m_Button; }; #endif //GTKMM_EXAMPLEWINDOW_H
File: examplewindow.cc (For use with gtkmm 2, not gtkmm 3)
#include "examplewindow.h" #include <iostream> ExampleWindow::ExampleWindow() : m_Button("sans") { set_title("Gtk::FontSelectionDialog example"); add(m_Button); m_Button.signal_font_set().connect(sigc::mem_fun(*this, &ExampleWindow::on_button_font_set) ); show_all_children(); } ExampleWindow::~ExampleWindow() { } void ExampleWindow::on_button_font_set() { Glib::ustring font_name = m_Button.get_font_name(); std::cout << "Font chosen: " << font_name << std::endl; }
File: main.cc (For use with gtkmm 2, not gtkmm 3)
#include "examplewindow.h" #include <gtkmm/main.h> int main(int argc, char *argv[]) { Gtk::Main kit(argc, argv); ExampleWindow window; //Shows the window and returns when it is closed. Gtk::Main::run(window); return 0; }