1 /*
2  * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3  *           (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
4  *
5  * This file is part of lsp-plugins
6  * Created on: 6 июл. 2017 г.
7  *
8  * lsp-plugins is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * any later version.
12  *
13  * lsp-plugins is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef UI_TK_LSPLABEL_H_
23 #define UI_TK_LSPLABEL_H_
24 
25 namespace lsp
26 {
27     namespace tk
28     {
29         class LSPLabel: public LSPWidget
30         {
31             public:
32                 static const w_class_t    metadata;
33 
34             protected:
35                 float               fVAlign;
36                 float               fHAlign;
37                 LSPFont             sFont;
38                 LSPLocalString      sText;
39                 ssize_t             nBorder;
40                 ssize_t             nMinWidth;
41                 ssize_t             nMinHeight;
42 
43             protected:
44                 void    query_safe_resize();
45 
46             public:
47                 explicit LSPLabel(LSPDisplay *dpy);
48                 virtual ~LSPLabel();
49 
50                 virtual status_t init();
51 
52                 virtual void destroy();
53 
54             public:
55                 /** Get font
56                  *
57                  * @return font
58                  */
font()59                 inline LSPFont             *font()  { return &sFont; }
60 
61                 /**
62                  * Get text
63                  * @return
64                  */
text()65                 inline LSPLocalString      *text()  { return &sText; };
text()66                 inline const LSPLocalString  *text() const      { return &sText; }
67 
68                 /** Get vertical alignment
69                  *
70                  * @return vertical alignment
71                  */
valign()72                 inline float                valign() const { return fVAlign; }
73 
74                 /** Get horizontal alignment
75                  *
76                  * @return horizontal alignment
77                  */
halign()78                 inline float                halign() const { return fHAlign; }
79 
80                 /** Get border
81                  *
82                  * @return border
83                  */
border()84                 inline float                border() const { return nBorder; }
85 
86             public:
87                 void set_valign(float align);
88 
89                 void set_halign(float align);
90 
91                 void set_align(float halign, float valign);
92 
93                 void set_border(float border);
94 
95                 void                        set_min_width(ssize_t value);
96                 void                        set_min_height(ssize_t value);
97 
min_width()98                 inline ssize_t              min_width() const       { return nMinWidth;     }
min_height()99                 inline ssize_t              min_height() const      { return nMinHeight;    }
100 
101             public:
102                 virtual void draw(ISurface *s);
103 
104                 virtual void size_request(size_request_t *r);
105         };
106 
107     } /* namespace tk */
108 } /* namespace lsp */
109 
110 #endif /* UI_TK_LSPLABEL_H_ */
111