16 #include <qpushbutton.h> 18 #include <qcheckbox.h> 19 #include <qlineedit.h> 21 #include <qcombobox.h> 22 #include <qapplication.h> 38 setFixedSize(width, height);
39 #ifdef OSX_QTGUI // make sure the Qt window is competely visible under OS X 45 #if QT_VERSION >= 0x040000 46 setWindowTitle(title);
47 setAttribute(Qt::WA_QuitOnClose,
true);
59 setFixedSize(width, height);
71 for (
int i = c-1; i >= 0; i--)
85 iw->setFixedSize(width, height);
101 QPushButton *pBtn =
new QPushButton((p != NULL ? p->
m_widget :
this));
103 pBtn->setFixedSize(width, height);
108 connect(pBtn, SIGNAL(clicked()), w, SLOT(Clicked()));
121 QLabel *pLabel =
new QLabel((p != NULL ? p->
m_widget :
this));
122 pLabel->setText(text);
123 pLabel->setFixedSize(width, height);
139 QCheckBox *pCheckBox =
new QCheckBox((p != NULL ? p->
m_widget :
this));
140 pCheckBox->setText(text);
141 pCheckBox->setFixedSize(width, height);
142 pCheckBox->move(x, y);
143 pCheckBox->setChecked(checked);
147 connect(pCheckBox, SIGNAL(toggled(
bool)), w, SLOT(Toggled(
bool)));
160 QLineEdit *pLineEdit =
new QLineEdit((p != NULL ? p->
m_widget :
this));
161 pLineEdit->setText(text);
162 pLineEdit->setFixedSize(width, height);
163 pLineEdit->move(x, y);
167 connect(pLineEdit, SIGNAL(textChanged(
const QString &)), w, SLOT(TextChanged(
const QString &)));
180 QSlider *pSlider =
new QSlider(Qt::Horizontal, (p != NULL ? p->
m_widget :
this));
181 pSlider->setFixedSize(width, height);
183 #if QT_VERSION >= 0x040000 184 pSlider->setMinimum(min_value);
185 pSlider->setMaximum(max_value);
186 pSlider->setTickPosition(QSlider::TicksBelow);
187 pSlider->setFocusPolicy(Qt::StrongFocus);
189 pSlider->setMinValue(min_value);
190 pSlider->setMaxValue(max_value);
191 pSlider->setTickmarks(QSlider::Below);
192 pSlider->setFocusPolicy(QWidget::StrongFocus);
194 pSlider->setValue(value);
195 pSlider->setPageStep(1);
196 pSlider->setTickInterval(step);
201 connect(pSlider, SIGNAL(valueChanged(
int)), w, SLOT(ValueChanged(
int)));
214 QComboBox *pComboBox =
new QComboBox((p != NULL ? p->
m_widget :
this));
215 pComboBox->setFixedSize(width, height);
216 pComboBox->move(x, y);
218 #if QT_VERSION >= 0x040000 219 for (
int i = 0; i < num_entries; i++)
221 pComboBox->addItem(entries[i]);
223 pComboBox->setCurrentIndex(current_entry);
225 for (
int i = 0; i < num_entries; i++)
227 pComboBox->insertItem(entries[i]);
229 pComboBox->setCurrentItem(current_entry);
234 connect(pComboBox, SIGNAL(activated(
int)), w, SLOT(ValueChanged(
int)));
246 CQtGLWidget *pGLWidget =
new CQtGLWidget(
this, (p != NULL ? p->
m_widget :
this));
247 pGLWidget->setFixedSize(width, height);
248 pGLWidget->move(x, y);
256 printf(
"WARNING: CQtMainWindow::AddGLWidget has been called, but USE_OPENGL = 0 in Makefile.base\n");
264 #if QT_VERSION >= 0x040000 265 #define GET_ASCII toAscii 267 #define GET_ASCII ascii 276 QPushButton *btn = (QPushButton*)w->
m_widget;
277 QString str = btn->text();
278 strncpy(text, str.GET_ASCII(),
len);
284 QCheckBox *btn = (QCheckBox*)w->
m_widget;
285 QString str = btn->text();
286 strncpy(text, str.GET_ASCII(),
len);
292 QLineEdit *le = (QLineEdit*)w->
m_widget;
293 QString str = le->text();
294 strncpy(text, str.GET_ASCII(),
len);
300 QLabel *label = (QLabel*)w->
m_widget;
301 QString str = label->text();
302 strncpy(text, str.GET_ASCII(),
len);
315 QPushButton *btn = (QPushButton*)w->
m_widget;
322 QCheckBox *btn = (QCheckBox*)w->
m_widget;
329 QLineEdit *le = (QLineEdit*)w->
m_widget;
336 QLabel *label = (QLabel*)w->
m_widget;
337 label->setText(text);
367 QCheckBox *cb = (QCheckBox*)w->
m_widget;
369 value = cb->isChecked();
375 QSlider *sl = (QSlider*)w->
m_widget;
383 QComboBox *cb = (QComboBox*)w->
m_widget;
385 #
if QT_VERSION >= 0x040000
386 value = cb->currentIndex();
388 value = cb->currentItem();
403 QCheckBox *cb = (QCheckBox*)w->
m_widget;
405 cb->setChecked(value != 0);
411 QSlider *sl = (QSlider*)w->
m_widget;
419 QComboBox *cb = (QComboBox*)w->
m_widget;
421 #
if QT_VERSION >= 0x040000
422 cb->setCurrentIndex(value);
424 cb->setCurrentItem(value);
441 QGLWidget *glw = (QGLWidget*)w->
m_widget;
462 QGLWidget *glw = (QGLWidget*)w->
m_widget;
503 #if QT_VERSION < 0x040000 506 # include <windows.h> 507 # include <shellapi.h> 508 #elif defined Q_WS_X11 509 # include <X11/Xlib.h> 511 # include <Carbon/Carbon.h> 521 #include <qpaintdevice.h> 527 int result = Qt::NoButton;
529 #if defined(Q_WS_WIN) 531 result |= GetAsyncKeyState(VK_SHIFT) < 0 ? Qt::ShiftButton : 0;
532 result |= GetAsyncKeyState(VK_MENU) < 0 ? Qt::AltButton : 0;
533 result |= GetAsyncKeyState(VK_CONTROL) < 0 ? Qt::ControlButton : 0;
535 #elif defined(Q_WS_X11) 541 bool status = XQueryPointer(QPaintDevice::x11AppDisplay(),
542 QPaintDevice::x11AppRootWindow(),
550 result |= keys_buttons & ShiftMask ? Qt::ShiftButton : 0;
551 result |= keys_buttons & Mod1Mask ? Qt::AltButton : 0;
552 result |= keys_buttons & ControlMask ? Qt::ControlButton : 0;
557 UInt32 modifiers = GetCurrentKeyModifiers();
558 if (modifiers & (1 << shiftKeyBit) modifiers |= Qt::ShiftButton;
559 if (modifiers & (1 << rightShiftKeyBit) modifiers |= Qt::ShiftButton;
560 if (modifiers & (1 << optionKeyBit) modifiers |= Qt::AltButton;
561 if (modifiers & (1 << rightOptionKeyBit) modifiers |= Qt::AltButton;
562 if (modifiers & (1 << controlKeyBit) modifiers |= Qt::ControlButton;
563 if (modifiers & (1 << rightControlKeyBit) modifiers |= Qt::ControlButton;
567 return Qt::ButtonState(result);
579 #if QT_VERSION >= 0x040000 580 mod = qApp->keyboardModifiers();
581 if (mod & Qt::ShiftModifier)
583 if (mod & Qt::ControlModifier)
585 if (mod & Qt::AltModifier)
589 if (mod & Qt::ShiftButton)
591 if (mod & Qt::ControlButton)
593 if (mod & Qt::AltButton)
void Show(WIDGET_HANDLE widget=0)
WIDGET_HANDLE AddCheckBox(int x, int y, int width, int height, const char *text, bool checked, WIDGET_HANDLE parent=0)
CMainWindowEventInterface * m_event_callback
static CQtApplicationHandler * GetApplicationHandler()
WIDGET_HANDLE AddTextEdit(int x, int y, int width, int height, const char *text, WIDGET_HANDLE parent=0)
WIDGET_HANDLE AddButton(int x, int y, int width, int height, const char *text, WIDGET_HANDLE parent=0)
bool SwapBuffersGLWidget(WIDGET_HANDLE widget)
void Hide(WIDGET_HANDLE widget=0)
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
CQtMainWindow(int x, int y, int width, int height, const char *title)
WIDGET_HANDLE AddSlider(int x, int y, int width, int height, int min_value, int max_value, int step, int value, WIDGET_HANDLE parent=0)
bool SetImage(WIDGET_HANDLE widget, const CByteImage *pImage)
WIDGET_HANDLE AddLabel(int x, int y, int width, int height, const char *text, WIDGET_HANDLE parent=0)
std::vector< CQtMainWindowWidget * > m_widgets
static Qt::ButtonState get_modifiers()
WIDGET_HANDLE AddImage(int x, int y, int width, int height, WIDGET_HANDLE parent=0)
int GetModifierKeyState()
GLsizei const GLfloat * value
bool SetValue(WIDGET_HANDLE widget, int value)
GLenum GLsizei GLsizei height
bool GetText(WIDGET_HANDLE widget, char *text, int len)
void closeEvent(QCloseEvent *e)
WIDGET_HANDLE AddComboBox(int x, int y, int width, int height, int num_entries, const char **entries, int current_entry, WIDGET_HANDLE parent=0)
bool SetText(WIDGET_HANDLE widget, const char *text)
bool MakeCurrentGLWidget(WIDGET_HANDLE widget)
bool GetValue(WIDGET_HANDLE widget, int &value)
GLubyte GLubyte GLubyte GLubyte w
WIDGET_HANDLE AddGLWidget(int x, int y, int width, int height, WIDGET_HANDLE parent=0)