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: 17 июл. 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_LSPGROUP_H_
23 #define UI_TK_LSPGROUP_H_
24 
25 namespace lsp
26 {
27     namespace tk
28     {
29         class LSPGroup: public LSPWidgetContainer
30         {
31             public:
32                 static const w_class_t    metadata;
33 
34             protected:
35                 typedef struct dimensions_t
36                 {
37                     size_t      nGapLeft;
38                     size_t      nGapTop;
39                     size_t      nGapRight;
40                     size_t      nGapBottom;
41                     size_t      nMinWidth;
42                     size_t      nMinHeight;
43                 } dimensions_t;
44 
45             protected:
46                 LSPLocalString  sText;
47                 LSPColor        sColor;
48                 size_t          nRadius;
49                 size_t          nBorder;
50                 LSPWidget      *pWidget;
51                 LSPFont         sFont;
52                 bool            bEmbed;
53 
54             protected:
55                 virtual LSPWidget  *find_widget(ssize_t x, ssize_t y);
56                 void                query_dimensions(dimensions_t *d);
57                 void                do_destroy();
58 
59             public:
text()60                 inline LSPLocalString *text()               { return &sText; }
text()61                 inline const LSPLocalString *text() const   { return &sText; }
color()62                 inline LSPColor    *color()                 { return &sColor; }
text_color()63                 inline LSPColor    *text_color()            { return sFont.color(); }
radius()64                 inline size_t       radius() const          { return nRadius; }
border()65                 inline size_t       border() const          { return nBorder; }
font()66                 inline LSPFont     *font()                  { return &sFont; }
embed()67                 inline bool         embed() const           { return bEmbed; }
68 
69             public:
70                 void                set_radius(size_t value);
71                 void                set_border(size_t value);
72                 void                set_embed(bool embed);
73 
74             public:
75                 explicit LSPGroup(LSPDisplay *dpy);
76                 virtual ~LSPGroup();
77 
78                 virtual status_t init();
79                 virtual void destroy();
80 
81             public:
82                 virtual void render(ISurface *s, bool force);
83 
84                 virtual status_t add(LSPWidget *widget);
85 
86                 virtual status_t remove(LSPWidget *widget);
87 
88                 virtual void size_request(size_request_t *r);
89 
90                 virtual void realize(const realize_t *r);
91         };
92 
93     } /* namespace tk */
94 } /* namespace lsp */
95 
96 #endif /* UI_TK_LSPGROUP_H_ */
97