Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

dropdownselector.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                              dropdownselector
00003                              -------------------
00004     copyright            : (C)  2006 by Martin Bickel
00005     email                : <bickel@asc-hq.org>
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 
00017 #include "dropdownselector.h"
00018 
00019 
00020 DropDownSelector::DropDownSelector( PG_Widget *parent, const PG_Rect &r, int itemnum, const char** items, const std::string &style )
00021    : PG_DropDown( parent, r, -1, style ), first(true)
00022 {
00023    SetEditable(false);
00024    sigSelectItem.connect( SigC::slot( *this, &DropDownSelector::itemSelected ));
00025 
00026    for ( int i = 0; i < itemnum; ++i )
00027       AddItem( items[i] );
00028       
00029 }
00030 
00031 
00032 DropDownSelector::DropDownSelector( PG_Widget *parent, const PG_Rect &r, const std::vector<ASCString>& names, const std::string &style )
00033    : PG_DropDown( parent, r, -1, style ), first(true)
00034 {
00035    SetEditable(false);
00036    sigSelectItem.connect( SigC::slot( *this, &DropDownSelector::itemSelected ));
00037 
00038    for ( std::vector<ASCString>::const_iterator i = names.begin(); i != names.end(); ++i )
00039       AddItem( *i );
00040 }
00041 
00042 
00043 
00044 DropDownSelector::DropDownSelector( PG_Widget *parent, const PG_Rect &r, int id, const std::string &style) 
00045    : PG_DropDown( parent, r, id, style ), first(true)
00046 {
00047    SetEditable(false);
00048    sigSelectItem.connect( SigC::slot( *this, &DropDownSelector::itemSelected ));
00049 }
00050 
00051 bool DropDownSelector::itemSelected(  ) // PG_ListBoxBaseItem* i, void* p
00052 {
00053    selectionSignal( GetSelectedItemIndex ());
00054    return true;
00055 }
00056 
00057 
00058 void DropDownSelector::AddItem (const std::string &text, void *userdata, Uint16 height)
00059 {
00060    PG_DropDown::AddItem( text, userdata, height );
00061    if ( first ) {
00062       first = false;
00063       SelectFirstItem();
00064    }
00065 }
00066 
00067 

Generated on Tue Jun 24 01:27:39 2008 for Advanced Strategic Command by  doxygen 1.4.2