Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SFXDATWIN_HXX
30 : : #define _SFXDATWIN_HXX
31 : :
32 : : #include <svtools/brwbox.hxx>
33 : : #include <svtools/brwhead.hxx>
34 : : #include <vcl/timer.hxx>
35 : : #include <vcl/image.hxx>
36 : : #include <svtools/transfer.hxx>
37 : : #include <vector>
38 : :
39 : : //===================================================================
40 : :
41 : : #define MIN_COLUMNWIDTH 2
42 : :
43 : : typedef ::std::vector< Rectangle* > RectangleList;
44 : :
45 : : //===================================================================
46 : :
47 : 94 : class ButtonFrame
48 : : {
49 : : Rectangle aRect;
50 : : Rectangle aInnerRect;
51 : : String aText;
52 : : sal_Bool bPressed;
53 : : sal_Bool bCurs;
54 : : sal_Bool m_bDrawDisabled;
55 : :
56 : : public:
57 : 94 : ButtonFrame( const Point& rPt, const Size& rSz,
58 : : const String &rText,
59 : : sal_Bool bPress,
60 : : sal_Bool bCursor,
61 : : sal_Bool _bDrawDisabled)
62 : : :aRect( rPt, rSz )
63 : 94 : ,aInnerRect( Point( aRect.Left()+1, aRect.Top()+1 ),
64 : 94 : Size( aRect.GetWidth()-2, aRect.GetHeight()-2 ) )
65 : : ,aText(rText)
66 : : ,bPressed(bPress)
67 : : ,bCurs(bCursor)
68 [ + - ]: 282 : ,m_bDrawDisabled(_bDrawDisabled)
69 : : {
70 : 94 : }
71 : :
72 : : void Draw( OutputDevice& rDev );
73 : : };
74 : :
75 : : //===================================================================
76 : :
77 : : class BrowserColumn
78 : : {
79 : : sal_uInt16 _nId;
80 : : sal_uLong _nOriginalWidth;
81 : : sal_uLong _nWidth;
82 : : Image _aImage;
83 : : String _aTitle;
84 : : sal_Bool _bFrozen;
85 : :
86 : : public:
87 : : BrowserColumn( sal_uInt16 nItemId, const Image &rImage,
88 : : const String& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom );
89 : : virtual ~BrowserColumn();
90 : :
91 : 4597 : sal_uInt16 GetId() const { return _nId; }
92 : :
93 : 4696 : sal_uLong Width() { return _nWidth; }
94 : : Image& GetImage() { return _aImage; }
95 : 78 : String& Title() { return _aTitle; }
96 : :
97 : 5108 : sal_Bool IsFrozen() const { return _bFrozen; }
98 : 66 : void Freeze( sal_Bool bFreeze = sal_True ) { _bFrozen = bFreeze; }
99 : :
100 : : virtual void Draw( BrowseBox& rBox, OutputDevice& rDev,
101 : : const Point& rPos, sal_Bool bCurs );
102 : :
103 : : void SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom);
104 : : void ZoomChanged(const Fraction& rNewZoom);
105 : : };
106 : :
107 : : //===================================================================
108 : :
109 : : class BrowserDataWin
110 : : :public Control
111 : : ,public DragSourceHelper
112 : : ,public DropTargetHelper
113 : : {
114 : : public:
115 : : BrowserHeader* pHeaderBar; // only for BROWSER_HEADERBAR_NEW
116 : : Window* pEventWin; // Window of forwarded events
117 : : ScrollBarBox* pCornerWin; // Window in the corner btw the ScrollBars
118 : : sal_Bool* pDtorNotify;
119 : : AutoTimer aMouseTimer; // recalls MouseMove on dragging out
120 : : MouseEvent aRepeatEvt; // a MouseEvent to repeat
121 : : Point aLastMousePos; // verhindert pseudo-MouseMoves
122 : :
123 : : String aRealRowCount; // zur Anzeige im VScrollBar
124 : :
125 : : RectangleList aInvalidRegion; // invalidated Rectangles during !UpdateMode
126 : : bool bInPaint; // TRUE while in Paint
127 : : bool bInCommand; // TRUE while in Command
128 : : bool bNoScrollBack; // nur vorwaerts scrollen
129 : : bool bNoHScroll; // kein horizontaler Scrollbar
130 : : bool bNoVScroll; // no vertical scrollbar
131 : : bool bAutoHScroll; // autohide horizontaler Scrollbar
132 : : bool bAutoVScroll; // autohide horizontaler Scrollbar
133 : : bool bUpdateMode; // nicht SV-UpdateMode wegen Invalidate()
134 : : bool bAutoSizeLastCol; // last column always fills up window
135 : : bool bResizeOnPaint; // outstanding resize-event
136 : : bool bUpdateOnUnlock; // Update() while locked
137 : : bool bInUpdateScrollbars; // Rekursionsschutz
138 : : bool bHadRecursion; // Rekursion war aufgetreten
139 : : bool bOwnDataChangedHdl; // dont change colors in DataChanged
140 : : bool bCallingDropCallback; // we're in a callback to AcceptDrop or ExecuteDrop curently
141 : : sal_uInt16 nUpdateLock; // lock count, dont call Control::Update()!
142 : : short nCursorHidden; // new conuter for DoHide/ShowCursor
143 : :
144 : : long m_nDragRowDividerLimit;
145 : : long m_nDragRowDividerOffset;
146 : :
147 : : public:
148 : : BrowserDataWin( BrowseBox* pParent );
149 : : ~BrowserDataWin();
150 : :
151 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
152 : : virtual void Paint( const Rectangle& rRect );
153 : : virtual void RequestHelp( const HelpEvent& rHEvt );
154 : : virtual void Command( const CommandEvent& rEvt );
155 : : virtual void MouseButtonDown( const MouseEvent& rEvt );
156 : : virtual void MouseMove( const MouseEvent& rEvt );
157 : : DECL_LINK( RepeatedMouseMove, void * );
158 : :
159 : : virtual void MouseButtonUp( const MouseEvent& rEvt );
160 : : virtual void KeyInput( const KeyEvent& rEvt );
161 : : virtual void Tracking( const TrackingEvent& rTEvt );
162 : :
163 : : // DropTargetHelper overridables
164 : : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
165 : : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
166 : :
167 : : // DragSourceHelper overridables
168 : : virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel );
169 : :
170 : :
171 : : BrowseEvent CreateBrowseEvent( const Point& rPosPixel );
172 : : void Repaint();
173 : 310 : BrowseBox* GetParent() const
174 : 310 : { return (BrowseBox*) Window::GetParent(); }
175 : 0 : const String& GetRealRowCount() const { return aRealRowCount; }
176 : :
177 : : void SetUpdateMode( sal_Bool bMode );
178 : 840 : bool GetUpdateMode() const { return bUpdateMode; }
179 : 2 : void EnterUpdateLock() { ++nUpdateLock; }
180 : : void LeaveUpdateLock();
181 : : void Update();
182 : : void DoOutstandingInvalidations();
183 : : void Invalidate( sal_uInt16 nFlags = 0 );
184 : : void Invalidate( const Rectangle& rRect, sal_uInt16 nFlags = 0 );
185 : 0 : void Invalidate( const Region& rRegion, sal_uInt16 nFlags = 0 )
186 : 0 : { Control::Invalidate( rRegion, nFlags ); }
187 : :
188 : : protected:
189 : : void StartRowDividerDrag( const Point& _rStartPos );
190 : : sal_Bool ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent );
191 : : };
192 : :
193 : : //-------------------------------------------------------------------
194 : :
195 : : inline void BrowserDataWin::Repaint()
196 : : {
197 : : if ( GetUpdateMode() )
198 : : Update();
199 : : Paint( Rectangle( Point(), GetOutputSizePixel() ) );
200 : : }
201 : :
202 : : //===================================================================
203 : :
204 [ - + ]: 240 : class BrowserScrollBar: public ScrollBar
205 : : {
206 : : sal_uLong _nTip;
207 : : sal_uLong _nLastPos;
208 : : BrowserDataWin* _pDataWin;
209 : :
210 : : public:
211 : 120 : BrowserScrollBar( Window* pParent, WinBits nStyle,
212 : : BrowserDataWin *pDataWin )
213 : : : ScrollBar( pParent, nStyle ),
214 : : _nTip( 0 ),
215 : : _nLastPos( ULONG_MAX ),
216 : 120 : _pDataWin( pDataWin )
217 : 120 : {}
218 : : //ScrollBar( Window* pParent, const ResId& rResId );
219 : :
220 : : virtual void Tracking( const TrackingEvent& rTEvt );
221 : : virtual void EndScroll();
222 : : };
223 : :
224 : : //===================================================================
225 : :
226 : : void InitSettings_Impl( Window *pWin,
227 : : sal_Bool bFont = sal_True, sal_Bool bForeground = sal_True, sal_Bool bBackground = sal_True );
228 : :
229 : : //===================================================================
230 : :
231 : : #endif
232 : :
233 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|