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