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_SIDEBAR_VALUESETWITHTEXT_CONTROL_HXX_
23 #define _SVX_SIDEBAR_VALUESETWITHTEXT_CONTROL_HXX_
24 
25 #include "svx/svxdllapi.h"
26 
27 #include <svtools/valueset.hxx>
28 
29 #include <vcl/image.hxx>
30 
31 #include <vector>
32 
33 namespace svx { namespace sidebar {
34 
35 /** Specialization of class <ValueSet>.
36     This specialization allows is a one-columned ValueSet which allow
37     items containing an image and a text or a text and a second text.
38 
39     Especially, used for sidebar related controls.
40 */
41 class SVX_DLLPUBLIC ValueSetWithTextControl : public ValueSet
42 {
43 public:
44     // control type of specialized <ValueSet>:
45     // - image + text
46     // - text + text
47     enum tControlType
48     {
49         IMAGE_TEXT,
50         TEXT_TEXT
51     };
52 
53     ValueSetWithTextControl(
54         const tControlType eControlType,
55         Window* pParent,
56         const ResId& rResId);
57 
58     virtual ~ValueSetWithTextControl(void);
59 
60     // add item for control type IMAGE_TEXT
61     // if control type does not match IMAGE_TEXT no item is added.
62     // @param pSelectedItemImage
63     // selection item image is optional. if not provided, it is the same as the image item
64     // @param pItemHelpText
65     // help text is optional. if not provided, it is the same as the item text
66     void AddItem(
67         const Image& rItemImage,
68         const Image* pSelectedItemImage,
69         const XubString& rItemText,
70         const XubString* pItemHelpText );
71 
72     // replace item images for control type IMAGE_TEXT
73     void ReplaceItemImages(
74         const sal_uInt16 nItemId,
75         const Image& rItemImage,
76         const Image* pSelectedItemImage );
77 
78     // add item for control type TEXT_TEXT
79     // if control type does not match TEXT_TEXT no item is added.
80     // @param pItemHelpText
81     // help text is optional. if not provided, it is the same as the item text
82     void AddItem(
83         const XubString& rItemText,
84         const XubString& rItemText2,
85         const XubString* pItemHelpText );
86 
87     virtual void UserDraw( const UserDrawEvent& rUDEvt );
88 
89 private:
90     struct ValueSetWithTextItem
91     {
92         Image maItemImage;
93         Image maSelectedItemImage;
94         XubString maItemText;
95         XubString maItemText2;
96     };
97 
98     typedef ::std::vector< ValueSetWithTextItem > tItemList;
99 
100     const tControlType meControlType;
101     tItemList maItems;
102 };
103 
104 } } // end of namespace svx::sidebar
105 
106 #endif
107