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"
20 a_annot = new annot_color;
22 a_annot->color = (Fl_Color) 5;
23 //cout << "type: " << a_annot->type << endl;
30 cb_annot_color(Fl_Button* o, void* v)
32 annot_instance * blah = (annot_instance *) v;
33 AnnotWindow* T= blah->mw_ptr;
34 T->cb_annot_color_i(o,blah->index);
37 AnnotWindow::AnnotWindow(int w, int h, const char* title,
38 vector<annot_color> * some_annots):Fl_Window(w,h,title)
42 the_annots = some_annots;
45 annot_color_buttons.clear();
48 annot_input_pack = new Fl_Pack(0, 0, w, h);
49 annot_input_pack->spacing(4);
51 // button to add new annot inputs
52 add_annot = new Fl_Button(0,0,100,24,"Add Annot Slot");
53 add_annot->callback((Fl_Callback*)add_annot_cb, this);
54 annot_input_pack->add(add_annot);
55 // test button to make sure annot data is being stored
56 test = new Fl_Button(0,0,100,24,"show annots");
57 test->callback((Fl_Callback*)print_cb, this);
58 annot_input_pack->add(test);
60 // creat an initial set of annot input widgets and attach to annot vector
61 annot_num = some_annots->size();
62 for (i = 0; i < annot_num; i++)
68 add(annot_input_pack);
75 //tmp_input->user_data((void*) i);
77 AnnotWindow::~AnnotWindow(){}
80 AnnotWindow::add_annot_input(int index)
82 Fl_Output * new_input;
83 Fl_Button *new_color_button;
84 annot_instance * something;
85 Fl_Pack * annot_hor_pack;
88 something = new annot_instance;
89 something->mw_ptr = this;
90 something->index = index;
92 annot_hor_pack = new Fl_Pack(0, 0, w(), 24);
93 annot_hor_pack->type(Fl_Pack::HORIZONTAL);
94 annot_hor_pack->spacing(4);
96 // setup the color display/selection button
97 new_color_button = new Fl_Button(0, 0, 24, 24, "");
98 new_color_button->color((*the_annots)[index].color);
99 new_color_button->box(FL_FLAT_BOX);
100 new_color_button->callback((Fl_Callback*)cb_annot_color, (void*) something);
101 annot_color_buttons.push_back(new_color_button);
102 annot_hor_pack->add(new_color_button);
105 // setup the annot inputs
106 new_input = new Fl_Output(0, 0, 200, 24, "");
107 new_input->value( ((*the_annots)[index].type).c_str() );
108 //new_input->callback((Fl_Callback*)cb_annot_in, (void*) something);
109 annot_ins.push_back(new_input);
110 annot_hor_pack->add(new_input);
112 annot_input_pack->add(annot_hor_pack);
122 AnnotWindow::cb_annot_in_i(Fl_Input* o, int i)
124 (*the_annots)[i].type = o->value();
128 AnnotWindow::cb_annot_color_i(Fl_Button* o, int i)
130 //Fl_Color new_color;
132 (*the_annots)[i].color = fl_show_colormap((*the_annots)[i].color);
133 //annot_color_buttons[i]->
134 o->color((*the_annots)[i].color);
138 void AnnotWindow::add_annot_cb(Fl_Button* o, void* v)
140 AnnotWindow* T=(AnnotWindow*)v;
141 T->add_annot_cb_real(o,v);
145 void AnnotWindow::add_annot_cb_real(Fl_Button* , void*)
147 annot_color blank_annot;
149 //blank_annot.name = "";
150 //blank_annot.seq = "";
151 blank_annot = new_blank_annot();
152 (*the_annots).push_back(blank_annot);
153 add_annot_input(annot_count++);
158 void AnnotWindow::print_cb(Fl_Button* o, void* v)
160 AnnotWindow* T=(AnnotWindow*)v;
161 T->print_cb_real(o,v);
165 void AnnotWindow::print_cb_real(Fl_Button* , void*)
169 for (i = 0; i < annot_count; i++)
170 cout << (*the_annots)[i].type << endl;
175 cb_annot_in(Fl_Input* o, void* v)
177 annot_instance * blah = (annot_instance *) v;
178 AnnotWindow* T= blah->mw_ptr;
179 T->cb_annot_in_i(o,blah->index);