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: 23 окт. 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_WIDGETS_LSPHYPERLINK_H_ 23 #define UI_TK_WIDGETS_LSPHYPERLINK_H_ 24 25 namespace lsp 26 { 27 namespace tk 28 { 29 class LSPHyperlink: public LSPLabel 30 { 31 public: 32 static const w_class_t metadata; 33 34 protected: 35 enum state_t 36 { 37 F_MOUSE_IN = 1 << 0, 38 F_MOUSE_DOWN = 1 << 1, 39 F_MOUSE_IGN = 1 << 2, 40 }; 41 42 protected: 43 LSPColor sHoverColor; 44 LSPString sUrl; 45 size_t nMFlags; 46 bool bFollow; 47 size_t nState; 48 LSPMenu sStdMenu; 49 LSPMenuItem *vStdItems[2]; 50 LSPMenu *pPopup; 51 52 protected: 53 static status_t slot_on_submit(LSPWidget *sender, void *ptr, void *data); 54 static status_t slot_copy_link_action(LSPWidget *sender, void *ptr, void *data); 55 56 public: 57 explicit LSPHyperlink(LSPDisplay *dpy); 58 virtual ~LSPHyperlink(); 59 60 virtual status_t init(); 61 62 virtual void destroy(); 63 64 public: url()65 inline const char *url() const { return sUrl.get_native(); } get_url(LSPString * dst)66 inline status_t get_url(LSPString *dst) const { return (dst->set(&sUrl)) ? STATUS_OK : STATUS_NO_MEM; }; hover()67 inline LSPColor *hover() { return &sHoverColor; } follow()68 inline bool follow() const { return bFollow; } popup()69 LSPMenu *popup() { return pPopup; } 70 71 public: 72 status_t set_url(const char *url); 73 74 status_t set_url(const LSPString *url); 75 76 void set_follow(bool follow = true); 77 78 status_t follow_url(); 79 80 status_t copy_url(clipboard_id_t cb); 81 set_popup(LSPMenu * popup)82 inline void set_popup(LSPMenu *popup) { pPopup = popup; } 83 84 public: 85 virtual void draw(ISurface *s); 86 87 virtual status_t on_mouse_in(const ws_event_t *e); 88 89 virtual status_t on_mouse_out(const ws_event_t *e); 90 91 virtual status_t on_mouse_move(const ws_event_t *e); 92 93 virtual status_t on_mouse_down(const ws_event_t *e); 94 95 virtual status_t on_mouse_up(const ws_event_t *e); 96 97 virtual status_t on_submit(); 98 99 }; 100 101 } /* namespace tk */ 102 } /* namespace lsp */ 103 104 #endif /* UI_TK_WIDGETS_LSPHYPERLINK_H_ */ 105