/***************************************************************************
                          SIMPLY POWERFUL TOOLKIT (SPTK)
                               DEMO PROGRAMS SET
                          combo_test.cpp  -  description
                             -------------------
    begin                : Fri Jun  6 10:43:19 PDT 2003
    copyright            : (C) 2003-2006 by Alexey Parshin
    email                : alexeyp@gmail.com
 ***************************************************************************/

/***************************************************************************
   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.

   Please report all bugs and problems to "alexeyp@gmail.com"
 ***************************************************************************/

#ifdef __BORLANDC__
#include <vcl.h>
#pragma hdrstop
#endif

#include <stdio.h>

#include <FL/Fl.h>

#include <sptk3/CButton.h>
#include <sptk3/CWindow.h>
#include <sptk3/CComboBox.h>
#include <sptk3/CColumn.h>

using namespace sptk;

void combo_cb(Fl_Widget *w,void *data) {
   CControl *control = dynamic_cast<CControl *>(w);
   if (!control) return;
   switch (control->eventType()) {
      case CE_FOCUS:
         puts("Got focus");
         break;
      case CE_UNFOCUS:
         puts("Lost focus");
         break;
      case CE_DATA_CHANGED:
         puts("Data Changed");
         break;
      case UC_ADD_ITEM:
         puts("Add Item Command");
         break;
      case UC_EDIT_ITEM:
         puts("Edit Item Command");
         break;
      case UC_DELETE_ITEM:
         puts("Delete Item Command");
         break;
      case CE_MOUSE_CLICK:
         puts("Mouse Click");
         break;
      case CE_MOUSE_DOUBLE_CLICK:
         puts("Mouse Double Click");
         break;
      case CE_KEYBOARD:
         puts("Keyboard Key Pressed");
         break;
      default:
         break;
   }
}

int main(int argc, char *argv[])
{
   CWindow w(450,200,"ComboBox Test");

   CComboBox cb("Test Combo Box:");

   CColumnList  columns;
   columns.push_back(CColumn("name",VAR_STRING,45));
   columns.push_back(CColumn("phone",VAR_STRING,140));
   columns.push_back(CColumn("city",VAR_STRING,120));
   cb.columns(columns);

   CStrings sl1("Alex|(415)-123-45678|SF","|");
   CStrings sl2("Eric|(510)-123-45678|Oakland","|");
   CStrings sl3("Gordon|(650)-123-45678|Los Angeles","|");
   CStrings sl4("Mark|(408)-123-45678|San Mateo","|");

   cb.addRow(sl1);
   cb.addRow(sl2);
   cb.addRow(sl3);
   cb.addRow(sl4);

   cb.buttons(SP_BROWSE_BUTTON|SP_ADD_BUTTON|SP_EDIT_BUTTON|SP_DELETE_BUTTON);
   cb.callback(combo_cb);

   w.resizable(w);
   w.end();
   w.show(argc,argv);

   CThemes::set("OSX");

   Fl::run();

   return 0;
}
