1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ControlHelper.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONTROLHELPER_HXX_
32 #define _CONTROLHELPER_HXX_
34 #include <rtl/ustring.hxx>
35 #include <com/sun/star/uno/Any.hxx>
41 #include <Cocoa/Cocoa.h>
43 #include "SalAquaConstants.h"
44 #include "FilterHelper.hxx"
45 #include "AquaFilePickerDelegate.hxx"
47 using namespace com::sun::star
;
54 //------------------------------------------------------------------------------------
55 // Constructor / Destructor
56 //------------------------------------------------------------------------------------
58 virtual ~ControlHelper();
60 //------------------------------------------------
61 // XInitialization delegate
62 //------------------------------------------------
63 void initialize( sal_Int16 templateId
);
65 //------------------------------------------------------------------------------------
66 // XFilePickerControlAccess function delegates
67 //------------------------------------------------------------------------------------
68 void setValue( sal_Int16 nControlId
, sal_Int16 nControlAction
, const uno::Any
& rValue
);
69 uno::Any
getValue( sal_Int16 nControlId
, sal_Int16 nControlAction
) const;
70 void enableControl( sal_Int16 nControlId
, sal_Bool bEnable
) const;
71 OUString
getLabel( sal_Int16 nControlId
);
72 void setLabel( sal_Int16 nControlId
, const NSString
* aLabel
);
74 //------------------------------------------------------------------------------------
76 //------------------------------------------------------------------------------------
77 void updateFilterUI();
79 //------------------------------------------------------------------------------------
81 //------------------------------------------------------------------------------------
83 AUTOEXTENSION
, //but autoextension is handled differently on MacOSX
100 //------------------------------------------------------------------------------------
102 //------------------------------------------------------------------------------------
103 inline NSView
* getUserPane() {
104 if (m_bIsUserPaneLaidOut
== false) {
110 inline bool getVisibility(ToggleType tToggle
) {
111 return m_bToggleVisibility
[tToggle
];
114 inline void setFilterControlNeeded(bool bNeeded
) {
115 m_bIsFilterControlNeeded
= bNeeded
;
116 if (bNeeded
== true) {
117 m_bUserPaneNeeded
= true;
121 inline void setFilterHelper(FilterHelper
* pFilterHelper
) {
122 m_pFilterHelper
= pFilterHelper
;
125 inline void setFilePickerDelegate(AquaFilePickerDelegate
* pDelegate
) {
126 m_pDelegate
= pDelegate
;
129 inline bool isAutoExtensionEnabled() {
130 return ([((NSButton
*) m_pToggles
[AUTOEXTENSION
]) state
] == NSOnState
);
134 //------------------------------------------------------------------------------------
135 // private member variables
136 //------------------------------------------------------------------------------------
138 /** the native view object */
141 /** the checkbox controls */
142 NSControl
* m_pToggles
[ TOGGLE_LAST
];
144 /** the visibility flags for the checkboxes */
145 bool m_bToggleVisibility
[TOGGLE_LAST
];
147 /** the special filter control */
148 NSPopUpButton
*m_pFilterControl
;
150 /** the popup menu controls (except for the filter control) */
151 NSControl
* m_pListControls
[ LIST_LAST
];
153 /** a map to store a control's label text */
154 ::std::map
<NSControl
*, NSString
*> m_aMapListLabels
;
156 /** a map to store a popup menu's label text field */
157 ::std::map
<NSPopUpButton
*, NSTextField
*> m_aMapListLabelFields
;
159 /** the visibility flags for the popup menus */
160 bool m_bListVisibility
[ LIST_LAST
];
162 /** indicates if a user pane is needed */
163 bool m_bUserPaneNeeded
;
165 /** indicates if the user pane was laid out already */
166 bool m_bIsUserPaneLaidOut
;
168 /** indicates if a filter control is needed */
169 bool m_bIsFilterControlNeeded
;
171 /** a list with all actively used controls */
172 ::std::list
<NSControl
*> m_aActiveControls
;
174 /** the filter helper */
175 FilterHelper
*m_pFilterHelper
;
177 /** the save or open panel's delegate */
178 AquaFilePickerDelegate
*m_pDelegate
;
180 //------------------------------------------------------------------------------------
182 //------------------------------------------------------------------------------------
183 void HandleSetListValue(const NSControl
* pControl
, const sal_Int16 nControlAction
, const uno::Any
& rValue
);
184 uno::Any
HandleGetListValue(const NSControl
* pControl
, const sal_Int16 nControlAction
) const;
186 void createControls();
187 void createFilterControl();
188 void createUserPane();
189 NSTextField
* createLabelWithString(const NSString
* label
);
191 int getControlElementName(const Class clazz
, const int nControlId
) const;
192 NSControl
* getControl( const sal_Int16 nControlId
) const;
193 static int getVerticalDistance(const NSControl
* first
, const NSControl
* second
);
195 void layoutControls();
198 #endif //_CONTROLHELPER_HXX_