~ubuntu-branches/ubuntu/wily/flrig/wily

« back to all changes in this revision

Viewing changes to .pc/0001-License-Declaration.patch/src/Fl_SigBar.cxx

  • Committer: Package Import Robot
  • Author(s): Kamal Mostafa
  • Date: 2014-10-25 11:17:10 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20141025111710-n32skgya3l9u1brw
Tags: 1.3.17-1
* New upstream release (Closes: #761839)
* Debian Standards-Version: 3.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// "$Id: Fl_SigBar.H
2
 
//
3
 
// Signal Bar widget definitions.
4
 
//
5
 
// Copyright 2011 Dave Freese, W1HKJ
6
 
//
7
 
// This source code is free software; you can redistribute it and/or
8
 
// modify it under the terms of the GNU Library General Public
9
 
// License as published by the Free Software Foundation; either
10
 
// version 2 of the License, or (at your option) any later version.
11
 
//
12
 
// This source code is distributed in the hope that it will be useful,
13
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
// Library General Public License for more details.
16
 
//
17
 
// You should have received a copy of the GNU Library General Public
18
 
// License along with this library; if not, write to the Free Software
19
 
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
 
// USA.
21
 
//
22
 
// Please report all bugs and problems to: w1hkj@w1hkj.com
23
 
//
24
 
// Contents:
25
 
//
26
 
//   Fl_SigBar::draw()          - Draw the check button.
27
 
//   Fl_SigBar::Fl_SigBar() - Construct a Fl_SigBar widget.
28
 
//
29
 
 
30
 
//
31
 
// Include necessary header files...
32
 
//
33
 
 
34
 
#include <stdio.h>
35
 
#include <math.h>
36
 
 
37
 
#include <FL/Fl.H>
38
 
#include <FL/fl_draw.H>
39
 
 
40
 
#include "Fl_SigBar.h"
41
 
 
42
 
//
43
 
// Fl_SigBar is a SigBar bar widget based off Fl_Widget that shows a
44
 
// standard Signal Bar with a peak reading indicator ...
45
 
//
46
 
 
47
 
//
48
 
// 'Fl_SigBar::draw()' - Draw the check button.
49
 
//
50
 
 
51
 
void Fl_SigBar::draw()
52
 
{
53
 
// Get the box borders...
54
 
        int bx = Fl::box_dx(box());
55
 
        int by = Fl::box_dy(box());
56
 
        int bw = Fl::box_dw(box());
57
 
        int bh = Fl::box_dh(box());
58
 
// Size of SigBar bar...
59
 
        int SigBar; 
60
 
        int PeakPos;
61
 
 
62
 
 
63
 
// Draw the SigBar bar...
64
 
// Draw the box and label...
65
 
        if (horiz == true) {
66
 
                int tx, tw;      // Temporary X + width
67
 
                tx = x() + bx;
68
 
                tw = w() - bw;
69
 
                SigBar = (int)(tw * (value_ - minimum_) / (maximum_ - minimum_) + 0.5f);
70
 
                PeakPos = (int)(tw * (peakv_ - minimum_) / (maximum_ - minimum_) + 0.5f);
71
 
                if (SigBar > 0 ) { //|| PeakPos > 0) {
72
 
 
73
 
                        fl_clip(x(), y(), SigBar + bx, h());
74
 
                        draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
75
 
                        fl_pop_clip();
76
 
 
77
 
                        fl_clip(tx + SigBar, y(), w() - SigBar, h());
78
 
                        draw_box(box(), x(), y(), w(), h(), active_r() ? color2() : fl_inactive(color2()));
79
 
                        fl_pop_clip();
80
 
 
81
 
                        fl_clip(tx + PeakPos, y(), 2, h());
82
 
                        draw_box(box(), x(), y(), w(), h(), pkcolor);
83
 
                        fl_pop_clip();
84
 
 
85
 
                } else
86
 
                        draw_box(box(), x(), y(), w(), h(), color2());
87
 
        } else {
88
 
                int ty, th;      // Temporary Y + height
89
 
                ty = y() + by;
90
 
                th = h() - bh;
91
 
                SigBar = (int)(th * (value_ - minimum_) / (maximum_ - minimum_) + 0.5f);
92
 
                PeakPos = (int)(th * (peakv_ - minimum_) / (maximum_ - minimum_) + 0.5f);
93
 
                if (SigBar > 0 ) { //|| PeakPos > 0) {
94
 
 
95
 
                        fl_clip(x(), y(), w(), SigBar + by);
96
 
                        draw_box(box(), x(), y(), w(), h(), FL_BLACK);
97
 
                        fl_pop_clip();
98
 
                        
99
 
 
100
 
                        fl_clip(x(), ty + SigBar, w(), h() - SigBar);
101
 
                        draw_box(box(), x(), y(), w(), h(), color());
102
 
                        fl_pop_clip();
103
 
                        
104
 
                        fl_clip(x(), ty + PeakPos, w(), 2);
105
 
                        draw_box(box(), x(), y(), w(), h(), pkcolor);
106
 
                        fl_pop_clip();
107
 
 
108
 
                } else
109
 
                        draw_box(box(), x(), y(), w(), h(), color2());
110
 
        }
111
 
}
112
 
 
113
 
 
114
 
//
115
 
// 'Fl_SigBar::Fl_SigBar()' - Construct a Fl_SigBar widget.
116
 
//
117
 
 
118
 
Fl_SigBar::Fl_SigBar(int X, int Y, int W, int H, const char* l)
119
 
: Fl_Widget(X, Y, W, H, l)
120
 
{
121
 
        align(FL_ALIGN_INSIDE);
122
 
        aging_ = 4;
123
 
        peakv_ = 0.0f;
124
 
        value_ = 0.0f;
125
 
        horiz = true;
126
 
        pkcolor = FL_RED;
127
 
        clear();
128
 
        avg_ = aging_ = 5;
129
 
}
130
 
 
131
 
void Fl_SigBar::peak( float v)
132
 
{
133
 
        peakv_ = v;
134
 
 
135
 
        for (int i = 1; i < aging_; i++)
136
 
                if (peakv_ < (peak_[i-1] = peak_[i])) 
137
 
                        peakv_ = peak_[i];
138
 
 
139
 
        peak_[aging_ - 1] = v;
140
 
 
141
 
}
142
 
 
143
 
void Fl_SigBar::value(float v)
144
 
{
145
 
        value_ -= vals_[0];
146
 
 
147
 
        for (int i = 1; i < avg_; i++) vals_[i-1] = vals_[i];
148
 
 
149
 
        value_ += (vals_[avg_- 1] = v / avg_); 
150
 
 
151
 
        peak(value_);
152
 
};
153
 
 
154
 
//
155
 
// End of "$Id: Fl_SigBar.cxx 4288 2005-04-16 00:13:17Z mike $".
156
 
//