Gtk::Dialog有以下几种:
Gtk::Dialog
Gtk::AboutDialog
Gtk::MessageDialog
Gtk::FileChooserDialog
Gtk::FontSelectionDialog
Gtk::ColorSelectionDialog
1. Gtk::Dialog只是原型可以使用get_vbox得到其中的Gtk::VBox layout.
及使用add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK)这种形式加入按钮。
int result = dialog.run();
switch(result)
{
case(Gtk::RESPONSE_OK)
{
//do something
}
case(Gtk::RESPONSE_XXX)
{
//do something
}
default:
{
//default
}
}
|
2. Gtk::AboutDialog
Gtk::AboutDialog dialog();
dialog.set_transient_for(*this)
m_Dialog.set_name("Example application");
m_Dialog.set_version("1.0.0");
m_Dialog.set_copyright("Murray Cumming");
m_Dialog.set_comments("This is just an example application.");
m_Dialog.set_license("LGPL");
m_Dialog.set_website("");
m_Dialog.set_website_label("gtkmm website");
std::list<Glib::ustring> list_authors;
list_authors.push_back("Murray Cumming");
list_authors.push_back("Somebody Else");
list_authors.push_back("AN Other");
m_Dialog.set_authors(list_authors);
|
3. Gtk::MessageDialog
Gtk::MessageDialog dialog(*this, "This is a QUESTION MessageDialog",
false /* use_markup */, Gtk::MESSAGE_QUESTION,
Gtk::BUTTONS_OK_CANCEL);
dialog.set_secondary_text(
"And this is the secondary text that explains things.");
int result = dialog.run();
|
4. Gtk::FileChooserDialog
Gtk::FileChooserDialog dialog("Please choose a folder",
Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
dialog.set_transient_for(*this);
//Add response buttons the the dialog:
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button("Select", Gtk::RESPONSE_OK);
int result = dialog.run();
//=============================
Gtk::FileChooserDialog dialog("Please choose a file",
Gtk::FILE_CHOOSER_ACTION_OPEN);
dialog.set_transient_for(*this);
//Add response buttons the the dialog:
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
//Add filters, so that only certain file types can be selected:
Gtk::FileFilter filter_text;
filter_text.set_name("Text files");
filter_text.add_mime_type("text/plain");
dialog.add_filter(filter_text);
Gtk::FileFilter filter_cpp;
filter_cpp.set_name("C/C++ files");
filter_cpp.add_mime_type("text/x-c");
filter_cpp.add_mime_type("text/x-c++");
filter_cpp.add_mime_type("text/x-c-header");
dialog.add_filter(filter_cpp);
Gtk::FileFilter filter_any;
filter_any.set_name("Any files");
filter_any.add_pattern("*");
dialog.add_filter(filter_any);
//Show the dialog and wait for a user response:
int result = dialog.run();
|
5. Gtk::FontSelectionDialog
Gtk::FontSelectionButton m_button;
m_button.signal_on_font_set(sigc::mem_fun(*this, &on_button_font));
void on_button_font(){
Glib::ustring font_name = m_Button.get_font_name();
}
|
6. Gtk::ColorSelectionDialog
Gtk::ColorSelectionButton m_button;
m_button.signal_on_color_set(sigc::mem_fun(*this, &on_button_font));
void on_button_font(){
Glib::ustring font_name = m_Button.get_color();
m_DrawingArea.modify_bg(Gtk::STATE_NORMAL, m_Color)
}
|
阅读(699) | 评论(0) | 转发(0) |