4040 */
4141int SVInput::handle (int evt)
4242{
43- // save and close the quicknote editor
44- if (evt == FL_KEYUP && app->quickNoteWindow != 0 )
45- {
46- if (Fl::event_key () == FL_Enter)
47- {
48- // get currently selected list item
49- int curLine = app->hostList ->value ();
50-
51- if (curLine > 0 )
52- {
53- HostItem * itm = static_cast <HostItem *>(app->hostList ->data (curLine));
54-
55- if (itm != NULL )
56- {
57- itm->quickNote = app->quickNoteInput ->value ();
58- app->quickNote ->copy_label (itm->quickNote .c_str ());
59- app->quickNoteInput ->value (" " );
60- app->quickNoteWindow ->hide ();
61- svConfigWrite ();
62- }
63- }
64- }
65- return 1 ;
66- }
67-
6843 static bool inMenu;
6944
7045 // handle child window input controls right-click
@@ -76,6 +51,9 @@ int SVInput::handle (int evt)
7651
7752 inMenu = true ;
7853
54+ // TODO: Make *one* menu display function instead of copying code over and over
55+ // TODO: Pass (this) to it
56+
7957 // create context menu
8058 // text,shortcut,callback,user_data,flags,labeltype,labelfont,labelsize
8159 const Fl_Menu_Item miMain[] = {
@@ -173,6 +151,53 @@ int SVSecretInput::handle (int evt)
173151}
174152
175153
154+ /* handle method for SVQuickNoteInput
155+ * (instance method)
156+ */
157+ int SVQuickNoteInput::handle (int evt)
158+ {
159+ // save and close the quicknote editor
160+ if (evt == FL_KEYUP && app->quickNoteWindow != 0 )
161+ {
162+ if (Fl::event_key () == FL_Enter)
163+ {
164+ // get currently selected list item
165+ int curLine = app->hostList ->value ();
166+
167+ if (curLine > 0 )
168+ {
169+ HostItem * itm = static_cast <HostItem *>(app->hostList ->data (curLine));
170+
171+ if (itm != NULL )
172+ {
173+ // set quickNote text
174+ itm->quickNote = std::string (app->quickNoteInput ->value ()).substr (0 , 256 );
175+
176+ if (itm->quickNote == " " )
177+ {
178+ app->quickNote ->textfont (FL_HELVETICA_ITALIC);
179+ app->quickNote ->value (" (no Quick Note)" );
180+ }
181+ else
182+ {
183+ app->quickNote ->textfont (FL_HELVETICA);
184+ app->quickNote ->value (itm->quickNote .c_str ());
185+ }
186+
187+ // clear the quickNote input and hide the quickNote input window
188+ app->quickNoteInput ->value (" " );
189+ app->quickNoteWindow ->hide ();
190+ svConfigWrite ();
191+ }
192+ }
193+ }
194+ return 1 ;
195+ }
196+
197+ return SVInput::handle (evt); // Fl_Input::handle(evt);
198+ }
199+
200+
176201/* handle method for SVBox
177202 * (instance method)
178203 */
@@ -191,7 +216,7 @@ int SVQuickNoteBox::handle (int evt)
191216
192217 Fl_Group * inputGroup = new Fl_Group (3 , 3 , 100 , 24 );
193218 inputGroup->box (FL_THIN_DOWN_BOX);
194- app->quickNoteInput = new SVInput (0 , 0 , 100 , 24 );
219+ app->quickNoteInput = new SVQuickNoteInput (0 , 0 , 100 , 24 );
195220 inputGroup->end ();
196221
197222 app->quickNoteWindow ->end ();
@@ -215,12 +240,16 @@ int SVQuickNoteBox::handle (int evt)
215240 app->quickNoteInput ->size (app->quickNote ->w (), app->quickNoteWindow ->h ());
216241 app->quickNoteInput ->value (itm->quickNote .c_str ());
217242
243+ // blank quickNote so user isn't confused by background text when editor displays
244+ app->quickNote ->value (" " );
245+
218246 app->quickNoteWindow ->show ();
219247 }
220248 }
221249 }
222250
223- return Fl_Box::handle (evt);
251+ // return Fl_Box::handle(evt);
252+ return Fl_Multiline_Output::handle (evt);
224253}
225254
226255/*
@@ -964,10 +993,13 @@ void svCreateGUI ()
964993
965994 // quicknote - very brief item info
966995 app->quickNote = new SVQuickNoteBox (0 , 22 , 100 , 50 );
967- app->quickNote ->labelsize (app->nAppFontSize );
996+ app->quickNote ->textsize ((app->nAppFontSize + 2 ));
997+ app->quickNote ->textfont (FL_HELVETICA_ITALIC);
968998 app->quickNote ->align (FL_ALIGN_TOP_LEFT | FL_ALIGN_INSIDE);
969999 app->quickNote ->box (FL_THIN_DOWN_BOX);
970- // // app->quickNote->labelfont(1);
1000+ app->quickNote ->wrap (1 );
1001+ app->quickNote ->clear_visible_focus ();
1002+ app->quickNote ->value (" (no Quick Note)" );
9711003
9721004 app->quickNoteGroup ->end ();
9731005
@@ -1475,7 +1507,8 @@ void svHandleHostListEvents (Fl_Widget *, void *)
14751507 {
14761508 // set itm's quicknote text, if any
14771509 app->quickNoteLabel ->label (" " );
1478- app->quickNote ->label (" " );
1510+ app->quickNote ->textfont (FL_HELVETICA_ITALIC);
1511+ app->quickNote ->value (" (no Quick Note)" );
14791512
14801513 return ;
14811514 }
@@ -1486,7 +1519,17 @@ void svHandleHostListEvents (Fl_Widget *, void *)
14861519
14871520 // set itm's quicknote text, if any
14881521 app->quickNoteLabel ->copy_label (itm->name .c_str ());
1489- app->quickNote ->copy_label (itm->quickNote .c_str ());
1522+
1523+ if (itm->quickNote == " " )
1524+ {
1525+ app->quickNote ->textfont (FL_HELVETICA_ITALIC);
1526+ app->quickNote ->value (" (no Quick Note)" );
1527+ }
1528+ else
1529+ {
1530+ app->quickNote ->textfont (FL_HELVETICA);
1531+ app->quickNote ->value (itm->quickNote .c_str ());
1532+ }
14901533
14911534 // *** DO *NOT* CHECK vnc FOR NULL HERE!!! ***
14921535 // *** IT'S OKAY IF vnc IS NULL AT THIS POINT!!! ***
@@ -2039,8 +2082,31 @@ void svHandleQuickNoteWindowEvents (Fl_Widget *, void *)
20392082 // window is closing
20402083 if (event == FL_LEAVE)
20412084 {
2042- app->quickNoteInput ->value (" " );
2043- app->quickNoteWindow ->hide ();
2085+ int nHostItemNum = app->hostList ->value ();
2086+ HostItem * itm = static_cast <HostItem *>(app->hostList ->data (nHostItemNum));
2087+
2088+ if (itm == NULL )
2089+ {
2090+ // set itm's quicknote text, if any
2091+ app->quickNoteLabel ->label (" " );
2092+ app->quickNote ->textfont (FL_HELVETICA_ITALIC);
2093+ app->quickNote ->value (" (no Quick Note)" );
2094+ }
2095+ else
2096+ {
2097+ app->quickNoteInput ->value (" " );
2098+ if (itm->quickNote == " " )
2099+ {
2100+ app->quickNote ->textfont (FL_HELVETICA_ITALIC);
2101+ app->quickNote ->value (" (no Quick Note)" );
2102+ }
2103+ else
2104+ {
2105+ app->quickNote ->textfont (FL_HELVETICA);
2106+ app->quickNote ->value (itm->quickNote .c_str ());
2107+ }
2108+ app->quickNoteWindow ->hide ();
2109+ }
20442110 }
20452111}
20462112
0 commit comments