1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
//------------------------------------------------------------------------
// Web (Highlight) button
//------------------------------------------------------------------------
//
// EdTile (C) 2001-2002 Andrew Apted
//
// 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.
//
//------------------------------------------------------------------------
using namespace std;
#include "z_config.h"
#include "FL/Fl_Window.H"
#include "FL/fl_draw.H"
#include "w_webbut.h"
#include "w_color.h"
#include "w_main.h"
WebButton::WebButton(int X, int Y, int W, int H, const char *label) :
Fl_Widget(X, Y, W, H, label),
value_(0), high_(0)
{
box(FL_FLAT_BOX);
color(FL_WHITE);
labelcolor(FL_BLACK);
}
WebButton::~WebButton()
{
// nothing needed
}
void WebButton::value(int new_v)
{
if (value_ != new_v)
{
value_ = new_v;
redraw();
}
}
void WebButton::draw()
{
labelcolor(value_ ? FL_RED : FL_BLACK);
draw_box(box(), color());
draw_label();
if (Fl::focus() == this)
draw_focus();
}
int WebButton::handle(int event)
{
/* put here to work, but very hackish */
if (high_ && !value_)
MainWin::appwin->ChangeCursor(FL_CURSOR_HAND);
switch (event)
{
case FL_ENTER:
high_ = 1;
redraw();
return 1;
case FL_LEAVE:
MainWin::appwin->ChangeCursor(FL_CURSOR_DEFAULT);
high_ = 0;
redraw();
return 1;
case FL_FOCUS:
case FL_UNFOCUS:
if (Fl::visible_focus())
{
redraw();
return 1;
}
return 0;
case FL_PUSH:
if (! value_)
{
// value_ = 1;
// redraw();
do_callback();
}
return 1;
case FL_DRAG:
case FL_RELEASE:
// these are currently ignored.
return 1;
default:
break;
}
return 0;
}
|