File: dropdownselector.cpp

package info (click to toggle)
asc 2.4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 75,080 kB
  • ctags: 24,943
  • sloc: cpp: 155,023; sh: 8,829; ansic: 6,890; makefile: 650; perl: 138
file content (67 lines) | stat: -rw-r--r-- 2,415 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/***************************************************************************
                             dropdownselector
                             -------------------
    copyright            : (C)  2006 by Martin Bickel
    email                : <bickel@asc-hq.org>
 ***************************************************************************/

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

#include "dropdownselector.h"


DropDownSelector::DropDownSelector( PG_Widget *parent, const PG_Rect &r, int itemnum, const char** items, const std::string &style )
   : PG_DropDown( parent, r, -1, style ), first(true)
{
   SetEditable(false);
   sigSelectItem.connect( SigC::slot( *this, &DropDownSelector::itemSelected ));

   for ( int i = 0; i < itemnum; ++i )
      AddItem( items[i] );
      
}


DropDownSelector::DropDownSelector( PG_Widget *parent, const PG_Rect &r, const std::vector<ASCString>& names, const std::string &style )
   : PG_DropDown( parent, r, -1, style ), first(true)
{
   SetEditable(false);
   sigSelectItem.connect( SigC::slot( *this, &DropDownSelector::itemSelected ));

   for ( std::vector<ASCString>::const_iterator i = names.begin(); i != names.end(); ++i )
      AddItem( *i );
}



DropDownSelector::DropDownSelector( PG_Widget *parent, const PG_Rect &r, int id, const std::string &style) 
   : PG_DropDown( parent, r, id, style ), first(true)
{
   SetEditable(false);
   sigSelectItem.connect( SigC::slot( *this, &DropDownSelector::itemSelected ));
}

bool DropDownSelector::itemSelected(  ) // PG_ListBoxBaseItem* i, void* p
{
   selectionSignal( GetSelectedItemIndex ());
   return true;
}


void DropDownSelector::AddItem (const std::string &text, void *userdata, Uint16 height)
{
   PG_DropDown::AddItem( text, userdata, height );
   if ( first ) {
      first = false;
      SelectFirstItem();
   }
}