reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

menu.hpp (1570B)


      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_MENU_HPP
     19 #define REAPACK_MENU_HPP
     20 
     21 #include <string>
     22 
     23 #ifdef _WIN32
     24 #  include <windows.h>
     25 #else
     26 #  include <swell/swell-types.h>
     27 #endif
     28 
     29 class Menu {
     30 public:
     31   Menu(HMENU handle = nullptr);
     32   ~Menu();
     33 
     34   UINT size() { return m_size; }
     35   bool empty() const { return m_size == 0; }
     36 
     37   UINT addAction(const std::string &label, int commandId);
     38   UINT addAction(const std::string &label, const char *namedCommand);
     39   void addSeparator();
     40   Menu addMenu(const std::string &label);
     41 
     42   int show(int x, int y, HWND parent) const;
     43   int show(HWND control, HWND parent) const;
     44 
     45   void enable(UINT);
     46   void disable(UINT);
     47   void setEnabled(bool, UINT);
     48 
     49   void check(UINT);
     50   void checkRadio(UINT);
     51 
     52 private:
     53   void append(MENUITEMINFO &);
     54 
     55   HMENU m_handle;
     56   bool m_ownership;
     57   UINT m_size;
     58 };
     59 
     60 #endif