Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / fpicker / source / aqua / ControlHelper.hxx
blobf984b5281c0f062d0e68abe103ac3cf7db3aca51
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, 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 IMAGE_ANCHOR,
86 LIST_LAST
90 // inline functions
92 NSView* getUserPane() {
93 if (!m_bIsUserPaneLaidOut) {
94 createUserPane();
96 return m_pUserPane;
99 bool getVisibility(ToggleType tToggle) {
100 return m_bToggleVisibility[tToggle];
103 void setFilterControlNeeded(bool bNeeded) {
104 m_bIsFilterControlNeeded = bNeeded;
105 if (bNeeded) {
106 m_bUserPaneNeeded = true;
110 void setFilterHelper(FilterHelper* pFilterHelper) {
111 m_pFilterHelper = pFilterHelper;
114 void setFilePickerDelegate(AquaFilePickerDelegate* pDelegate) {
115 m_pDelegate = pDelegate;
118 bool isAutoExtensionEnabled() {
119 return ([static_cast<NSButton*>(m_pToggles[AUTOEXTENSION]) state] == NSControlStateValueOn);
122 private:
124 // private member variables
127 /** the native view object */
128 NSView* m_pUserPane;
130 /** the checkbox controls */
131 NSControl* m_pToggles[ TOGGLE_LAST ];
133 /** the visibility flags for the checkboxes */
134 bool m_bToggleVisibility[TOGGLE_LAST];
136 /** the special filter control */
137 NSPopUpButton *m_pFilterControl;
139 /** the popup menu controls (except for the filter control) */
140 NSControl* m_pListControls[ LIST_LAST ];
142 /** a map to store a control's label text */
143 ::std::map<NSControl *, NSString *> m_aMapListLabels;
145 /** a map to store a popup menu's label text field */
146 ::std::map<NSPopUpButton *, NSTextField *> m_aMapListLabelFields;
148 /** the visibility flags for the popup menus */
149 bool m_bListVisibility[ LIST_LAST ];
151 /** indicates if a user pane is needed */
152 bool m_bUserPaneNeeded;
154 /** indicates if the user pane was laid out already */
155 bool m_bIsUserPaneLaidOut;
157 /** indicates if a filter control is needed */
158 bool m_bIsFilterControlNeeded;
160 /** a list with all actively used controls */
161 ::std::list<NSControl*> m_aActiveControls;
163 /** the filter helper */
164 FilterHelper *m_pFilterHelper;
166 /** the save or open panel's delegate */
167 AquaFilePickerDelegate *m_pDelegate;
170 // private methods
172 void HandleSetListValue(const NSControl* pControl, const sal_Int16 nControlAction, const uno::Any& rValue);
174 void createControls();
175 void createFilterControl();
176 void createUserPane();
178 static int getControlElementName(const Class clazz, const int nControlId);
179 NSControl* getControl( const sal_Int16 nControlId ) const;
180 static int getVerticalDistance(const NSControl* first, const NSControl* second);
182 void layoutControls();
185 #endif // INCLUDED_FPICKER_SOURCE_AQUA_CONTROLHELPER_HXX
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */