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_FONTLB_HXX 25 #define SVX_FONTLB_HXX 26 27 #ifndef _SVTABBOX_HXX 28 #include <svtools/svtabbx.hxx> 29 #endif 30 #include <vcl/virdev.hxx> 31 #include "svx/svxdllapi.h" 32 #include <layout/layout.hxx> 33 34 // ============================================================================ 35 36 /** A list box string item which stores its text and font. */ 37 class SvLBoxFontString : public SvLBoxString 38 { 39 private: 40 Font maFont; /// The font used by this item. 41 bool mbUseColor; /// true = use font color, false = default listbox color. 42 43 public: 44 SvLBoxFontString(); 45 SvLBoxFontString( 46 SvLBoxEntry* pEntry, 47 sal_uInt16 nFlags, 48 const XubString& rString, 49 const Font& rFont, 50 const Color* pColor = NULL ); 51 52 virtual ~SvLBoxFontString(); 53 54 /** Creates a new empty list box item. */ 55 virtual SvLBoxItem* Create() const; 56 57 void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* ); 58 59 /** Paints this entry to the specified position, using the own font settings. */ 60 void Paint( 61 const Point& rPos, 62 SvLBox& rDev, 63 sal_uInt16 nFlags, 64 SvLBoxEntry* pEntry ); 65 }; 66 67 68 // ============================================================================ 69 70 /** A list box supporting formatted string entries. */ 71 class SVX_DLLPUBLIC SvxFontListBox : public SvTabListBox 72 { 73 private: 74 Font maStdFont; /// Used for entries without specific font. 75 76 // The following members are used to store additional parameters for InitEntry(). 77 Font maEntryFont; /// Current entry font used in InitEntry(). 78 const Color* mpEntryColor; /// Current entry color used in InitEntry(). 79 bool mbUseFont; /// true = Use maEntryFont/mpEntryColor in InitEntry(). 80 81 public: 82 SvxFontListBox( Window* pParent, const ResId& rResId ); 83 84 /** Inserts a list entry and sets the font used for this entry. 85 @param pColor The font color. NULL = use default listbox text color. */ 86 void InsertFontEntry( 87 const String& rString, const Font& rFont, const Color* pColor = NULL ); 88 89 /** Selects/deselects an entry specified by its position in the list box. */ 90 void SelectEntryPos( sal_uInt16 nPos, bool bSelect = true ); 91 /** Removes a selection. */ 92 void SetNoSelection(); 93 94 /** Returns the position of the entry currently selected or LIST_APPEND. */ 95 sal_uLong GetSelectEntryPos() const; 96 /** Returns the text of the selected entry or an empty string. */ 97 XubString GetSelectEntry() const; 98 99 protected: 100 /** Initializes a new SvLBoxFontString entry. 101 @descr Uses current value of maEntryFont to set the entry font (if mbUseFont is true). */ 102 virtual void InitEntry( 103 SvLBoxEntry* pEntry, 104 const XubString& rEntryText, 105 const Image& rCollImg, 106 const Image& rExpImg, 107 SvLBoxButtonKind eButtonKind ); 108 }; 109 110 #if ENABLE_LAYOUT 111 112 namespace layout 113 { 114 class SvxFontListBoxImpl; 115 class SVX_DLLPUBLIC SvxFontListBox : public ListBox 116 { 117 /*DECL_GET_IMPL( SvxFontListBox ); 118 DECL_CONSTRUCTORS( SvxFontListBox, ListBox, WB_BORDER ); 119 DECL_GET_WINDOW (SvxFontListBox);*/ 120 121 public: 122 SvxFontListBox( Context*, const char* ); 123 ~SvxFontListBox (); 124 sal_uInt16 InsertFontEntry (String const& entry, Font const& font, Color const* color=0); 125 }; 126 }; 127 128 #endif 129 130 131 // ============================================================================ 132 133 #endif 134 135