knob::knob() { knob_value = 0; value = 0; snap = false; invert = false; rounded = 5; min = 0; max = 1; drag = false; label = "KNOB"; pos_mode = 0; top_colour.set( "#550000"); bottom_colour.set( "#220000"); // make the click events call the on_button_press_event function // add_events( Gdk::BUTTON_PRESS_MASK); set_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK); // make the click event do that function signal_button_press_event().connect( sigc::mem_fun(*this, &knob::on_button_press_event) ); set_size_request(40,70); }
/** Crea la capa de la imagen. @param iPixbuf, Glib::RefPtr<Gdk::Pixbuf> contiene el pixbuf de la imagen. @param ancho, entero que contiene el ancho de la imagen. @param alto, entero que contiene el alto de la imagen. */ void PanelDibujado::creaCapaImagen(Glib::RefPtr<Gdk::Pixbuf> iPixbuf, int ancho, int alto) { if(surfaceImagen) { surfaceImagen->finish(); } if(surfaceCelulas) { surfaceCelulas->finish(); } surfaceImagen = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, ancho, alto); surfaceCelulas = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, ancho, alto); //Inicializamos la capa de las celulas sistemDibujo->getCapaCelula()->setContexCelulasPrin(surfaceCelulas); sistemDibujo->getCapaCelula()->setContexCelulasSecun(surfaceCelulas); //Creamos el contexto de cairo cr1 = Cairo::Context::create(surfaceCelulas); cr = Cairo::Context::create (surfaceImagen); //Establecemos el operador de dibujado cr1->set_operator(Cairo::OPERATOR_SOURCE); cr->set_operator(Cairo::OPERATOR_SOURCE); Gdk::Cairo::set_source_pixbuf(cr, iPixbuf, 0, 0); cr->rectangle(0, 0, ancho, alto); cr->fill(); set_size_request(ancho, alto); }
PlayerPlaylist::PlayerPlaylist() : m_VBox(Gtk::ORIENTATION_VERTICAL) { set_size_request(400, 200); add(m_VBox); //Add the TreeView, inside a ScrolledWindow, with the button underneath: m_ScrolledWindow.add(m_TreeView); //Only show the scrollbars when they are necessary: m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); m_VBox.pack_start(m_ScrolledWindow); //Create the Tree model: m_refTreeModel = Gtk::ListStore::create(m_Columns); m_TreeView.set_model(m_refTreeModel); //Add the TreeView's view columns: //This number will be shown with the default numeric formatting. m_TreeView.append_column("N", m_Columns.m_col_id); m_TreeView.append_column("Artist", m_Columns.m_col_artist); m_TreeView.append_column("Album", m_Columns.m_col_album); m_TreeView.append_column("Title", m_Columns.m_col_title); }
Gui_DisplayBaseClass::Gui_DisplayBaseClass(Gui_ProcessorHandler& processor_hand): m_processor_hand(processor_hand), m_deco(this,processor_hand,m_show_idx,m_show_point,m_ROI), m_ROI(cv::Point(0,0),cv::Point(0,0)), m_draw_result(false), m_alph_mask(128), m_show_idx(-1),m_show_point(false),m_show_mask(true), m_cursor(Gdk::CROSS) { this->add_events( Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK ); this->signal_scroll_event().connect( sigc::mem_fun( *this, &Gui_DisplayBaseClass::on_scroll) ); this->signal_button_press_event().connect( sigc::mem_fun( *this, &Gui_DisplayBaseClass::on_click) ); m_color.set_rgb_p(0.2,0.2,0.2); this->modify_bg(Gtk::STATE_NORMAL,m_color); m_processor_hand.signal_state().connect( sigc::mem_fun(*this,&Gui_DisplayBaseClass::myRedraw)); Glib::RefPtr< Gdk::Screen > screen = Gdk::Screen::get_default(); Gdk::Rectangle rect; screen->get_monitor_geometry(screen->get_primary_monitor(),rect); set_size_request(rect.get_width()/4,rect.get_height()/4); makeLUT(); }
Start::Start() : m_button_1("North"), m_button_2("South") // creates a new button with label "Hello World". { // Parametry okna. set_border_width(30); //odleg³oœæ pomiêdzy obramowaniem okna, a elementami wewn¹trz set_title("Learn 2015"); //tytu³ set_size_request(300,150); //rozmiar set_position(Gtk::WIN_POS_CENTER); // pozyzja okna - wyœrodkowana wzgledem pulpitu set_resizable( false ); // blokowanie zmiany rozmiaru okna // Kontener poziomy 1 Kontener_poziomy_1.pack_start( m_button_1, Gtk::PACK_EXPAND_WIDGET, 10 ); Kontener_poziomy_1.pack_start( m_button_2, Gtk::PACK_EXPAND_WIDGET, 10 ); Kontener_poziomy_1.set_homogeneous( true ); //Ujednolicenie rozmiaru przycisków // When the button receives the "clicked" signal, it will call the // on_button_clicked() method defined below. m_button_1.signal_clicked().connect(sigc::mem_fun(*this, &Start::on_button_clicked_1)); m_button_2.signal_clicked().connect(sigc::mem_fun(*this, &Start::on_button_clicked_2)); // This packs the button into the Window (a container). add( Kontener_poziomy_1 ); show_all(); //add(m_button); // The final step is to display this newly created widget... //m_button_1.show(); //m_button_2.show(); }
seqtime::seqtime(sequence *a_seq, int a_zoom, Gtk::Adjustment *a_hadjust): DrawingArea() { m_seq = a_seq; m_zoom = a_zoom; m_hadjust = a_hadjust; add_events( Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK ); // in the construor you can only allocate colors, // get_window() returns 0 because we have not be realized Glib::RefPtr<Gdk::Colormap> colormap = get_default_colormap(); m_black = Gdk::Color( "black" ); m_white = Gdk::Color( "white" ); m_grey = Gdk::Color( "grey" ); colormap->alloc_color( m_black ); colormap->alloc_color( m_white ); colormap->alloc_color( m_grey ); /* set default size */ set_size_request( 10, c_timearea_y ); m_scroll_offset_ticks = 0; m_scroll_offset_x = 0; set_double_buffered( false ); }
/** * Constructor */ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) { // call this first initStrings(); Gtk::Notebook *tabs=new Gtk::Notebook(); tabs->set_scrollable(); Gtk::Widget *splash=build_splash_widget(); if (splash) { tabs->append_page(*manage(splash), _("_Splash"), true); } tabs->append_page(*manage( make_scrolled_text(authors_text)), _("_Authors"), true); tabs->append_page(*manage( make_scrolled_text(translators_text)), _("_Translators"), true); tabs->append_page(*manage( make_scrolled_text(license_text)), _("_License"), true); #if WITH_GTKMM_3_0 get_content_area()->pack_end(*manage(tabs), true, true); #else get_vbox()->pack_end(*manage(tabs), true, true); #endif tabs->show_all(); add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE); set_default_response(Gtk::RESPONSE_CLOSE); Gtk::Label *label=new Gtk::Label(); gchar *label_text = g_strdup_printf("<small>Inkscape %s</small>", Inkscape::version_string); label->set_markup(label_text); label->set_alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER); label->set_padding(5,0); g_free(label_text); label->set_selectable(true); label->show(); #if WITH_GTKMM_3_0 get_content_area()->pack_start(*manage(label), false, false); #else get_vbox()->pack_start(*manage(label), false, false); #endif Gtk::Requisition requisition; #if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_preferred_size(reinterpret_cast<GtkWidget*>(gobj()), &requisition, NULL); #else gtk_widget_size_request (reinterpret_cast<GtkWidget*>(gobj()), &requisition); #endif // allow window to shrink set_size_request(0, 0); set_default_size(requisition.width, requisition.height); }
MidiControllerDisplay::MidiControllerDisplay(gx_engine::GxMachineBase& machine, unsigned int n, const gx_engine::midi_controller_list& ctrl, const Glib::ustring& name) : Gtk::ProgressBar(), ctr(n) { machine.signal_midi_value_changed().connect( sigc::mem_fun(this, &MidiControllerDisplay::midi_value_changed)); set_size_request(300, 50); set_text(name); machine.request_midi_value_update(); }
void BuilderHomeButton::initialize() { set_size_request(350, 65); set_alignment(0.5, 0.5); mp_InnerBox = Gtk::manage(new Gtk::HBox()); mp_InnerBox->set_visible(true); add(*mp_InnerBox); }
MyArea::MyArea(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder) : Gtk::DrawingArea(cobject) { priv = new MyArea_private(); set_size_request(800,640); set_events( Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK ); show(); }
/** * Constructor */ Messages::Messages() : UI::Widget::Panel("", "/dialogs/messages", SP_VERB_DIALOG_DEBUG), buttonClear(_("_Clear"), _("Clear log messages")), checkCapture(_("Capture log messages"), _("Capture log messages")) { Gtk::Box *contents = _getContents(); /* * Menu replaced with buttons * menuBar.items().push_back( Gtk::Menu_Helpers::MenuElem(_("_File"), fileMenu) ); fileMenu.items().push_back( Gtk::Menu_Helpers::MenuElem(_("_Clear"), sigc::mem_fun(*this, &Messages::clear) ) ); fileMenu.items().push_back( Gtk::Menu_Helpers::MenuElem(_("Capture log messages"), sigc::mem_fun(*this, &Messages::captureLogMessages) ) ); fileMenu.items().push_back( Gtk::Menu_Helpers::MenuElem(_("Release log messages"), sigc::mem_fun(*this, &Messages::releaseLogMessages) ) ); contents->pack_start(menuBar, Gtk::PACK_SHRINK); */ //### Set up the text widget messageText.set_editable(false); textScroll.add(messageText); textScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); contents->pack_start(textScroll); buttonBox.set_spacing(6); buttonBox.pack_start(checkCapture, true, true, 6); buttonBox.pack_end(buttonClear, false, false, 10); contents->pack_start(buttonBox, Gtk::PACK_SHRINK); // sick of this thing shrinking too much set_size_request(400, 300); show_all_children(); message(_("Ready.")); buttonClear.signal_clicked().connect(sigc::mem_fun(*this, &Messages::clear)); checkCapture.signal_clicked().connect(sigc::mem_fun(*this, &Messages::toggleCapture)); /* * TODO - Setting this preference doesn't capture messages that the user can see. * Inkscape creates an instance of a dialog on startup and sends messages there, but when the user * opens the dialog View > Messages the DialogManager creates a new instance of this class that is not capturing messages. * * message(_("Enable log display by setting dialogs.debug 'redirect' attribute to 1 in preferences.xml")); */ handlerDefault = 0; handlerGlibmm = 0; handlerAtkmm = 0; handlerPangomm = 0; handlerGdkmm = 0; handlerGtkmm = 0; }
CPagePreview::CPagePreview() { page_width = 120; page_height = 180; image_width_ratio = 0.5; image_height_ratio = 0.5; set_size_request(120,180); }
ActivityDrawingArea::ActivityDrawingArea() : currentColourScheme(ActivityDrawingArea::INACTIVE_COLOURS), defaultColourScheme(ActivityDrawingArea::STANDARD_COLOURS) { //std::cout << "ActivityDrawingArea::ActivityDrawingArea()" << std::endl; this->signal_expose_event().connect(sigc::mem_fun(*this, &ActivityDrawingArea::on_expose_event)); set_size_request(-1, ActivityDrawingArea::ACTIVITY_HEIGHT); this->setActivated(false); }
gui::PlotWindow::PlotWindow(const std::string title, const std::vector<int>& data) : plotArea_(data) { set_title(title); set_resizable(false); set_size_request(256 + BORDER_WIDTH, 256 + BORDER_WIDTH); set_border_width(BORDER_WIDTH); add(plotArea_); plotArea_.show(); }
XmlTypeBox::XmlTypeBox(value::Xml* xml) : Gtk::Dialog("XML", true, true), mValue(xml) { makeBox(); mBuff->set_text(xml->writeToString()); set_size_request(350, 350); show_all(); }
VistaSeleccioneIntervaloSegundos::VistaSeleccioneIntervaloSegundos() { set_title("Ha seleccionado un video, cada cuantos segundos se enviaran los frames?"); set_size_request(550,100); vbox = get_vbox(); vbox->add(segs); vbox->add(ok); ok.set_label("OK"); ok.signal_clicked().connect( sigc::mem_fun(*this, &VistaSeleccioneIntervaloSegundos::on_button_OK) ); }
XmlTypeBox::XmlTypeBox(std::string& string) : Gtk::Dialog("XML", true, true), mValue(0), mXml(&string) { makeBox(); mBuff->set_text(string); set_size_request(350, 350); show_all(); }
GUIWindow::GUIWindow() : bigbox(Gtk::ORIENTATION_VERTICAL, 15), filebox(Gtk::ORIENTATION_HORIZONTAL, 5), sizebox(Gtk::ORIENTATION_VERTICAL, 5) { resLevel = 3; set_border_width(10); bigbox.set_homogeneous(false); filebox.set_homogeneous(false); set_size_request(400, 600); set_title("Mosaic Masterpiece"); add(bigbox); filename.set_max_length(300); filename.set_text("Pick an image..."); tags.set_text("Tags..."); tags.set_max_length(300); browse.set_label("Browse..."); close.set_label("Close"); run.set_label("RUN!"); low.set_label("Low"); med.set_label("Medium"); high.set_label("High"); sizegroup = low.get_group(); med.set_group(sizegroup); high.set_group(sizegroup); high.set_active(true); run.signal_clicked().connect(sigc::mem_fun(*this, &GUIWindow::OnRun)); close.signal_clicked().connect(sigc::mem_fun(*this, &GUIWindow::OnClose)); low.signal_clicked().connect(sigc::mem_fun(*this, &GUIWindow::LowRes)); med.signal_clicked().connect(sigc::mem_fun(*this, &GUIWindow::MedRes)); high.signal_clicked().connect(sigc::mem_fun(*this, &GUIWindow::HighRes)); status.set_label("Waiting for a picture..."); //filebox.pack_start(filename); //filebox.pack_start(run); sizebox.pack_start(low); sizebox.pack_start(med); sizebox.pack_start(high); bigbox.pack_start(status); bigbox.pack_start(filename); bigbox.pack_start(browse); bigbox.pack_start(sizebox); bigbox.pack_start(tags); bigbox.pack_start(run); bigbox.pack_start(close); show_all_children(); mm.OpenPipe(); }
TimeLine::TimeLine(LibbenchWindow* window) : m_mainWindow(window) , m_timeStart(0.0) { m_layout = create_pango_layout(""); m_font.set_family("DejaVu Sans"); m_font.set_weight(Pango::WEIGHT_LIGHT); m_font.set_size(8 * PANGO_SCALE); m_font.set_stretch(Pango::STRETCH_NORMAL); set_size_request(-1, 25); }
void Gobby::CloseButton::on_style_changed( const Glib::RefPtr<Gtk::Style>& previous_style) #endif { int width; int height; gtk_icon_size_lookup_for_settings( gtk_widget_get_settings(GTK_WIDGET(gobj())), GTK_ICON_SIZE_MENU, &width, &height); set_size_request(width + 2, height + 2); }
MarketBuildOptionsDialog::MarketBuildOptionsDialog(const std::string& CommonBuildOptions, const std::string& BuildOptions, const std::string FuncID) : Gtk::Dialog(), m_CommonBuildOptions(CommonBuildOptions),m_BuildOptions(BuildOptions),m_FuncID(FuncID) { set_size_request(450,-1); set_border_width(6); Gtk::Label* InfoLabel = Gtk::manage(new Gtk::Label()); InfoLabel->set_markup(std::string("<i>")+_("These options control the builds of source packages.\nChanging this is at your own risk.")+std::string("</i>")); InfoLabel->set_justify(Gtk::JUSTIFY_CENTER); get_vbox()->pack_start(*InfoLabel); Gtk::Label* CommonOptsLabel = Gtk::manage(new Gtk::Label()); if (!FuncID.empty()) CommonOptsLabel->set_markup(_("<u>Common source build options:</u>\n") +openfluid::tools::ReplaceEmptyString(CommonBuildOptions,_("<i>none</i>"))); else CommonOptsLabel->set_label(""); CommonOptsLabel->set_alignment(0,0.5); get_vbox()->pack_start(*CommonOptsLabel,Gtk::PACK_SHRINK,12); Gtk::Label* EditLabel = Gtk::manage(new Gtk::Label()); if (!FuncID.empty()) { EditLabel->set_label(_("Specific build options for ")+FuncID+_(":")); } else { EditLabel->set_label(_("Common source build options:")); } EditLabel->set_alignment(0,0.5); get_vbox()->pack_start(*EditLabel); if (FuncID.empty()) m_OptionsEntry.set_text(CommonBuildOptions); else m_OptionsEntry.set_text(BuildOptions); get_vbox()->pack_start(m_OptionsEntry); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); if(m_FuncID.empty()) set_title(_("Common build options for all source packages")); else set_title(_("Build options for ") + m_FuncID); show_all_children(); }
CreateWireframeDialog::CreateWireframeDialog(const Glib::ustring & title) : Dialog(title, true), m_filled(false), m_minVertices(false), m_coordBox(Gtk::manage(new CoordBox())), m_nameLabel(Gtk::manage(new Gtk::Label("Name: "))), m_nameEntry(Gtk::manage(new Gtk::Entry())) { set_size_request(-1, 230); set_resizable(false); set_border_width(10); // Entry for the name Gtk::HBox * const name_hbox = Gtk::manage(new Gtk::HBox()); name_hbox->pack_start(*m_nameLabel, Gtk::PACK_SHRINK, 0); name_hbox->pack_start(*m_nameEntry, Gtk::PACK_EXPAND_WIDGET, 0); name_hbox->set_spacing(0); name_hbox->set_homogeneous(false); // Check box for filling Gtk::CheckButton * const filled_button = Gtk::manage(new Gtk::CheckButton("Filled shape")); filled_button->signal_toggled().connect(sigc::mem_fun(*this, &CreateWireframeDialog::on_filled_button_toggled)); filled_button->set_active(false); get_content_area()->pack_start(*name_hbox, Gtk::PACK_SHRINK, 5); get_content_area()->pack_start(*filled_button, Gtk::PACK_SHRINK, 5); Gtk::Frame * const coord_frame = Gtk::manage(new Gtk::Frame("Points")); Gtk::ScrolledWindow * const scrolled_window = Gtk::manage(new Gtk::ScrolledWindow()); scrolled_window->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); scrolled_window->set_size_request(-1, 150); scrolled_window->set_border_width(5); scrolled_window->add(*m_coordBox); m_coordBox->set_spacing(0); coord_frame->add(*scrolled_window); get_content_area()->pack_start(*coord_frame, Gtk::PACK_SHRINK, 0); // Entries for the coordinates m_coordBox->add_coord(); m_coordBox->add_coord(); m_coordBox->add_coord(); // Add buttons (from left to right) add_button("Cancel", Gtk::RESPONSE_CANCEL); add_button("Add point", Gtk::RESPONSE_APPLY); add_button("OK", Gtk::RESPONSE_OK); signal_response().connect_notify(sigc::mem_fun(*this, &CreateWireframeDialog::on_my_response)); set_default_response(Gtk::RESPONSE_OK); show_all_children(); }
void FieldView::Assign(const FieldView& fw){ //reinitialize properties width = fw.width; height = fw.height; field = fw.field; sx = fw.sx; sy = fw.sy; DrawGrid(); //redrawing grid DrawAllDots(); //redrawing dots //changing sizes set_size_request((width * CELL_SIZE * 1.75), (height * CELL_SIZE * 1.75)); }
MyArea::MyArea() { try { m_PxlBuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, false, 8, 800, 480); } catch (const Gdk::PixbufError& ex) { // std::cerr << "PixbufError: " << ex.what() << std::endl; } if (m_PxlBuf) set_size_request(m_PxlBuf->get_width() / 2, m_PxlBuf->get_height() / 2); }
void perftime::on_realize() { // we need to do the default realize Gtk::DrawingArea::on_realize(); // Now we can allocate any additional resources we need m_window = get_window(); m_gc = Gdk::GC::create( m_window ); m_window->clear(); set_size_request( 10, c_timearea_y ); }
MapWindow::MapWindow() : m_draw(), m_VertParentBox(Gtk::ORIENTATION_VERTICAL), m_HorzChildBox(Gtk::ORIENTATION_HORIZONTAL), m_Button_File(), m_Button_Solve(), m_WorkerThread(NULL), DialogWindow() { // Add the text for the file button and picture m_Button_File.add_pixlabel("open.gif","Choose file"); m_Button_Solve.add_pixlabel("worker.gif","Solve path"); // Add a buffer border to the window set_border_width(10); // Set title, maximize window set_title("Astar"); maximize(); // Set the minimum window size set_size_request(400,300); // Connect button handlers m_Button_File.signal_clicked().connect(sigc::mem_fun(*this, &MapWindow::on_button_file_clicked) ); m_Button_Solve.signal_clicked().connect(sigc::mem_fun(*this, &MapWindow::on_button_solve_clicked) ); // Connect dispatcher for worker thread m_Dispatcher.connect(sigc::mem_fun(*this, &MapWindow::on_notification_from_worker_thread)); // Disable the Solve button m_Button_Solve.set_sensitive(false); // Add a vertical box add(m_VertParentBox); m_VertParentBox.show(); // Horizontal box contains the buttons m_HorzChildBox.pack_end(m_Button_File,Gtk::PACK_EXPAND_PADDING,0); m_HorzChildBox.pack_end(m_Button_Solve,Gtk::PACK_EXPAND_PADDING,0); // Vertical box contains the horizontal box and the drawing area m_VertParentBox.pack_start(m_HorzChildBox,false,false,10); m_VertParentBox.pack_start(m_draw); // Show show_all_children(); }
DebugDialogImpl::DebugDialogImpl() { set_title(_("Messages")); set_size_request(300, 400); #if WITH_GTKMM_3_0 Gtk::Box *mainVBox = get_content_area(); #else Gtk::Box *mainVBox = get_vbox(); #endif //## Add a menu for clear() Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(_("_File"), true)); item->set_submenu(fileMenu); menuBar.append(*item); item = Gtk::manage(new Gtk::MenuItem(_("_Clear"), true)); item->signal_activate().connect(sigc::mem_fun(*this, &DebugDialogImpl::clear)); fileMenu.append(*item); item = Gtk::manage(new Gtk::MenuItem(_("Capture log messages"))); item->signal_activate().connect(sigc::mem_fun(*this, &DebugDialogImpl::captureLogMessages)); fileMenu.append(*item); item = Gtk::manage(new Gtk::MenuItem(_("Release log messages"))); item->signal_activate().connect(sigc::mem_fun(*this, &DebugDialogImpl::releaseLogMessages)); fileMenu.append(*item); mainVBox->pack_start(menuBar, Gtk::PACK_SHRINK); //### Set up the text widget messageText.set_editable(false); textScroll.add(messageText); textScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); mainVBox->pack_start(textScroll); show_all_children(); message("ready."); message("enable log display by setting "); message("dialogs.debug 'redirect' attribute to 1 in preferences.xml"); handlerDefault = 0; handlerGlibmm = 0; handlerAtkmm = 0; handlerPangomm = 0; handlerGdkmm = 0; handlerGtkmm = 0; }
ImageView::ImageView(const string& filename) { try{ myImage = Gdk::Pixbuf::create_from_file(filename); }catch(...) { std::cerr<<"An error occured while loading the image file."<<std::endl; } if(myImage) set_size_request(myImage->get_width(), myImage->get_height()); set_halign(Gtk::ALIGN_CENTER); set_valign(Gtk::ALIGN_CENTER); }
MainWindow::MainWindow() { set_title("ひらがな電卓Calc-H ver.0.8.8"); set_size_request(500, 280); Pango::FontDescription font_desc; #ifdef _WIN32 font_desc.set_family("MS Gothic"); #else font_desc.set_family("typewriter"); #endif m_label.modify_font(font_desc); m_entry.modify_font(font_desc); m_textview.modify_font(font_desc); m_button_enter.modify_font(font_desc); set_border_width(4); m_hbox.set_border_width(8); m_vbox.set_border_width(8); m_text_buf = Gtk::TextBuffer::create(); m_textview.set_buffer(m_text_buf); m_label.set_label("にゅうりょく:"); m_entry.set_text(""); m_button_enter.set_label("Enter"); m_button_enter.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_button_enter) ); m_hbox.pack_start(m_label, Gtk::PACK_SHRINK); m_hbox.pack_start(m_entry); m_hbox.pack_start(m_button_enter, Gtk::PACK_SHRINK); m_vbox.pack_start(m_textview); m_vbox.pack_start(m_hbox, Gtk::PACK_SHRINK); add(m_vbox); show_all_children(); m_button_enter.set_can_default(); set_focus(m_entry); std::string contents; contents += ch_logo; contents += '\n'; add_output(contents); } // MainWindow::MainWindow
void maintime::on_realize() { // we need to do the default realize Gtk::DrawingArea::on_realize(); // Now we can allocate any additional resources we need m_window = get_window(); m_gc = Gdk::GC::create( m_window ); m_window->clear(); /* set default size */ set_size_request( c_maintime_x , c_maintime_y ); }