/** * Copyright Mikael Högdahl - triyana@users.sourceforge.net * * This source is distributed under the terms of the Q Public License version 1.0, * created by Trolltech (www.trolltech.com). */ #include "Fl_Select.h" #include "Fl_Defines.h" #include #include #include /** * Create a list selection dialog * @param MHVector* - Vector with selection strings */ Fl_Select::Fl_Select (const char** data, int size, int sel) : Fl_Dialog (405, 435, "Select Item") { Fl_Window* o = this; o->box(FL_UP_BOX); o->when(FL_WHEN_ENTER_KEY); { Fl_Input* o = aInput = new Fl_Input(5, 10, 280, 25); o->when(FL_WHEN_CHANGED); } { Fl_Browser* o = aBrowser = new Fl_Browser(5, 40, 280, 390); o->type(2); o->labelfont(1); o->align(FL_ALIGN_TOP_LEFT); o->when(FL_WHEN_CHANGED); } aSelect = new Fl_Return_Button(295, 10, 100, 25, "Select"); aCancel = new Fl_Button(295, 45, 100, 25, "Cancel"); o->end(); aBrowser->callback (Fl_Dialog::cb1_, this); aCancel->callback (Fl_Dialog::cb2_, this); aInput->callback (Fl_Dialog::cb3_, this); aSelect->callback (Fl_Dialog::cb4_, this); for (int f = 0; f < size; f++) aBrowser->add (data[f]); if (sel < size && sel >= 0) aBrowser->select (sel + 1); Fl::focus (aInput); aData = data; aSize = size; } /** * */ void Fl_Select::cb3 () { int f; for (f = 0;f < aSize; f++) { if (STRCASECMP (aData[f], aInput->value()) >= 0) break; } aBrowser->value (f + (f < aSize ? 1 : 0)); }