1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #ifndef _SV_SPLIT_HXX 23 #define _SV_SPLIT_HXX 24 25 #include <vcl/sv.h> 26 #include <vcl/dllapi.h> 27 #include <vcl/window.hxx> 28 29 #define SPLITTER_DEFAULTSTEPSIZE 0xFFFF 30 31 // ------------ 32 // - Splitter - 33 // ------------ 34 35 class VCL_DLLPUBLIC Splitter : public Window 36 { 37 private: 38 Window* mpRefWin; 39 long mnSplitPos; 40 long mnLastSplitPos; 41 long mnStartSplitPos; 42 Point maDragPos; 43 Rectangle maDragRect; 44 sal_Bool mbHorzSplit; 45 sal_Bool mbDragFull; 46 sal_Bool mbKbdSplitting; 47 long mbInKeyEvent; 48 long mnKeyboardStepSize; 49 Link maStartSplitHdl; 50 Link maSplitHdl; 51 Link maEndSplitHdl; 52 53 SAL_DLLPRIVATE void ImplInitSplitterData(); 54 SAL_DLLPRIVATE void ImplDrawSplitter(); 55 SAL_DLLPRIVATE void ImplSplitMousePos( Point& rPos ); 56 SAL_DLLPRIVATE void ImplStartKbdSplitting(); 57 SAL_DLLPRIVATE void ImplKbdTracking( KeyCode aKeyCode ); 58 SAL_DLLPRIVATE sal_Bool ImplSplitterActive(); 59 SAL_DLLPRIVATE Splitter* ImplFindSibling(); 60 SAL_DLLPRIVATE void ImplRestoreSplitter(); 61 SAL_DLLPRIVATE void ImplInitHorVer(bool bNew); 62 63 // Copy assignment is forbidden and not implemented. 64 SAL_DLLPRIVATE Splitter (const Splitter &); 65 SAL_DLLPRIVATE Splitter& operator= (const Splitter &); 66 67 protected: 68 using Window::ImplInit; 69 SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nWinStyle ); 70 71 public: 72 explicit Splitter( Window* pParent, WinBits nStyle = WB_VSCROLL ); 73 explicit Splitter( Window* pParent, const ResId& ); 74 virtual ~Splitter(); 75 76 virtual void StartSplit(); 77 virtual void EndSplit(); 78 virtual void Split(); 79 virtual void Splitting( Point& rSplitPos ); 80 81 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 82 virtual void Tracking( const TrackingEvent& rTEvt ); 83 84 virtual long Notify( NotifyEvent& rNEvt ); 85 86 virtual void GetFocus(); 87 virtual void LoseFocus(); 88 virtual void KeyInput( const KeyEvent& rKEvt ); 89 virtual void Paint( const Rectangle& rPaintRect ); 90 91 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 92 93 void StartDrag(); 94 95 void SetDragRectPixel( const Rectangle& rDragRect, 96 Window* pRefWin = NULL ); GetDragRectPixel() const97 const Rectangle& GetDragRectPixel() const { return maDragRect; } GetDragWindow() const98 Window* GetDragWindow() const { return mpRefWin; } 99 100 virtual void SetSplitPosPixel( long nPos ); GetSplitPosPixel() const101 long GetSplitPosPixel() const { return mnSplitPos; } 102 103 void SetLastSplitPosPixel( long nNewPos ); GetLastSplitPosPixel() const104 long GetLastSplitPosPixel() const { return mnLastSplitPos; } 105 IsHorizontal() const106 sal_Bool IsHorizontal() const { return mbHorzSplit; } 107 void SetHorizontal(bool bNew); 108 109 // set the stepsize of the splitter for cursor movement 110 // the default is 10% of the reference window's width/height 111 void SetKeyboardStepSize( long nStepSize ); 112 long GetKeyboardStepSize() const; 113 SetStartSplitHdl(const Link & rLink)114 void SetStartSplitHdl( const Link& rLink ) { maStartSplitHdl = rLink; } GetStartSplitHdl() const115 const Link& GetStartSplitHdl() const { return maStartSplitHdl; } SetSplitHdl(const Link & rLink)116 void SetSplitHdl( const Link& rLink ) { maSplitHdl = rLink; } SetEndSplitHdl(const Link & rLink)117 void SetEndSplitHdl( const Link& rLink ) { maEndSplitHdl = rLink; } GetEndSplitHdl() const118 const Link& GetEndSplitHdl() const { return maEndSplitHdl; } GetSplitHdl() const119 const Link& GetSplitHdl() const { return maSplitHdl; } 120 }; 121 122 #endif // _SV_SPLIT_HXX 123 124