Update NTK.
[nondaw.git] / timeline / src / Sequence_Point.C
blobb461f1924672b471ac4e07a7033d26bc668a04ac
2 /*******************************************************************************/
3 /* Copyright (C) 2008 Jonathan Moore Liles                                     */
4 /*                                                                             */
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.                                                  */
9 /*                                                                             */
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   */
13 /* more details.                                                               */
14 /*                                                                             */
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 #include "Sequence_Point.H"
22 #include <FL/fl_draw.H>
26 Sequence_Point::Sequence_Point ( const Sequence_Point &rhs ) : Sequence_Widget( rhs )
28     if ( rhs._label )
29         _label = strdup( rhs._label );
30     else
31         _label = 0;
34 Sequence_Point::Sequence_Point ( )
36     _label = NULL;
38     color( FL_CYAN );
41 Sequence_Point::~Sequence_Point ( )
43     if ( _label )
44         free( _label );
49 void
50 Sequence_Point::get ( Log_Entry &e ) const
52     Sequence_Widget::get( e );
55 void
56 Sequence_Point::set ( Log_Entry &e )
58     Sequence_Widget::set( e );
60     for ( int i = 0; i < e.size(); ++i )
61     {
62         const char *s, *v;
64         e.get( i, &s, &v );
66         if ( ! strcmp( ":start", s ) )
67         {
68             sequence()->sort();
69         }
71     }
74 static void
75 draw_marker ( Fl_Color c )
77     fl_color( c );
79     fl_begin_polygon();
81 #define vv(x,y) fl_vertex( x, y );
83     vv( 0.0, 0.0 );
84     vv( 0.0, 0.6 );
85     vv( 0.5, 1.0 );
86     vv( 1.0, 0.6 );
87     vv( 1.0, 0.0 );
88     vv( 0.0, 0.0 );
90     fl_end_polygon();
92     fl_color( fl_darker( c ) );
94     fl_begin_line();
96     vv( 0.0, 0.0 );
97     vv( 0.0, 0.6 );
98     vv( 0.5, 1.0 );
99     vv( 1.0, 0.6 );
100     vv( 1.0, 0.0 );
101     vv( 0.0, 0.0 );
103     fl_end_line();
106 void
107 Sequence_Point::draw_box ( void )
109     const int X = x() - (abs_w() >> 1);
111     const int Y = y();
113     fl_push_matrix();
114     fl_translate( X, Y );
115     fl_scale( abs_w(), h() );
117     Fl_Color c = selected() ? selection_color() : color();
119     draw_marker( c );
121     fl_pop_matrix();
124 void
125 Sequence_Point::draw ( void )
127 //            Sequence_Widget::draw();
129     draw_label( _label, align() );