00001 // Copyright (c) 2003 - 2004 Anselm R. Garbe <anselmg at t-online.de> 00002 // See ../LICENSE.txt for license details. 00003 // 00004 // $Id: menu.h 7 2007-05-24 11:03:53Z eg1981 $ 00005 00006 #ifndef __MENU_H 00007 #define __MENU_H 00008 00009 #include "ncwm.h" 00010 00011 extern "C" { 00012 #include <X11/Xlib.h> 00013 } 00014 00015 #include <list> 00016 #include <string> 00017 00018 #include "widget.h" 00019 00020 class Action; 00021 class Client; 00022 class Item; 00023 class Label; 00024 class Monitor; 00025 class Theme; 00026 00027 typedef list<Action *> LAction; 00028 typedef list<Item *> LItem; 00029 00033 class Item { 00034 00035 public: 00036 00037 // The type of this items is related to the data_ pointer which must 00038 // of following type if the specific type has been choosen: 00039 // ACTION -> Action * 00040 // CLIENT -> Client * (attached client) 00041 // DCLIENT -> Client * (detached client) 00042 // WORKSPACE -> Workspace * 00043 // ROOT -> 0 00044 // ROOTITEM -> 0 00045 // SEPARATOR -> 0 00046 enum Type {ACTION, CLIENT, DCLIENT, WORKSPACE, ROOT, 00047 ROOTITEM, SEPARATOR}; 00048 00049 Item(string name, void *data, Type type); 00050 ~Item(); 00051 00052 LItem *items(); 00053 00054 void addItem(Item *item); 00055 void removeItem(Item *item); 00056 00057 Type type() const; 00058 string name() const; 00059 Item *parent() const; 00060 void setParent(Item *parent); 00061 void *data() const; 00062 00063 unsigned int size(); 00064 00065 private: 00066 00067 string name_; 00068 void *data_; 00069 LItem items_; 00070 Type type_; 00071 Item *parent_; 00072 00073 }; 00074 00075 00079 class Menu : public Widget { 00080 00081 public: 00082 00083 Menu(Monitor *monitor); 00084 00085 ~Menu(); 00086 00087 void manage(); 00088 void updateItemTree(); 00089 00091 void illuminate(); 00092 00093 void handleButtonPress(XButtonEvent *event); 00094 void handleMotionNotify(XMotionEvent *event); 00095 00096 virtual void show(); 00097 virtual void hide(); 00098 00099 private: 00100 00101 void initActions(); 00102 00103 void escape(); 00104 00105 Theme *theme_; 00106 Label *label_; 00107 LAction actions_; 00108 Item *root_; 00109 Item *subRoot_; 00110 Item *selected_; 00111 }; 00112 00113 #endif // __MENU_H