xref: /AOO41X/main/vcl/inc/vcl/floatwin.hxx (revision 47148b3bc50811ceb41802e4cc50a5db21535900)
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_FLOATWIN_HXX
25 #define _SV_FLOATWIN_HXX
26 
27 #include <vcl/sv.h>
28 #include <vcl/dllapi.h>
29 #include <vcl/syswin.hxx>
30 
31 class ToolBox;
32 class PopupModeEvent;
33 
34 // ------------------------
35 // - FloatingWindow-Types -
36 // ------------------------
37 
38 #define FLOATWIN_POPUPMODE_ALLOWTEAROFF         ((sal_uLong)0x00000001)
39 #define FLOATWIN_POPUPMODE_ANIMATIONSLIDE       ((sal_uLong)0x00000002)
40 #define FLOATWIN_POPUPMODE_NOAUTOARRANGE        ((sal_uLong)0x00000004)
41 #define FLOATWIN_POPUPMODE_NOANIMATION          ((sal_uLong)0x00000008)
42 #define FLOATWIN_POPUPMODE_DOWN                 ((sal_uLong)0x00000010)
43 #define FLOATWIN_POPUPMODE_UP                   ((sal_uLong)0x00000020)
44 #define FLOATWIN_POPUPMODE_LEFT                 ((sal_uLong)0x00000040)
45 #define FLOATWIN_POPUPMODE_RIGHT                ((sal_uLong)0x00000080)
46 #define FLOATWIN_POPUPMODE_NOFOCUSCLOSE         ((sal_uLong)0x00000100)
47 #define FLOATWIN_POPUPMODE_NOKEYCLOSE           ((sal_uLong)0x00000200)
48 #define FLOATWIN_POPUPMODE_NOMOUSECLOSE         ((sal_uLong)0x00000400)
49 #define FLOATWIN_POPUPMODE_NOMOUSERECTCLOSE     ((sal_uLong)0x00000800)
50 #define FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE  ((sal_uLong)0x00001000)
51 #define FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE      ((sal_uLong)0x00002000)
52 #define FLOATWIN_POPUPMODE_PATHMOUSECANCELCLICK ((sal_uLong)0x00004000)
53 #define FLOATWIN_POPUPMODE_NEWLEVEL             ((sal_uLong)0x00008000)
54 #define FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE       ((sal_uLong)0x00010000)
55 #define FLOATWIN_POPUPMODE_GRABFOCUS            ((sal_uLong)0x00020000)
56 
57 #define FLOATWIN_POPUPMODEEND_CANCEL            ((sal_uInt16)0x0001)
58 #define FLOATWIN_POPUPMODEEND_TEAROFF           ((sal_uInt16)0x0002)
59 #define FLOATWIN_POPUPMODEEND_DONTCALLHDL       ((sal_uInt16)0x0004)
60 #define FLOATWIN_POPUPMODEEND_CLOSEALL          ((sal_uInt16)0x0008)
61 
62 #define FLOATWIN_TITLE_NORMAL                   ((sal_uInt16)0x0001)
63 #define FLOATWIN_TITLE_TEAROFF                  ((sal_uInt16)0x0002)
64 #define FLOATWIN_TITLE_NONE                     ((sal_uInt16)0x0004)
65 
66 // ------------------
67 // - FloatingWindow -
68 // ------------------
69 
70 class VCL_DLLPUBLIC FloatingWindow : public SystemWindow
71 {
72     class   ImplData;
73 private:
74     FloatingWindow* mpNextFloat;
75     Window*         mpFirstPopupModeWin;
76     ImplData*       mpImplData;
77     Rectangle       maFloatRect;
78     sal_uLong           mnPostId;
79     sal_uLong           mnPopupModeFlags;
80     sal_uInt16          mnTitle;
81     sal_uInt16          mnOldTitle;
82     sal_Bool            mbInPopupMode;
83     sal_Bool            mbPopupMode;
84     sal_Bool            mbPopupModeCanceled;
85     sal_Bool            mbPopupModeTearOff;
86     sal_Bool            mbMouseDown;
87     sal_Bool            mbOldSaveBackMode;
88     sal_Bool            mbGrabFocus;    // act as key input window, although focus is not set
89     sal_Bool            mbInCleanUp;
90     Link            maPopupModeEndHdl;
91 
92 //#if 0 // _SOLAR__PRIVATE
93     SAL_DLLPRIVATE void    ImplCallPopupModeEnd();
94     DECL_DLLPRIVATE_LINK(  ImplEndPopupModeHdl, void* );
95 
96     // Copy assignment is forbidden and not implemented.
97     SAL_DLLPRIVATE         FloatingWindow (const FloatingWindow &);
98     SAL_DLLPRIVATE         FloatingWindow & operator= (const FloatingWindow &);
99 
100 protected:
101     using Window::ImplInit;
102     SAL_DLLPRIVATE void    ImplInit( Window* pParent, WinBits nStyle );
103     SAL_DLLPRIVATE void    ImplInitSettings();
104     SAL_DLLPRIVATE void    ImplLoadRes( const ResId& rResId );
105 
106 public:
107 #define IMPL_FLOATWIN_HITTEST_OUTSIDE       ((sal_uInt16)0x0001)
108 #define IMPL_FLOATWIN_HITTEST_WINDOW        ((sal_uInt16)0x0002)
109 #define IMPL_FLOATWIN_HITTEST_RECT          ((sal_uInt16)0x0004)
110     SAL_DLLPRIVATE FloatingWindow*  ImplFloatHitTest( Window* pReference, const Point& rPos, sal_uInt16& rHitTest );
111     SAL_DLLPRIVATE FloatingWindow*  ImplFindLastLevelFloat();
112     SAL_DLLPRIVATE sal_Bool             ImplIsFloatPopupModeWindow( const Window* pWindow );
ImplSetMouseDown()113     SAL_DLLPRIVATE void             ImplSetMouseDown() { mbMouseDown = sal_True; }
ImplIsMouseDown() const114     SAL_DLLPRIVATE sal_Bool             ImplIsMouseDown() const  { return mbMouseDown; }
115     SAL_DLLPRIVATE static Point     ImplCalcPos( Window* pWindow,
116                                                  const Rectangle& rRect, sal_uLong nFlags,
117                                                  sal_uInt16& rArrangeIndex );
118     SAL_DLLPRIVATE void             ImplEndPopupMode( sal_uInt16 nFlags = 0, sal_uLong nFocusId = 0 );
119     SAL_DLLPRIVATE Rectangle&       ImplGetItemEdgeClipRect();
ImplIsInPrivatePopupMode() const120     SAL_DLLPRIVATE sal_Bool             ImplIsInPrivatePopupMode() const { return mbInPopupMode; }
121 //#endif
122 
123 public:
124     explicit        FloatingWindow( Window* pParent, WinBits nStyle = WB_STDFLOATWIN );
125     explicit        FloatingWindow( Window* pParent, const ResId& );
126     virtual         ~FloatingWindow();
127 
128     virtual long    Notify( NotifyEvent& rNEvt );
129     virtual void    StateChanged( StateChangedType nType );
130     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
131 
132     virtual void    PopupModeEnd();
133 
134     void            SetTitleType( sal_uInt16 nTitle );
GetTitleType() const135     sal_uInt16          GetTitleType() const { return mnTitle; }
136 
137     void            StartPopupMode( const Rectangle& rRect, sal_uLong nFlags = 0 );
138     void            StartPopupMode( ToolBox* pBox, sal_uLong nFlags = 0  );
139     void            EndPopupMode( sal_uInt16 nFlags = 0 );
140     void            AddPopupModeWindow( Window* pWindow );
141     void            RemovePopupModeWindow( Window* pWindow );
GetPopupModeFlags() const142     sal_uLong           GetPopupModeFlags() const { return mnPopupModeFlags; }
SetPopupModeFlags(sal_uLong nFlags)143     void            SetPopupModeFlags( sal_uLong nFlags ) { mnPopupModeFlags = nFlags; }
IsInPopupMode() const144     sal_Bool            IsInPopupMode() const { return mbPopupMode; }
IsInCleanUp() const145     sal_Bool            IsInCleanUp() const { return mbInCleanUp; }
IsPopupModeCanceled() const146     sal_Bool            IsPopupModeCanceled() const { return mbPopupModeCanceled; }
IsPopupModeTearOff() const147     sal_Bool            IsPopupModeTearOff() const { return mbPopupModeTearOff; }
148 
SetPopupModeEndHdl(const Link & rLink)149     void            SetPopupModeEndHdl( const Link& rLink ) { maPopupModeEndHdl = rLink; }
GetPopupModeEndHdl() const150     const Link&     GetPopupModeEndHdl() const  { return maPopupModeEndHdl; }
151 
GrabsFocus() const152     sal_Bool            GrabsFocus() const { return mbGrabFocus; }
153 
154     static Point    CalcFloatingPosition( Window* pWindow, const Rectangle& rRect, sal_uLong nFlags, sal_uInt16& rArrangeIndex );
155 };
156 
157 #endif // _SV_FLOATWIN_HXX
158