1 // 2 // pwrmeter.h 3 // 4 // PWRmeter bar widget routines. 5 // ---------------------------------------------------------------------------- 6 // Copyright (C) 2014 7 // David Freese, W1HKJ 8 // 9 // This file is part of fldigi 10 // 11 // fldigi is free software; you can redistribute it and/or modify 12 // it under the terms of the GNU General Public License as published by 13 // the Free Software Foundation; either version 3 of the License, or 14 // (at your option) any later version. 15 // 16 // fldigi is distributed in the hope that it will be useful, 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 // GNU General Public License for more details. 20 // 21 // You should have received a copy of the GNU General Public License 22 // along with this program. If not, see <http://www.gnu.org/licenses/>. 23 // ---------------------------------------------------------------------------- 24 25 26 #ifndef PWRMETER 27 #define PWRMETER 28 29 // 30 // Include necessary headers. 31 // 32 33 #include <FL/Fl.H> 34 #include <FL/Fl_Widget.H> 35 36 // 37 // PWRmeter class... 38 // 39 40 class PWRmeter : public Fl_Widget 41 { 42 public: 43 enum {P25, P50, P100, P200, AUTO}; 44 45 private: 46 double value_, 47 maximum_; 48 int sval; // Size of sval bar... 49 int bx, by, bw, bh; // Box areas... 50 int tx, tw; // Temporary X + width 51 int ty, th; // Temporary Y + height 52 int sx; // meter left offset 53 int meter_width; 54 int meter_height; 55 int select_; 56 Fl_Color bgnd_; 57 Fl_Color fgnd_; 58 Fl_Color scale_color; 59 static const char *W25_face; 60 static const char *W50_face; 61 static const char *W100_face; 62 static const char *W200_face; 63 64 void (*cbFunc)(Fl_Widget *, void *); 65 66 protected: 67 virtual void draw(); 68 69 public: 70 PWRmeter(int x, int y, int w, int h, const char *l = 0); 71 value(double v)72 void value(double v) { value_ = v; redraw(); } value()73 double value() const { return (value_); } 74 void resize(int x, int y, int w, int h); 75 int handle(int); 76 set_background(Fl_Color c1)77 void set_background(Fl_Color c1) { bgnd_ = c1; redraw(); } set_metercolor(Fl_Color c2)78 void set_metercolor(Fl_Color c2) { fgnd_ = c2; redraw(); } set_scalecolor(Fl_Color c3)79 void set_scalecolor(Fl_Color c3) { scale_color = c3; redraw(); } 80 81 void select(int sel); 82 callback(void (* cbf)(Fl_Widget *,void *))83 void callback (void (*cbf)(Fl_Widget *, void *) ){ cbFunc = cbf;} do_callback()84 void do_callback() { 85 if (cbFunc) cbFunc(this, (void*)0); 86 } 87 88 private: 89 void select_auto(); 90 void select_25W(); 91 void select_50W(); 92 void select_100W(); 93 void select_200W(); 94 }; 95 96 97 #endif // !pwrmeter 98 99