background_chooser_dialog.cc
author hegyi
Fri, 02 Feb 2007 10:13:33 +0000
changeset 187 b465e2c34f23
child 194 6b2b718420eb
permissions -rw-r--r--
Zoom is now available with mouse-wheel.
     1 #include "background_chooser_dialog.h"
     2 #include <gtkmm/stock.h>
     3 #include "mapstorage.h"
     4 
     5 BackgroundChooserDialog::BackgroundChooserDialog(MapStorage* ms) :
     6   mapstorage(ms),
     7   btnClear(Gtk::Stock::CLEAR)
     8 {
     9   set_has_separator(false);
    10 
    11   Gtk::VBox* pVBox = get_vbox();
    12 
    13   lblBackground.set_text("<b>Background image file</b>");
    14   lblBackground.set_use_markup();
    15   lblBackground.set_alignment(Gtk::ALIGN_LEFT);
    16   lblScaling.set_text("<b>Scaling factor</b>");
    17   lblScaling.set_use_markup();
    18   lblScaling.set_alignment(Gtk::ALIGN_LEFT);
    19   fcbBackground.set_width_chars(30);
    20   fcbBackground.set_action(Gtk::FILE_CHOOSER_ACTION_OPEN);
    21   if (mapstorage->isBackgroundSet())
    22   {
    23     fcbBackground.set_filename(mapstorage->getBackgroundFilename());
    24   }
    25 
    26   fcbBackground.signal_selection_changed().connect(
    27     sigc::mem_fun(*this, &BackgroundChooserDialog::setBackground));
    28 
    29   btnClear.signal_clicked().connect(
    30     sigc::mem_fun(*this, &BackgroundChooserDialog::clearBackground));
    31 
    32   pVBox->pack_start(lblBackground, Gtk::PACK_SHRINK);
    33   pVBox->pack_start(box, Gtk::PACK_SHRINK);
    34   box.pack_start(fcbBackground, Gtk::PACK_EXPAND_WIDGET);
    35   box.pack_start(btnClear, Gtk::PACK_SHRINK);
    36   pVBox->pack_start(lblScaling, Gtk::PACK_SHRINK);
    37   pVBox->pack_start(sbScaling, Gtk::PACK_SHRINK);
    38 
    39   add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
    40 
    41   show_all_children();
    42 }
    43 
    44 void BackgroundChooserDialog::clearBackground()
    45 {
    46   fcbBackground.unselect_all();
    47 }
    48 
    49 void BackgroundChooserDialog::setBackground()
    50 {
    51   mapstorage->setBackground(fcbBackground.get_filename());
    52 }