Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

/cygdrive/d/Eigene Dateien/!DProcs/code_gen/app.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 
00003 
00004 //---------------------------------------------------------------------------
00005 #include "QWidget.h"
00006 #include "QScreen.h"
00007 #include "QWindow.h"
00008 #include "QFont.h"
00009 #include "QButton.h"
00010 #include "QCaptionButton.h"
00011 #include "QCheckBox.h"
00012 #include "QRadioButton.h"
00013 #include "QRadioButtonGroup.h"
00014 #include "QTextEdit.h"
00015 #include "QToolBar.h"
00016 
00017 
00018 #include <iostream>
00019 using namespace std;
00020 
00021 QScreen *screen;
00022 
00023 void glutResize(int width, int height)
00024 {
00025   glViewport(0, 0, width, height);
00026   glMatrixMode(GL_PROJECTION);
00027   glLoadIdentity();
00028   glOrtho(0,width,height,0,-1,1);
00029   glMatrixMode(GL_MODELVIEW);
00030   screen->setWidth(width);
00031   screen->setHeight(height);
00032 }
00033 
00034 void glutKeyboard(unsigned char key, int x, int y)
00035 {
00036     switch (key)
00037     {
00038         case 27:   std::exit(0);
00039     }
00040    screen->glutKeyboard(key,x,y);
00041 }
00042 
00043 void glutKeyboardUp(unsigned char key, int x, int y)
00044 {
00045    screen->glutKeyboardUp(key,x,y);
00046 }
00047 
00048 
00049 void glutSpecial(int key, int x, int y)
00050 {
00051  screen->glutSpecialFunc(key,x,y);
00052 }
00053 
00054 void glutMotion(int x, int y) 
00055 {
00056   screen->glutMotion(x,y);
00057 }
00058 
00059 void glutMouse(int button, int state, int x, int y)
00060 {
00061    
00062     screen->glutMouse(button,state,x,y);  
00063 }
00064 
00065 void glutDisplay()
00066 {
00067   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00068   screen->glutDisplay();
00069   glutSwapBuffers();
00070 }
00071 
00072 
00073 
00074 void myMethod1(QWidget* Sender, QEvent* e);
00075 
00076 void myMethod2(QWidget* Sender, QEvent* e)
00077 {
00078   QCaptionButton* bn = dynamic_cast<QCaptionButton*>(Sender);
00079   if (bn)
00080     cout << "Sie haben " << bn->getCaption() << " angeklickt!" << endl;
00081   else
00082     cout << "Methode wurde nicht von einem Button ausgelöst" << endl;
00083 }
00084 
00085 
00086 
00087 void myMethod3(QWidget* Sender, QEvent* e)
00088 {
00089   QRadioButton* bn = dynamic_cast<QRadioButton*>(Sender);
00090   if (bn)
00091     cout << "Sie haben " << bn->getCaption() << " angeklickt!" << endl;
00092   else
00093     cout << "Methode wurde nicht von einem Button ausgelöst" << endl;
00094 }
00095 
00096 
00097 
00098 
00099 class MyWindow : public QWindow
00100 {
00101   private:
00102     
00103 
00104   public:
00105     QToolBar* toolbar;
00106     QTextEdit* textedit;
00107     QCheckBox* toolbarWidth;
00108     QRadioButtonGroup* rgroup;
00109     QToolBar* radio_toolbar;
00110 
00111     void layout()
00112     {
00113        QWindow::layout();
00114 
00115     }
00116 
00117     MyWindow(QWidget* Owner):QWindow(Owner),toolbarWidth(0),radio_toolbar(0)
00118     {
00119       setWidth(400);
00120       setHeight(200);
00121 
00122       textedit = new QTextEdit(this);
00123       textedit->setLeft(10);
00124       textedit->setTop(70);
00125       textedit->setWidth(150);
00126       textedit->setText("Neu !!!");
00127 
00128       // checkbox
00129       toolbarWidth = new QCheckBox(this);
00130       toolbarWidth->setLeft(10);
00131       toolbarWidth->setTop(95);
00132       toolbarWidth->setCaption("Toolbar Breite anpassen");
00133 
00134 
00135       // radio group
00136       rgroup = new QRadioButtonGroup();
00137 
00138       // toolbar for radio buttons
00139       radio_toolbar = new QToolBar(this);
00140       radio_toolbar->setWidth(300);
00141       radio_toolbar->setTop(150);
00142 
00143       // radio buttons
00144       QRadioButton * radio1 = new QRadioButton(radio_toolbar);
00145       radio1->getFont()->setSize(12);
00146       radio1->setRadioButtonGroup(rgroup);
00147       radio1->setState(cbChecked);      
00148       radio1->setCaption("Item 1");
00149       radio1->onClick = myMethod3;
00150 
00151       QRadioButton * radio2 = new QRadioButton(radio_toolbar);
00152       radio2->setRadioButtonGroup(rgroup);
00153       radio2->setCaption("Item 2");
00154       radio2->setState(cbUnchecked);
00155       radio2->getFont()->setSize(12);
00156       radio2->onClick = myMethod3;
00157 
00158 
00159       // toobar
00160       toolbar = new QToolBar(this);
00161 
00162       // create buttons in toolbar
00163       QCaptionButton * bn = new QCaptionButton(toolbar);
00164       bn->setCaption("Fenster");
00165       bn->onPress = myMethod1;
00166 
00167       QCaptionButton * bn2 = new QCaptionButton(toolbar);
00168       bn2->setCaption("Button 2");
00169       bn2->onPress = myMethod2;
00170 
00171       QCaptionButton * bn3 = new QCaptionButton(toolbar);
00172       bn3->setCaption("Button 3");
00173       bn3->onPress = myMethod2;
00174 
00175       toolbar->setWidth(350);
00176 
00177 
00178     }
00179 
00180 
00181 
00182 };
00183 
00184 
00185 void myMethod1(QWidget* Sender, QEvent* e)
00186 {
00187   MyWindow* win = dynamic_cast<MyWindow*>(Sender->getOwner()->getOwner());
00188 
00189   if (win)
00190   {
00191     MyWindow* newwin = new MyWindow(screen);
00192     string cap = win->textedit->getText();
00193     newwin->setCaption(cap);
00194   }
00195   
00196 }
00197 
00198 
00199 void myShutDown(QWidget* Sender, QEvent* e)
00200 {
00201   std::exit(0);
00202 }
00203 
00204 void mySubWindow(QWidget* Sender, QEvent* e)
00205 {
00206   QWindow * win = new QWindow(screen);
00207   win->setWidth (200);
00208   win->setHeight(200);
00209   QWindow * subwin = new QWindow(win);
00210   subwin->setWidth(100);
00211   subwin->setHeight(100);
00212 
00213 }
00214 
00215 int main(int argc, char* argv[])
00216 {
00217 
00218         glutInit(&argc, argv);
00219         glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
00220 
00221     glutInitWindowSize(500, 400);
00222     glutInitWindowPosition(100, 100);
00223     glutCreateWindow("mini QT");
00224 
00225         screen = new QScreen(0);
00226 
00227     QToolBar * toolbar = new QToolBar(screen);
00228     toolbar->setWidth(420);
00229 
00230     QCaptionButton * bnStart = new QCaptionButton(toolbar);
00231     bnStart->setCaption("Start");
00232 
00233     QCaptionButton * bnShutDown = new QCaptionButton(toolbar);
00234     bnShutDown->setCaption("Shut Down");
00235     bnShutDown->onPress = myShutDown;
00236 
00237     QCaptionButton * bnSubWin = new QCaptionButton(toolbar);
00238     bnSubWin->setCaption("Sub Window");
00239     bnSubWin->onPress = mySubWindow;
00240 
00241     toolbar->layout();
00242 
00243 
00244         MyWindow* win = new MyWindow(screen);
00245 
00246 
00247     glutReshapeFunc(glutResize);
00248     glutDisplayFunc(glutDisplay);
00249         glutKeyboardFunc(glutKeyboard);
00250         glutKeyboardUpFunc(glutKeyboardUp);
00251         glutSpecialFunc(glutSpecial);
00252     glutMouseFunc(glutMouse);
00253         glutMotionFunc(glutMotion);
00254 
00255         glutMainLoop();
00256         return 0;
00257 }
00258 //---------------------------------------------------------------------------
00259 
00260 
00261 

Generated on Thu Mar 18 18:33:47 2004 for miniQT by doxygen1.2.18