ASPiK SDK
icommand.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #pragma once
6 
7 #include "../../lib/cstring.h"
8 #include "interface.h"
9 
10 //------------------------------------------------------------------------
11 namespace VSTGUI {
12 namespace Standalone {
13 
14 //------------------------------------------------------------------------
24 struct Command
25 {
26  UTF8String group;
27  UTF8String name;
28 };
29 
30 //------------------------------------------------------------------------
31 inline bool operator== (const Command& c1, const Command& c2)
32 {
33  return c1.group == c2.group && c1.name == c2.name;
34 }
35 
36 //------------------------------------------------------------------------
37 inline bool operator!= (const Command& c1, const Command& c2)
38 {
39  return c1.group != c2.group || c1.name != c2.name;
40 }
41 
42 //------------------------------------------------------------------------
47 class ICommandHandler : public Interface
48 {
49 public:
51  virtual bool canHandleCommand (const Command& command) = 0;
53  virtual bool handleCommand (const Command& command) = 0;
54 };
55 
56 //------------------------------------------------------------------------
61 namespace CommandGroup {
62 
63 static constexpr IdStringPtr Application = "Application";
64 static constexpr IdStringPtr File = "File";
65 static constexpr IdStringPtr Edit = "Edit";
66 static constexpr IdStringPtr Window = "Window";
67 
68 //------------------------------------------------------------------------
69 } // CommandGroup
70 
71 //------------------------------------------------------------------------
72 namespace CommandName {
73 
74 static constexpr IdStringPtr About = "About";
75 static constexpr IdStringPtr Preferences = "Preferences...";
76 static constexpr IdStringPtr Quit = "Quit";
77 static constexpr IdStringPtr Help = "Help";
78 static constexpr IdStringPtr New = "New";
79 static constexpr IdStringPtr Open = "Open...";
80 static constexpr IdStringPtr Save = "Save";
81 static constexpr IdStringPtr SaveAs = "Save As...";
82 static constexpr IdStringPtr CloseWindow = "Close Window";
83 static constexpr IdStringPtr Undo = "Undo";
84 static constexpr IdStringPtr Redo = "Redo";
85 static constexpr IdStringPtr Cut = "Cut";
86 static constexpr IdStringPtr Copy = "Copy";
87 static constexpr IdStringPtr Paste = "Paste";
88 static constexpr IdStringPtr Delete = "Delete";
89 static constexpr IdStringPtr SelectAll = "Select All";
90 
91 static constexpr IdStringPtr MenuSeparator = "~";
92 
93 } // CommandName
94 
95 //------------------------------------------------------------------------
100 namespace Commands {
101 
102 static const Command About {CommandGroup::Application, CommandName::About};
103 static const Command Preferences {CommandGroup::Application, CommandName::Preferences};
104 static const Command Quit {CommandGroup::Application, CommandName::Quit};
105 static const Command Help {CommandGroup::Application, CommandName::Help};
106 
107 static const Command NewDocument {CommandGroup::File, CommandName::New};
108 static const Command OpenDocument {CommandGroup::File, CommandName::Open};
109 static const Command SaveDocument {CommandGroup::File, CommandName::Save};
110 static const Command SaveDocumentAs {CommandGroup::File, CommandName::SaveAs};
111 static const Command CloseWindow {CommandGroup::File, CommandName::CloseWindow};
112 
113 static const Command Undo {CommandGroup::Edit, CommandName::Undo};
114 static const Command Redo {CommandGroup::Edit, CommandName::Redo};
115 static const Command Cut {CommandGroup::Edit, CommandName::Cut};
116 static const Command Copy {CommandGroup::Edit, CommandName::Copy};
117 static const Command Paste {CommandGroup::Edit, CommandName::Paste};
118 static const Command Delete {CommandGroup::Edit, CommandName::Delete};
119 static const Command SelectAll {CommandGroup::Edit, CommandName::SelectAll};
120 
121 //------------------------------------------------------------------------
122 } // Commands
123 
124 //------------------------------------------------------------------------
125 } // Standalone
126 } // VSTGUI
Definition: icommand.h:47
virtual bool canHandleCommand(const Command &command)=0
Definition: interface.h:13
Definition: customcontrols.cpp:8
Definition: icommand.h:24
Definition: preferences.h:17
virtual bool handleCommand(const Command &command)=0
holds an UTF8 encoded string and a platform representation of it
Definition: cstring.h:56