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