Debian Codegraph @

Qt/EditorWidget.h

raw symbols SCIP
1 /* Copyright 2003 Kjetil S. Matheussen
2
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License
5 as published by the Free Software Foundation; either version 2
6 of the License, or (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17 #ifndef EDITOR_WIDGET_H
18 #define EDITOR_WIDGET_H
19
20 #ifdef USE_QT3
21 #include <qmenubar.h>
22 #include <qmainwindow.h>
23 #include <qslider.h>
24 #include <qtimer.h>
25
26 # if USE_GTK_VISUAL
27 # include "qtxembed-1.3-free/src/qtxembed.h"
28 # endif
29
30 #include <qapplication.h>
31 #include <qpixmap.h>
32 #include <qimage.h>
33 #include <qpointarray.h>
34 #include <qlabel.h>
35 #endif // USE_QT3
36
37 #ifdef USE_QT4
38 //Added by qt3to4:
39 #include <QWidget>
40 #include <QLabel>
41 //#include <Q3PointArray>
42 #include <QPainter>
43 #endif
44
45 #ifdef USE_QT3
46 # define Q3PointArray QPointArray
47 # define Q3PopupMenu QPopupMenu
48 #endif
49
50 #define GFX_DONTSHRINK
51 #include "../common/nsmtracker.h"
52 #include "../common/windows_proc.h"
53
54 #include "../common/visual_proc.h"
55 #include "../common/visual_op_queue_proc.h"
56
57
58 // Don't paint on the frame.
59 //#define XOFFSET 5
60 //#define YOFFSET 2
61
62
63 class QMainWindow;
64 class QSplitter;
65
66 #if USE_QIMAGE_BUFFER
67 typedef QImage PaintBuffer;
68 #else
69 typedef QPixmap PaintBuffer;
70 #endif
71
72 class EditorWidget : public QWidget //QFrame
73 //class EditorWidget : public QtXEmbedContainer //QWidget //QFrame
74 {
75
76 public:
77 EditorWidget(QWidget *parent=0, const char *name="no name" );
78 ~EditorWidget();
79
80 #if USE_QT_VISUAL && USE_QT4
81 //const QPaintEngine* paintEngine();
82 #endif
83
84 QColor colors[16]; // color array
85
86 #if USE_QT_VISUAL
87 PaintBuffer *paintbuffer;
88
89 PaintBuffer *cursorbuffer;
90 #endif
91
92 //void timerEvent(QTimerEvent *);
93
94 struct Tracker_Windows *window; // Not sure if this one is used.
95
96 QMainWindow *main_window;
97
98 #if USE_QT_VISUAL
99 QPainter *painter; // Set in paintEvent
100 QPainter *paintbuffer_painter; // Set in paintEvent
101 QPainter *cursorbuffer_painter; // Set in paintEvent
102
103 QFont font;
104 #endif
105
106 //QFrame *status_frame;
107 QLabel *status_label;
108
109 QSplitter *xsplitter;
110 QSplitter *ysplitter;
111
112 int get_editor_width(){
113 //return this->width()-XOFFSET-2; // Fine tuned. No logical reason behind it. (2 is probably just the frame border width)
114 return this->width();
115 }
116
117 int get_editor_height(){
118 //return this->height()-YOFFSET-2; // Fine tuned. No logical reason behind it. (2 is probably just the frame border width)
119 return this->height();
120 }
121
122 //Q3PointArray qpa;
123
124 void updateEditor();
125
126 void callCustomEvent(){
127 customEvent(NULL);
128 }
129
130 #if USE_QT_VISUAL && USE_QIMAGE_BUFFER
131 void init_buffers(){
132 const QImage::Format image_format = QImage::Format_RGB32;
133
134 if(this->paintbuffer==NULL || this->cursorbuffer==NULL || this->paintbuffer->width()<this->width() || this->paintbuffer->height()<this->height()){
135 delete this->paintbuffer_painter;
136 delete this->cursorbuffer_painter;
137
138 delete this->paintbuffer;
139 delete this->cursorbuffer;
140 this->paintbuffer = new QImage(this->width(), this->height(), image_format);
141 this->cursorbuffer = new QImage(this->width(), this->height(), image_format);
142
143 this->paintbuffer_painter = new QPainter(this->paintbuffer);
144 this->cursorbuffer_painter = new QPainter(this->cursorbuffer);
145
146 this->paintbuffer_painter->setFont(this->font);
147 }
148
149 #if 1
150 {
151 this->cursorbuffer_painter->fillRect(0,0,this->width(),this->height(),this->colors[15]);
152 }
153 #if 0
154 {
155 this->paintbuffer_painter->fillRect(0,0,this->width(),this->height(),this->colors[0]);
156 }
157 #endif
158 #endif
159 }
160
161 #else
162 void init_buffers(){
163 #if USE_QT_VISUAL
164 if(this->paintbuffer==NULL || this->cursorbuffer==NULL){
165 this->paintbuffer=new QPixmap(editor->width(),editor->height());
166 this->cursorbuffer=new QPixmap(editor->width(),editor->height());
167 #ifdef USE_QT3
168 this->paintbuffer->setOptimization(QPixmap::BestOptim);
169 this->cursorbuffer->setOptimization(QPixmap::BestOptim);
170 #endif
171 }else{
172 this->paintbuffer->resize(this->width(), this->height());
173 this->cursorbuffer->resize(this->width(), this->height());
174 }
175 #endif
176 }
177 #endif
178
179 protected:
180 // bool event(QEvent *);
181 #if 1 //USE_QT_VISUAL
182 void paintEvent( QPaintEvent * );
183 #endif
184
185 #if 0 // Using X11filter for keys
186 void keyPressEvent(QKeyEvent *);
187 void keyReleaseEvent(QKeyEvent *qkeyevent);
188 #endif
189
190 #if USE_QT_VISUAL
191 void mousePressEvent( QMouseEvent *);
192 void mouseReleaseEvent( QMouseEvent *);
193 void mouseMoveEvent( QMouseEvent *);
194 #endif
195 void resizeEvent( QResizeEvent *);
196 void closeEvent(QCloseEvent *);
197 void customEvent(QEvent *);
198 };
199
200 #endif
201