Tutorial |
||
|
||
|
FontSelection(); |
FontSelectionDialog(); explicit FontSelectionDialog(const String& title); |
Gtk::Button* ok_button()
const; Gtk::Button* apply_button() const; Gtk::Button* cancel_button() const; |
bool
set_font_name(const String& fontname); String get_font_name() const; |
void
set_preview_text(const String& text); String get_preview_text() const; |
Pango::FontFamily*
get_font_family() const; Pango::FontFace* get_font_face() const; |
FontDescription(const String& desc); |
void
modify_font(const
Pango::FontDescription& font_desc); |
#include<inti/main.h> #include <inti/core.h> #include <inti/gtk/label.h> using namespace Inti; class FontSelectionWindow : public Gtk::Window { Gtk::Label *label; protected: void on_select_font(); public: FontSelectionWindow(); virtual ~FontSelectionWindow(); }; |
#include"fontselection.h" #include <inti/gtk/button.h> #include <inti/gtk/fontselection.h> #include <inti/pango/font.h> #include <iostream> FontSelectionWindow::FontSelectionWindow() { // Sets the border width of the window. set_title("Font Selection Example"); set_border_width(10); Gtk::VBox *vbox = new Gtk::VBox; add(*vbox); // Create a label and add it to the vbox label = new Gtk::Label("Welcome to Inti"); label->set_size_request(300, 100); vbox->pack_start(*label); // Creates a new button and add it to the vbox Gtk::Button *button = new Gtk::Button("Select a font"); vbox->pack_start(*button); // When the button receives the "clicked" signal, it calls the on_select_font() slot. button->sig_clicked().connect(slot(this, &FontSelectionWindow::on_select_font)); // The final step is to display this newly created widgets. vbox->show_all(); } FontSelectionWindow::~FontSelectionWindow() { } void FontSelectionWindow::on_select_font() { // Create a temporary FontSelectionDialog on the stack Gtk::FontSelectionDialog dialog("Select a font"); // Call Gtk::Dialog::run() which runs a modal dialog if (dialog.run()) { // Get the selected font name String font_name = dialog.get_font_name(); // Print the font name to the standard output std::cout << "The selected font name is \"" << font_name << "\"" << std::endl; // Modify the label's font and destroy the dialog label->modify_font(Pango::FontDescription(font_name)); dialog.dispose(); } } int main (int argc, char *argv[]) { using namespace Main; init(&argc, &argv); FontSelectionWindow window; window.sig_destroy().connect(slot(&Inti::Main::quit)); window.show(); run(); return 0; } |
|
|||
|
|||