From 364fadcbea5f37799bb42e663106e3a007746984 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 20:45:53 +0100 Subject: strip copyright --- src/Fl_Search_Chooser.cxx | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'src/Fl_Search_Chooser.cxx') diff --git a/src/Fl_Search_Chooser.cxx b/src/Fl_Search_Chooser.cxx index 62aa7d1..f1cd6c3 100644 --- a/src/Fl_Search_Chooser.cxx +++ b/src/Fl_Search_Chooser.cxx @@ -1,24 +1,3 @@ -// -// Search Chooser widget for the Fast Light Tool Kit (FLTK). -// -// Copyright by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// -// #include #include -- cgit v1.2.3 From 6c50749f40e50a4b6a260a262b40035bfe83fd76 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 20:49:30 +0100 Subject: add simplified copyright --- src/Fl_Search_Chooser.cxx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Fl_Search_Chooser.cxx') diff --git a/src/Fl_Search_Chooser.cxx b/src/Fl_Search_Chooser.cxx index f1cd6c3..28396a0 100644 --- a/src/Fl_Search_Chooser.cxx +++ b/src/Fl_Search_Chooser.cxx @@ -1,3 +1,8 @@ +// +// Copyright 2006 Johannes Hofmann +// +// This software may be used and distributed according to the terms +// of the GNU General Public License, incorporated herein by reference. #include #include -- cgit v1.2.3 From ea2c78254d2c487d838b23e90dd3672dfd6939fc Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 21:31:32 +0100 Subject: fix segfault in Fl_Search_Chooser --- src/Fl_Search_Chooser.cxx | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/Fl_Search_Chooser.cxx') diff --git a/src/Fl_Search_Chooser.cxx b/src/Fl_Search_Chooser.cxx index 28396a0..d9bc92c 100644 --- a/src/Fl_Search_Chooser.cxx +++ b/src/Fl_Search_Chooser.cxx @@ -83,11 +83,6 @@ Fl_Search_Chooser::Fl_Search_Chooser(const char *title) { w->end(); } -Fl_Search_Chooser::~Fl_Search_Chooser() { - delete sb; - delete w; -} - void Fl_Search_Chooser::add(const char *t, void *d) { sb->add(t, d); -- cgit v1.2.3 From f8fb82ba705f6314d502b8efc8f03ecd16b8bed8 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 22:27:04 +0100 Subject: more reindent --- src/Fl_Search_Chooser.cxx | 117 +++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 59 deletions(-) (limited to 'src/Fl_Search_Chooser.cxx') diff --git a/src/Fl_Search_Chooser.cxx b/src/Fl_Search_Chooser.cxx index d9bc92c..d4f93b2 100644 --- a/src/Fl_Search_Chooser.cxx +++ b/src/Fl_Search_Chooser.cxx @@ -13,98 +13,97 @@ int Fl_Search_Browser::find_prefix(const char *p) { - int i = find_prefix(p, 1, size()); - if (i == -1) { - return 1; - } else { - deselect(); - middleline(i); - select(i); - return 0; - } + int i = find_prefix(p, 1, size()); + if (i == -1) { + return 1; + } else { + deselect(); + middleline(i); + select(i); + return 0; + } }; int Fl_Search_Browser::find_prefix(const char *p, int s, int e) { - if (s < 0 || e > size() || s > e) { - fprintf(stderr, "Invalid search range %d %d\n", s, e); - return 1; - } else if (e - s <= 1) { - if (strncasecmp(p, text(s), strlen(p)) == 0) { - return s; - } else if (strncasecmp(p, text(e), strlen(p)) == 0){ - return e; - } else { - return -1; - } - } else { - int med = s + (e - s) / 2; - if (strncasecmp(p, text(med), strlen(p)) > 0) { - return find_prefix(p, med, e); - } else { - return find_prefix(p, s, med); - } - } + if (s < 0 || e > size() || s > e) { + fprintf(stderr, "Invalid search range %d %d\n", s, e); + return 1; + } else if (e - s <= 1) { + if (strncasecmp(p, text(s), strlen(p)) == 0) { + return s; + } else if (strncasecmp(p, text(e), strlen(p)) == 0){ + return e; + } else { + return -1; + } + } else { + int med = s + (e - s) / 2; + if (strncasecmp(p, text(med), strlen(p)) > 0) { + return find_prefix(p, med, e); + } else { + return find_prefix(p, s, med); + } + } } static void input_cb(Fl_Input* in, void*c) { - Fl_Search_Browser *sb = ((Fl_Search_Chooser *) c)->sb; - sb->find_prefix(in->value()); + Fl_Search_Browser *sb = ((Fl_Search_Chooser *) c)->sb; + sb->find_prefix(in->value()); } static void ok_cb(Fl_Input* in, void*c) { - Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c; - sc->w->hide(); + Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c; + sc->w->hide(); } static void cancel_cb(Fl_Input* in, void*c) { - Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c; - sc->sb->deselect(); - sc->w->hide(); + Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c; + sc->sb->deselect(); + sc->w->hide(); } Fl_Search_Chooser::Fl_Search_Chooser(const char *title) { - w = new Fl_Window(320, 320, title?title:"Choose"); - Fl_Group *g = new Fl_Group(10, 10, w->w() - 10, w->h() - 10); - sb = new Fl_Search_Browser(g->x(), g->y(), g->w() , g->h() - 100, NULL); - sb->type(FL_HOLD_BROWSER); - Fl_Input *in = new Fl_Input(g->x()+50, g->h()-80, g->w()-80, 20, "Search"); - in->callback((Fl_Callback*) input_cb, this); - in->when(FL_WHEN_CHANGED); - Fl_Button *cancel_b = new Fl_Button(g->w()-200, g->h()-30, 80, 25, "Cancel"); - cancel_b->callback((Fl_Callback*) cancel_cb, this); - Fl_Button *ok_b = new Fl_Button(g->w()-100, g->h()-30, 80, 25, "Ok"); - ok_b->callback((Fl_Callback*) ok_cb, this); - Fl::focus(in); - g->end(); - w->end(); + w = new Fl_Window(320, 320, title?title:"Choose"); + Fl_Group *g = new Fl_Group(10, 10, w->w() - 10, w->h() - 10); + sb = new Fl_Search_Browser(g->x(), g->y(), g->w() , g->h() - 100, NULL); + sb->type(FL_HOLD_BROWSER); + Fl_Input *in = new Fl_Input(g->x()+50, g->h()-80, g->w()-80, 20, "Search"); + in->callback((Fl_Callback*) input_cb, this); + in->when(FL_WHEN_CHANGED); + Fl_Button *cancel_b = new Fl_Button(g->w()-200, g->h()-30, 80, 25, "Cancel"); + cancel_b->callback((Fl_Callback*) cancel_cb, this); + Fl_Button *ok_b = new Fl_Button(g->w()-100, g->h()-30, 80, 25, "Ok"); + ok_b->callback((Fl_Callback*) ok_cb, this); + Fl::focus(in); + g->end(); + w->end(); } void Fl_Search_Chooser::add(const char *t, void *d) { - sb->add(t, d); + sb->add(t, d); } void * Fl_Search_Chooser::data() { - int v = sb->value(); - if (v) { - return sb->data(v); - } else { - return NULL; - } + int v = sb->value(); + if (v) { + return sb->data(v); + } else { + return NULL; + } } void Fl_Search_Chooser::show() { - w->show(); + w->show(); } int Fl_Search_Chooser::shown() { - return w->shown(); + return w->shown(); } - -- cgit v1.2.3