calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / fpicker / source / aqua / ControlHelper.hxx
blob5da540df61ec760aa6153d73d90b90ca5434cc19
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 #pragma once
22 #include <rtl/ustring.hxx>
23 #include <com/sun/star/uno/Any.hxx>
25 #include <list>
26 #include <map>
28 #include <premac.h>
29 #include <Cocoa/Cocoa.h>
30 #include <postmac.h>
31 #include "SalAquaConstants.h"
32 #include "FilterHelper.hxx"
33 #include "AquaFilePickerDelegate.hxx"
35 using namespace com::sun::star;
37 class ControlHelper {
39 public:
42 // Constructor / Destructor
44 ControlHelper();
45 virtual ~ControlHelper();
48 // XInitialization delegate
50 void initialize( sal_Int16 templateId );
53 // XFilePickerControlAccess function delegates
55 void setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const uno::Any& rValue );
56 uno::Any getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) const;
57 void enableControl( sal_Int16 nControlId, bool bEnable ) const;
58 OUString getLabel( sal_Int16 nControlId );
59 void setLabel( sal_Int16 nControlId, NSString* aLabel );
62 // other stuff
64 void updateFilterUI();
67 // Type definitions
69 enum ToggleType {
70 AUTOEXTENSION, //but autoextension is handled differently on MacOSX
71 PASSWORD,
72 FILTEROPTIONS,
73 READONLY,
74 LINK,
75 PREVIEW,
76 SELECTION,
77 TOGGLE_LAST
80 enum ListType {
81 VERSION,
82 TEMPLATE,
83 IMAGE_TEMPLATE,
84 IMAGE_ANCHOR,
85 LIST_LAST
89 // inline functions
91 NSView* getUserPane() {
92 if (!m_bIsUserPaneLaidOut) {
93 createUserPane();
95 return m_pUserPane;
98 bool getVisibility(ToggleType tToggle) {
99 return m_bToggleVisibility[tToggle];
102 void setFilterControlNeeded(bool bNeeded) {
103 m_bIsFilterControlNeeded = bNeeded;
104 if (bNeeded) {
105 m_bUserPaneNeeded = true;
109 void setFilterHelper(FilterHelper* pFilterHelper) {
110 m_pFilterHelper = pFilterHelper;
113 void setFilePickerDelegate(AquaFilePickerDelegate* pDelegate) {
114 m_pDelegate = pDelegate;
117 bool isAutoExtensionEnabled() {
118 return ([static_cast<NSButton*>(m_pToggles[AUTOEXTENSION]) state] == NSControlStateValueOn);
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);
173 void createControls();
174 void createFilterControl();
175 void createUserPane();
177 static int getControlElementName(const Class clazz, const int nControlId);
178 NSControl* getControl( const sal_Int16 nControlId ) const;
179 static int getVerticalDistance(const NSControl* first, const NSControl* second);
181 void layoutControls();
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */