~ubuntu-branches/ubuntu/trusty/fluxbox/trusty-proposed

« back to all changes in this revision

Viewing changes to util/fbrun/FbRun.hh

  • Committer: Bazaar Package Importer
  • Author(s): Dmitry E. Oboukhov
  • Date: 2008-07-01 10:38:14 UTC
  • mfrom: (2.1.12 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080701103814-khx2b6il152x9p93
Tags: 1.0.0+deb1-8
* x-dev has been removed from build-depends (out-of-date package).
* Standards-Version bumped to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// FbRun.hh
2
 
// Copyright (c) 2002 - 2005 Henrik Kinnunen (fluxgen at fluxbox dot 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 4043 2005-06-03 07:25:48Z mathias $
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
 
*/
40
 
class FbRun: public FbTk::TextBox {
41
 
public:
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
 
 
69
 
private:
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
 
    void tabCompleteApps();
86
 
 
87
 
    FbTk::Font m_font; ///< font used to draw command text
88
 
    Display *m_display;  ///< display connection
89
 
    int m_bevel;
90
 
    FbTk::GContext m_gc; ///< graphic context
91
 
    bool m_end; ///< marks when this object is done
92
 
    std::vector<std::string> m_history; ///< history list of commands
93
 
    std::string m_history_file; ///< holds filename for command history file
94
 
    size_t m_current_history_item; ///< holds current position in command history
95
 
    
96
 
    typedef std::vector<std::string> AppsContainer;
97
 
    typedef AppsContainer::iterator AppsContainerIt;
98
 
    AppsContainer m_apps; ///< holds all apps in $PATH
99
 
    size_t m_current_apps_item; ///< holds current position in apps-history
100
 
    
101
 
    Cursor m_cursor;
102
 
 
103
 
    FbTk::FbPixmap m_pixmap;
104
 
};
105
 
 
106
 
#endif // FBRUN_HH