aboutsummaryrefslogtreecommitdiff
path: root/util/fbrun/FbRun.hh
diff options
context:
space:
mode:
Diffstat (limited to 'util/fbrun/FbRun.hh')
-rw-r--r--util/fbrun/FbRun.hh99
1 files changed, 99 insertions, 0 deletions
diff --git a/util/fbrun/FbRun.hh b/util/fbrun/FbRun.hh
new file mode 100644
index 0000000..7856bdd
--- /dev/null
+++ b/util/fbrun/FbRun.hh
@@ -0,0 +1,99 @@
1// FbRun.hh
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id: FbRun.hh,v 1.14 2003/08/27 14:04:12 fluxgen Exp $
23
24#ifndef FBRUN_HH
25#define FBRUN_HH
26
27#include "FbTk/EventHandler.hh"
28#include "FbTk/Font.hh"
29#include "FbTk/FbWindow.hh"
30#include "FbTk/TextBox.hh"
31#include "FbTk/GContext.hh"
32#include "FbTk/FbPixmap.hh"
33
34#include <string>
35#include <vector>
36
37/**
38 Creates and managed a run window
39*/
40class FbRun: public FbTk::TextBox {
41public:
42 FbRun(int x = 0, int y = 0, size_t width = 200);
43 ~FbRun();
44 void handleEvent(XEvent * const ev);
45 void setTitle(const std::string &title);
46 void resize(unsigned int width, unsigned int height);
47
48 /// load and reconfigure for new font
49 bool loadFont(const std::string &fontname);
50 void setForegroundColor(const FbTk::Color &color);
51 void setAntialias(bool val) { m_font.setAntialias(val); }
52 const FbTk::Font &font() const { return m_font; }
53 /// execute command and exit
54 void run(const std::string &execstring);
55 /// is this application done?
56 bool end() const { return m_end; }
57 /**
58 loads history file.
59 @return true on success, else false
60 */
61 bool loadHistory(const char *filename);
62 /**
63 @name events
64 */
65 ///@{
66 void keyPressEvent(XKeyEvent &ev);
67 ///@}
68
69private:
70 void nextHistoryItem();
71 void prevHistoryItem();
72 void drawString(int x, int y, const char *text, size_t len);
73 void getSize(size_t &width, size_t &height);
74 void createWindow(int x, int y, size_t width, size_t height);
75 void redrawLabel();
76 /// set no maximizable for this window
77 void setNoMaximize();
78
79 void insertCharacter(char key);
80 void adjustStartPos();
81 void adjustEndPos();
82 void firstHistoryItem();
83 void lastHistoryItem();
84 void tabCompleteHistory();
85
86 FbTk::Font m_font; ///< font used to draw command text
87 Display *m_display; ///< display connection
88 int m_bevel;
89 FbTk::GContext m_gc; ///< graphic context
90 bool m_end; ///< marks when this object is done
91 std::vector<std::string> m_history; ///< history list of commands
92 size_t m_current_history_item; ///< holds current position in command history
93 std::string m_history_file; ///< holds filename for command history file
94 Cursor m_cursor;
95
96 FbTk::FbPixmap m_pixmap;
97};
98
99#endif // FBRUN_HH