xref: /trunk/main/svtools/source/brwbox/datwin.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 _SFXDATWIN_HXX
29 #define _SFXDATWIN_HXX
30 
31 #ifndef _BRWBOX_HXX
32 #include <svtools/brwbox.hxx>
33 #endif
34 #include <svtools/brwhead.hxx>
35 #include <vcl/timer.hxx>
36 #ifndef _IMAGE_HXX //autogen
37 #include <vcl/image.hxx>
38 #endif
39 #include <tools/list.hxx>
40 #include <svtools/transfer.hxx>
41 
42 //===================================================================
43 
44 #define MIN_COLUMNWIDTH  2
45 #define DRAG_CRITICAL    4
46 
47 DECLARE_LIST( RectangleList, Rectangle* )
48 
49 //===================================================================
50 
51 class ButtonFrame
52 {
53     Rectangle   aRect;
54     Rectangle   aInnerRect;
55     String      aText;
56     sal_Bool        bPressed;
57     sal_Bool        bCurs;
58     sal_Bool        bAbbr;
59     sal_Bool        m_bDrawDisabled;
60 
61 public:
62                ButtonFrame( const Point& rPt, const Size& rSz,
63                             const String &rText,
64                             sal_Bool bPress = sal_False,
65                             sal_Bool bCursor = sal_False,
66                             sal_Bool bAbbreviate = sal_True,
67                             sal_Bool _bDrawDisabled = sal_False)
68                 :aRect( rPt, rSz )
69                 ,aInnerRect( Point( aRect.Left()+1, aRect.Top()+1 ),
70                             Size( aRect.GetWidth()-2, aRect.GetHeight()-2 ) )
71                 ,aText(rText)
72                 ,bPressed(bPress)
73                 ,bCurs(bCursor)
74                 ,bAbbr(bAbbreviate)
75                 ,m_bDrawDisabled(_bDrawDisabled)
76             {
77             }
78 
79     void    Draw( OutputDevice& rDev );
80 };
81 
82 //===================================================================
83 
84 class BrowserColumn
85 {
86     sal_uInt16              _nId;
87     sal_uLong               _nOriginalWidth;
88     sal_uLong               _nWidth;
89     Image               _aImage;
90     String              _aTitle;
91     sal_Bool                _bFrozen;
92     HeaderBarItemBits   _nFlags;
93 
94 public:
95                         BrowserColumn( sal_uInt16 nItemId, const Image &rImage,
96                                         const String& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom,
97                                         HeaderBarItemBits nFlags );
98     virtual            ~BrowserColumn();
99 
100     sal_uInt16              GetId() const { return _nId; }
101 
102     sal_uLong               Width() { return _nWidth; }
103     Image&              GetImage() { return _aImage; }
104     String&             Title() { return _aTitle; }
105     HeaderBarItemBits&  Flags() { return _nFlags; }
106 
107     sal_Bool                IsFrozen() const { return _bFrozen; }
108     void                Freeze( sal_Bool bFreeze = sal_True ) { _bFrozen = bFreeze; }
109 
110     virtual void        Draw( BrowseBox& rBox, OutputDevice& rDev,
111                               const Point& rPos, sal_Bool bCurs  );
112 
113     void                SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom);
114     void                ZoomChanged(const Fraction& rNewZoom);
115 };
116 
117 //===================================================================
118 
119 class BrowserDataWin
120             :public Control
121             ,public DragSourceHelper
122             ,public DropTargetHelper
123 {
124 public:
125     BrowserHeader*  pHeaderBar;     // only for BROWSER_HEADERBAR_NEW
126     Window*         pEventWin;      // Window of forwarded events
127     ScrollBarBox*   pCornerWin;     // Window in the corner btw the ScrollBars
128     sal_Bool*           pDtorNotify;
129     AutoTimer       aMouseTimer;    // recalls MouseMove on dragging out
130     MouseEvent      aRepeatEvt;     // a MouseEvent to repeat
131     Point           aLastMousePos;  // verhindert pseudo-MouseMoves
132 
133     String          aRealRowCount;  // zur Anzeige im VScrollBar
134 
135     RectangleList   aInvalidRegion; // invalidated Rectangles during !UpdateMode
136     FASTBOOL        bInPaint;       // sal_True while in Paint
137     FASTBOOL        bInCommand;     // sal_True while in Command
138     FASTBOOL        bNoScrollBack;  // nur vorwaerts scrollen
139     FASTBOOL        bNoHScroll;     // kein horizontaler Scrollbar
140     FASTBOOL        bNoVScroll;     // no vertical scrollbar
141     FASTBOOL        bAutoHScroll;   // autohide horizontaler Scrollbar
142     FASTBOOL        bAutoVScroll;   // autohide horizontaler Scrollbar
143     FASTBOOL        bUpdateMode;    // nicht SV-UpdateMode wegen Invalidate()
144     FASTBOOL        bAutoSizeLastCol;// last column always fills up window
145     FASTBOOL        bResizeOnPaint; // outstanding resize-event
146     FASTBOOL        bUpdateOnUnlock;    // Update() while locked
147     FASTBOOL        bInUpdateScrollbars;    // Rekursionsschutz
148     FASTBOOL        bHadRecursion;          // Rekursion war aufgetreten
149     FASTBOOL        bOwnDataChangedHdl;     // dont change colors in DataChanged
150     FASTBOOL        bCallingDropCallback;   // we're in a callback to AcceptDrop or ExecuteDrop curently
151     sal_uInt16          nUpdateLock;    // lock count, dont call Control::Update()!
152     short           nCursorHidden;  // new conuter for DoHide/ShowCursor
153 
154     long            m_nDragRowDividerLimit;
155     long            m_nDragRowDividerOffset;
156 
157 public:
158                     BrowserDataWin( BrowseBox* pParent );
159                     ~BrowserDataWin();
160 
161     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
162     virtual void    Paint( const Rectangle& rRect );
163     virtual void    RequestHelp( const HelpEvent& rHEvt );
164     virtual void    Command( const CommandEvent& rEvt );
165     virtual void    MouseButtonDown( const MouseEvent& rEvt );
166     virtual void    MouseMove( const MouseEvent& rEvt );
167                     DECL_LINK( RepeatedMouseMove, void * );
168 
169     virtual void    MouseButtonUp( const MouseEvent& rEvt );
170     virtual void    KeyInput( const KeyEvent& rEvt );
171     virtual void    Tracking( const TrackingEvent& rTEvt );
172 
173     // DropTargetHelper overridables
174     virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
175     virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
176 
177     // DragSourceHelper overridables
178     virtual void    StartDrag( sal_Int8 _nAction, const Point& _rPosPixel );
179 
180 
181     BrowseEvent     CreateBrowseEvent( const Point& rPosPixel );
182     void            Repaint();
183     BrowseBox*      GetParent() const
184                          { return (BrowseBox*) Window::GetParent(); }
185     const String&   GetRealRowCount() const { return aRealRowCount; }
186 
187     void            SetUpdateMode( sal_Bool bMode );
188     FASTBOOL        GetUpdateMode() const { return bUpdateMode; }
189     void            EnterUpdateLock() { ++nUpdateLock; }
190     void            LeaveUpdateLock();
191     void            Update();
192     void            DoOutstandingInvalidations();
193     void            Invalidate( sal_uInt16 nFlags = 0 );
194     void            Invalidate( const Rectangle& rRect, sal_uInt16 nFlags = 0 );
195     void            Invalidate( const Region& rRegion, sal_uInt16 nFlags = 0 )
196                     { Control::Invalidate( rRegion, nFlags ); }
197 
198 protected:
199     void            StartRowDividerDrag( const Point& _rStartPos );
200     sal_Bool            ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent );
201 };
202 
203 //-------------------------------------------------------------------
204 
205 inline void BrowserDataWin::Repaint()
206 {
207     if ( GetUpdateMode() )
208         Update();
209     Paint( Rectangle( Point(), GetOutputSizePixel() ) );
210 }
211 
212 //===================================================================
213 
214 class BrowserScrollBar: public ScrollBar
215 {
216     sal_uLong           _nTip;
217     sal_uLong           _nLastPos;
218     BrowserDataWin* _pDataWin;
219 
220 public:
221                     BrowserScrollBar( Window* pParent, WinBits nStyle,
222                                       BrowserDataWin *pDataWin )
223                     :   ScrollBar( pParent, nStyle ),
224                         _nTip( 0 ),
225                         _nLastPos( ULONG_MAX ),
226                         _pDataWin( pDataWin )
227                     {}
228                     //ScrollBar( Window* pParent, const ResId& rResId );
229 
230     virtual void    Tracking( const TrackingEvent& rTEvt );
231     virtual void    EndScroll();
232 };
233 
234 //===================================================================
235 
236 void InitSettings_Impl( Window *pWin,
237          sal_Bool bFont = sal_True, sal_Bool bForeground = sal_True, sal_Bool bBackground = sal_True );
238 
239 //===================================================================
240 
241 #ifdef DBG_MI
242 
243 void DoLog_Impl( const BrowseBox *pThis, const char *pWhat, const char *pWho );
244 #define LOG(pThis,what,who) DoLog_Impl(pThis,what,who)
245 
246 #else
247 
248 #define LOG(pThis,what,who)
249 
250 #endif
251 
252 
253 #endif
254 
255