2 /*******************************************************************************/
3 /* Copyright (C) 2007-2008 Jonathan Moore Liles */
5 /* This program is free software; you can redistribute it and/or modify it */
6 /* under the terms of the GNU General Public License as published by the */
7 /* Free Software Foundation; either version 2 of the License, or (at your */
8 /* option) any later version. */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
12 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
15 /* You should have received a copy of the GNU General Public License along */
16 /* with This program; see the file COPYING. If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /*******************************************************************************/
20 /* This file contains ALL platform specific drawing code required by the canvas */
25 #include "../common.h"
29 #include "../canvas.H"
33 unsigned char r, g, b;
36 struct color_table color_defs[] = {
37 { EMPTY, 18, 18, 18 },
40 { CONTINUED, 80, 80, 80 },
42 { HIT, 255, 255, 255 },
43 { PLAYHEAD, 10, 69, 10 },
44 { SELECTED, 255, 10, 255 },
47 Fl_Color *state_colors;
49 Fl_Color velocity_colors[128];
50 Fl_Color velocity2_colors[128];
52 bool draw_borders = 1;
62 velocity_colors[i] = fl_color_average( FL_GRAY, fl_rgb_color( i * 2, 255 - i * 2, 32 ), 0.4 );
63 velocity2_colors[i] = fl_color_average( FL_WHITE, velocity_colors[i], 0.5 );
66 state_colors = (Fl_Color*)malloc(sizeof( Fl_Color ) * MAX_STATE );
68 for ( i = elementsof( color_defs ); i--; )
70 state_colors[ color_defs[i].state ] = fl_rgb_color( color_defs[i].r,
77 gui_draw_ruler ( int x, int y, int w, int div_w, int div, int ofs, int p1, int p2 )
81 fl_font( FL_TIMES, ruler_height );
85 fl_color( canvas_background_color );
87 // fl_rectf( x, y, x + (div_w * w), y + h );
88 fl_rectf( x, y, (div_w * w), h );
92 fl_line( x + div_w / 2, y, x + div_w * w, y );
97 for ( i = 0; i < w; i++ )
100 int nx = x + (i * div_w) + (div_w / 2);
104 fl_line( nx, y, nx, y + h );
107 sprintf( pat, "%i", 1 + (k / z ));
109 fl_color( FL_WHITE );
110 fl_draw( pat, nx + div_w / 2, y + h + 1 / 2 );
118 fl_color( FL_GREEN );
122 fl_rectf( x + (div_w * p1), y + h / 2, div_w, h / 2 );
128 fl_color( FL_GREEN );
131 fl_rectf( x + (div_w * p2), y + h / 2, div_w, h / 2 );
140 gui_clear_area ( int x, int y, int w, int h )
142 fl_color( canvas_background_color );
144 fl_rectf( x, y, w, h );
148 gui_draw_string ( int x, int y, int w, int h, int color, const char *s, bool draw )
155 fl_font( FL_COURIER, min( h, 18 ) );
159 if ( fl_not_clipped( x, y, rw, h ) && draw )
161 gui_clear_area( x, y, w, h );
164 fl_color( velocity_colors[ color ] );
166 fl_color( FL_DARK_CYAN );
168 fl_draw( s, x, y + h / 2 + fl_descent() );
175 gui_draw_shape ( int x, int y, int w, int h, int shape, int state, int flags, int color )
177 /* take advantage of FLTK's clipping */
178 if ( ! fl_not_clipped( x, y, w, h ) )
181 if ( flags & F_PLAYHEAD )
183 state = state == FULL ? HIT : PLAYHEAD;
184 flags &= ~ F_SELECTION;
189 if ( state == FULL && color )
191 c1 = velocity_colors[ color ];
192 c2 = velocity2_colors[ color ];
196 c1 = state_colors[ state ];
197 c2 = fl_color_average( FL_WHITE, c1, 0.1 );
200 if ( flags & F_SELECTION )
201 fl_color( fl_darker( fl_color() ) );
208 // fl_rectf( x, y, w, h, FL_BLACK );
211 fl_rectf( x + bw, y + bw, w - bw * 2, h - bw * 2 );
215 fl_line_style( FL_SOLID, 2 );
216 fl_rect( x + bw + 1, y + bw + 1, w - (bw+1) * 2, h - (bw+1) * 2 );
217 fl_line_style( FL_SOLID, 0 );
221 fl_draw_box( FL_THIN_UP_BOX, x + bw, y + bw, w - bw * 2, h - bw * 2, c1 );
224 ASSERTION( "unknown shape" );
228 if ( flags & F_P1 || flags & F_P2 )
231 fl_color( FL_GREEN );
238 fl_rectf( x + (w / 2) - (rw / 2), y + (h / 2) - (rh / 2), rw, rh );
246 clear_status ( void * )
248 ui->status->label( NULL );
251 /** inform the user of something via a status bar */
253 gui_status ( const char *fmt, ... )
257 static char pat[256];
261 va_start( args, fmt );
262 vsnprintf( pat, 256, fmt, args );
266 ui->status->label( pat );
268 Fl::add_timeout( 5.0f, clear_status );