/***************************************************************************
                          SIMPLY POWERFUL TOOLKIT (SPTK)
                               DEMO PROGRAMS SET
                          radio_buttons.cpp  -  description
                             -------------------
    begin                : January 3, 2003
    copyright            : (C) 2003 by Alexey S.Parshin
    email                : alexeyp@gmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

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

#include <string.h>
#include <FL/Fl.H>
#include <FL/Fl_Button.H>

#include <sptk3/CWindow.h>
#include <sptk3/CDataControl.h>
#include <sptk3/CRadioButtons.h>
#include <sptk3/CThemes.h>
#include <sptk3/CGroup.h>
#include <sptk3/CButton.h>

CInput *i;
CRadioButtons *cb;

void button_cb(Fl_Widget *b,void *) {
   if ( strcmp(b->label(),"Get Choice") == 0)
      i->data(cb->data());
   else  cb->data(i->data());
}

int main(int argc, char *argv[]) {
   CWindow w(400,300);

   CRadioButtons cbl("RadioButtons: ");
   cbl.buttons(CStrings("First,Second,Third,A very long choice label meant to occupy two rows,*",","));
   cb = &cbl;

   CInput    input("Test");
   i = &input;

   CGroup g("",10,SP_ALIGN_BOTTOM);
   CButton   btn1("Set Choice",SP_ALIGN_RIGHT);
   btn1.callback(button_cb);

   CButton   btn2("Get Choice",SP_ALIGN_RIGHT);
   btn2.callback(button_cb);

   w.show(argc,argv);

   CThemes::set("Keramic");
   w.relayout();

   Fl::run();

   return 0;
}
