Debian Codegraph @

src/af/xap/cocoa/xap_CocoaWidget.cpp

raw
1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
2
3 /* AbiSource Application Framework
4 * Copyright (C) 2005 Hubert Figuiere
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA.
20 */
21
22
23 #import <Cocoa/Cocoa.h>
24
25 #include "ut_assert.h"
26 #include "ut_string_class.h"
27
28 #include "xap_CocoaWidget.h"
29 #include "xap_CocoaDialog_Utilities.h"
30
31 XAP_CocoaWidget::XAP_CocoaWidget(id w) :
32 XAP_Widget(),
33 m_widget(w)
34 {
35 //
36 }
37
38 XAP_CocoaWidget::~XAP_CocoaWidget()
39 {
40 //
41 }
42
43 /** set the widget enabled/disabled state */
44 void XAP_CocoaWidget::setState(bool enabled)
45 {
46 [m_widget setEnabled:enabled];
47 }
48
49
50 /** set the widget enabled/disabled state */
51 bool XAP_CocoaWidget::getState(void)
52 {
53 return [m_widget isEnabled];
54 }
55
56 /** set the widget visible state */
57 void XAP_CocoaWidget::setVisible(bool /*visible*/)
58 {
59 UT_ASSERT(UT_NOT_IMPLEMENTED);
60 }
61 /** get the widget visible state */
62 bool XAP_CocoaWidget::getVisible(void)
63 {
64 UT_ASSERT(UT_NOT_IMPLEMENTED);
65 return true;
66 }
67
68 /** set the widget int value */
69 void XAP_CocoaWidget::setValueInt(int val)
70 {
71 [m_widget setIntValue:val];
72 }
73
74 /** get the widget int value */
75 int XAP_CocoaWidget::getValueInt(void)
76 {
77 return [m_widget intValue];
78 }
79
80
81 /** set the widget value as string */
82 void XAP_CocoaWidget::setValueString(const UT_UTF8String &val)
83 {
84 NSString *str = [[NSString alloc ]initWithUTF8String:val.utf8_str()];
85
86 [m_widget setStringValue:str];
87 [str release];
88 }
89
90 /** get the widget value as string */
91 void XAP_CocoaWidget::getValueString(UT_UTF8String &val)
92 {
93 NSString * str = [m_widget stringValue];
94 val.assign([str UTF8String]);
95 }
96
97 /** set the widget value as float */
98 void XAP_CocoaWidget::setValueFloat(float val)
99 {
100 [m_widget setFloatValue:val];
101
102 }
103
104 /** get the widget value as float */
105 float XAP_CocoaWidget::getValueFloat(void)
106 {
107 return [m_widget floatValue];
108 }
109
110
111 /** set the widget label */
112 void XAP_CocoaWidget::setLabel(const UT_UTF8String &val)
113 {
114 SetNSControlLabel(m_widget, val);
115 }
116
117 void XAP_CocoaWidget::setLabel(const std::string &val)
118 {
119 SetNSControlLabel(m_widget, val);
120 }