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_SVTOOLS_STDMENU_HXX
21 : #define INCLUDED_SVTOOLS_STDMENU_HXX
22 :
23 : #include <svtools/svtdllapi.h>
24 : #include <tools/link.hxx>
25 : #include <vcl/menu.hxx>
26 :
27 : class FontList;
28 : namespace vcl {
29 : class FontInfo;
30 : }
31 :
32 : /*************************************************************************
33 :
34 : Description
35 : ============
36 :
37 : class FontNameMenu
38 :
39 : Description
40 :
41 : Allows the selection of fonts. The menu is filled with the FontNames by
42 : the method Fill(). Fill() automatically sorts the FontNames (incl. all
43 : umlauts and language-dependent). Using SetCurName()/GetCurName(), the
44 : current FontName can be set/requested. If SetCurName() is called with
45 : an empty string, no entry is displayed as the current one.
46 : Before the Select call, the selected name is automatically set as the
47 : current one and would be displayed as the current name on the next call.
48 : Because of this, the current FontName should be set using SetCurName()
49 : if necessary before calling PopupMenu::Execute().
50 :
51 : As the Ids and the internal structure of the menu are not known, a
52 : Select handler must be set in order to notice the selection of a name.
53 :
54 : No further items can be inserted into that menu.
55 :
56 : Later on, the menu shall display the same bitmaps as the FontNameBox.
57 : On many systems, where menues don't scroll automatically, an A-Z menu
58 : might be interposed. As a menu has always needed long when many Fonts
59 : are installed, this menu should only be generated once.
60 :
61 : References
62 :
63 : FontList; FontSizeMenu; FontNameBox
64 :
65 : --------------------------------------------------------------------------
66 :
67 : class FontSizeMenu
68 :
69 : Description
70 :
71 : Allows the selection of font sizes. The FontSizeMenu is filled using
72 : Fill(). The selected font size can be queried using GetCurHeight().
73 : Using SetCurHeight()/GetCurHeight(), the current font size can be set/
74 : requested. If SetCurHeight() is called with 0, no entry is displayed
75 : as the current one.
76 : Before the Select call, the selected size is automatically set as the
77 : current one and would be displayed as the current size on the next call.
78 : Because of this, the current font size should be set using SetCurHeight()
79 : if necessary before calling PopupMenu::Execute(). As the font sizes
80 : depend on the selected Font, the Menu should be re-filled with the
81 : sizes of the font using Fill() after a change to the font name.
82 :
83 : As the Ids and the internal structure of the menu are not known, a
84 : Select handler must be set in order to notice the selection of a size.
85 :
86 : All sizes are given in 1/10 points.
87 :
88 : No further items can be inserted into that menu.
89 :
90 : Later on, the menu shall display the sizes in respect to the system.
91 : For example, Mac could possibly show an outline of the fonts that are
92 : available as bitmaps.
93 :
94 : References
95 :
96 : FontList; FontNameMenu; FontSizeBox
97 :
98 : *************************************************************************/
99 :
100 : class SVT_DLLPUBLIC FontNameMenu : public PopupMenu
101 : {
102 : private:
103 : OUString maCurName;
104 : Link<> maSelectHdl;
105 : Link<> maHighlightHdl;
106 :
107 : public:
108 : FontNameMenu();
109 : virtual ~FontNameMenu();
110 :
111 : virtual void Select() SAL_OVERRIDE;
112 : virtual void Highlight() SAL_OVERRIDE;
113 :
114 : void Fill( const FontList* pList );
115 :
116 : void SetCurName( const OUString& rName );
117 0 : const OUString& GetCurName() const { return maCurName; }
118 :
119 0 : void SetSelectHdl( const Link<>& rLink ) { maSelectHdl = rLink; }
120 : const Link<>& GetSelectHdl() const { return maSelectHdl; }
121 : void SetHighlightHdl( const Link<>& rLink ) { maHighlightHdl = rLink; }
122 : const Link<>& GetHighlightHdl() const { return maHighlightHdl; }
123 : };
124 :
125 : class SVT_DLLPUBLIC FontSizeMenu : public PopupMenu
126 : {
127 : private:
128 : long* mpHeightAry;
129 : long mnCurHeight;
130 : Link<> maSelectHdl;
131 : Link<> maHighlightHdl;
132 :
133 : public:
134 : FontSizeMenu();
135 : virtual ~FontSizeMenu();
136 :
137 : virtual void Select() SAL_OVERRIDE;
138 : virtual void Highlight() SAL_OVERRIDE;
139 :
140 : void Fill( const vcl::FontInfo& rInfo, const FontList* pList );
141 :
142 : void SetCurHeight( long nHeight );
143 0 : long GetCurHeight() const { return mnCurHeight; }
144 :
145 0 : void SetSelectHdl( const Link<>& rLink ) { maSelectHdl = rLink; }
146 : const Link<>& GetSelectHdl() const { return maSelectHdl; }
147 : void SetHighlightHdl( const Link<>& rLink ) { maHighlightHdl = rLink; }
148 : const Link<>& GetHighlightHdl() const { return maHighlightHdl; }
149 : };
150 :
151 : #endif // INCLUDED_SVTOOLS_STDMENU_HXX
152 :
153 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|