⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialogs.cpp

📁 linux pritner GUI
💻 CPP
📖 第 1 页 / 共 2 页
字号:
}void FileReadSelectDialog::finish(void) {  parent.set_sensitive(true);  hide_all();  if (in_exec_loop) Gtk::Main::quit();  // if we have not called exec(), then this dialog is self-owning and it is safe to call `delete this'  else delete this;}bool FileReadSelectDialog::on_delete_event(GdkEventAny*) {  finish();  return true; // returning true prevents destroy sig being emitted}GplDialog::GplDialog(int size): Gtk::Window(Gtk::WINDOW_TOPLEVEL),                             in_exec_loop(false), standard_size(size),			     result(rejected), accept_button(gettext("Accept")),			     reject_button(gettext("Reject")),		             label(gettext("Do you accept the Conditions, Notices "					   "and Disclaimers shown above?")),			     table(3, 2, false) {  editbox.set_editable(false);  editbox.modify_font(Pango::FontDescription(prog_config.fixed_font));  editbox.get_buffer()->set_text(copyright_msg);  scrolled_window.set_shadow_type(Gtk::SHADOW_IN);  scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);  scrolled_window.add(editbox);  get_longest_button_text();  table.attach(scrolled_window, 0, 2, 0, 1, Gtk::FILL | Gtk::EXPAND,	       Gtk::FILL | Gtk::EXPAND, 0, 0);  table.attach(label, 0, 2, 1, 2, Gtk::FILL | Gtk::EXPAND,	       Gtk::SHRINK, 0, standard_size/3);  table.attach(accept_button, 0, 1, 2, 3, Gtk::SHRINK,	       Gtk::SHRINK, 0, standard_size/3);  table.attach(reject_button, 1, 2, 2, 3, Gtk::SHRINK,	       Gtk::SHRINK, 0, standard_size/3);  accept_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &GplDialog::selected), accepted));  reject_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &GplDialog::selected), rejected));  add(table);    set_title(gettext("efax-gtk: Conditions, Notices and Disclaimers"));  set_modal(true);  set_default_size(standard_size * 25, standard_size * 16);    set_border_width(standard_size/4);  set_position(Gtk::WIN_POS_CENTER_ON_PARENT);    grab_focus();  accept_button.unset_flags(Gtk::CAN_FOCUS);  reject_button.unset_flags(Gtk::CAN_FOCUS);  editbox.unset_flags(Gtk::CAN_FOCUS);    show_all();}int GplDialog::exec(void) {  in_exec_loop = true;  Gtk::Main::run();  return result;}void GplDialog::selected(Result selection) {  hide_all();  result = selection;  if (in_exec_loop) Gtk::Main::quit(); // this will cause the exec() method to return, with result as its return value}bool GplDialog::on_delete_event(GdkEventAny*) {  selected(rejected);  return true; // returning true prevents destroy sig being emitted}bool GplDialog::on_key_press_event(GdkEventKey* event_p) {  int keycode = event_p->keyval;    if (keycode == GDK_Escape) selected(rejected);    else if (keycode == GDK_Home || keycode == GDK_End	   || keycode == GDK_Up || keycode == GDK_Down	   || keycode == GDK_Page_Up || keycode == GDK_Page_Down) {    editbox.on_key_press_event(event_p);    return false;  }  return true;}void GplDialog::get_longest_button_text(void) {  std::vector<Glib::ustring> text_vec;  text_vec.push_back(gettext("Accept"));  text_vec.push_back(gettext("Reject"));  Gtk::Button button;  std::vector<Glib::ustring>::const_iterator temp_iter;  std::vector<Glib::ustring>::const_iterator max_width_iter;  int width;  int height;  int max_width;  for (temp_iter = text_vec.begin(), max_width_iter = text_vec.begin(),	 width = 0, height = 0, max_width = 0;       temp_iter != text_vec.end(); ++temp_iter) {    button.create_pango_layout(*temp_iter)->get_pixel_size(width, height);    if (width > max_width) {      max_width = width;      max_width_iter = temp_iter;    }  }  max_text = *max_width_iter;}void GplDialog::on_style_changed(const Glib::RefPtr<Gtk::Style>& prev_style) {  // before we set the buttons, do anything else necessary with the new style  Gtk::Window::on_style_changed(prev_style);  //now set the buttons in GplDialog  int width = 0;  int height = 0;  Gtk::Button button;  button.set_style(get_style());  button.create_pango_layout(max_text)->get_pixel_size(width, height);  // add padding  width += 18;  height += 12;  // have some sensible minimum width and height if a very small font chosen  const int min_width = standard_size * 4;  const int min_height = 30;  if (width < min_width) width = min_width;  if (height < min_height) height = min_height;  accept_button.set_size_request(width, height);  reject_button.set_size_request(width, height);}InfoDialog::InfoDialog(const Glib::ustring& text, const Glib::ustring& caption, int standard_size,                       Gtk::MessageType message_type, Gtk::Window& window, bool modal):#if GTKMM_VERSION >= 24                             Gtk::MessageDialog(text, false, message_type, Gtk::BUTTONS_CLOSE),#else                             Gtk::MessageDialog(text, message_type, Gtk::BUTTONS_CLOSE),#endif			     in_exec_loop(false), is_modal(modal),			     parent(window) {  set_title(caption);  set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);  if (is_modal) {    set_transient_for(parent);    parent.set_sensitive(false);    set_modal(true);  }  get_action_area()->set_layout(Gtk::BUTTONBOX_SPREAD);  Gtk::Button* button_p = static_cast<Gtk::Button*>(get_action_area()->children().front().get_widget());  button_p->signal_clicked().connect(sigc::mem_fun(*this, &InfoDialog::selected));  set_position(Gtk::WIN_POS_CENTER_ON_PARENT);  set_resizable(false);  set_icon(prog_config.window_icon_r);  show_all();}void InfoDialog::exec(void) {  in_exec_loop = true;  Gtk::Main::run();}void InfoDialog::selected(void) {  if (is_modal) parent.set_sensitive(true);  hide_all();  if (in_exec_loop) Gtk::Main::quit();  // if we have not called exec(), then this dialog is self-owning and it is safe to call `delete this'  else delete this;}bool InfoDialog::on_delete_event(GdkEventAny*) {  selected();  return true; // returning true prevents destroy sig being emitted}bool InfoDialog::on_key_press_event(GdkEventKey* event_p) {  if (event_p->keyval == GDK_Return || event_p->keyval == GDK_Escape) selected();  return false;}PromptDialog::PromptDialog(const Glib::ustring& text, const Glib::ustring& caption, int standard_size, Gtk::Window& window, bool modal):                             Gtk::Window(Gtk::WINDOW_TOPLEVEL),			     in_exec_loop(false), is_modal(modal),			     result(false), ok_button(Gtk::Stock::OK),			     cancel_button(Gtk::Stock::CANCEL),			     button_box(Gtk::BUTTONBOX_END, standard_size/2),			     label(text), table(2, 1, false), parent(window) {  label.set_line_wrap(true);  button_box.add(cancel_button);  button_box.add(ok_button);  table.attach(label, 0, 1, 0, 1, Gtk::FILL | Gtk::EXPAND,	 Gtk::FILL | Gtk::EXPAND, standard_size/2, standard_size/4);  table.attach(button_box, 0, 1, 1, 2, Gtk::FILL | Gtk::EXPAND,	 Gtk::SHRINK, standard_size/2, standard_size/4);  ok_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &PromptDialog::selected), true));  cancel_button.signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &PromptDialog::selected), false));  ok_button.set_flags(Gtk::CAN_DEFAULT);  cancel_button.set_flags(Gtk::CAN_DEFAULT);  add(table);    set_title(caption);  set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);  if (is_modal) {    set_transient_for(parent);    parent.set_sensitive(false);    set_modal(true);  }  set_border_width(standard_size/2);  ok_button.grab_focus();  set_position(Gtk::WIN_POS_CENTER_ON_PARENT);  set_resizable(false);  set_icon(prog_config.window_icon_r);  show_all();}bool PromptDialog::exec(void) {  in_exec_loop = true;  Gtk::Main::run();  return result;}void PromptDialog::selected(bool accept) {  if (is_modal) parent.set_sensitive(true); // do this before we emit accepted()  hide_all();  result = accept;  if (accept) accepted();  else rejected();  if (in_exec_loop) Gtk::Main::quit();  // if we have not called exec(), then this dialog is self-owning and it is safe to call `delete this'  else delete this;}bool PromptDialog::on_delete_event(GdkEventAny*) {  selected(false);  return true; // returning true prevents destroy sig being emitted}bool PromptDialog::on_key_press_event(GdkEventKey* event_p) {  if (event_p->keyval == GDK_Escape) selected(false);  if (event_p->keyval == GDK_Return || event_p->keyval == GDK_Tab) Gtk::Window::on_key_press_event(event_p);  return false;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -