22 : m_main_window(main_window), m_type(type), m_widget(NULL)
67 : QWidget(pParent),
CQtMainWindowWidget(main_window,
eImage), m_pBuffer(NULL), m_nWidth(0), m_nHeight(0), m_mouse_down(false)
72 #if QT_VERSION >= 0x040000 73 setBackgroundRole(QPalette::NoRole);
75 setBackgroundMode(Qt::NoBackground);
78 setMouseTracking(
true);
80 #if QT_VERSION >= 0x040000 81 setFocusPolicy(Qt::ClickFocus);
83 setFocusPolicy(QWidget::ClickFocus);
112 for (
int i = 0; i < nPixels; i++)
113 output[i] = 255 << 24 | pixels[i] << 16 | pixels[i] << 8 | pixels[i];
121 for (
int offset = 0, i = 0; i < nPixels; i++)
123 output[i] = 255 << 24 | pixels[
offset] << 16 | pixels[
offset + 1] << 8 | pixels[
offset + 2];
130 const unsigned char *pixels_r = pImage->
pixels;
131 const unsigned char *pixels_g = pixels_r + nPixels;
132 const unsigned char *pixels_b = pixels_g + nPixels;
135 for (
int i = 0; i < nPixels; i++)
136 output[i] = 255 << 24 | pixels_r[i] << 16 | pixels_g[i] << 8 | pixels_b[i];
139 #if QT_VERSION >= 0x040000 150 QPainter painter(
this);
152 #if QT_VERSION >= 0x040000 158 painter.drawImage(0, 0, image);
169 unsigned int swap = x0;
175 unsigned int swap = y0;
180 QPen pen(Qt::white, 1);
182 painter.drawRect(x0, y0, x1 - x0, y1 - y0);
189 if (e->button() == Qt::LeftButton)
218 default: printf(
"unknown mouse button pressed\n");
break;
249 unsigned int swap = x0;
255 unsigned int swap = y0;
266 update(x0, y0, x1 - x0, y1 - y0);
283 default: printf(
"unknown mouse button released\n");
break;
287 ec->
MouseUp(w, btn, e->x(), e->y());
302 unsigned int swap = x0;
308 unsigned int swap = y0;
313 update(x0, y0, x1 - x0, y1 - y0);
335 unsigned int swap = x0;
341 unsigned int swap = y0;
346 update(x0, y0, x1 - x0, y1 - y0);
366 #if QT_VERSION >= 0x040000 367 ec->
KeyDown(w, e->text().toInt());
382 #if QT_VERSION >= 0x040000 383 ec->
KeyUp(w, e->text().toInt());
385 ec->
KeyUp(w, e->ascii());
394 CQtGLWidget::CQtGLWidget(
CQtMainWindow *main_window, QWidget *pParent)
401 setMouseTracking(
true);
403 #if QT_VERSION >= 0x040000 404 setFocusPolicy(Qt::ClickFocus);
406 setFocusPolicy(QWidget::ClickFocus);
410 CQtGLWidget::~CQtGLWidget()
414 void CQtGLWidget::mousePressEvent(QMouseEvent * e)
427 default: printf(
"unknown mouse button pressed\n");
break;
435 void CQtGLWidget::mouseReleaseEvent(QMouseEvent * e)
448 default: printf(
"unknown mouse button released\n");
break;
452 ec->
MouseUp(w, btn, e->x(), e->y());
456 void CQtGLWidget::mouseMoveEvent(QMouseEvent * e)
467 void CQtGLWidget::keyPressEvent(QKeyEvent * e)
475 #if QT_VERSION >= 0x040000 476 ec->
KeyDown(w, e->text().toInt());
483 void CQtGLWidget::keyReleaseEvent(QKeyEvent * e)
491 #if QT_VERSION >= 0x040000 492 ec->
KeyUp(w, e->text().toInt());
494 ec->
KeyUp(w, e->ascii());
virtual void KeyUp(WIDGET_HANDLE widget, int key)
virtual void ButtonPushed(WIDGET_HANDLE widget)
virtual void ValueChanged(WIDGET_HANDLE widget, int value)
virtual void KeyDown(WIDGET_HANDLE widget, int key)
void TextChanged(const QString &str)
int width
The width of the image in pixels.
CMainWindowEventInterface * GetEventCallback()
CQtMainWindowWidget(CQtMainWindow *main_window, QtWidgetType type)
GLenum GLsizei GLenum GLenum const GLvoid * image
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
virtual void MouseDown(WIDGET_HANDLE widget, int button, int x, int y)
GLuint GLuint GLsizei GLenum type
unsigned char * pixels
The pointer to the the pixels.
GLsizei const GLfloat * value
virtual void MouseMove(WIDGET_HANDLE widget, int x, int y)
virtual void PointClicked(WIDGET_HANDLE widget, int x, int y)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
int height
The height of the image in pixels.
#define IVT_MIDDLE_BUTTON
ImageType type
The type of the image.
CQtMainWindow * m_main_window
void ValueChanged(int value)
Interface for the event mechanism of GUIs using the GUI toolkit of the IVT.
GLubyte GLubyte GLubyte GLubyte w
virtual void RectSelected(WIDGET_HANDLE widget, int x0, int y0, int x1, int y1)
virtual void MouseUp(WIDGET_HANDLE widget, int button, int x, int y)