Go to the documentation of this file.00001 #include "vgui_qt_window.h"
00002
00003 #include <vgui/vgui.h>
00004 #include <vgui/vgui_menu.h>
00005
00006 #include "vgui_qt_adaptor.h"
00007 #include "vgui_qt_menu.h"
00008 #include "vgui_qt_statusbar.h"
00009
00010 #include <qmenubar.h>
00011 #include <qvgroupbox.h>
00012 #include <qlabel.h>
00013 #include <qlayout.h>
00014 #include <qframe.h>
00015
00016
00017 void vgui_qt_window::setup_widget(int w, int h, const char* title)
00018 {
00019 this->setCaption(title);
00020 this->resize(w,h);
00021
00022 QWidget* mainwidget = new QWidget(this, "vgui_qt_gl_main_widget");
00023
00024
00025 QFrame* frame = new QFrame (mainwidget, "vgui_qt_gl_frame");
00026 frame->setFrameStyle (QFrame::Sunken | QFrame::StyledPanel);
00027 frame->setLineWidth (2);
00028
00029
00030 adaptor = new vgui_qt_adaptor(frame);
00031 QHBoxLayout* hlayout = new QHBoxLayout (frame, 2, 2, "vgui_qt_gl_hlayout");
00032 hlayout->addWidget (adaptor, 1);
00033
00034
00035 QVBoxLayout* vlayout = new QVBoxLayout (mainwidget, 15, 5, "vgui_qt_gl_vlayout");
00036 vlayout->addWidget(frame, 1);
00037
00038 setCentralWidget(mainwidget);
00039
00040 #ifndef __SGI_CC // SGI's iostream does not allow re-initialising
00041 vgui::out.rdbuf(statusbar.statusbuf);
00042 #endif
00043 }
00044
00045
00046 vgui_qt_window::vgui_qt_window(int w, int h, const char* title)
00047 : QMainWindow(0, "vgui_qt_mainwindow_without_menu"),
00048 statusbar (this),
00049 use_menubar(false),
00050 use_statusbar(true)
00051 {
00052 setup_widget(w, h, title);
00053 }
00054
00055
00056
00057 vgui_qt_window::vgui_qt_window(int w, int h, const vgui_menu& menu, const char* title)
00058 : QMainWindow(0, "vgui_qt_mainwindow_with_menu"),
00059 statusbar (this),
00060 use_menubar(true),
00061 use_statusbar(true)
00062 {
00063 setup_widget(w, h, title);
00064 set_menubar(menu);
00065 }
00066
00067
00068
00069 void vgui_qt_window::set_menubar(const vgui_menu &menu)
00070 {
00071 use_menubar = true;
00072
00073 vgui_qt_menu* qm;
00074 for (unsigned int i=0; i < menu.size(); ++i)
00075 {
00076 qm = new vgui_qt_menu(*(menu[i].menu));
00077 menuBar()->insertItem(menu[i].name.c_str(), (QPopupMenu*) qm);
00078 }
00079 }