1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datwin.hxx,v $
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 _SFXDATWIN_HXX
32 #define _SFXDATWIN_HXX
35 #include <svtools/brwbox.hxx>
37 #include <svtools/brwhead.hxx>
38 #include <vcl/timer.hxx>
39 #ifndef _IMAGE_HXX //autogen
40 #include <vcl/image.hxx>
42 #include <tools/list.hxx>
43 #include <svtools/transfer.hxx>
45 //===================================================================
47 #define MIN_COLUMNWIDTH 2
48 #define DRAG_CRITICAL 4
50 DECLARE_LIST( RectangleList
, Rectangle
* )
52 //===================================================================
65 ButtonFrame( const Point
& rPt
, const Size
& rSz
,
69 BOOL bAbbreviate
= TRUE
,
70 BOOL _bDrawDisabled
= FALSE
)
72 ,aInnerRect( Point( aRect
.Left()+1, aRect
.Top()+1 ),
73 Size( aRect
.GetWidth()-2, aRect
.GetHeight()-2 ) )
78 ,m_bDrawDisabled(_bDrawDisabled
)
82 void Draw( OutputDevice
& rDev
);
85 //===================================================================
90 ULONG _nOriginalWidth
;
95 HeaderBarItemBits _nFlags
;
98 BrowserColumn( USHORT nItemId
, const Image
&rImage
,
99 const String
& rTitle
, ULONG nWidthPixel
, const Fraction
& rCurrentZoom
,
100 HeaderBarItemBits nFlags
);
101 virtual ~BrowserColumn();
103 USHORT
GetId() const { return _nId
; }
105 ULONG
Width() { return _nWidth
; }
106 Image
& GetImage() { return _aImage
; }
107 String
& Title() { return _aTitle
; }
108 HeaderBarItemBits
& Flags() { return _nFlags
; }
110 BOOL
IsFrozen() const { return _bFrozen
; }
111 void Freeze( BOOL bFreeze
= TRUE
) { _bFrozen
= bFreeze
; }
113 virtual void Draw( BrowseBox
& rBox
, OutputDevice
& rDev
,
114 const Point
& rPos
, BOOL bCurs
);
116 void SetWidth(ULONG nNewWidthPixel
, const Fraction
& rCurrentZoom
);
117 void ZoomChanged(const Fraction
& rNewZoom
);
120 //===================================================================
124 ,public DragSourceHelper
125 ,public DropTargetHelper
128 BrowserHeader
* pHeaderBar
; // only for BROWSER_HEADERBAR_NEW
129 Window
* pEventWin
; // Window of forwarded events
130 ScrollBarBox
* pCornerWin
; // Window in the corner btw the ScrollBars
132 AutoTimer aMouseTimer
; // recalls MouseMove on dragging out
133 MouseEvent aRepeatEvt
; // a MouseEvent to repeat
134 Point aLastMousePos
; // verhindert pseudo-MouseMoves
136 String aRealRowCount
; // zur Anzeige im VScrollBar
138 RectangleList aInvalidRegion
; // invalidated Rectangles during !UpdateMode
139 FASTBOOL bInPaint
; // TRUE while in Paint
140 FASTBOOL bInCommand
; // TRUE while in Command
141 FASTBOOL bNoScrollBack
; // nur vorwaerts scrollen
142 FASTBOOL bNoHScroll
; // kein horizontaler Scrollbar
143 FASTBOOL bNoVScroll
; // no vertical scrollbar
144 FASTBOOL bAutoHScroll
; // autohide horizontaler Scrollbar
145 FASTBOOL bAutoVScroll
; // autohide horizontaler Scrollbar
146 FASTBOOL bUpdateMode
; // nicht SV-UpdateMode wegen Invalidate()
147 FASTBOOL bAutoSizeLastCol
;// last column always fills up window
148 FASTBOOL bHighlightAuto
; // new auto-highlight by SetFont() etc.
149 FASTBOOL bResizeOnPaint
; // outstanding resize-event
150 FASTBOOL bUpdateOnUnlock
; // Update() while locked
151 FASTBOOL bInUpdateScrollbars
; // Rekursionsschutz
152 FASTBOOL bHadRecursion
; // Rekursion war aufgetreten
153 FASTBOOL bOwnDataChangedHdl
; // dont change colors in DataChanged
154 FASTBOOL bCallingDropCallback
; // we're in a callback to AcceptDrop or ExecuteDrop curently
155 USHORT nUpdateLock
; // lock count, dont call Control::Update()!
156 short nCursorHidden
; // new conuter for DoHide/ShowCursor
158 long m_nDragRowDividerLimit
;
159 long m_nDragRowDividerOffset
;
162 BrowserDataWin( BrowseBox
* pParent
);
165 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
166 virtual void Paint( const Rectangle
& rRect
);
167 virtual void RequestHelp( const HelpEvent
& rHEvt
);
168 virtual void Command( const CommandEvent
& rEvt
);
169 virtual void MouseButtonDown( const MouseEvent
& rEvt
);
170 virtual void MouseMove( const MouseEvent
& rEvt
);
171 DECL_LINK( RepeatedMouseMove
, void * );
173 virtual void MouseButtonUp( const MouseEvent
& rEvt
);
174 virtual void KeyInput( const KeyEvent
& rEvt
);
175 virtual void Tracking( const TrackingEvent
& rTEvt
);
177 // DropTargetHelper overridables
178 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
179 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
181 // DragSourceHelper overridables
182 virtual void StartDrag( sal_Int8 _nAction
, const Point
& _rPosPixel
);
185 BrowseEvent
CreateBrowseEvent( const Point
& rPosPixel
);
187 BrowseBox
* GetParent() const
188 { return (BrowseBox
*) Window::GetParent(); }
189 const String
& GetRealRowCount() const { return aRealRowCount
; }
191 void SetUpdateMode( BOOL bMode
);
192 FASTBOOL
GetUpdateMode() const { return bUpdateMode
; }
193 void EnterUpdateLock() { ++nUpdateLock
; }
194 void LeaveUpdateLock();
196 void DoOutstandingInvalidations();
197 void Invalidate( USHORT nFlags
= 0 );
198 void Invalidate( const Rectangle
& rRect
, USHORT nFlags
= 0 );
199 void Invalidate( const Region
& rRegion
, USHORT nFlags
= 0 )
200 { Control::Invalidate( rRegion
, nFlags
); }
203 void StartRowDividerDrag( const Point
& _rStartPos
);
204 BOOL
ImplRowDividerHitTest( const BrowserMouseEvent
& _rEvent
);
207 //-------------------------------------------------------------------
209 inline void BrowserDataWin::Repaint()
211 if ( GetUpdateMode() )
213 Paint( Rectangle( Point(), GetOutputSizePixel() ) );
216 //===================================================================
218 class BrowserScrollBar
: public ScrollBar
222 BrowserDataWin
* _pDataWin
;
225 BrowserScrollBar( Window
* pParent
, WinBits nStyle
,
226 BrowserDataWin
*pDataWin
)
227 : ScrollBar( pParent
, nStyle
),
229 _nLastPos( ULONG_MAX
),
230 _pDataWin( pDataWin
)
232 //ScrollBar( Window* pParent, const ResId& rResId );
234 virtual void Tracking( const TrackingEvent
& rTEvt
);
235 virtual void EndScroll();
238 //===================================================================
240 void InitSettings_Impl( Window
*pWin
,
241 BOOL bFont
= TRUE
, BOOL bForeground
= TRUE
, BOOL bBackground
= TRUE
);
243 //===================================================================
247 void DoLog_Impl( const BrowseBox
*pThis
, const char *pWhat
, const char *pWho
);
248 #define LOG(pThis,what,who) DoLog_Impl(pThis,what,who)
252 #define LOG(pThis,what,who)