00001 // Copyright (c) 2003 - 2004 Anselm R. Garbe <anselmg at t-online.de> 00002 // See ../LICENSE.txt for license details. 00003 // 00004 // $Id: action.h 7 2007-05-24 11:03:53Z eg1981 $ 00005 00006 #ifndef __ACTION_H 00007 #define __ACTION_H 00008 00009 extern "C" { 00010 #include <X11/Xlib.h> 00011 } 00012 00013 #include <list> 00014 #include <string> 00015 #include "ncwm.h" 00016 00017 class Action; 00018 class Actions; 00019 class Prompt; 00020 class Shortcut; 00021 class Validators; 00022 00023 // Method pointer type for actions 00024 typedef void (Actions::*ToPerform)(Action *, const char *); 00025 typedef bool (Validators::*IsValid)(); 00026 00027 typedef list<Prompt *> LPrompt; 00028 00030 class Action 00031 { 00032 00033 public: 00034 00035 enum Type {INTERN, EXTERN, SEQUENCE, UNKNOWN}; 00036 00037 Action(string id, ToPerform toPerform, 00038 IsValid isValid, Type type = INTERN, char *argument = 0); 00039 00040 ~Action(); 00041 00042 string id() const; 00043 00044 unsigned int promptsCount() const; 00045 00047 void perform(); 00048 00050 bool isValid(); 00051 00053 IsValid getIsValid() const; 00054 00055 void setShortcut(Shortcut *shortcut); 00056 00057 Shortcut *shortcut() const; 00058 00059 void setArgument(char *argument); 00060 00061 char *argument() const; 00062 00063 Type type() const; 00064 00065 void setType(Type type); 00066 00068 Prompt *prompt(unsigned int index); 00069 00070 LPrompt *prompts(); 00071 00072 ToPerform getToPerform() const; 00073 00074 void setListenOn(Shortcut *listenOn); 00075 00076 Shortcut *listenOn() const; 00077 00078 private: 00079 00080 string id_; 00081 ToPerform toPerform_; 00082 IsValid isValid_; 00083 00084 // for keyboard bindings 00085 Shortcut *shortcut_; 00086 Shortcut *listenOn_; 00087 00088 // for special stuff 00089 char *argument_; 00090 Type type_; 00091 LPrompt prompts_; 00092 00093 }; 00094 00095 #endif // __ACTION_H