diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2010-10-31 22:39:40 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2010-10-31 22:39:40 +0000 |
| commit | 5560a4f0f1f5b4799a8c5162212e7ec22c601ae5 (patch) | |
| tree | 42be986576fa49dabfe7ba33af6eeb893c3ebff5 /src | |
| parent | 1e26ada2c5be6bf9ca45884bebc0228319c3c226 (diff) | |
Fixed a few pedantic warnings. Added Fl::option as discussed in STR #2368, but I am not too happy with it yet. Please see discussion in that STR.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7789 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl.cxx | 32 | ||||
| -rw-r--r-- | src/Fl_Input.cxx | 16 | ||||
| -rw-r--r-- | src/Fl_Menu_add.cxx | 50 | ||||
| -rw-r--r-- | src/Fl_cocoa.mm | 2 |
4 files changed, 88 insertions, 12 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx index 9ebf023f6..b855f487f 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -85,6 +85,10 @@ int Fl::e_length; int Fl::visible_focus_ = 1, Fl::dnd_text_ops_ = 1; +unsigned char Fl::options_[] = { 0, 0 }; +unsigned char Fl::options_read_ = 0; + + Fl_Window *fl_xfocus; // which window X thinks has focus Fl_Window *fl_xmousewin;// which window X thinks has FL_ENTER Fl_Window *Fl::grab_; // most recent Fl::grab() @@ -1734,6 +1738,33 @@ void Fl::clear_widget_pointer(Fl_Widget const *w) } } + +bool Fl::option(Fl_Option o) +{ + if (!options_read_) { + int tmp; + { // first, read the system wide preferences + Fl_Preferences prefs(Fl_Preferences::SYSTEM, "fltk.org", "fltk"); + Fl_Preferences opt(prefs, "options"); + prefs.get("ArrowFocus", tmp, 0); options_[OPTION_ARROW_FOCUS] = tmp; + prefs.get("NativeFilechooser", tmp, 0); options_[OPTION_NATIVE_FILECHOOSER] = tmp; + } + { // next, check the user preferences + Fl_Preferences prefs(Fl_Preferences::USER, "fltk.org", "fltk"); + Fl_Preferences opt(prefs, "options"); + prefs.get("ArrowFocus", tmp, 0); options_[OPTION_ARROW_FOCUS] = tmp; + prefs.get("NativeFilechooser", tmp, 0); options_[OPTION_NATIVE_FILECHOOSER] = tmp; + } + { // now, if the developer has registered this app, we could as for per-application preferences + } + options_read_ = 1; + } + if (o<0 || o>=OPTION_LAST) + return false; + return (bool)options_[o]; +} + + // Helper class Fl_Widget_Tracker /** @@ -1753,6 +1784,7 @@ Fl_Widget_Tracker::~Fl_Widget_Tracker() { Fl::release_widget_pointer(wp_); // remove pointer from watch list } + // // End of "$Id$". // diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx index 9277c37e2..9006411bc 100644 --- a/src/Fl_Input.cxx +++ b/src/Fl_Input.cxx @@ -382,7 +382,8 @@ int Fl_Input::handle_key() { case ctrl('A'): // go to the beginning of the current line return shift_position(line_start(position())) + NORMAL_INPUT_MOVE; case ctrl('B'): // go one character backward - return shift_position(position()-1) + NORMAL_INPUT_MOVE; + i = shift_position(position()-1) + NORMAL_INPUT_MOVE; + return Fl::option(Fl::OPTION_ARROW_FOCUS) ? i : 1; case ctrl('C'): // copy return copy(1); case ctrl('D'): // cut the next character @@ -396,7 +397,8 @@ int Fl_Input::handle_key() { case ctrl('E'): // go to the end of the line return shift_position(line_end(position())) + NORMAL_INPUT_MOVE; case ctrl('F'): // go to the next character - return shift_position(position()+1) + NORMAL_INPUT_MOVE; + i = shift_position(position()+1) + NORMAL_INPUT_MOVE; + return Fl::option(Fl::OPTION_ARROW_FOCUS) ? i : 1; case ctrl('H'): // cut the previous character if (readonly()) { fl_beep(); @@ -417,7 +419,10 @@ int Fl_Input::handle_key() { return copy_cuts(); case ctrl('N'): // go down one line i = position(); - if (line_end(i) >= size()) return NORMAL_INPUT_MOVE; + if (line_end(i) >= size()) { + if (input_type()==FL_MULTILINE_INPUT && !Fl::option(Fl::OPTION_ARROW_FOCUS)) return 1; + return NORMAL_INPUT_MOVE; + } while (repeat_num--) { i = line_end(i); if (i >= size()) break; @@ -427,7 +432,10 @@ int Fl_Input::handle_key() { return 1; case ctrl('P'): // go up one line i = position(); - if (!line_start(i)) return NORMAL_INPUT_MOVE; + if (!line_start(i)) { + if (input_type()==FL_MULTILINE_INPUT && !Fl::option(Fl::OPTION_ARROW_FOCUS)) return 1; + return NORMAL_INPUT_MOVE; + } while(repeat_num--) { i = line_start(i); if (!i) break; diff --git a/src/Fl_Menu_add.cxx b/src/Fl_Menu_add.cxx index facd7e431..340f9558f 100644 --- a/src/Fl_Menu_add.cxx +++ b/src/Fl_Menu_add.cxx @@ -51,6 +51,8 @@ extern Fl_Menu_* fl_menu_array_owner; // in Fl_Menu_.cxx // above pointers to detect if the array belongs to an Fl_Menu_ // widget, and if so it reallocates as necessary. + + // Insert a single Fl_Menu_Item into an array of size at offset n, // if this is local_array it will be reallocated if needed. static Fl_Menu_Item* array_insert( @@ -81,6 +83,8 @@ static Fl_Menu_Item* array_insert( return array; } + + // Comparison that does not care about deleted '&' signs: static int compare(const char* a, const char* b) { for (;;) { @@ -97,6 +101,8 @@ static int compare(const char* a, const char* b) { } } + + /** Adds an item. The text is split at '/' characters to automatically produce submenus (actually a totally unnecessary feature as you can now add submenu titles directly by setting SUBMENU in the flags): @@ -111,15 +117,26 @@ int Fl_Menu_Item::add( return(insert(-1,mytext,sc,cb,data,myflags)); // -1: append } -/** Inserts an item at position \p index. - - If \p index is -1, the item is added the same way as Fl_Menu_Item::add(). - If 'mytext' contains any un-escaped front slashes (/), it's assumed - a menu pathname is being specified, and the value of \p index - will be ignored. - In all other aspects, the behavior of insert() is the same as add(). +/** + Inserts an item at position \p index. + + If \p index is -1, the item is added the same way as Fl_Menu_Item::add(). + + If 'mytext' contains any un-escaped front slashes (/), it's assumed + a menu pathname is being specified, and the value of \p index + will be ignored. + + In all other aspects, the behavior of insert() is the same as add(). + + \param index insert new items here + \param mytext new label string, details see above + \param sc keyboard shortcut for new item + \param cb callback function for new item + \param data user data for new item + \param myflags menu flags as described in FL_Menu_Item + \returns the index into the menu() array, where the entry was added */ int Fl_Menu_Item::insert( int index, @@ -199,6 +216,8 @@ int Fl_Menu_Item::insert( return m-array; } + + /** Adds a new menu item. @@ -307,6 +326,8 @@ int Fl_Menu_::add(const char *label,int shortcut,Fl_Callback *callback,void *use return(insert(-1,label,shortcut,callback,userdata,flags)); // -1: append } + + /** Inserts a new menu item at the specified \p index position. @@ -387,6 +408,8 @@ int Fl_Menu_::insert( return r; } + + /** This is a Forms (and SGI GL library) compatible add function, it adds many menu items, with '|' separating the menu items, and tab @@ -399,6 +422,9 @@ int Fl_Menu_::insert( same special characters as described for the long version of add(). No items must be added to a menu during a callback to the same menu. + + \param str string containing multiple menu labels as described above + \returns the index into the menu() array, where the entry was added */ int Fl_Menu_::add(const char *str) { char buf[1024]; @@ -417,10 +443,15 @@ int Fl_Menu_::add(const char *str) { return r; } + + /** Changes the text of item \p i. This is the only way to get slash into an add()'ed menu item. If the menu array was directly set with menu(x) then copy() is done to make a private array. + + \param i index into menu array + \param str new label for menu item at index i */ void Fl_Menu_::replace(int i, const char *str) { if (i<0 || i>=size()) return; @@ -431,11 +462,16 @@ void Fl_Menu_::replace(int i, const char *str) { } menu_[i].text = str; } + + + /** Deletes item \p i from the menu. If the menu array was directly set with menu(x) then copy() is done to make a private array. No items must be removed from a menu during a callback to the same menu. + + \param i index into menu array */ void Fl_Menu_::remove(int i) { int n = size(); diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 315747f7c..d9a97f59b 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -993,7 +993,7 @@ OSStatus cocoaKeyboardHandler(NSEvent *theEvent) UniChar one; CFStringGetCharacters((CFStringRef)sim, CFRangeMake(0, 1), &one); sym = one; - // charactersIgnoringModifiers does'nt ignore shift, remove it when it's on + // charactersIgnoringModifiers doesn't ignore shift, remove it when it's on if(sym >= 'A' && sym <= 'Z') sym += 32; } |
