Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SVX_FONTLB_HXX
21 : #define INCLUDED_SVX_FONTLB_HXX
22 :
23 : #include <svtools/svtabbx.hxx>
24 : #include <svtools/svlbitm.hxx>
25 : #include <vcl/virdev.hxx>
26 : #include <svx/svxdllapi.h>
27 :
28 :
29 :
30 : /** A list box string item which stores its text and font. */
31 : class SvLBoxFontString : public SvLBoxString
32 : {
33 : private:
34 : vcl::Font maFont; /// The font used by this item.
35 : bool mbUseColor; /// true = use font color, false = default listbox color.
36 :
37 : public:
38 : SvLBoxFontString();
39 : SvLBoxFontString(
40 : SvTreeListEntry* pEntry,
41 : sal_uInt16 nFlags,
42 : const OUString& rString,
43 : const vcl::Font& rFont,
44 : const Color* pColor = NULL );
45 :
46 : virtual ~SvLBoxFontString();
47 :
48 : /** Creates a new empty list box item. */
49 : virtual SvLBoxItem* Create() const SAL_OVERRIDE;
50 :
51 : void InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* ) SAL_OVERRIDE;
52 :
53 : /** Paints this entry to the specified position, using the own font settings. */
54 : virtual void Paint(
55 : const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) SAL_OVERRIDE;
56 : };
57 :
58 :
59 :
60 :
61 : /** A list box supporting formatted string entries. */
62 0 : class SVX_DLLPUBLIC SvxFontListBox : public SvTabListBox
63 : {
64 : private:
65 : vcl::Font maStdFont; /// Used for entries without specific font.
66 :
67 : // The following members are used to store additional parameters for InitEntry().
68 : vcl::Font maEntryFont; /// Current entry font used in InitEntry().
69 : const Color* mpEntryColor; /// Current entry color used in InitEntry().
70 : bool mbUseFont; /// true = Use maEntryFont/mpEntryColor in InitEntry().
71 :
72 : public:
73 : SvxFontListBox(vcl::Window* pParent, WinBits nStyle = WB_BORDER);
74 :
75 : /** Inserts a list entry and sets the font used for this entry.
76 : @param pColor The font color. NULL = use default listbox text color. */
77 : void InsertFontEntry(
78 : const OUString& rString, const vcl::Font& rFont, const Color* pColor = NULL );
79 :
80 : /** Selects/deselects an entry specified by its position in the list box. */
81 : void SelectEntryPos( sal_uLong nPos, bool bSelect = true );
82 : /** Removes a selection. */
83 : void SetNoSelection();
84 :
85 : /** Returns the position of the entry currently selected or TREELIST_APPEND.
86 : */
87 : sal_uLong GetSelectEntryPos() const;
88 : /** Returns the text of the selected entry or an empty string. */
89 : OUString GetSelectEntry() const;
90 :
91 : protected:
92 : /** Initializes a new SvLBoxFontString entry.
93 : @descr Uses current value of maEntryFont to set the entry font (if mbUseFont is true). */
94 : virtual void InitEntry(
95 : SvTreeListEntry* pEntry,
96 : const OUString& rEntryText,
97 : const Image& rCollImg,
98 : const Image& rExpImg,
99 : SvLBoxButtonKind eButtonKind) SAL_OVERRIDE;
100 : };
101 :
102 :
103 :
104 : #endif
105 :
106 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|