update dev300-m57
[ooovba.git] / sc / source / ui / inc / fieldwnd.hxx
bloba62534b9613e11a2d421e6f49825940a0ab42e75
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fieldwnd.hxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_FIELDWND_HXX
32 #define SC_FIELDWND_HXX
34 #include <vector>
35 #include "address.hxx"
36 #include <vcl/ctrl.hxx>
37 #include <vcl/fixed.hxx>
38 #include <cppuhelper/weakref.hxx>
40 #define MAX_LABELS 256
41 #define PAGE_SIZE 16 // count of visible fields for scrollbar
42 #define LINE_SIZE 8 // count of fields per column for scrollbar
43 #define MAX_FIELDS 8 // maximum count of fields for row/col/data area
44 #define MAX_PAGEFIELDS 10 // maximum count of fields for page area
46 #define OWIDTH PivotGlobal::nObjWidth
47 #define OHEIGHT PivotGlobal::nObjHeight
48 #define SSPACE PivotGlobal::nSelSpace
50 class ScDPLayoutDlg;
51 class ScAccessibleDataPilotControl;
53 //===================================================================
55 /** Type of content area. */
56 enum ScDPFieldType
58 TYPE_PAGE, /// Area for all page fields.
59 TYPE_ROW, /// Area for all row fields.
60 TYPE_COL, /// Area for all column fields.
61 TYPE_DATA, /// Area for all data fields.
62 TYPE_SELECT /// Selection area with all fields.
65 //-------------------------------------------------------------------
67 /** Represents a field area in the DataPilot layout dialog. */
68 class ScDPFieldWindow : public Control
70 private:
71 String aName; /// name of the control, used in Accessibility
72 ScDPLayoutDlg* pDlg; /// Parent dialog.
73 Rectangle aWndRect; /// Area rectangle in pixels.
74 FixedText* pFtCaption; /// FixedText containing the name of the control.
75 Point aTextPos; /// Position of the caption text.
76 std::vector< String > aFieldArr; /// Pointer to string array of the field names.
77 ScDPFieldType eType; /// Type of this area.
78 Color aFaceColor; /// Color for dialog background.
79 Color aWinColor; /// Color for window background.
80 Color aTextColor; /// Color for text in buttons.
81 Color aWinTextColor; /// Color for text in field windows.
82 size_t nFieldSize; /// Maximum count of fields.
83 size_t nFieldSelected; /// Currently selected field.
85 com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessible > xAccessible;
86 ScAccessibleDataPilotControl* pAccessible;
88 /** Initilize the object. */
89 void Init();
91 /** Reads all needed style settings. */
92 void GetStyleSettings();
94 /** Draws the background. */
95 void DrawBackground( OutputDevice& rDev );
96 /** Draws a field into the specified rectangle. */
97 void DrawField(
98 OutputDevice& rDev,
99 const Rectangle& rRect,
100 const String& rText,
101 bool bFocus );
103 /** @return TRUE, if the field index is inside of the control area. */
104 bool IsValidIndex( size_t nIndex ) const;
105 /** @return TRUE, if the field with the given index exists. */
106 bool IsExistingIndex( size_t nIndex ) const;
107 /** @return The new selection index after moving to the given direction. */
108 size_t CalcNewFieldIndex( SCsCOL nDX, SCsROW nDY ) const;
110 /** Sets selection to the field with index nIndex. */
111 void SetSelection( size_t nIndex );
112 /** Sets selection to first field. */
113 void SetSelectionHome();
114 /** Sets selection to last field. */
115 void SetSelectionEnd();
116 /** Sets selection to new position relative to current. */
117 void MoveSelection( USHORT nKeyCode, SCsCOL nDX, SCsROW nDY );
119 /** Moves the selected field to nDestIndex. */
120 void MoveField( size_t nDestIndex );
121 /** Moves the selected field to the given direction. */
122 void MoveFieldRel( SCsCOL nDX, SCsROW nDY );
124 /** Updates the tab stop style bits. */
125 void UpdateStyle();
127 protected:
128 virtual void Paint( const Rectangle& rRect );
129 virtual void DataChanged( const DataChangedEvent& rDCEvt );
130 virtual void MouseButtonDown( const MouseEvent& rMEvt );
131 virtual void MouseButtonUp( const MouseEvent& rMEvt );
132 virtual void MouseMove( const MouseEvent& rMEvt );
133 virtual void KeyInput( const KeyEvent& rKEvt );
134 virtual void GetFocus();
135 virtual void LoseFocus();
136 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
138 public:
139 ScDPFieldWindow(
140 ScDPLayoutDlg* pDialog,
141 const ResId& rResId,
142 ScDPFieldType eFieldType,
143 FixedText* pFtFieldCaption );
144 ScDPFieldWindow(
145 ScDPLayoutDlg* pDialog,
146 const ResId& rResId,
147 ScDPFieldType eFieldType,
148 const String& aName );
149 virtual ~ScDPFieldWindow();
151 /** Reads the FixedText's text with mnemonic and hides the FixedText. */
152 void UseMnemonic();
154 /** Draws the complete control. */
155 void Redraw();
157 /** @return The pixel position of a field (without bound check). */
158 Point GetFieldPosition( size_t nIndex ) const;
159 /** @return The pixel size of a field. */
160 Size GetFieldSize() const;
162 /** @return The index of the selected field. */
163 inline bool IsEmpty() const { return aFieldArr.empty(); }
164 /** @return The index of the selected field. */
165 inline size_t GetSelectedField() const { return nFieldSelected; }
166 /** @return The pixel position of the last possible field. */
167 Point GetLastPosition() const;
169 /** @return The count of existing fields. */
170 inline size_t GetFieldCount() const { return aFieldArr.size(); }
171 /** Inserts a field to the specified index. */
172 void AddField( const String& rText, size_t nNewIndex );
173 /** Removes a field from the specified index. */
174 void DelField( size_t nDelIndex );
175 /** Removes all fields. */
176 void ClearFields();
177 /** Changes the text on an existing field. */
178 void SetFieldText( const String& rText, size_t nIndex );
179 /** Returns the text of an existing field. */
180 const String& GetFieldText( size_t nIndex ) const;
182 /** Inserts a field using the specified pixel position.
183 @param rPos The coordinates to insert the field.
184 @param rnIndex The new index of the field is returned here.
185 @return TRUE, if the field has been created. */
186 bool AddField( const String& rText, const Point& rPos, size_t& rnIndex );
187 /** Calculates the field index at a specific pixel position.
188 @param rnIndex The index of the field is returned here.
189 @return TRUE, if the index value is valid. */
190 bool GetFieldIndex( const Point& rPos, size_t& rnIndex ) const;
191 /** Calculates a field index at a specific pixel position. Returns in every
192 case the index of an existing field.
193 @param rnIndex The index of the field is returned here.
194 @return TRUE, if the index value is valid. */
195 void GetExistingIndex( const Point& rPos, size_t& rnIndex );
197 /** Notifies this control that the offset of the first field has been changed.
198 The control has to adjust the selection to keep the same field selected
199 on scrolling with scrollbar. */
200 void ModifySelectionOffset( long nOffsetDiff );
201 /** Selects the next field. Called i.e. after moving a field from SELECT area. */
202 void SelectNext();
204 /** @return The name of the control without shortcut. */
205 inline String GetName() const { return aName; }
207 /** @return The description of the control which is used for the accessibility objects. */
208 String GetDescription() const;
210 /** Grabs focus and sets new selection. */
211 void GrabFocusWithSel( size_t nIndex );
213 /** @return The type of the FieldWindow. */
214 inline ScDPFieldType GetType() const { return eType; }
217 //===================================================================
219 #endif // SC_FIELDWND_HXX