1 /*
2 * ===========================
3 * VDK Visual Development Kit
4 * Version 2.0.3
5 * January 2003
6 * ===========================
7 *
8 * Copyright (C) 1998, Mario Motta
9 * Developed by Mario Motta <mmotta@guest.net>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 * 02111-1307, USA.
25 */
26 #include <vdk/vdkhlbuttonbar.h>
27 DEFINE_SIGNAL_LIST (VDKHLButtonBar, VDKFrame);
28 /*
29 */
VDKHLButtonBar(VDKForm * owner,int mode,int shadow)30 VDKHLButtonBar::VDKHLButtonBar (VDKForm* owner, int mode,
31 int shadow): VDKFrame (owner, NULL, mode, shadow),
32 ButtonPressed ("ButtonPressed", this, -1)
33 {
34 }
35 /*
36 */
~VDKHLButtonBar()37 VDKHLButtonBar::~VDKHLButtonBar ()
38 {
39 }
40 /*
41 */
42 bool
OnClick(VDKObject * sender)43 VDKHLButtonBar::OnClick (VDKObject* sender)
44 {
45 ButtonListIterator li (blist);
46 int t = 0;
47 for (;li;li++, t++)
48 if (li.current () == sender)
49 break;
50 if (t < blist.size ())
51 {
52 ButtonPressed (t);
53 SignalEmit (clicked_signal);
54 SignalEmit ("clicked");
55 }
56 else
57 ButtonPressed (-1);
58 return true;
59 }
60 /*
61 */
62 void
AddButton(const char ** pixdata,const char * tip,const char * text)63 VDKHLButtonBar::AddButton (const char** pixdata,
64 const char* tip,
65 const char* text)
66 {
67 VDKHLButton *button = new VDKHLButton (Owner (),pixdata, text);
68 if (tip)
69 button->SetTip (tip);
70 Add (button, l_justify, false, false, 0);
71 blist.add (button);
72 SignalConnect (button, "clicked", &VDKHLButtonBar::OnClick);
73 }
74 /*
75 */
76 void
AddButton(const char * pixfile,const char * tip,const char * text)77 VDKHLButtonBar::AddButton (const char* pixfile,
78 const char* tip,
79 const char* text)
80 {
81 VDKHLButton *button = new VDKHLButton (Owner (),pixfile, text);
82 if (tip)
83 button->SetTip (tip);
84 Add (button, l_justify, false, false, 0);
85 blist.add (button);
86 SignalConnect (button, "clicked", &VDKHLButtonBar::OnClick);
87 }
88 /*
89 */
90 VDKHLButton*
operator [](int n)91 VDKHLButtonBar::operator[](int n)
92 {
93 if( (n >= 0) && (n < blist.size()))
94 return blist[n];
95 else
96 return NULL;
97 }
98