control.hpp (1511B)
1 /* ReaPack: Package manager for REAPER 2 * Copyright (C) 2015-2025 Christian Fillion 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef REAPACK_CONTROL_HPP 19 #define REAPACK_CONTROL_HPP 20 21 #ifdef _WIN32 22 # include <windows.h> 23 #else 24 # include <swell/swell.h> 25 #endif 26 27 class Dialog; 28 29 class Control { 30 public: 31 Control(HWND handle) : m_handle(handle) {} 32 virtual ~Control() = default; 33 34 HWND handle() const { return m_handle; } 35 36 protected: 37 friend Dialog; 38 39 virtual void onNotify(LPNMHDR, LPARAM) {} 40 virtual bool onContextMenu(HWND, int, int) { return false; } 41 42 private: 43 HWND m_handle; 44 }; 45 46 class InhibitControl { 47 public: 48 InhibitControl(Control *ctrl) : InhibitControl(ctrl->handle()) {} 49 InhibitControl(HWND handle) : m_handle(handle) { setRedraw(true); } 50 ~InhibitControl() { setRedraw(false); } 51 52 private: 53 void setRedraw(const bool inhibit); 54 55 HWND m_handle; 56 }; 57 58 #endif