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 _SVTOOLS_EDITBROWSEBOX_HXX_ 29*cdf0e10cSrcweir #define _SVTOOLS_EDITBROWSEBOX_HXX_ 30*cdf0e10cSrcweir #define SVTOOLS_IN_EDITBROWSEBOX_HXX 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "svtools/svtdllapi.h" 33*cdf0e10cSrcweir #include <tools/ref.hxx> 34*cdf0e10cSrcweir #include <tools/rtti.hxx> 35*cdf0e10cSrcweir #include <vcl/window.hxx> 36*cdf0e10cSrcweir #include <vcl/combobox.hxx> 37*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #ifndef _IMAGEBTN_HXX 40*cdf0e10cSrcweir #include <vcl/button.hxx> 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir #include <svtools/brwbox.hxx> 43*cdf0e10cSrcweir #include <vcl/timer.hxx> 44*cdf0e10cSrcweir #include <svtools/brwhead.hxx> 45*cdf0e10cSrcweir #include <svtools/svmedit.hxx> 46*cdf0e10cSrcweir #include <vcl/svapp.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir //================================================================== 49*cdf0e10cSrcweir // EditBrowseBoxFlags (EBBF) 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #define EBBF_NONE ((sal_Int32)0x0000) 52*cdf0e10cSrcweir /** if this bit is _not_ set, the handle column will be invalidated upon 53*cdf0e10cSrcweir changing the row in the browse box. This is for forcing the row picture to 54*cdf0e10cSrcweir be repainted. If you do not have row pictures or text, you don't need this 55*cdf0e10cSrcweir invalidation, then you would specify this bit to prevent flicker 56*cdf0e10cSrcweir */ 57*cdf0e10cSrcweir #define EBBF_NO_HANDLE_COLUMN_CONTENT ((sal_Int32)0x0001) 58*cdf0e10cSrcweir /** set this bit to activate the cell on a MouseButtonDown, not a MouseButtonUp event 59*cdf0e10cSrcweir */ 60*cdf0e10cSrcweir #define EBBF_ACTIVATE_ON_BUTTONDOWN ((sal_Int32)0x0002) 61*cdf0e10cSrcweir /** if this bit is set and EBBF_NO_HANDLE_COLUMN_CONTENT is _not_ set, the handle 62*cdf0e10cSrcweir column is drawn with the text contained in column 0 instead of an image 63*cdf0e10cSrcweir */ 64*cdf0e10cSrcweir #define EBBF_HANDLE_COLUMN_TEXT ((sal_Int32)0x0004) 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir /** If this bit is set, tab traveling is somewhat modified<br/> 67*cdf0e10cSrcweir If the control gets the focus because the user pressed the TAB key, then the 68*cdf0e10cSrcweir first or last cell (depending on whether the traveling was cycling forward or backward) 69*cdf0e10cSrcweir gets activated. 70*cdf0e10cSrcweir @see Window::GetGetFocusFlags 71*cdf0e10cSrcweir @see GETFOCUS_* 72*cdf0e10cSrcweir */ 73*cdf0e10cSrcweir #define EBBF_SMART_TAB_TRAVEL ((sal_Int32)0x0008) 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir /// @deprecated 76*cdf0e10cSrcweir #define EBBF_NOROWPICTURE EBBF_NO_HANDLE_COLUMN_CONTENT 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir //================================================================== 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir class Edit; 81*cdf0e10cSrcweir class ListBoxFrame; 82*cdf0e10cSrcweir class ButtonCtrl; 83*cdf0e10cSrcweir class SpinField; 84*cdf0e10cSrcweir class FormattedField; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir // ....................................................................... 87*cdf0e10cSrcweir namespace svt 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir // ....................................................................... 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir class CellControllerRef; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir //================================================================== 94*cdf0e10cSrcweir //= CellController 95*cdf0e10cSrcweir //================================================================== 96*cdf0e10cSrcweir class SVT_DLLPUBLIC CellController : public SvRefBase 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir friend class EditBrowseBox; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir protected: 101*cdf0e10cSrcweir Control* pWindow; 102*cdf0e10cSrcweir sal_Bool bSuspended; // <sal_True> if the window is hidden and disabled 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir public: 105*cdf0e10cSrcweir TYPEINFO(); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir CellController(Control* pW); 108*cdf0e10cSrcweir virtual ~CellController(); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir Control& GetWindow() const { return *const_cast< CellController* >( this )->pWindow; } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir virtual void SetModified(); 113*cdf0e10cSrcweir virtual void ClearModified() = 0; 114*cdf0e10cSrcweir virtual sal_Bool IsModified() const = 0; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir // commit any current changes. Especially, do any reformatting you need (from input formatting 117*cdf0e10cSrcweir // to output formatting) here 118*cdf0e10cSrcweir // 95826 - 2002-10-14 - fs@openoffice.org 119*cdf0e10cSrcweir virtual void CommitModifications(); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir // suspending the controller is not culmulative! 122*cdf0e10cSrcweir void suspend( ); 123*cdf0e10cSrcweir void resume( ); 124*cdf0e10cSrcweir inline sal_Bool isSuspended( ) const { return bSuspended; } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir protected: 127*cdf0e10cSrcweir virtual sal_Bool MoveAllowed(const KeyEvent& rEvt) const; 128*cdf0e10cSrcweir virtual void SetModifyHdl(const Link& rLink) = 0; 129*cdf0e10cSrcweir virtual sal_Bool WantMouseEvent() const; 130*cdf0e10cSrcweir }; 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir SV_DECL_IMPL_REF(CellController); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir //================================================================== 135*cdf0e10cSrcweir //= IEditImplementation 136*cdf0e10cSrcweir //================================================================== 137*cdf0e10cSrcweir class IEditImplementation 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir public: 140*cdf0e10cSrcweir virtual Control& GetControl() = 0; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir virtual String GetText( LineEnd aSeparator ) const = 0; 143*cdf0e10cSrcweir virtual void SetText( const String& _rStr ) = 0; 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir virtual sal_Bool IsReadOnly() const = 0; 146*cdf0e10cSrcweir virtual void SetReadOnly( sal_Bool bReadOnly ) = 0; 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir virtual xub_StrLen GetMaxTextLen() const = 0; 149*cdf0e10cSrcweir virtual void SetMaxTextLen( xub_StrLen _nMaxLen ) = 0; 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir virtual Selection GetSelection() const = 0; 152*cdf0e10cSrcweir virtual void SetSelection( const Selection& _rSelection ) = 0; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir virtual void ReplaceSelected( const String& _rStr ) = 0; 155*cdf0e10cSrcweir virtual void DeleteSelected() = 0; 156*cdf0e10cSrcweir virtual String GetSelected( LineEnd aSeparator ) const = 0; 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir virtual void SetModified() = 0; 159*cdf0e10cSrcweir virtual sal_Bool IsModified() const = 0; 160*cdf0e10cSrcweir virtual void ClearModified() = 0; 161*cdf0e10cSrcweir virtual void SetModifyHdl( const Link& _rLink ) = 0; 162*cdf0e10cSrcweir }; 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir //================================================================== 165*cdf0e10cSrcweir //= GenericEditImplementation 166*cdf0e10cSrcweir //================================================================== 167*cdf0e10cSrcweir template <class EDIT> 168*cdf0e10cSrcweir class GenericEditImplementation : public IEditImplementation 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir EDIT& m_rEdit; 171*cdf0e10cSrcweir public: 172*cdf0e10cSrcweir GenericEditImplementation( EDIT& _rEdit ); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir EDIT& GetEditWindow() { return static_cast< EDIT& >( GetControl() ); } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir virtual Control& GetControl(); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir virtual String GetText( LineEnd aSeparator ) const; 179*cdf0e10cSrcweir virtual void SetText( const String& _rStr ); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir virtual sal_Bool IsReadOnly() const; 182*cdf0e10cSrcweir virtual void SetReadOnly( sal_Bool bReadOnly ); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir virtual xub_StrLen GetMaxTextLen() const; 185*cdf0e10cSrcweir virtual void SetMaxTextLen( xub_StrLen _nMaxLen ); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir virtual Selection GetSelection() const; 188*cdf0e10cSrcweir virtual void SetSelection( const Selection& _rSelection ); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir virtual void ReplaceSelected( const String& _rStr ); 191*cdf0e10cSrcweir virtual void DeleteSelected(); 192*cdf0e10cSrcweir virtual String GetSelected( LineEnd aSeparator ) const; 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir virtual void SetModified(); 195*cdf0e10cSrcweir virtual sal_Bool IsModified() const; 196*cdf0e10cSrcweir virtual void ClearModified(); 197*cdf0e10cSrcweir virtual void SetModifyHdl( const Link& _rLink ); 198*cdf0e10cSrcweir }; 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir #include <svtools/editimplementation.hxx> 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir //================================================================== 203*cdf0e10cSrcweir //= MultiLineTextCell 204*cdf0e10cSrcweir //================================================================== 205*cdf0e10cSrcweir /** a multi line edit which can be used in a cell of a EditBrowseBox 206*cdf0e10cSrcweir */ 207*cdf0e10cSrcweir class SVT_DLLPUBLIC MultiLineTextCell : public MultiLineEdit 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir public: 210*cdf0e10cSrcweir MultiLineTextCell( Window* _pParent, WinBits _nStyle ) 211*cdf0e10cSrcweir :MultiLineEdit( _pParent, _nStyle ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir protected: 216*cdf0e10cSrcweir // Window overridables 217*cdf0e10cSrcweir virtual long PreNotify( NotifyEvent& rNEvt ); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // MultiLineEdit overridables 220*cdf0e10cSrcweir virtual void Modify(); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir private: 223*cdf0e10cSrcweir sal_Bool dispatchKeyEvent( const KeyEvent& _rEvent ); 224*cdf0e10cSrcweir }; 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir //================================================================== 227*cdf0e10cSrcweir //= concrete edit implementations 228*cdf0e10cSrcweir //================================================================== 229*cdf0e10cSrcweir typedef GenericEditImplementation< Edit > EditImplementation; 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir typedef GenericEditImplementation< MultiLineTextCell > MultiLineEditImplementation_Base; 232*cdf0e10cSrcweir class SVT_DLLPUBLIC MultiLineEditImplementation : public MultiLineEditImplementation_Base 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir public: 235*cdf0e10cSrcweir MultiLineEditImplementation( MultiLineTextCell& _rEdit ) : MultiLineEditImplementation_Base( _rEdit ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir virtual String GetText( LineEnd aSeparator ) const; 240*cdf0e10cSrcweir virtual String GetSelected( LineEnd aSeparator ) const; 241*cdf0e10cSrcweir }; 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir //================================================================== 244*cdf0e10cSrcweir //= EditCellController 245*cdf0e10cSrcweir //================================================================== 246*cdf0e10cSrcweir class SVT_DLLPUBLIC EditCellController : public CellController 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir IEditImplementation* m_pEditImplementation; 249*cdf0e10cSrcweir sal_Bool m_bOwnImplementation; // did we create m_pEditImplementation? 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir public: 252*cdf0e10cSrcweir TYPEINFO(); 253*cdf0e10cSrcweir EditCellController( Edit* _pEdit ); 254*cdf0e10cSrcweir EditCellController( MultiLineTextCell* _pEdit ); 255*cdf0e10cSrcweir EditCellController( IEditImplementation* _pImplementation ); 256*cdf0e10cSrcweir ~EditCellController( ); 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir const IEditImplementation* GetEditImplementation( ) const { return m_pEditImplementation; } 259*cdf0e10cSrcweir IEditImplementation* GetEditImplementation( ) { return m_pEditImplementation; } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir virtual void SetModified(); 262*cdf0e10cSrcweir virtual sal_Bool IsModified() const; 263*cdf0e10cSrcweir virtual void ClearModified(); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir protected: 266*cdf0e10cSrcweir virtual sal_Bool MoveAllowed(const KeyEvent& rEvt) const; 267*cdf0e10cSrcweir virtual void SetModifyHdl(const Link& rLink); 268*cdf0e10cSrcweir }; 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir //================================================================== 271*cdf0e10cSrcweir //= SpinCellController 272*cdf0e10cSrcweir //================================================================== 273*cdf0e10cSrcweir class SVT_DLLPUBLIC SpinCellController : public CellController 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir public: 276*cdf0e10cSrcweir TYPEINFO(); 277*cdf0e10cSrcweir SpinCellController(SpinField* pSpinField); 278*cdf0e10cSrcweir SpinField& GetSpinWindow() const {return (SpinField &)GetWindow();} 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir virtual void SetModified(); 281*cdf0e10cSrcweir virtual sal_Bool IsModified() const; 282*cdf0e10cSrcweir virtual void ClearModified(); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir protected: 285*cdf0e10cSrcweir virtual sal_Bool MoveAllowed(const KeyEvent& rEvt) const; 286*cdf0e10cSrcweir virtual void SetModifyHdl(const Link& rLink); 287*cdf0e10cSrcweir }; 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir //================================================================== 290*cdf0e10cSrcweir //= CheckBoxControl 291*cdf0e10cSrcweir //================================================================== 292*cdf0e10cSrcweir class SVT_DLLPUBLIC CheckBoxControl : public Control 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir CheckBox* pBox; 295*cdf0e10cSrcweir Rectangle aFocusRect; 296*cdf0e10cSrcweir Link m_aClickLink,m_aModifyLink; 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir public: 299*cdf0e10cSrcweir CheckBoxControl(Window* pParent, WinBits nWinStyle = 0); 300*cdf0e10cSrcweir ~CheckBoxControl(); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir virtual void GetFocus(); 303*cdf0e10cSrcweir virtual long PreNotify(NotifyEvent& rEvt); 304*cdf0e10cSrcweir virtual void Paint(const Rectangle& rClientRect); 305*cdf0e10cSrcweir virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); 306*cdf0e10cSrcweir virtual void StateChanged( StateChangedType nStateChange ); 307*cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& _rEvent ); 308*cdf0e10cSrcweir virtual void Resize(); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir void SetClickHdl(const Link& rHdl) {m_aClickLink = rHdl;} 311*cdf0e10cSrcweir const Link& GetClickHdl() const {return m_aClickLink;} 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir void SetModifyHdl(const Link& rHdl) {m_aModifyLink = rHdl;} 314*cdf0e10cSrcweir const Link& GetModifyHdl() const {return m_aModifyLink;} 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir CheckBox& GetBox() {return *pBox;}; 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir private: 319*cdf0e10cSrcweir DECL_LINK( OnClick, void* ); 320*cdf0e10cSrcweir }; 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir //================================================================== 323*cdf0e10cSrcweir //= CheckBoxCellController 324*cdf0e10cSrcweir //================================================================== 325*cdf0e10cSrcweir class SVT_DLLPUBLIC CheckBoxCellController : public CellController 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir public: 328*cdf0e10cSrcweir TYPEINFO(); 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir CheckBoxCellController(CheckBoxControl* pWin):CellController(pWin){} 331*cdf0e10cSrcweir CheckBox& GetCheckBox() const; 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir virtual sal_Bool IsModified() const; 334*cdf0e10cSrcweir virtual void ClearModified(); 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir protected: 337*cdf0e10cSrcweir virtual void SetModifyHdl(const Link& rLink); 338*cdf0e10cSrcweir virtual sal_Bool WantMouseEvent() const; 339*cdf0e10cSrcweir }; 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir //================================================================== 342*cdf0e10cSrcweir //= ComboBoxControl 343*cdf0e10cSrcweir //================================================================== 344*cdf0e10cSrcweir class SVT_DLLPUBLIC ComboBoxControl : public ComboBox 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir friend class ComboBoxCellController; 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir public: 349*cdf0e10cSrcweir ComboBoxControl(Window* pParent, WinBits nWinStyle = 0); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir protected: 352*cdf0e10cSrcweir virtual long PreNotify( NotifyEvent& rNEvt ); 353*cdf0e10cSrcweir }; 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir //================================================================== 356*cdf0e10cSrcweir //= ComboBoxCellController 357*cdf0e10cSrcweir //================================================================== 358*cdf0e10cSrcweir class SVT_DLLPUBLIC ComboBoxCellController : public CellController 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir public: 361*cdf0e10cSrcweir TYPEINFO(); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir ComboBoxCellController(ComboBoxControl* pParent); 364*cdf0e10cSrcweir ComboBoxControl& GetComboBox() const {return (ComboBoxControl &)GetWindow();} 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir virtual sal_Bool IsModified() const; 367*cdf0e10cSrcweir virtual void ClearModified(); 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir protected: 370*cdf0e10cSrcweir virtual sal_Bool MoveAllowed(const KeyEvent& rEvt) const; 371*cdf0e10cSrcweir virtual void SetModifyHdl(const Link& rLink); 372*cdf0e10cSrcweir }; 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir //================================================================== 375*cdf0e10cSrcweir //= ListBoxControl 376*cdf0e10cSrcweir //================================================================== 377*cdf0e10cSrcweir class SVT_DLLPUBLIC ListBoxControl : public ListBox 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir friend class ListBoxCellController; 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir public: 382*cdf0e10cSrcweir ListBoxControl(Window* pParent, WinBits nWinStyle = 0); 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir protected: 385*cdf0e10cSrcweir virtual long PreNotify( NotifyEvent& rNEvt ); 386*cdf0e10cSrcweir }; 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir //================================================================== 389*cdf0e10cSrcweir //= ListBoxCellController 390*cdf0e10cSrcweir //================================================================== 391*cdf0e10cSrcweir class SVT_DLLPUBLIC ListBoxCellController : public CellController 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir public: 394*cdf0e10cSrcweir TYPEINFO(); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir ListBoxCellController(ListBoxControl* pParent); 397*cdf0e10cSrcweir ListBoxControl& GetListBox() const {return (ListBoxControl &)GetWindow();} 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir virtual sal_Bool IsModified() const; 400*cdf0e10cSrcweir virtual void ClearModified(); 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir protected: 403*cdf0e10cSrcweir virtual sal_Bool MoveAllowed(const KeyEvent& rEvt) const; 404*cdf0e10cSrcweir virtual void SetModifyHdl(const Link& rLink); 405*cdf0e10cSrcweir }; 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir //================================================================== 408*cdf0e10cSrcweir //= FormattedFieldCellController 409*cdf0e10cSrcweir //================================================================== 410*cdf0e10cSrcweir class SVT_DLLPUBLIC FormattedFieldCellController : public EditCellController 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir public: 413*cdf0e10cSrcweir TYPEINFO(); 414*cdf0e10cSrcweir FormattedFieldCellController( FormattedField* _pFormatted ); 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir virtual void CommitModifications(); 417*cdf0e10cSrcweir }; 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir //================================================================== 420*cdf0e10cSrcweir //= EditBrowserHeader 421*cdf0e10cSrcweir //================================================================== 422*cdf0e10cSrcweir class SVT_DLLPUBLIC EditBrowserHeader : public BrowserHeader 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir public: 425*cdf0e10cSrcweir EditBrowserHeader( BrowseBox* pParent, WinBits nWinBits = WB_BUTTONSTYLE ) 426*cdf0e10cSrcweir :BrowserHeader(pParent, nWinBits){} 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir protected: 429*cdf0e10cSrcweir virtual void DoubleClick(); 430*cdf0e10cSrcweir }; 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir //================================================================== 433*cdf0e10cSrcweir //= EditBrowseBox 434*cdf0e10cSrcweir //================================================================== 435*cdf0e10cSrcweir class EditBrowseBoxImpl; 436*cdf0e10cSrcweir class SVT_DLLPUBLIC EditBrowseBox: public BrowseBox 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir friend class EditBrowserHeader; 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir enum BrowseInfo 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir COLSELECT = 1, 443*cdf0e10cSrcweir ROWSELECT = 2, 444*cdf0e10cSrcweir ROWCHANGE = 4, 445*cdf0e10cSrcweir COLCHANGE = 8 446*cdf0e10cSrcweir }; 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir public: 449*cdf0e10cSrcweir enum RowStatus 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir CLEAN = 0, 452*cdf0e10cSrcweir CURRENT = 1, 453*cdf0e10cSrcweir CURRENTNEW = 2, 454*cdf0e10cSrcweir MODIFIED = 3, 455*cdf0e10cSrcweir NEW = 4, 456*cdf0e10cSrcweir DELETED = 5, 457*cdf0e10cSrcweir PRIMARYKEY = 6, 458*cdf0e10cSrcweir CURRENT_PRIMARYKEY = 7, 459*cdf0e10cSrcweir FILTER = 8, 460*cdf0e10cSrcweir HEADERFOOTER = 9 461*cdf0e10cSrcweir }; 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir private: 464*cdf0e10cSrcweir // forbid these ones 465*cdf0e10cSrcweir EditBrowseBox(EditBrowseBox&); 466*cdf0e10cSrcweir EditBrowseBox& operator=(EditBrowseBox&); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir class BrowserMouseEventPtr 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir BrowserMouseEvent* pEvent; 471*cdf0e10cSrcweir sal_Bool bDown; 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir public: 474*cdf0e10cSrcweir BrowserMouseEventPtr():pEvent(NULL){} 475*cdf0e10cSrcweir ~BrowserMouseEventPtr(){Clear();} 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir sal_Bool Is() const {return pEvent != NULL;} 478*cdf0e10cSrcweir sal_Bool IsDown() const {return bDown;} 479*cdf0e10cSrcweir const BrowserMouseEvent* operator->() const {return pEvent;} 480*cdf0e10cSrcweir const BrowserMouseEvent& operator*() const {return *pEvent;} 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir SVT_DLLPUBLIC void Clear(); 483*cdf0e10cSrcweir void Set(const BrowserMouseEvent* pEvt, sal_Bool bIsDown); 484*cdf0e10cSrcweir } aMouseEvent; 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir const BrowserMouseEvent* pMouseEvent; // is set during a mouse event 487*cdf0e10cSrcweir CellControllerRef aController, 488*cdf0e10cSrcweir aOldController; 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir sal_uLong nStartEvent, nEndEvent, nCellModifiedEvent; // event ids 491*cdf0e10cSrcweir Window* m_pFocusWhileRequest; 492*cdf0e10cSrcweir // In ActivateCell, we grab the focus asynchronously, but if between requesting activation 493*cdf0e10cSrcweir // and the asynchornous event the focus has changed, we won't grab it for ourself. 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir long nPaintRow; // row beeing painted 496*cdf0e10cSrcweir long nEditRow, nOldEditRow; 497*cdf0e10cSrcweir sal_uInt16 nEditCol, nOldEditCol; 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir sal_Bool bHasFocus : 1; 500*cdf0e10cSrcweir mutable sal_Bool bPaintStatus : 1; // paint a status (image) in the handle column 501*cdf0e10cSrcweir sal_Bool bActiveBeforeTracking; 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir CheckBoxControl* pCheckBoxPaint; 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir sal_Int32 m_nBrowserFlags; 506*cdf0e10cSrcweir ImageList m_aStatusImages; 507*cdf0e10cSrcweir ::std::auto_ptr< EditBrowseBoxImpl> m_aImpl; 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir protected: 510*cdf0e10cSrcweir BrowserHeader* pHeader; 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir sal_Bool isGetCellFocusPending() const { return nStartEvent != 0; } 513*cdf0e10cSrcweir void cancelGetCellFocus() { if (nStartEvent) Application::RemoveUserEvent(nStartEvent); nStartEvent = 0; } 514*cdf0e10cSrcweir void forceGetCellFocus() { cancelGetCellFocus(); LINK(this, EditBrowseBox, StartEditHdl).Call((void*)NULL); } 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir BrowserMouseEventPtr& getMouseEvent() { return aMouseEvent; } 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir protected: 519*cdf0e10cSrcweir BrowserHeader* GetHeaderBar() const {return pHeader;} 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir virtual BrowserHeader* CreateHeaderBar(BrowseBox* pParent); 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir // if you want to have an own header ... 524*cdf0e10cSrcweir virtual BrowserHeader* imp_CreateHeaderBar(BrowseBox* pParent); 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir virtual void ColumnMoved(sal_uInt16 nId); 527*cdf0e10cSrcweir virtual void ColumnResized(sal_uInt16 nColId); 528*cdf0e10cSrcweir virtual void Resize(); 529*cdf0e10cSrcweir virtual void ArrangeControls(sal_uInt16& nX, sal_uInt16 nY); 530*cdf0e10cSrcweir virtual sal_Bool SeekRow(long nRow); 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir virtual void GetFocus(); 533*cdf0e10cSrcweir virtual void LoseFocus(); 534*cdf0e10cSrcweir virtual void KeyInput(const KeyEvent& rEvt); 535*cdf0e10cSrcweir virtual void MouseButtonDown(const BrowserMouseEvent& rEvt); 536*cdf0e10cSrcweir virtual void MouseButtonUp(const BrowserMouseEvent& rEvt); 537*cdf0e10cSrcweir virtual void StateChanged( StateChangedType nType ); 538*cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir using BrowseBox::MouseButtonUp; 541*cdf0e10cSrcweir using BrowseBox::MouseButtonDown; 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir virtual long PreNotify(NotifyEvent& rNEvt ); 544*cdf0e10cSrcweir virtual long Notify(NotifyEvent& rNEvt); 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir virtual void EndScroll(); 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir // should be used instead of GetFieldRectPixel, 'cause this method here takes into account the borders 549*cdf0e10cSrcweir Rectangle GetCellRect(long nRow, sal_uInt16 nColId, sal_Bool bRelToBrowser = sal_True) const; 550*cdf0e10cSrcweir virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId); 551*cdf0e10cSrcweir virtual sal_uInt32 GetAutoColumnWidth(sal_uInt16 nColId); 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir virtual void PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const; 554*cdf0e10cSrcweir virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId) const = 0; 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir virtual RowStatus GetRowStatus(long nRow) const; 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir virtual void RowHeightChanged(); 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir // callbacks for the data window 561*cdf0e10cSrcweir virtual void ImplStartTracking(); 562*cdf0e10cSrcweir virtual void ImplTracking(); 563*cdf0e10cSrcweir virtual void ImplEndTracking(); 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir // when changing a row: 566*cdf0e10cSrcweir // CursorMoving: cursor is beeing moved, but GetCurRow() still provides the old row 567*cdf0e10cSrcweir virtual sal_Bool CursorMoving(long nNewRow, sal_uInt16 nNewCol); 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir // cursor has been moved 570*cdf0e10cSrcweir virtual void CursorMoved(); 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir virtual void CellModified(); // called whenever a cell has been modified 573*cdf0e10cSrcweir virtual sal_Bool SaveModified(); // called whenever a cell should be left, and it's content should be saved 574*cdf0e10cSrcweir // return sal_False prevents leaving the cell 575*cdf0e10cSrcweir virtual sal_Bool SaveRow(); // commit the current row 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir virtual sal_Bool IsModified() const {return aController.Is() && aController->IsModified();} 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir virtual CellController* GetController(long nRow, sal_uInt16 nCol); 580*cdf0e10cSrcweir virtual void InitController(CellControllerRef& rController, long nRow, sal_uInt16 nCol); 581*cdf0e10cSrcweir virtual void ResizeController(CellControllerRef& rController, const Rectangle&); 582*cdf0e10cSrcweir virtual void ReleaseController(CellControllerRef& pController, long nRow, sal_uInt16 nCol); 583*cdf0e10cSrcweir virtual void DoubleClick(const BrowserMouseEvent&); 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir void ActivateCell() { ActivateCell(GetCurRow(), GetCurColumnId()); } 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir // retrieve the image for the row status 588*cdf0e10cSrcweir virtual Image GetImage(RowStatus) const; 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir // inserting columns 591*cdf0e10cSrcweir // if you don't set a width, this will be calculated automatically 592*cdf0e10cSrcweir // if the id isn't set the smallest unused will do it ... 593*cdf0e10cSrcweir virtual sal_uInt16 AppendColumn(const String& rName, sal_uInt16 nWidth = 0, sal_uInt16 nPos = HEADERBAR_APPEND, sal_uInt16 nId = (sal_uInt16)-1); 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir // called whenever (Shift)Tab or Enter is pressed. If true is returned, these keys 596*cdf0e10cSrcweir // result in traveling to the next or to th previous cell 597*cdf0e10cSrcweir virtual sal_Bool IsTabAllowed(sal_Bool bForward) const; 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir virtual sal_Bool IsCursorMoveAllowed(long nNewRow, sal_uInt16 nNewColId) const; 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir void PaintTristate(OutputDevice& rDev, const Rectangle& rRect,const TriState& eState,sal_Bool _bEnabled=sal_True) const; 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir void AsynchGetFocus(); 604*cdf0e10cSrcweir // secure starting of StartEditHdl 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir public: 607*cdf0e10cSrcweir EditBrowseBox(Window* pParent, sal_Int32 nBrowserFlags = EBBF_NONE, WinBits nBits = WB_TABSTOP, BrowserMode nMode = 0 ); 608*cdf0e10cSrcweir EditBrowseBox(Window* pParent, const ResId& rId, sal_Int32 nBrowserFlags = EBBF_NONE, BrowserMode nMode = 0 ); 609*cdf0e10cSrcweir ~EditBrowseBox(); 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir sal_Bool IsEditing() const {return aController.Is();} 612*cdf0e10cSrcweir void InvalidateStatusCell(long nRow) {RowModified(nRow, 0);} 613*cdf0e10cSrcweir void InvalidateHandleColumn(); 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir // late construction 616*cdf0e10cSrcweir virtual void Init(); 617*cdf0e10cSrcweir virtual void RemoveRows(); 618*cdf0e10cSrcweir virtual void Dispatch(sal_uInt16 nId); 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir CellControllerRef Controller() const { return aController; } 621*cdf0e10cSrcweir sal_Int32 GetBrowserFlags() const { return m_nBrowserFlags; } 622*cdf0e10cSrcweir void SetBrowserFlags(sal_Int32 nFlags); 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir virtual void ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bSetCellFocus = sal_True); 625*cdf0e10cSrcweir virtual void DeactivateCell(sal_Bool bUpdate = sal_True); 626*cdf0e10cSrcweir // Children --------------------------------------------------------------- 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir /** Creates the accessible object of a data table cell. 629*cdf0e10cSrcweir @param nRow 630*cdf0e10cSrcweir The row index of the cell. 631*cdf0e10cSrcweir @param nColumnId 632*cdf0e10cSrcweir The column ID of the cell. 633*cdf0e10cSrcweir @return 634*cdf0e10cSrcweir The XAccessible interface of the specified cell. */ 635*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 636*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible > 637*cdf0e10cSrcweir CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnPos ); 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir /** @return The count of additional controls of the control area. */ 640*cdf0e10cSrcweir virtual sal_Int32 GetAccessibleControlCount() const; 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir /** Creates the accessible object of an additional control. 643*cdf0e10cSrcweir @param nIndex 644*cdf0e10cSrcweir The 0-based index of the control. 645*cdf0e10cSrcweir @return 646*cdf0e10cSrcweir The XAccessible interface of the specified control. */ 647*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 648*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible > 649*cdf0e10cSrcweir CreateAccessibleControl( sal_Int32 nIndex ); 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir /** Creates the accessible object of a column header. 652*cdf0e10cSrcweir @param nColumnId 653*cdf0e10cSrcweir The column ID of the header. 654*cdf0e10cSrcweir @return 655*cdf0e10cSrcweir The XAccessible interface of the specified column header. */ 656*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 657*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible > 658*cdf0e10cSrcweir CreateAccessibleRowHeader( sal_Int32 _nRow ); 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir /** Sets focus to current cell of the data table. */ 661*cdf0e10cSrcweir virtual void GrabTableFocus(); 662*cdf0e10cSrcweir 663*cdf0e10cSrcweir virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex); 664*cdf0e10cSrcweir virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint); 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 667*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible > CreateAccessibleCheckBoxCell(long _nRow, sal_uInt16 _nColumnPos,const TriState& eState,sal_Bool _bEnabled=sal_True); 668*cdf0e10cSrcweir protected: 669*cdf0e10cSrcweir // creates the accessible which wraps the active cell 670*cdf0e10cSrcweir void implCreateActiveAccessible( ); 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir private: 673*cdf0e10cSrcweir virtual void PaintField(OutputDevice& rDev, const Rectangle& rRect, 674*cdf0e10cSrcweir sal_uInt16 nColumnId ) const; 675*cdf0e10cSrcweir using Control::ImplInitSettings; 676*cdf0e10cSrcweir SVT_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); 677*cdf0e10cSrcweir SVT_DLLPRIVATE void DetermineFocus( const sal_uInt16 _nGetFocusFlags = 0); 678*cdf0e10cSrcweir inline void HideAndDisable(CellControllerRef& rController); 679*cdf0e10cSrcweir inline void EnableAndShow() const; 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir SVT_DLLPRIVATE void implActivateCellOnMouseEvent(const BrowserMouseEvent& _rEvt, sal_Bool _bUp); 682*cdf0e10cSrcweir SVT_DLLPRIVATE void impl_construct(); 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir DECL_DLLPRIVATE_LINK(ModifyHdl, void* ); 685*cdf0e10cSrcweir DECL_DLLPRIVATE_LINK(StartEditHdl, void* ); 686*cdf0e10cSrcweir DECL_DLLPRIVATE_LINK(EndEditHdl, void* ); 687*cdf0e10cSrcweir DECL_DLLPRIVATE_LINK(CellModifiedHdl, void* ); 688*cdf0e10cSrcweir }; 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir // ....................................................................... 691*cdf0e10cSrcweir } // namespace svt 692*cdf0e10cSrcweir // ....................................................................... 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir #undef SVTOOLS_IN_EDITBROWSEBOX_HXX 695*cdf0e10cSrcweir #endif // _SVTOOLS_EDITBROWSEBOX_HXX_ 696*cdf0e10cSrcweir 697