LibreOffice Module fpicker (master) 1
ControlHelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <rtl/ustring.hxx>
23#include <com/sun/star/uno/Any.hxx>
24
25#include <list>
26#include <map>
27
28#include <premac.h>
29#include <Cocoa/Cocoa.h>
30#include <postmac.h>
31#include "SalAquaConstants.h"
32#include "FilterHelper.hxx"
34
35using namespace com::sun::star;
36
38
39public:
40
41
42 // Constructor / Destructor
43
45 virtual ~ControlHelper();
46
47
48 // XInitialization delegate
49
50 void initialize( sal_Int16 templateId );
51
52
53 // XFilePickerControlAccess function delegates
54
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 );
60
61
62 // other stuff
63
64 void updateFilterUI();
65
66
67 // Type definitions
68
70 AUTOEXTENSION, //but autoextension is handled differently on MacOSX
79 };
80
81 enum ListType {
87 };
88
89
90 // inline functions
91
92 NSView* getUserPane() {
95 }
96 return m_pUserPane;
97 }
98
99 bool getVisibility(ToggleType tToggle) {
100 return m_bToggleVisibility[tToggle];
101 }
102
103 void setFilterControlNeeded(bool bNeeded) {
104 m_bIsFilterControlNeeded = bNeeded;
105 if (bNeeded) {
106 m_bUserPaneNeeded = true;
107 }
108 }
109
110 void setFilterHelper(FilterHelper* pFilterHelper) {
111 m_pFilterHelper = pFilterHelper;
112 }
113
115 m_pDelegate = pDelegate;
116 }
117
119 return ([static_cast<NSButton*>(m_pToggles[AUTOEXTENSION]) state] == NSControlStateValueOn);
120 }
121
122private:
123
124 // private member variables
125
126
128 NSView* m_pUserPane;
129
131 NSControl* m_pToggles[ TOGGLE_LAST ];
132
135
137 NSPopUpButton *m_pFilterControl;
138
141
143 ::std::map<NSControl *, NSString *> m_aMapListLabels;
144
146 ::std::map<NSPopUpButton *, NSTextField *> m_aMapListLabelFields;
147
150
153
156
159
161 ::std::list<NSControl*> m_aActiveControls;
162
165
168
169
170 // private methods
171
172 void HandleSetListValue(const NSControl* pControl, const sal_Int16 nControlAction, const uno::Any& rValue);
173
174 void createControls();
175 void createFilterControl();
176 void createUserPane();
177
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);
181
182 void layoutControls();
183};
184
185/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 nControlId
void createControls()
FilterHelper * m_pFilterHelper
the filter helper
uno::Any getValue(sal_Int16 nControlId, sal_Int16 nControlAction) const
NSView * m_pUserPane
the native view object
void setFilterControlNeeded(bool bNeeded)
::std::list< NSControl * > m_aActiveControls
a list with all actively used controls
bool m_bToggleVisibility[TOGGLE_LAST]
the visibility flags for the checkboxes
NSControl * m_pListControls[LIST_LAST]
the popup menu controls (except for the filter control)
bool m_bUserPaneNeeded
indicates if a user pane is needed
void createFilterControl()
bool m_bIsUserPaneLaidOut
indicates if the user pane was laid out already
void setFilePickerDelegate(AquaFilePickerDelegate *pDelegate)
void initialize(sal_Int16 templateId)
NSControl * getControl(const sal_Int16 nControlId) const
void setLabel(sal_Int16 nControlId, NSString *aLabel)
void setFilterHelper(FilterHelper *pFilterHelper)
NSView * getUserPane()
OUString getLabel(sal_Int16 nControlId)
void updateFilterUI()
AquaFilePickerDelegate * m_pDelegate
the save or open panel's delegate
static int getControlElementName(const Class clazz, const int nControlId)
NSControl * m_pToggles[TOGGLE_LAST]
the checkbox controls
static int getVerticalDistance(const NSControl *first, const NSControl *second)
void layoutControls()
void enableControl(sal_Int16 nControlId, bool bEnable) const
void HandleSetListValue(const NSControl *pControl, const sal_Int16 nControlAction, const uno::Any &rValue)
NSPopUpButton * m_pFilterControl
the special filter control
void createUserPane()
::std::map< NSPopUpButton *, NSTextField * > m_aMapListLabelFields
a map to store a popup menu's label text field
bool getVisibility(ToggleType tToggle)
bool isAutoExtensionEnabled()
bool m_bListVisibility[LIST_LAST]
the visibility flags for the popup menus
bool m_bIsFilterControlNeeded
indicates if a filter control is needed
virtual ~ControlHelper()
void setValue(sal_Int16 nControlId, sal_Int16 nControlAction, const uno::Any &rValue)
::std::map< NSControl *, NSString * > m_aMapListLabels
a map to store a control's label text
OUString aLabel