=begin
/****************************************************************************
** $Id: qt/examples/box/globjwin.cpp   2.2.2   edited 2000-08-31 $
**
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
**
** This file is part of an example program for Qt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
=end

#include <qpushbutton.h>
#include <qslider.h>
#include <qlayout.h>
#include <qframe.h>
#include <qmenubar.h>
#include <qpopupmenu.h>
#include <qapplication.h>
#include <qkeycode.h>
#include "globjwin.h"
#include "glbox.h"
require "qt2"
include Qt2
require "opengl"
include GL
require "qt2gl"
include Qt2gl

class GLObjectWindow < QWidget
def initialize( parent=nil, name="" )
    super( parent, name )


    #// Create a menu
    file = QPopupMenu.new( self )
    file.insertItem( "Exit",  QApplication::qApp, "quit()", CTRL+Key_Q )

    #// Create a menu bar
    m = QMenuBar.new( self )
    m.setSeparator( QMenuBar::InWindowsStyle )
    m.insertItem("&File", file )

    #// Create a nice frame to put around the OpenGL widget
    f = QFrame.new( self, "frame" )
    f.setFrameStyle( QFrame::Sunken | QFrame::Panel )
    f.setLineWidth( 2 )

    #// Create our OpenGL widget
    c = GLBox.new( f, "glbox")

    #// Create the three sliders one for each rotation axis
    x = QSlider.new ( 0, 360, 60, 0, QSlider::Vertical, self, "xsl" )
    x.setTickmarks( QSlider::Left )
    Qt2::connect( x, QSIGNAL("valueChanged(int)"),c,"setXRotation(int)" )

    y = QSlider.new ( 0, 360, 60, 0, QSlider::Vertical, self, "ysl" )
    y.setTickmarks( QSlider::Left )
    Qt2::connect( y, QSIGNAL("valueChanged(int)"),c,"setYRotation(int)" )

    z = QSlider.new ( 0, 360, 60, 0, QSlider::Vertical, self, "zsl" )
    z.setTickmarks( QSlider::Left )
    Qt2::connect( z, QSIGNAL("valueChanged(int)"),c,"setZRotation(int)" )


    #// Now that we have all the widgets, put them into a nice layout

    #// Put the sliders on top of each other
    vlayout = QVBoxLayout.new( 20, "vlayout")
    vlayout.addWidget( x )
    vlayout.addWidget( y )
    vlayout.addWidget( z )

    #// Put the GL widget inside the frame
    flayout = QHBoxLayout.new( f, 2, 2, "flayout")
    flayout.addWidget( c, 1 )

    #// Top level layout, puts the sliders to the left of the frame/GL widget
    hlayout = QHBoxLayout.new( self, 20, 20, "hlayout")
    hlayout.setMenuBar( m )
    hlayout.addLayout( vlayout )
    hlayout.addWidget( f, 1 )
end
end

