diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2003-05-21 16:12:14 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2003-05-21 16:12:14 +0000 |
| commit | ba892d265222409f0887b9cb92923c501b48decd (patch) | |
| tree | 032e0ba3d8ceca83af23f4ccb8d01b53aca0cbf7 /src | |
| parent | 2549a4ad6285fe28341979b0a64f289feaedb531 (diff) | |
Add find() method to help widget and search box to help dialog.
Default to blue for the selection color on OSX; otherwise links and
other visual elements are not the correct color.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2993 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Help_Dialog.cxx | 24 | ||||
| -rw-r--r-- | src/Fl_Help_Dialog.fl | 22 | ||||
| -rw-r--r-- | src/Fl_Help_View.cxx | 66 | ||||
| -rw-r--r-- | src/Fl_get_system_colors.cxx | 6 |
4 files changed, 99 insertions, 19 deletions
diff --git a/src/Fl_Help_Dialog.cxx b/src/Fl_Help_Dialog.cxx index 9cbb757ff..eab956c1b 100644 --- a/src/Fl_Help_Dialog.cxx +++ b/src/Fl_Help_Dialog.cxx @@ -106,6 +106,13 @@ void Fl_Help_Dialog::cb_larger_(Fl_Button* o, void* v) { ((Fl_Help_Dialog*)(o->parent()->user_data()))->cb_larger__i(o,v); } +inline void Fl_Help_Dialog::cb_find__i(Fl_Input*, void*) { + find_pos_ = view_->find(find_->value(), find_pos_); +} +void Fl_Help_Dialog::cb_find_(Fl_Input* o, void* v) { + ((Fl_Help_Dialog*)(o->parent()->user_data()))->cb_find__i(o,v); +} + Fl_Help_Dialog::Fl_Help_Dialog() { Fl_Double_Window* w; { Fl_Double_Window* o = window_ = new Fl_Double_Window(530, 385, "Help Dialog"); @@ -129,37 +136,42 @@ Fl_Help_Dialog::Fl_Help_Dialog() { o->callback((Fl_Callback*)cb_Close); o->label(fl_close); } - { Fl_Button* o = back_ = new Fl_Button(365, 350, 25, 25, "@<-"); + { Fl_Button* o = back_ = new Fl_Button(355, 350, 25, 25, "@<-"); o->tooltip("Show the previous help page."); o->shortcut(0xff51); o->labelcolor(2); o->callback((Fl_Callback*)cb_back_); } - { Fl_Button* o = forward_ = new Fl_Button(395, 350, 25, 25, "@->"); + { Fl_Button* o = forward_ = new Fl_Button(390, 350, 25, 25, "@->"); o->tooltip("Show the next help page."); o->shortcut(0xff53); o->labelcolor(2); o->callback((Fl_Callback*)cb_forward_); } - { Fl_Button* o = smaller_ = new Fl_Button(305, 350, 25, 25, "F"); + { Fl_Button* o = smaller_ = new Fl_Button(285, 350, 25, 25, "F"); o->tooltip("Make the help text smaller."); o->labelfont(1); o->labelsize(10); o->callback((Fl_Callback*)cb_smaller_); } - { Fl_Button* o = larger_ = new Fl_Button(335, 350, 25, 25, "F"); + { Fl_Button* o = larger_ = new Fl_Button(320, 350, 25, 25, "F"); o->tooltip("Make the help text larger."); o->labelfont(1); o->labelsize(16); o->callback((Fl_Callback*)cb_larger_); } + { Fl_Input* o = find_ = new Fl_Input(10, 350, 265, 25); + o->callback((Fl_Callback*)cb_find_); + o->when(FL_WHEN_ENTER_KEY_ALWAYS); + } o->end(); } back_->deactivate(); forward_->deactivate(); -index_ = -1; -max_ = 0; +index_ = -1; +max_ = 0; +find_pos_ = 0; fl_register_images(); } diff --git a/src/Fl_Help_Dialog.fl b/src/Fl_Help_Dialog.fl index 982df46e9..dff63a7f9 100644 --- a/src/Fl_Help_Dialog.fl +++ b/src/Fl_Help_Dialog.fl @@ -12,11 +12,12 @@ class FL_EXPORT Fl_Help_Dialog {open decl {int max_;} {} decl {int line_[100];} {} decl {char file_[100][256];} {} + decl {int find_pos_;} {} Function {Fl_Help_Dialog()} {open } { Fl_Window window_ { label {Help Dialog} open - private xywh {470 380 530 385} type Double resizable visible + private xywh {398 65 530 385} type Double resizable visible } { Fl_Group view_ { callback {if (view_->changed()) @@ -47,7 +48,7 @@ else if (view_->filename()) { strlcpy(file_[index_], view_->filename(), sizeof(file_[0])); line_[index_] = view_->topline(); -}} open selected +}} open private xywh {10 10 510 330} box DOWN_BOX selection_color 15 resizable code0 {\#include <FL/Fl_Help_View.H>} class Fl_Help_View @@ -72,7 +73,7 @@ if (strcmp(view_->filename(), file_[index_]) != 0) view_->load(file_[index_]); view_->topline(line_[index_]);} - private tooltip {Show the previous help page.} xywh {365 350 25 25} shortcut 0xff51 labelcolor 2 + private tooltip {Show the previous help page.} xywh {355 350 25 25} shortcut 0xff51 labelcolor 2 } Fl_Button forward_ { label {@->} @@ -88,7 +89,7 @@ if (strcmp(view_->filename(), file_[index_]) != 0) view_->load(file_[index_]); view_->topline(line_[index_]);} - private tooltip {Show the next help page.} xywh {395 350 25 25} shortcut 0xff53 labelcolor 2 + private tooltip {Show the next help page.} xywh {390 350 25 25} shortcut 0xff53 labelcolor 2 } Fl_Button smaller_ { label F @@ -98,7 +99,7 @@ view_->topline(line_[index_]);} if (view_->textsize() <= 8) smaller_->deactivate(); larger_->activate();} - private tooltip {Make the help text smaller.} xywh {305 350 25 25} labelfont 1 labelsize 10 + private tooltip {Make the help text smaller.} xywh {285 350 25 25} labelfont 1 labelsize 10 } Fl_Button larger_ { label F @@ -108,14 +109,19 @@ larger_->activate();} if (view_->textsize() >= 18) larger_->deactivate(); smaller_->activate();} - private tooltip {Make the help text larger.} xywh {335 350 25 25} labelfont 1 labelsize 16 + private tooltip {Make the help text larger.} xywh {320 350 25 25} labelfont 1 labelsize 16 + } + Fl_Input find_ { + callback {find_pos_ = view_->find(find_->value(), find_pos_);} selected + private xywh {10 350 265 25} when 10 } } code {back_->deactivate(); forward_->deactivate(); -index_ = -1; -max_ = 0; +index_ = -1; +max_ = 0; +find_pos_ = 0; fl_register_images();} {} } diff --git a/src/Fl_Help_View.cxx b/src/Fl_Help_View.cxx index e9d338b63..58c177fcb 100644 --- a/src/Fl_Help_View.cxx +++ b/src/Fl_Help_View.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Help_View.cxx,v 1.1.2.46 2003/01/30 21:41:54 easysw Exp $" +// "$Id: Fl_Help_View.cxx,v 1.1.2.47 2003/05/21 16:12:14 easysw Exp $" // // Fl_Help_View widget routines. // @@ -767,6 +767,68 @@ Fl_Help_View::draw() // +// 'Fl_Help_View::find()' - Find the specified string... +// + +int // O - Matching position or -1 if not found +Fl_Help_View::find(const char *s, // I - String to find + int p) // I - Starting position +{ + int i, // Looping var + c; // Current character + Fl_Help_Block *b; // Current block + const char *bp, // Block matching pointer + *bs, // Start of current comparison + *sp; // Search string pointer + + + // Range check input... + if (!s) return -1; + + if (p < 0 || p >= (int)strlen(value_)) p = 0; + else if (p > 0) p ++; + + // Look for the string... + for (i = nblocks_, b = blocks_; i > 0; i --, b ++) { + if (b->end < (value_ + p)) + continue; + + if (b->start < (value_ + p)) bp = value_ + p; + else bp = b->start; + + for (sp = s, bs = bp; *sp && *bp && bp < b->end; bp ++) { + if (*bp == '<') { + // skip to end of element... + while (*bp && bp < b->end && *bp != '>') bp ++; + continue; + } else if (*bp == '&') { + // decode HTML entity... + if ((c = quote_char(bp + 1)) < 0) c = '&'; + else bp = strchr(bp + 1, ';') + 1; + } else c = *bp; + + if (tolower(*sp) == tolower(c)) sp ++; + else { + // No match, so reset to start of search... + sp = s; + bs ++; + bp = bs; + } + } + + if (!*sp) { + // Found a match! + topline(b->y - b->h); + return (b->end - value_); + } + } + + // No match! + return (-1); +} + + +// // 'Fl_Help_View::format()' - Format the help text. // @@ -2731,5 +2793,5 @@ hscrollbar_callback(Fl_Widget *s, void *) // -// End of "$Id: Fl_Help_View.cxx,v 1.1.2.46 2003/01/30 21:41:54 easysw Exp $". +// End of "$Id: Fl_Help_View.cxx,v 1.1.2.47 2003/05/21 16:12:14 easysw Exp $". // diff --git a/src/Fl_get_system_colors.cxx b/src/Fl_get_system_colors.cxx index 180d42cf7..43d998aee 100644 --- a/src/Fl_get_system_colors.cxx +++ b/src/Fl_get_system_colors.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.19 2003/05/18 22:12:21 easysw Exp $" +// "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.20 2003/05/21 16:12:14 easysw Exp $" // // System color support for the Fast Light Tool Kit (FLTK). // @@ -150,7 +150,7 @@ void Fl::get_system_colors() foreground(0, 0, 0); background(0xd8, 0xd8, 0xd8); background2(0xff, 0xff, 0xff); - set_selection_color(0x80, 0x80, 0x80); + set_selection_color(0x00, 0x00, 0x80); } #else @@ -320,5 +320,5 @@ int Fl::reload_scheme() { // -// End of "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.19 2003/05/18 22:12:21 easysw Exp $". +// End of "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.20 2003/05/21 16:12:14 easysw Exp $". // |
