1 // This file is part of the Mussa source distribution.
2 // http://mussa.caltech.edu/
3 // Contact author: Tristan De Buysscher, tristan@caltech.edu
5 // This program and all associated source code files are Copyright (C) 2005
6 // the California Institute of Technology, Pasadena, CA, 91125 USA. It is
7 // under the GNU Public License; please see the included LICENSE.txt
8 // file for more information, or contact Tristan directly.
11 #include "mussa_gui_annot_window.hh"
13 #include <FL/fl_show_colormap.H>
22 a_annot = new annot_color;
24 a_annot->color = (Fl_Color) 5;
25 //cout << "type: " << a_annot->type << endl;
32 cb_annot_color(Fl_Button* o, void* v)
34 annot_instance * blah = (annot_instance *) v;
35 AnnotWindow* T= blah->mw_ptr;
36 T->cb_annot_color_i(o,blah->index);
39 AnnotWindow::AnnotWindow(int w, int h, const char* title,
40 vector<annot_color> * some_annots):Fl_Window(w,h,title)
44 the_annots = some_annots;
47 annot_color_buttons.clear();
50 annot_input_pack = new Fl_Pack(0, 0, w, h);
51 annot_input_pack->spacing(4);
53 // button to add new annot inputs
54 add_annot = new Fl_Button(0,0,100,24,"Add Annot Slot");
55 add_annot->callback((Fl_Callback*)add_annot_cb, this);
56 annot_input_pack->add(add_annot);
57 // test button to make sure annot data is being stored
58 test = new Fl_Button(0,0,100,24,"show annots");
59 test->callback((Fl_Callback*)print_cb, this);
60 annot_input_pack->add(test);
62 // creat an initial set of annot input widgets and attach to annot vector
63 annot_num = some_annots->size();
64 for (i = 0; i < annot_num; i++)
70 add(annot_input_pack);
77 //tmp_input->user_data((void*) i);
79 AnnotWindow::~AnnotWindow(){}
82 AnnotWindow::add_annot_input(int index)
84 Fl_Output * new_input;
85 Fl_Button *new_color_button;
86 annot_instance * something;
87 Fl_Pack * annot_hor_pack;
90 something = new annot_instance;
91 something->mw_ptr = this;
92 something->index = index;
94 annot_hor_pack = new Fl_Pack(0, 0, w(), 24);
95 annot_hor_pack->type(Fl_Pack::HORIZONTAL);
96 annot_hor_pack->spacing(4);
98 // setup the color display/selection button
99 new_color_button = new Fl_Button(0, 0, 24, 24, "");
100 new_color_button->color((*the_annots)[index].color);
101 new_color_button->box(FL_FLAT_BOX);
102 new_color_button->callback((Fl_Callback*)cb_annot_color, (void*) something);
103 annot_color_buttons.push_back(new_color_button);
104 annot_hor_pack->add(new_color_button);
107 // setup the annot inputs
108 new_input = new Fl_Output(0, 0, 200, 24, "");
109 new_input->value( ((*the_annots)[index].type).c_str() );
110 //new_input->callback((Fl_Callback*)cb_annot_in, (void*) something);
111 annot_ins.push_back(new_input);
112 annot_hor_pack->add(new_input);
114 annot_input_pack->add(annot_hor_pack);
124 AnnotWindow::cb_annot_in_i(Fl_Input* o, int i)
126 (*the_annots)[i].type = o->value();
130 AnnotWindow::cb_annot_color_i(Fl_Button* o, int i)
132 //Fl_Color new_color;
134 (*the_annots)[i].color = fl_show_colormap((*the_annots)[i].color);
135 //annot_color_buttons[i]->
136 o->color((*the_annots)[i].color);
140 void AnnotWindow::add_annot_cb(Fl_Button* o, void* v)
142 AnnotWindow* T=(AnnotWindow*)v;
143 T->add_annot_cb_real(o,v);
147 void AnnotWindow::add_annot_cb_real(Fl_Button* , void*)
149 annot_color blank_annot;
151 //blank_annot.name = "";
152 //blank_annot.seq = "";
153 blank_annot = new_blank_annot();
154 (*the_annots).push_back(blank_annot);
155 add_annot_input(annot_count++);
160 void AnnotWindow::print_cb(Fl_Button* o, void* v)
162 AnnotWindow* T=(AnnotWindow*)v;
163 T->print_cb_real(o,v);
167 void AnnotWindow::print_cb_real(Fl_Button* , void*)
171 for (i = 0; i < annot_count; i++)
172 cout << (*the_annots)[i].type << endl;
177 cb_annot_in(Fl_Input* o, void* v)
179 annot_instance * blah = (annot_instance *) v;
180 AnnotWindow* T= blah->mw_ptr;
181 T->cb_annot_in_i(o,blah->index);