xref: /AOO41X/main/svtools/inc/svtools/expander.hxx (revision 01aa44aa134af97080e2cf8e8bf3a0a4cd1cffe0)
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 
23 
24 #ifndef _SV_EXPANDER_HXX
25 #define _SV_EXPANDER_HXX
26 
27 #include <vcl/ctrl.hxx>
28 #include <vcl/image.hxx>
29 
30 enum SvExpanderStateType
31 {
32     EST_MIN=1,
33     EST_PLUS=2,
34     EST_MIN_DOWN=3,
35     EST_PLUS_DOWN=4,
36     EST_NONE=5,
37     EST_MIN_DIS=6,
38     EST_PLUS_DIS=7,
39     EST_MIN_DOWN_DIS=8,
40     EST_PLUS_DOWN_DIS=9
41 };
42 
43 class SvExpander: public Control
44 {
45 private:
46         Point                   aImagePos;
47         Point                   aTextPos;
48         Image                   aActiveImage;
49         Rectangle               maFocusRect;
50         ImageList               maExpanderImages;
51         sal_Bool                    mbIsExpanded;
52         sal_Bool                    mbHasFocusRect;
53         sal_Bool                    mbIsInMouseDown;
54         Link                    maToggleHdl;
55         SvExpanderStateType eType;
56 
57 protected:
58 
59         virtual long    PreNotify( NotifyEvent& rNEvt );
60         virtual void    MouseButtonDown( const MouseEvent& rMEvt );
61         virtual void    MouseMove( const MouseEvent& rMEvt );
62         virtual void    MouseButtonUp( const MouseEvent& rMEvt );
63         virtual void    Paint( const Rectangle& rRect );
64         virtual void    KeyInput( const KeyEvent& rKEvt );
65         virtual void    KeyUp( const KeyEvent& rKEvt );
66 
67         virtual void    Click();
68         virtual void    Resize();
69 
70 public:
71         SvExpander( Window* pParent, WinBits nStyle = 0 );
72         SvExpander( Window* pParent, const ResId& rResId );
73 
IsExpanded()74         sal_Bool            IsExpanded() {return mbIsExpanded;}
75 
76         void            SetToExpanded(sal_Bool bFlag=sal_True);
77 
78         void            SetExpanderImage( SvExpanderStateType eType);
79         Image           GetExpanderImage(SvExpanderStateType eType);
80         Size            GetMinSize() const;
81 
SetToggleHdl(const Link & rLink)82         void            SetToggleHdl( const Link& rLink ) { maToggleHdl = rLink; }
GetToggleHdl() const83         const Link&     GetToggleHdl() const { return maToggleHdl; }
84 };
85 
86 
87 
88 #endif
89