~ubuntu-branches/ubuntu/precise/apvlv/precise

« back to all changes in this revision

Viewing changes to src/ApvlvView.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ritter
  • Date: 2009-07-15 14:48:33 UTC
  • Revision ID: james.westby@ubuntu.com-20090715144833-k4hx9jqtb6vef121
Tags: upstream-0.0.6.8
ImportĀ upstreamĀ versionĀ 0.0.6.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the apvlv package
 
3
 *
 
4
 * Copyright (C) 2008 Alf.
 
5
 *
 
6
 * Contact: Alf <naihe2010@gmail.com>
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU General Public License
 
10
 * as published by the Free Software Foundation; either version 2.0 of
 
11
 * the License, or (at your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful, but
 
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
16
 * General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public
 
19
 * License along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
21
 *
 
22
 */
 
23
/* @CPPFILE ApvlvView.hpp
 
24
 *
 
25
 *  Author: Alf <naihe2010@gmail.com>
 
26
 */
 
27
/* @date Created: 2008/09/30 00:00:00 Alf */
 
28
 
 
29
#ifndef _APVLV_VIEW_H_
 
30
#define _APVLV_VIEW_H_
 
31
 
 
32
#ifdef HAVE_CONFIG_H
 
33
# include "config.hpp"
 
34
#endif
 
35
 
 
36
#include "ApvlvDoc.hpp"
 
37
#include "ApvlvWindow.hpp"
 
38
 
 
39
#include <iostream>
 
40
 
 
41
#include <gtk/gtk.h>
 
42
 
 
43
#include <list>
 
44
 
 
45
namespace apvlv
 
46
{
 
47
  typedef enum
 
48
    {
 
49
      SEARCH = '/',
 
50
      BACKSEARCH = '?',
 
51
      COMMANDMODE = ':'
 
52
    } cmd_mode_type;
 
53
 
 
54
  class ApvlvDoc;
 
55
  class ApvlvWindow;
 
56
 
 
57
  class ApvlvView
 
58
    {
 
59
  public:
 
60
    ApvlvView (const char *);
 
61
 
 
62
    ~ApvlvView ();
 
63
 
 
64
    void show ();
 
65
 
 
66
    GtkWidget *widget ();
 
67
 
 
68
    ApvlvWindow *currentWindow ();
 
69
 
 
70
    void delcurrentWindow ();
 
71
 
 
72
    void newtab (const char *filename);
 
73
 
 
74
    void newtab (ApvlvCore *core);
 
75
 
 
76
    void promptcommand (char ch);
 
77
 
 
78
    void promptcommand (const char *str);
 
79
 
 
80
    void run (const char *str);
 
81
 
 
82
    bool loadfile (string file);
 
83
 
 
84
    bool loadfile (const char *filename);
 
85
 
 
86
    bool loaddir (const char *path);
 
87
 
 
88
    ApvlvCore * hasloaded (const char *filename, int type);
 
89
 
 
90
    void regloaded (ApvlvCore *);
 
91
 
 
92
    void open ();
 
93
 
 
94
    void opendir ();
 
95
 
 
96
    void close ();
 
97
 
 
98
    void quit ();
 
99
 
 
100
    void fullscreen ();
 
101
 
 
102
    returnType process (int times, guint keyval);
 
103
 
 
104
    returnType subprocess (int times, guint keyval);
 
105
 
 
106
    void cmd_show ();
 
107
 
 
108
    void cmd_hide ();
 
109
 
 
110
    void cmd_auto (const char *);
 
111
 
 
112
  private:
 
113
    ApvlvDoc *crtadoc ();
 
114
 
 
115
    void refresh ();
 
116
 
 
117
    bool destroy;
 
118
 
 
119
    GCompletion *filecompleteinit (const char *s);
 
120
 
 
121
    void runcmd (const char *cmd);
 
122
 
 
123
    int new_tabcontext (ApvlvCore *core, bool insertAfterCurr);
 
124
 
 
125
    void delete_tabcontext (int tabPos);
 
126
 
 
127
    void switch_tabcontext (int tabPos);
 
128
 
 
129
    // Caclulate number of pixels that the document should be.
 
130
    //  This figure accounts for decorations like (mCmdBar and mHaveTabs).
 
131
    // Returns a nonnegative number.
 
132
    int adjheight ();
 
133
 
 
134
    void switchtab (int tabPos);
 
135
 
 
136
    // Update the tab's context and update tab label.
 
137
    void windowadded ();
 
138
 
 
139
    void updatetabname ();
 
140
    bool mHasCmd, mHasTabs;
 
141
 
 
142
    guint mProCmd;
 
143
 
 
144
    GtkWidget *mCommandBar;
 
145
    GtkWidget *mMainWindow;
 
146
 
 
147
    GtkWidget *mTabContainer;
 
148
 
 
149
    struct TabEntry {
 
150
        ApvlvWindow *root;
 
151
        ApvlvWindow *curr;
 
152
 
 
153
        int numwindows;
 
154
        TabEntry (ApvlvWindow *_r, ApvlvWindow *_c, int _n) 
 
155
          : root(_r), curr(_c), numwindows(_n)
 
156
          { }
 
157
    };
 
158
    // possibly use GArray instead
 
159
    std::vector<TabEntry> mTabList;
 
160
    int mCurrTabPos;
 
161
 
 
162
    gboolean mHasFull;
 
163
    int mWidth, mHeight;
 
164
 
 
165
    static void apvlv_view_delete_cb (GtkWidget * wid, GtkAllocation * al,
 
166
                                      ApvlvView * view);
 
167
    static void apvlv_view_resized_cb (GtkWidget * wid, GtkAllocation * al,
 
168
                                       ApvlvView * view);
 
169
    static gint apvlv_view_keypress_cb (GtkWidget * wid, GdkEvent * ev, ApvlvView * view);
 
170
 
 
171
    static gint apvlv_view_commandbar_cb (GtkWidget * wid, GdkEvent * ev, ApvlvView * view);
 
172
 
 
173
    static void apvlv_notebook_switch_cb (GtkWidget * wid, GtkNotebookPage *page, guint num, ApvlvView *view);
 
174
 
 
175
    ApvlvWindow *mRootWindow;
 
176
 
 
177
    GSList *mDocs;
 
178
 
 
179
    static const int APVLV_CMD_BAR_HEIGHT, APVLV_TABS_HEIGHT;
 
180
    };
 
181
 
 
182
  extern ApvlvView *gView;
 
183
}
 
184
 
 
185
#endif