|
| 1 | +/* |
| 2 | + * Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 | + * (C) 2025 Vladimir Sadovnikov <sadko4u@gmail.com> |
| 4 | + * |
| 5 | + * This file is part of lsp-tk-lib |
| 6 | + * Created on: 15 мая 2025 г. |
| 7 | + * |
| 8 | + * lsp-tk-lib 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-tk-lib 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-tk-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 | + */ |
| 21 | + |
| 22 | +#ifndef LSP_PLUG_IN_TK_PROP_ENUM_WINDOWSTATE_H_ |
| 23 | +#define LSP_PLUG_IN_TK_PROP_ENUM_WINDOWSTATE_H_ |
| 24 | + |
| 25 | +namespace lsp |
| 26 | +{ |
| 27 | + namespace tk |
| 28 | + { |
| 29 | + /** |
| 30 | + * Border style class of window |
| 31 | + */ |
| 32 | + class WindowState: public Enum |
| 33 | + { |
| 34 | + protected: |
| 35 | + static const prop::enum_t ENUM[]; |
| 36 | + |
| 37 | + protected: |
| 38 | + explicit WindowState(prop::Listener *listener = NULL): Enum(ENUM, ws::BS_SINGLE, listener) {}; |
| 39 | + WindowState(const WindowState &) = delete; |
| 40 | + WindowState(WindowState &&) = delete; |
| 41 | + WindowState & operator = (const WindowState &) = delete; |
| 42 | + WindowState & operator = (WindowState &&) = delete; |
| 43 | + |
| 44 | + public: |
| 45 | + inline ws::window_state_t get() const { return ws::window_state_t(nValue); } |
| 46 | + inline ws::window_state_t set(ws::window_state_t v) |
| 47 | + { return ws::window_state_t(Enum::set(v)); }; |
| 48 | + |
| 49 | + inline bool minimized() const { return get() == ws::WS_MINIMIZED; } |
| 50 | + inline bool maximized() const { return get() == ws::WS_MAXIMIZED; } |
| 51 | + inline bool normal() const { return get() == ws::WS_NORMAL; } |
| 52 | + |
| 53 | + inline ws::window_state_t set_minimized() { return set(ws::WS_MINIMIZED); } |
| 54 | + inline ws::window_state_t set_maximized() { return set(ws::WS_MAXIMIZED); } |
| 55 | + inline ws::window_state_t set_normal() { return set(ws::WS_NORMAL); } |
| 56 | + }; |
| 57 | + |
| 58 | + namespace prop |
| 59 | + { |
| 60 | + class WindowState: public tk::WindowState |
| 61 | + { |
| 62 | + public: |
| 63 | + explicit WindowState(prop::Listener *listener = NULL): tk::WindowState(listener) {}; |
| 64 | + WindowState(const WindowState &) = delete; |
| 65 | + WindowState(WindowState &&) = delete; |
| 66 | + WindowState & operator = (const WindowState &) = delete; |
| 67 | + WindowState & operator = (WindowState &&) = delete; |
| 68 | + |
| 69 | + public: |
| 70 | + /** |
| 71 | + * Bind property with specified name to the style of linked widget |
| 72 | + */ |
| 73 | + inline status_t bind(atom_t property, Style *style) { return tk::WindowState::bind(property, style); } |
| 74 | + inline status_t bind(const char *property, Style *style) { return tk::WindowState::bind(property, style); } |
| 75 | + inline status_t bind(const LSPString *property, Style *style) { return tk::WindowState::bind(property, style); } |
| 76 | + |
| 77 | + /** |
| 78 | + * Unbind property |
| 79 | + */ |
| 80 | + inline status_t unbind() { return tk::WindowState::unbind(); }; |
| 81 | + |
| 82 | + /** |
| 83 | + * Change value without notification of any listener |
| 84 | + * @param value value to set |
| 85 | + */ |
| 86 | + inline void commit_value(ws::window_state_t state) { nValue = state; } |
| 87 | + |
| 88 | + inline void listener(prop::Listener *listener) { pListener = listener; } |
| 89 | + }; |
| 90 | + |
| 91 | + } /* namespace prop */ |
| 92 | + } /* namespace tk */ |
| 93 | +} /* namespace lsp */ |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | +#endif /* LSP_PLUG_IN_TK_PROP_ENUM_WINDOWSTATE_H_ */ |
0 commit comments