xref: /AOO41X/main/svx/inc/svx/galctrl.hxx (revision 3334a7e6acdae9820fa1a6f556bb10129a8de6b2)
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 _SVX_GALCTRL_HXX_
25 #define _SVX_GALCTRL_HXX_
26 
27 #include <vcl/dialog.hxx>
28 #include <vcl/graph.hxx>
29 #include <vcl/fixed.hxx>
30 #include <vcl/group.hxx>
31 #include <vcl/button.hxx>
32 #include <vcl/lstbox.hxx>
33 #include <vcl/menu.hxx>
34 #include <vcl/edit.hxx>
35 #include <vcl/combobox.hxx>
36 #include <vcl/sound.hxx>
37 #include <svl/slstitm.hxx>
38 #include <svtools/transfer.hxx>
39 #include <svtools/valueset.hxx>
40 #include <svtools/brwbox.hxx>
41 #include <svtools/grfmgr.hxx>
42 #include "svx/galmisc.hxx"
43 #include "svx/svxdllapi.h"
44 
45 // ------------
46 // - Forwards -
47 // ------------
48 
49 class GalleryTheme;
50 class GalleryBrowser2;
51 
52 // ------------------
53 // - GalleryPreview -
54 // ------------------
55 
56 class SVX_DLLPUBLIC GalleryPreview : public Window, public DropTargetHelper, public DragSourceHelper
57 {
58 private:
59 
60     GraphicObject       aGraphicObj;
61     Rectangle           aPreviewRect;
62     GalleryTheme*       mpTheme;
63 
64     SVX_DLLPRIVATE sal_Bool             ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const;
65     SVX_DLLPRIVATE void                InitSettings();
66 
67     // Window
68     SVX_DLLPRIVATE virtual void         Paint(const Rectangle& rRect);
69     SVX_DLLPRIVATE virtual void         MouseButtonDown(const MouseEvent& rMEvt);
70     SVX_DLLPRIVATE virtual void     Command(const CommandEvent& rCEvt);
71     SVX_DLLPRIVATE virtual void     KeyInput( const KeyEvent& rKEvt );
72     SVX_DLLPRIVATE virtual void        DataChanged( const DataChangedEvent& rDCEvt );
73 
74 
75     // DropTargetHelper
76     SVX_DLLPRIVATE virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
77     SVX_DLLPRIVATE virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
78 
79     // DragSourceHelper
80     SVX_DLLPRIVATE virtual void     StartDrag( sal_Int8 nAction, const Point& rPosPixel );
81 
82                         DECL_LINK( MenuSelectHdl, Menu* );
83 
84 public:
85 
86                         GalleryPreview( GalleryBrowser2* pParent, GalleryTheme* pTheme );
87                         GalleryPreview( Window* pParent, const ResId& rResId  );
88                         ~GalleryPreview();
89 
SetGraphic(const Graphic & rGraphic)90     void                SetGraphic( const Graphic& rGraphic ) { aGraphicObj.SetGraphic( rGraphic ); }
91     bool                SetGraphic( const INetURLObject& );
92     void                PreviewMedia( const INetURLObject& rURL );
93 };
94 
95 // -------------------
96 // - GalleryIconView -
97 // -------------------
98 
99 class GalleryIconView : public ValueSet, public DropTargetHelper, public DragSourceHelper
100 {
101     using ValueSet::StartDrag;
102 
103 private:
104 
105     GalleryTheme*       mpTheme;
106 
107     void                InitSettings();
108 
109     // ValueSet
110     virtual void        UserDraw( const UserDrawEvent& rUDEvt );
111 
112     // Window
113     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
114     virtual void        Command( const CommandEvent& rCEvt );
115     virtual void        KeyInput( const KeyEvent& rKEvt );
116     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
117 
118     // DropTargetHelper
119     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt );
120     virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt );
121 
122     // DragSourceHelper
123     virtual void        StartDrag( sal_Int8 nAction, const Point& rPosPixel );
124 
125 public:
126 
127                         GalleryIconView( GalleryBrowser2* pParent, GalleryTheme* pTheme );
128                         ~GalleryIconView();
129 };
130 
131 // -------------------
132 // - GalleryListView -
133 // -------------------
134 
135 class GalleryListView : public BrowseBox
136 {
137     using BrowseBox::AcceptDrop;
138     using BrowseBox::ExecuteDrop;
139 
140 private:
141 
142     Link                maSelectHdl;
143     GalleryTheme*       mpTheme;
144     sal_uIntPtr               mnCurRow;
145     sal_Bool                mbInit;
146 
147     void                InitSettings();
148 
149     // BrowseBox
150     virtual sal_Bool        SeekRow( long nRow );
151     virtual void        PaintField( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const;
152     virtual void        DoubleClick( const BrowserMouseEvent& rEvt );
153     virtual void        Select();
154     virtual sal_Int8    AcceptDrop( const BrowserAcceptDropEvent& rEvt );
155     virtual sal_Int8    ExecuteDrop( const BrowserExecuteDropEvent& rEvt );
156     virtual void        KeyInput( const KeyEvent& rKEvt );
157 
158     // Window
159     virtual void        Command( const CommandEvent& rCEvt );
160     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
161 
162     // DragSourceHelper
163     virtual void        StartDrag( sal_Int8 nAction, const Point& rPosPixel );
164 
165 public:
166 
167                         GalleryListView( GalleryBrowser2* pParent, GalleryTheme* pTheme );
168                         ~GalleryListView();
169 
SetSelectHdl(const Link & rSelectHdl)170     void                SetSelectHdl( const Link& rSelectHdl ) { maSelectHdl = rSelectHdl; }
171 
172     /** GetCellText returns the text at the given position
173         @param  _nRow
174             the number of the row
175         @param  _nColId
176             the ID of the column
177         @return
178             the text out of the cell
179     */
180     virtual String  GetCellText(long _nRow, sal_uInt16 _nColId) const;
181 
182     // from IAccessibleTableProvider
183     virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex);
184     virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint);
185 };
186 
187 #endif // _SVX_GALCTRL_HXX_
188