00001 // Copyright (c) 2003 - 2004 Anselm R. Garbe <anselmg at t-online.de> 00002 // See ../LICENSE.txt for license details. 00003 // 00004 // $Id: inputbar.h 7 2007-05-24 11:03:53Z eg1981 $ 00005 00006 #ifndef __INPUTBAR_H 00007 #define __INPUTBAR_H 00008 00009 #include <set> 00010 #include <stack> 00011 #include <string> 00012 #include "ncwm.h" 00013 00014 #include "bar.h" 00015 00016 class Action; 00017 class Monitor; 00018 class Prompt; 00019 class Theme; 00020 00021 typedef set<string> Sstring; 00022 typedef stack<Sstring::iterator> SSstringIter; 00023 00027 class InputBar: public Bar 00028 { 00029 00030 public: 00031 00032 InputBar(Monitor *monitor, Rectangle *rect); 00033 00034 ~InputBar(); 00035 00036 virtual void illuminate(); 00037 00038 virtual void handleMotionNotify(XMotionEvent *event); 00039 virtual void handleButtonPress(XButtonEvent *event); 00040 virtual void handleButtonRelease(XButtonEvent *event); 00041 00043 void handleInput(XKeyEvent *event); 00044 void handlePressedReturn(); 00045 00046 void runKey(Prompt *prompt); 00047 void runArgument(Action *action); 00048 00049 private: 00050 00051 bool isArgument() const; 00052 00053 string text(bool onExecEnter = false); 00054 00055 void queryText(string text); 00056 void removeChar(); 00057 void clearPrevPartitionsStack(); 00058 00059 void selectNextEntry(); 00060 void selectPrevEntry(); 00061 00062 void escape(); 00063 00065 Action *currAction_; 00066 00067 Sstring names_; 00068 00069 bool isArgument_; 00070 Sstring::iterator entryBegin_; 00071 Sstring::iterator entryEnd_; 00072 Sstring::iterator partitionBegin_; 00073 Sstring::iterator partitionEnd_; 00074 Sstring::iterator selected_; 00075 SSstringIter prevPartitions_; 00076 Prompt *prompt_; 00077 string text_; 00078 string args_; 00079 unsigned int promptCounter_; 00080 }; 00081 00082 #endif // __INPUTBAR_H