Debian Codegraph @

src/af/xap/cocoa/xap_GenericListChooser_Controller.cpp

raw
1 /* AbiWord
2 * Copyright (C) 2002-2003 Hubert Figuiere
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #import <Cocoa/Cocoa.h>
21
22 #include "ut_types.h"
23
24 #import "xap_GenericListChooser_Controller.h"
25
26
27 @implementation XAP_GenericListChooser_Controller
28
29 + (XAP_GenericListChooser_Controller *)loadFromNib
30 {
31 XAP_GenericListChooser_Controller * dlg = [[XAP_GenericListChooser_Controller alloc] initWithWindowNibName:@"xap_GenericListChooser_Controller"];
32 return [dlg autorelease];
33 }
34
35 - (void)windowDidLoad
36 {
37 [m_listTable setDoubleAction:@selector(listClicked:)];
38 }
39
40
41 - (IBAction)cancelClicked:(id)sender
42 {
43 UT_UNUSED(sender);
44 if (_proxy) {
45 _proxy->cancelAction();
46 }
47 }
48
49 - (IBAction)listClicked:(id)sender
50 {
51 UT_UNUSED(sender);
52 if (_proxy) {
53 _proxy->selectAction();
54 }
55 }
56
57 - (IBAction)okClicked:(id)sender
58 {
59 UT_UNUSED(sender);
60 if (_proxy) {
61 _proxy->okAction();
62 }
63 }
64
65 - (void)setTitle:(NSString*)title
66 {
67 [[self window] setTitle:title];
68 }
69
70
71 - (void)setLabel:(NSString*)label
72 {
73 [m_enclosingBox setTitle:label];
74 }
75
76
77 - (void)setXAPProxy:(XAP_GenericListChooser_Proxy*)proxy
78 {
79 _proxy = proxy;
80 }
81
82 - (void)setDataSource:(id)obj
83 {
84 [m_listTable setDataSource:obj];
85 }
86
87 - (void)setSelected:(int)idx
88 {
89 [m_listTable selectRowIndexes:[NSIndexSet indexSetWithIndex:idx] byExtendingSelection:NO];
90 [m_listTable scrollRowToVisible:(int)idx];
91 }
92
93 - (int)selected
94 {
95 return [m_listTable selectedRow];
96 }
97
98
99 @end