Add new Fl_Flip_Button class.

This commit is contained in:
Jonathan Moore Liles 2008-03-12 15:13:47 -05:00
parent da12ff957c
commit 90a45ba11c
2 changed files with 82 additions and 8 deletions

66
Fl_Flip_Button.H Normal file
View File

@ -0,0 +1,66 @@
/*******************************************************************************/
/* Copyright (C) 2008 Jonathan Moore Liles */
/* */
/* This program is free software; you can redistribute it and/or modify it */
/* under the terms of the GNU General Public License as published by the */
/* Free Software Foundation; either version 2 of the License, or (at your */
/* option) any later version. */
/* */
/* 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; see the file COPYING. If not,write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
/* Simple extension of Fl_Button to support different lables for the
* two button states. Simpler than using a an Fl_Choice when all you
* need is two states. Set the label to "foo/bar" for "foo" to be the
* off label and "bar" the on. Obviously you should make sure that
* each label will fit. */
#include <FL/Fl_Button.H>
#include <stdlib.h>
#include <stdio.h>
class Fl_Flip_Button : public Fl_Button
{
char *_off;
char *_on;
public:
Fl_Flip_Button ( int X, int Y, int W, int H, const char *L = 0 ) :
Fl_Button( X, Y, W, H, 0 )
{
sscanf( L, "%a[^/]/%as", &_off, &_on );
type( FL_TOGGLE_BUTTON );
}
virtual ~Fl_Flip_Button ( ) { }
protected:
virtual void
draw ( void )
{
if ( value() )
{
if ( label() != _on )
label( _on );
}
else
if ( label() != _off )
label( _off );
draw_box( box(), x(), y(), w(), h(), value() ? selection_color() : color() );
draw_label();
}
};

View File

@ -8,6 +8,9 @@ decl {\#include "DPM.H"} {public global
decl {\#include "Fl_Scalepack.H"} {public global decl {\#include "Fl_Scalepack.H"} {public global
} }
decl {\#include "Fl_Flip_Button.H"} {public global
}
widget_class Mixer_Strip {open widget_class Mixer_Strip {open
xywh {1051 42 124 816} type Double box UP_FRAME color 32 selection_color 63 resizable xywh {1051 42 124 816} type Double box UP_FRAME color 32 selection_color 63 resizable
code0 {size( 120, h() );} visible code0 {size( 120, h() );} visible
@ -36,37 +39,42 @@ widget_class Mixer_Strip {open
private xywh {82 143 35 25} type Toggle private xywh {82 143 35 25} type Toggle
} }
} }
Fl_Button {} {
label {output/input} selected
xywh {52 182 59 25} type Toggle box ROUNDED_BOX color 106 selection_color 65 align 64
class Fl_Flip_Button
}
Fl_Group {} {open Fl_Group {} {open
xywh {13 178 104 509} resizable xywh {8 208 103 471} resizable
} { } {
Fl_Value_Slider gain { Fl_Value_Slider gain {
label Gain label Gain
callback {// parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );} callback {// parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );}
xywh {14 195 33 471} type {Vert Knob} color 32 selection_color 1 minimum 1.5 maximum 0 step 0.01 value 1 textsize 14 xywh {9 208 33 448} type {Vert Knob} color 32 selection_color 1 minimum 1.5 maximum 0 step 0.01 value 1 textsize 14
} }
Fl_Pack meters_pack { Fl_Pack meters_pack {
label meters open selected label meters open
xywh {57 189 59 490} type HORIZONTAL xywh {52 208 59 471} type HORIZONTAL labeltype NO_LABEL align 0
class Fl_Scalepack class Fl_Scalepack
} { } {
Fl_Box meter { Fl_Box meter {
label DPM label DPM
xywh {57 193 28 484} box ROUNDED_BOX selection_color 88 xywh {52 208 28 459} box ROUNDED_BOX selection_color 88
class DPM class DPM
} }
Fl_Box {} { Fl_Box {} {
label DPM label DPM
xywh {86 193 30 484} box ROUNDED_BOX selection_color 88 xywh {81 208 30 459} box ROUNDED_BOX selection_color 88
class DPM class DPM
} }
Fl_Box {} { Fl_Box {} {
label DPM label DPM
xywh {96 203 20 476} box ROUNDED_BOX selection_color 88 xywh {91 208 20 461} box ROUNDED_BOX selection_color 88
class DPM class DPM
} }
Fl_Box {} { Fl_Box {} {
label DPM label DPM
xywh {106 213 20 476} box ROUNDED_BOX selection_color 88 xywh {101 208 10 471} box ROUNDED_BOX selection_color 88
class DPM class DPM
} }
} }