/***************************************************************************
                          SIMPLY POWERFUL TOOLKIT (SPTK)
                               DEMO PROGRAMS SET
                          cscroll_test.cpp  -  description
                             -------------------
    begin                : January 3, 2003
    copyright            : (C) 2003-2006 by Alexey S.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 <FL/Fl.H>
#include <FL/Fl_Pixmap.H>
#include <sptk3/CWindow.h>
#include <sptk3/CDataControl.h>
#include <sptk3/CGroup.h>
#include <sptk3/CScroll.h>
#include <sptk3/CButton.h>
#include <sptk3/CCheckButtons.h>
#include <sptk3/CRadioButtons.h>
#include <sptk3/CListView.h>
#include <sptk3/CThemes.h>
#include <stdio.h>

using namespace sptk;

//#include "brushed.xpm"
//Fl_Pixmap background(brushed_xpm);

void exit_cb(Fl_Widget *w,void *) {
   w->window()->hide();
}

int main() {
   // CWindow supports auto-layout
   CWindow w(250,150,"CScroll test");
   w.resizable(w);
   //w.color(0xC0C8FF00);
   //w.backgroundImage(&background);

   CScroll sc("",20,SP_ALIGN_CLIENT);
   sc.color(w.color());
   sc.box(FL_DOWN_BOX);
   sc.layoutSpacing(0);

   CGroup gr("",20,SP_ALIGN_CLIENT);
   //gr.backgroundImage(&background);

   // CCheckButtons figures out the size from the list
   // of choices. The default alignment is SP_ALIGN_TOP,
   // and you can change it in ctor
   CCheckButtons cbl("Check Buttons: ");
   cbl.buttons(CStrings("first,second,third,*",","));

   CRadioButtons rbl("Radio Buttons: ");
   rbl.buttons(CStrings("first,second,third,*",","));

   // CListView is more flexible, than CCheckButtons or
   // CRadioButtons, it's vertical size is defined with
   // the layoutSize parameter in ctor as 150.
   // SP_ALIGN_CLIENT allows that widget to occupy all
   // the space left after all the other widgets are 
   // put in place
   CListView listView("List View:",10,SP_ALIGN_CLIENT);
   listView.columns().push_back(CColumn("column 1",VAR_INT,70));
   listView.columns().push_back(CColumn("column 2",VAR_INT,70));
   listView.columns().push_back(CColumn("column 3",VAR_STRING,200));
   listView.columns().push_back(CColumn("column 4",VAR_STRING));

   // Add 10 items
   char buffer1[10];
   char buffer2[10];
   for(int a=0; a<10; a++) {
      sprintf(buffer1,"%i",a);
      sprintf(buffer2,"%i",100000-a);
      cpchar rowData[] = {buffer1,buffer2, "Column 2", "-----------Long column-----------"};
      CPackedStrings *ps = new CPackedStrings(4,rowData);
      listView.addRow(ps);
   }

   sc.end();

   // That group keeps togeteher the buttons. These
   // buttons use the default alignment for buttons - 
   // SP_ALIGN_RIGHT, and the text/icon defined by the 
   // button kind.
   CGroup buttonGroup("",10,SP_ALIGN_BOTTOM);
   //buttonGroup.box(FL_THIN_DOWN_FRAME);
   CButton exitButton(SP_EXIT_BUTTON);
   exitButton.callback(exit_cb);
   buttonGroup.end();

   w.end();

   CThemes::set("Blue");

   w.show();

   Fl::run();

   return 0;
}
