Blame view

Giac_maj/giac-1.4.9/src/Flve_Check_Button.cc 1.68 KB
6663b6c9   adorian   projet complet av...
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
  //	======================================================================
  //	File:    Flve_Input.cxx - Flve_Input implementation
  //	Library: flvw - FLTK Virtual widget library
  //	Version: 0.1.0
  //	Started: 01/12/2000
  //
  //	Copyright (C) 1999 Laurence Charlton
  //
  //	Description:
  //	Flve_Input implements cell text editing for a list/table.
  //	======================================================================
  
  #ifdef HAVE_CONFIG_H
  #include "config.h"
  #endif
  #ifndef IN_GIAC
  #include <giac/first.h>
  #else
  #include "first.h"
  #endif
  #ifdef HAVE_LIBFLTK
  
  #include <FL/Fl.H>
  #include "Flve_Check_Button.H"
  #include <FL/fl_draw.H>
  
  int Flve_Check_Button::handle(int event)
  {
  	int stat;
  
  	stat = Fl_Check_Button::handle(event);
  	if (!stat)
  	{
  		switch( event )
  		{
  			case FL_FOCUS:
  			case FL_UNFOCUS:
  				return 1;
  
  			case FL_KEYBOARD:
  				switch(Fl::event_key())
  				{
  					case ' ':
  						value( !value() );
  						redraw();
  						return 1;
  				}
  				break;
  		}
  
  		if (owner && event==FL_KEYBOARD)
  			if ( owner->handle(FL_SHORTCUT) )
  				return 1;
  	}
  	return stat;
  }
  
  void draw_flve_check_button( int X, int Y, int W, int H, Flve_Check_Button *b, char *v )
  {
  	int x, y,  w, h;
  	w = W;
  	h = H;
  	if (H<W)
  		w = h;
  	else
  		h = w;
  	x = X;	// + (W-w)/2;
  	y = Y;	// + (H-h)/2;
  	x++;
  	y++;
  	w-=2;
  	h-=2;
  	fl_color( b?b->color():(Fl_Color)(FL_GRAY_RAMP+17) );
  	fl_rectf( X, Y, W, H );
  	if (b)
  	{
  		if (*v=='1')
  			fl_draw_box( b->down_box(), x, y, w, h, b->selection_color() );
  		else
  			fl_draw_box( b->down_box(), x, y, w, h, b->color() );
  	} else
  	{
  		if (*v=='1')
  			fl_draw_box( FL_THIN_DOWN_BOX, x, y, w, h, FL_RED );
  		else
  			fl_draw_box( FL_THIN_DOWN_BOX, x, y, w, h, (Fl_Color)(FL_GRAY_RAMP+17) );
  	}
  }
  
  
  #endif