--- /dev/null
+/* Demo Recorder for MAEMO 5
+* Copyright (C) 2010 Dru Moore <usr@dru-id.co.uk>
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2,
+* or (at your option) any later version, as published by the Free
+* Software Foundation
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details
+*
+* You should have received a copy of the GNU General Public
+* License along with this program; if not, write to the
+* Free Software Foundation, Inc.,
+* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+namespace IdWorks {
+
+public class MeterWidget : Gtk.VBox {
+
+ private Gtk.Label title_label;
+ private Gtk.Label peak_label;
+ private Gtk.Label decay_label;
+ private DbMonitorWidget meter;
+
+ private static const int BORDER_WIDTH = 4;
+ private static const int BORDER_HEIGHT = 4;
+ //private Pango.Layout layout;
+ private static const double MIN_VALUE = 0.0;
+ private static const double MAX_VALUE = 1.5;
+
+ private static const double ZERO_VALUE = 1.0;
+
+ private double peak;
+ private double decay;
+ public void set_peak(double val) {
+ this.peak = (MAX_VALUE > val) ? val : MAX_VALUE;
+ this.peak_label.set_text("%02.2f".printf(val));
+ meter.set_peak(Math.pow (10, val / 20));
+ }
+ public void set_decay(double val) {
+ this.decay = (MAX_VALUE > val) ? val : MAX_VALUE;
+ this.decay_label.set_text("%02.2f".printf(val));
+ meter.set_decay(Math.pow (10, val / 20));
+ }
+ private DbMonitorWidget.Layout layout = DbMonitorWidget.Layout.VERTICAL;
+ public void set_layout(DbMonitorWidget.Layout layout) {
+ this.layout = layout;
+ meter.set_layout(layout);
+ }
+
+ public string title {
+ get {
+ return title_label.get_text();
+ }
+ set {
+ title_label.set_text(value);
+ }
+ }
+
+ construct {
+ title_label = new Gtk.Label("");
+ title_label.modify_font(Pango.FontDescription.from_string("Sans 20"));
+ title_label.set_padding(4, 2);
+ //title_label.set_alignment(0,0);
+
+ this.pack_start(title_label, false, true, 4);
+
+ meter = new DbMonitorWidget();
+ meter.set_layout(layout);
+ meter.set_peak(0.0);
+ meter.set_decay(0.0);
+ this.pack_start(meter, true, true, 0);
+
+ Gtk.HBox display = new Gtk.HBox(true, 8);
+
+ peak_label = new Gtk.Label("0.0");
+ peak_label.modify_font(Pango.FontDescription.from_string("Sans 40"));
+ peak_label.set_padding(4, 2);
+ //peak_label.set_alignment(0,0);
+ decay_label = new Gtk.Label("0.0");
+ decay_label.modify_font(Pango.FontDescription.from_string("Sans 40"));
+ decay_label.set_padding(4, 2);
+ //decay_label.set_alignment(0,0);
+
+ display.add(peak_label);
+ display.add(decay_label);
+
+ this.pack_start(display, false, true, 0);
+
+ Gtk.HBox display2 = new Gtk.HBox(true, 0);
+
+ Gtk.Label peak_label2 = new Gtk.Label("dB Peak");
+ peak_label2.modify_font(Pango.FontDescription.from_string("Sans 16"));
+ peak_label2.set_padding(0, 0);
+ //peak_label2.set_alignment(0,0);
+ Gtk.Label decay_label2 = new Gtk.Label("dB Decay");
+ decay_label2.modify_font(Pango.FontDescription.from_string("Sans 16"));
+ decay_label2.set_padding(0, 0);
+ //decay_label2.set_alignment(0,0);
+
+ display2.add(peak_label2);
+ display2.add(decay_label2);
+
+ this.pack_start(display2, false, true, 0);
+
+ }
+
+}
+
+}