xref: /aoo41x/main/svx/inc/svdibrow.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SVDIBROW_HXX
29 #define _SVDIBROW_HXX
30 
31 #include <svtools/brwbox.hxx>
32 #include <vcl/edit.hxx>
33 #include <vcl/floatwin.hxx>
34 
35 class SfxItemSet;
36 class ImpItemListRow;
37 class BrowserMouseEvent;
38 
39 class _SdrItemBrowserControl: public BrowseBox
40 {
41 friend class ImpItemEdit;
42 	Container aList;
43 	long nAktPaintRow;
44 	Edit* pEditControl;
45 	XubString aWNamMerk;
46 	Link aEntryChangedHdl;
47 	Link aSetDirtyHdl;
48 	ImpItemListRow* pAktChangeEntry;
49 	long   nLastWhichOfs;
50 	sal_uInt16 nLastWhich;
51 	sal_uInt16 nLastWhichOben;
52 	sal_uInt16 nLastWhichUnten;
53 	FASTBOOL bWhichesButNames;
54 	FASTBOOL bDontHideIneffectiveItems;
55 	FASTBOOL bDontSortItems;
56 	FASTBOOL bShowWhichIds;
57 	FASTBOOL bShowRealValues;
58 private:
59 #if _SOLAR__PRIVATE
60 	void ImpCtor();
61 	void ImpSetEntry(const ImpItemListRow& rEntry, sal_uIntPtr nEntryNum);
62 	ImpItemListRow* ImpGetEntry(sal_uIntPtr nPos) const { return (ImpItemListRow*)aList.GetObject(nPos); }
63 	void ImpSaveWhich();
64 	void ImpRestoreWhich();
65 #endif // __PRIVATE
66 protected:
67 	virtual long GetRowCount() const;
68 	virtual sal_Bool SeekRow(long nRow);
69 	virtual void PaintField(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId) const;
70 	virtual void DoubleClick(const BrowserMouseEvent&);
71 	virtual void KeyInput(const KeyEvent& rEvt);
72 	virtual void Select();
73 	virtual void SetDirty(); // wird z.B. bei Modusumschaltungen gerufen
74 	virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex);
75 	virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint);
76 public:
77 	_SdrItemBrowserControl(Window* pParent, WinBits nBits=WB_3DLOOK|WB_BORDER|WB_TABSTOP);
78 	virtual ~_SdrItemBrowserControl();
79 	void Clear();
80 	void SetAttributes(const SfxItemSet* pAttr, const SfxItemSet* p2ndSet=NULL);
81 	sal_uIntPtr GetCurrentPos() const;
82 	sal_uInt16 GetCurrentWhich() const;
83 	virtual FASTBOOL BegChangeEntry(sal_uIntPtr nPos);
84 	virtual FASTBOOL EndChangeEntry();
85 	virtual void     BrkChangeEntry();
86 
87 	/** GetCellText returns the text at the given position
88 		@param	_nRow
89 			the number of the row
90 		@param	_nColId
91 			the ID of the column
92 		@return
93 			the text out of the cell
94 	*/
95 	virtual String	GetCellText(long _nRow, sal_uInt16 _nColId) const;
96 
97 	const ImpItemListRow* GetAktChangeEntry() const { return pAktChangeEntry; }
98 	XubString GetNewEntryValue() const                 { return pEditControl->GetText(); }
99 	void SetEntryChangedHdl(const Link& rLink)      { aEntryChangedHdl=rLink; }
100 	const Link& GetEntryChangedHdl() const          { return aEntryChangedHdl; }
101 	void SetSetDirtyHdl(const Link& rLink)          { aSetDirtyHdl=rLink; }
102 	const Link& GetSetDirtyHdl() const              { return aSetDirtyHdl; }
103 };
104 
105 #define WB_STDSIZEABLEDOCKWIN  (WB_STDDOCKWIN|WB_3DLOOK|WB_CLOSEABLE|WB_SIZEMOVE)
106 #define WB_STDSIZEABLEFLOATWIN (WB_STDFLOATWIN|WB_3DLOOK|WB_CLOSEABLE|WB_SIZEMOVE)
107 
108 class _SdrItemBrowserWindow: public FloatingWindow {
109 	_SdrItemBrowserControl aBrowse;
110 public:
111 	_SdrItemBrowserWindow(Window* pParent, WinBits nBits=WB_STDSIZEABLEDOCKWIN);
112 	virtual ~_SdrItemBrowserWindow();
113 	virtual void Resize();
114 	virtual void GetFocus();
115 	void Clear()                                            { aBrowse.Clear(); }
116 	void SetAttributes(const SfxItemSet* pAttr, const SfxItemSet* p2ndSet=NULL) { aBrowse.SetAttributes(pAttr,p2ndSet); }
117 	void SetFloatingMode(FASTBOOL /*bOn*/) {}
118 	const _SdrItemBrowserControl& GetBrowserControl() const { return aBrowse; }
119 	_SdrItemBrowserControl& GetBrowserControl()             { return aBrowse; }
120 };
121 
122 class SdrView;
123 
124 class SdrItemBrowser: public _SdrItemBrowserWindow {
125 	Timer aIdleTimer;
126 	SdrView* pView;
127 	FASTBOOL bDirty;
128 private:
129 	static Window* ImpGetViewWin(SdrView& rView);
130 	DECL_LINK(IdleHdl,Timer*);
131 	DECL_LINK(ChangedHdl,_SdrItemBrowserControl*);
132 	DECL_LINK(SetDirtyHdl,_SdrItemBrowserControl*);
133 public:
134 	SdrItemBrowser(SdrView& rView);
135 	void ForceParent();
136 	void SetView(SdrView& rView) { pView=&rView; ForceParent(); SetDirty(); }
137 	void SetDirty();
138 	void Undirty();
139 	void ForceUndirty() { if (bDirty) Undirty(); }
140 };
141 
142 #endif //_SVDIBROW_HXX
143 
144 
145