Canola  0.8.D001
canola/nixie_tubes.cc
Go to the documentation of this file.
00001 //
00002 // canola - canon canola 1614p emulator
00003 // Copyright (C) 2011, 2012 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, version 3, as
00007 // published by the Free Software Foundation.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License along
00015 // with this program. If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #include <canola/load_image.h>
00019 #include <canola/nixie_tubes.h>
00020 
00021 
00022 nixie_tubes::~nixie_tubes()
00023 {
00024 }
00025 
00026 
00027 nixie_tubes::nixie_tubes()
00028 {
00029     if (!images[0])
00030         load_images();
00031 
00032     overflow.set(images[0]);
00033     bezel_left.set(images[3]);
00034     bezel_right.set(images[4]);
00035     negative.set(images[5]);
00036 
00037     tube_layout.pack_start(overflow, Gtk::PACK_SHRINK);
00038     tube_layout.pack_start(bezel_left, Gtk::PACK_SHRINK);
00039     for (int j = 15; j >= 0; --j)
00040     {
00041         tubes[j].set_number(j + 1);
00042         tube_layout.pack_start(tubes[j], Gtk::PACK_SHRINK);
00043     }
00044     tube_layout.pack_start(bezel_right, Gtk::PACK_SHRINK);
00045     tube_layout.pack_start(negative, Gtk::PACK_SHRINK);
00046 
00047     Gdk::RGBA gray("#404040");
00048     tube_bg.add(tube_layout);
00049     tube_bg.override_background_color(gray, Gtk::STATE_FLAG_NORMAL);
00050 
00051     lamp_layout.pack_start(m1_lamp, Gtk::PACK_SHRINK);
00052     lamp_layout.pack_start(m2_lamp, Gtk::PACK_SHRINK);
00053     lamp_layout.pack_start(entry_lamp, Gtk::PACK_SHRINK);
00054 
00055     // HBox and VBox don't have an associated drawable, so you can't
00056     // set their backgrounds.  Instead you have to wrap them in a
00057     // Gtk::EventBox and set the event box's background.
00058     lamp_bg.add(lamp_layout);
00059     lamp_bg.override_background_color(gray, Gtk::STATE_FLAG_NORMAL);
00060 
00061     pack_start(tube_bg, Gtk::PACK_SHRINK);
00062     pack_start(lamp_bg, Gtk::PACK_SHRINK);
00063 }
00064 
00065 
00066 void
00067 nixie_tubes::load_images(void)
00068 {
00069     images[0] = load_gui_image("nixie-tube-32-overflow-blank");
00070     images[1] = load_gui_image("nixie-tube-32-overflow-off");
00071     images[2] = load_gui_image("nixie-tube-32-overflow-on");
00072 
00073     images[3] = load_gui_image("nixie-tube-32-bezel-left");
00074     images[4] = load_gui_image("nixie-tube-32-bezel-right");
00075 
00076     images[5] = load_gui_image("nixie-tube-32-negative-blank");
00077     images[6] = load_gui_image("nixie-tube-32-negative-off");
00078     images[7] = load_gui_image("nixie-tube-32-negative-on");
00079 
00080     images[8] = load_gui_image("nixie-tube-32-m1-off");
00081     images[9] = load_gui_image("nixie-tube-32-m1-on");
00082     images[10] = load_gui_image("nixie-tube-32-m2-off");
00083     images[11] = load_gui_image("nixie-tube-32-m2-on");
00084     images[12] = load_gui_image("nixie-tube-32-entry-off");
00085     images[13] = load_gui_image("nixie-tube-32-entry-on");
00086 }
00087 
00088 
00089 void
00090 nixie_tubes::set_value(const display &value)
00091 {
00092     overflow.set(images[1 + value.overflow]);
00093     for (unsigned j = 0; j < 16; ++j)
00094     {
00095         tubes[j].set_value(value.tubes[j]);
00096     }
00097     negative.set(images[6 + value.negative]);
00098 
00099     m1_lamp.set(images[8 + value.m1]);
00100     m2_lamp.set(images[10 + value.m2]);
00101     entry_lamp.set(images[12 + value.entry]);
00102 }