diff options
author | fluxgen <fluxgen> | 2006-06-10 20:04:34 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2006-06-10 20:04:34 (GMT) |
commit | d218f02f80395bdfa34fcac3b8147d0be5e6b420 (patch) | |
tree | 1162c44c7f5eab4ff3dfe97860d33c6319e23035 /src/FbTk | |
parent | 928aa33dfe88df7c071109a9ad5adfa8bc972811 (diff) | |
download | fluxbox_pavel-d218f02f80395bdfa34fcac3b8147d0be5e6b420.zip fluxbox_pavel-d218f02f80395bdfa34fcac3b8147d0be5e6b420.tar.bz2 |
added new command: ToggleCmd, works like a macro but executes the commands one at the time. Thanks Mark Tiefenbruck
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/MacroCommand.cc | 18 | ||||
-rw-r--r-- | src/FbTk/MacroCommand.hh | 13 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/FbTk/MacroCommand.cc b/src/FbTk/MacroCommand.cc index adee9cb..491b01e 100644 --- a/src/FbTk/MacroCommand.cc +++ b/src/FbTk/MacroCommand.cc | |||
@@ -38,6 +38,24 @@ void MacroCommand::execute() { | |||
38 | m_commandlist[i]->execute(); | 38 | m_commandlist[i]->execute(); |
39 | } | 39 | } |
40 | 40 | ||
41 | ToggleCommand::ToggleCommand() { | ||
42 | m_state = 0; | ||
43 | } | ||
44 | |||
45 | void ToggleCommand::add(RefCount<Command> &com) { | ||
46 | m_commandlist.push_back(com); | ||
47 | } | ||
48 | |||
49 | size_t ToggleCommand::size() const { | ||
50 | return m_commandlist.size(); | ||
51 | } | ||
52 | |||
53 | void ToggleCommand::execute() { | ||
54 | m_commandlist[m_state]->execute(); | ||
55 | if (++m_state >= m_commandlist.size()) | ||
56 | m_state = 0; | ||
57 | } | ||
58 | |||
41 | }; // end namespace FbTk | 59 | }; // end namespace FbTk |
42 | 60 | ||
43 | 61 | ||
diff --git a/src/FbTk/MacroCommand.hh b/src/FbTk/MacroCommand.hh index f29e05c..7aa9d66 100644 --- a/src/FbTk/MacroCommand.hh +++ b/src/FbTk/MacroCommand.hh | |||
@@ -42,6 +42,19 @@ private: | |||
42 | std::vector<RefCount<Command> > m_commandlist; | 42 | std::vector<RefCount<Command> > m_commandlist; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /// executes one command at a time | ||
46 | class ToggleCommand:public Command { | ||
47 | public: | ||
48 | ToggleCommand(); | ||
49 | void add(RefCount<Command> &com); | ||
50 | size_t size() const; | ||
51 | virtual void execute(); | ||
52 | |||
53 | private: | ||
54 | std::vector<RefCount<Command> > m_commandlist; | ||
55 | size_t m_state; | ||
56 | }; | ||
57 | |||
45 | } // end namespace FbTk | 58 | } // end namespace FbTk |
46 | 59 | ||
47 | #endif // FBTK_MACROCOMMAND_HH | 60 | #endif // FBTK_MACROCOMMAND_HH |