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 #ifndef INCLUDED_FPICKER_SOURCE_AQUA_CONTROLHELPER_HXX
21 #define INCLUDED_FPICKER_SOURCE_AQUA_CONTROLHELPER_HXX
22 
23 #include <rtl/ustring.hxx>
24 #include <com/sun/star/uno/Any.hxx>
25 
26 #include <list>
27 #include <map>
28 
29 #include <premac.h>
30 #include <Cocoa/Cocoa.h>
31 #include <postmac.h>
32 #include "SalAquaConstants.h"
33 #include "FilterHelper.hxx"
35 
36 using namespace com::sun::star;
37 
39 
40 public:
41 
42 
43  // Constructor / Destructor
44 
45  ControlHelper();
46  virtual ~ControlHelper();
47 
48 
49  // XInitialization delegate
50 
51  void initialize( sal_Int16 templateId );
52 
53 
54  // XFilePickerControlAccess function delegates
55 
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 );
61 
62 
63  // other stuff
64 
65  void updateFilterUI();
66 
67 
68  // Type definitions
69 
70  enum ToggleType {
71  AUTOEXTENSION, //but autoextension is handled differently on MacOSX
78  TOGGLE_LAST
79  };
80 
81  enum ListType {
86  LIST_LAST
87  };
88 
89 
90  // inline functions
91 
92  NSView* getUserPane() {
93  if (!m_bIsUserPaneLaidOut) {
94  createUserPane();
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 
122 private:
123 
124  // private member variables
125 
126 
128  NSView* m_pUserPane;
129 
131  NSControl* m_pToggles[ TOGGLE_LAST ];
132 
134  bool m_bToggleVisibility[TOGGLE_LAST];
135 
137  NSPopUpButton *m_pFilterControl;
138 
140  NSControl* m_pListControls[ LIST_LAST ];
141 
143  ::std::map<NSControl *, NSString *> m_aMapListLabels;
144 
146  ::std::map<NSPopUpButton *, NSTextField *> m_aMapListLabelFields;
147 
149  bool m_bListVisibility[ LIST_LAST ];
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 #endif // INCLUDED_FPICKER_SOURCE_AQUA_CONTROLHELPER_HXX
186 
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, rtl_uString *keyName, RegValueType valueType, RegValue pData, sal_uInt32 valueSize)
::std::list< NSControl * > m_aActiveControls
a list with all actively used controls
AquaFilePickerDelegate * m_pDelegate
the save or open panel's delegate
::std::map< NSControl *, NSString * > m_aMapListLabels
a map to store a control's label text
bool m_bIsFilterControlNeeded
indicates if a filter control is needed
css::beans::Optional< css::uno::Any > getValue(OUString const &id)
css::uno::Any const & rValue
bool m_bIsUserPaneLaidOut
indicates if the user pane was laid out already
bool m_bUserPaneNeeded
indicates if a user pane is needed
bool isAutoExtensionEnabled()
void setFilePickerDelegate(AquaFilePickerDelegate *pDelegate)
sal_Int16 nControlId
void setFilterControlNeeded(bool bNeeded)
NSView * m_pUserPane
the native view object
FilterHelper * m_pFilterHelper
the filter helper
OUString aLabel
NSView * getUserPane()
NSPopUpButton * m_pFilterControl
the special filter control
::std::map< NSPopUpButton *, NSTextField * > m_aMapListLabelFields
a map to store a popup menu's label text field
bool getVisibility(ToggleType tToggle)
void setFilterHelper(FilterHelper *pFilterHelper)