Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / fpicker / source / aqua / ControlHelper.hxx
blobc77ed935b11d81a81477ca9ade228f9f4462dced
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FPICKER_SOURCE_AQUA_CONTROLHELPER_HXX
21 #define INCLUDED_FPICKER_SOURCE_AQUA_CONTROLHELPER_HXX
23 #include <rtl/ustring.hxx>
24 #include <com/sun/star/uno/Any.hxx>
26 #include <list>
27 #include <map>
29 #include <premac.h>
30 #include <Cocoa/Cocoa.h>
31 #include <postmac.h>
32 #include "SalAquaConstants.h"
33 #include "FilterHelper.hxx"
34 #include "AquaFilePickerDelegate.hxx"
36 using namespace com::sun::star;
38 class ControlHelper {
40 public:
43 // Constructor / Destructor
45 ControlHelper();
46 virtual ~ControlHelper();
49 // XInitialization delegate
51 void initialize( sal_Int16 templateId );
54 // XFilePickerControlAccess function delegates
56 void setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const uno::Any& rValue );
57 uno::Any getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) const;
58 void enableControl( sal_Int16 nControlId, sal_Bool bEnable ) const;
59 OUString getLabel( sal_Int16 nControlId );
60 void setLabel( sal_Int16 nControlId, NSString* aLabel );
63 // other stuff
65 void updateFilterUI();
68 // Type definitions
70 enum ToggleType {
71 AUTOEXTENSION, //but autoextension is handled differently on MacOSX
72 PASSWORD,
73 FILTEROPTIONS,
74 READONLY,
75 LINK,
76 PREVIEW,
77 SELECTION,
78 TOGGLE_LAST
81 enum ListType {
82 VERSION,
83 TEMPLATE,
84 IMAGE_TEMPLATE,
85 LIST_LAST
89 // inline functions
91 inline NSView* getUserPane() {
92 if (m_bIsUserPaneLaidOut == false) {
93 createUserPane();
95 return m_pUserPane;
98 inline bool getVisibility(ToggleType tToggle) {
99 return m_bToggleVisibility[tToggle];
102 inline void setFilterControlNeeded(bool bNeeded) {
103 m_bIsFilterControlNeeded = bNeeded;
104 if (bNeeded == true) {
105 m_bUserPaneNeeded = true;
109 inline void setFilterHelper(FilterHelper* pFilterHelper) {
110 m_pFilterHelper = pFilterHelper;
113 inline void setFilePickerDelegate(AquaFilePickerDelegate* pDelegate) {
114 m_pDelegate = pDelegate;
117 inline bool isAutoExtensionEnabled() {
118 return ([((NSButton*) m_pToggles[AUTOEXTENSION]) state] == NSOnState);
121 private:
123 // private member variables
126 /** the native view object */
127 NSView* m_pUserPane;
129 /** the checkbox controls */
130 NSControl* m_pToggles[ TOGGLE_LAST ];
132 /** the visibility flags for the checkboxes */
133 bool m_bToggleVisibility[TOGGLE_LAST];
135 /** the special filter control */
136 NSPopUpButton *m_pFilterControl;
138 /** the popup menu controls (except for the filter control) */
139 NSControl* m_pListControls[ LIST_LAST ];
141 /** a map to store a control's label text */
142 ::std::map<NSControl *, NSString *> m_aMapListLabels;
144 /** a map to store a popup menu's label text field */
145 ::std::map<NSPopUpButton *, NSTextField *> m_aMapListLabelFields;
147 /** the visibility flags for the popup menus */
148 bool m_bListVisibility[ LIST_LAST ];
150 /** indicates if a user pane is needed */
151 bool m_bUserPaneNeeded;
153 /** indicates if the user pane was laid out already */
154 bool m_bIsUserPaneLaidOut;
156 /** indicates if a filter control is needed */
157 bool m_bIsFilterControlNeeded;
159 /** a list with all actively used controls */
160 ::std::list<NSControl*> m_aActiveControls;
162 /** the filter helper */
163 FilterHelper *m_pFilterHelper;
165 /** the save or open panel's delegate */
166 AquaFilePickerDelegate *m_pDelegate;
169 // private methods
171 void HandleSetListValue(const NSControl* pControl, const sal_Int16 nControlAction, const uno::Any& rValue);
172 uno::Any HandleGetListValue(const NSControl* pControl, const sal_Int16 nControlAction) const;
174 void createControls();
175 void createFilterControl();
176 void createUserPane();
177 NSTextField* createLabelWithString(NSString* label);
179 int getControlElementName(const Class clazz, const int nControlId) const;
180 NSControl* getControl( const sal_Int16 nControlId ) const;
181 static int getVerticalDistance(const NSControl* first, const NSControl* second);
183 void layoutControls();
186 #endif // INCLUDED_FPICKER_SOURCE_AQUA_CONTROLHELPER_HXX
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */