#!/usr/local/bin/ruby
require "qt2"
include Qt2
require "qt2iconview"
include Qt2iconview
require "qt2table"
include Qt2table

class Form1 < QWizard
def initialize

   @image0_data = [   "32 32 10 1",
   ". c None",
   "# c #000000",
   "b c #00c200",
   "e c #313031",
   "h c #410000",
   "d c #5a595a",
   "g c #a4a1a4",
   "f c #c5c2c5",
   "a c #c5ffc5",
   "c c #ffffff",
   "...###..........................",
   "...#aa##........................",
   ".###baaa##......................",
   ".#cd##baaa##....................",
   ".#cccd##baaa##..##e.............",
   ".#cccccd##baaa##aaa##...........",
   ".#cccccccd##baaaaaaaa##.........",
   ".#cccccccccd##baaaaaaa#.........",
   ".#cccccfcffgg#bbbbaaaaa#........",
   ".#ccccccfcfffd#bbbbbbaa#........",
   ".#cccfcfcfcffgd##bh#bbba#.......",
   ".#ccccfcfffffffgd#dd##ba#.......",
   ".#cfcfcfcfffffffffgfgd#bb#......",
   ".#ccfcfffffffffgfgfgfgd#b#......",
   ".#cfcfcfffffffffgfgfggd#b#......",
   ".#fcfffffffffgfgfgggggd#b#......",
   ".#cfcfffffffffgfgfggggd#b#......",
   ".#fffffffffgfgfgggggggdhb#......",
   ".#ffffffffffgfgfggggggd#b#......",
   ".#ggfffffgfgfgggggggggd#b#......",
   ".#ddggffffgfgfggggggggd#b#......",
   "..##ddggfgfgggggggggggd#b#......",
   "....##ddgggfggggggggggd#b#......",
   "......##ddggggggggggggd#b#......",
   "........##ddggggggggggd#b#......",
   "..........##ddggggggggd#b#......",
   "............##ddggggggd#b###....",
   "..............##ddggggd#b#####..",
   "................##ddggd#b######.",
   "..................##ddd#b#####..",
   "....................##d#b###....",
   "......................####......"]

   @image0 = QPixmap.new(@image0_data)
   setName("Form1")
   setGeometry(0,0,421,301)
   setCaption(tr("Form1"))

   @page1 = QWidget.new(self)
   @page1.setName("page1")

   rvbox_0 = QVBoxLayout.new(@page1)
   rvbox_0.setMargin(11)
   rvbox_0.setSpacing(6)

   @TextLabel1 = QLabel.new(@page1)
   @TextLabel1.setName("TextLabel1")
   @TextLabel1.setText(tr("This is an example for ui2rb script.

How to use ui2rb?

1. Install ruby and qt2 library for ruby.
   (http://sfns.u-shizuoka-ken.ac.jp/geneng/horie_hp/ruby/index.html)"))
   @TextLabel1.setAlignment(AlignTop|AlignLeft)
   QToolTip::add(@TextLabel1,"This is Label")
   QWhatsThis::add(@TextLabel1,"This is message for you!")

   rvbox_0.addWidget(@TextLabel1,0)
   addPage(@page1,tr("Page1"))

   @page2 = QWidget.new(self)
   @page2.setName("page2")

   rvbox_1 = QVBoxLayout.new(@page2)
   rvbox_1.setMargin(11)
   rvbox_1.setSpacing(6)

   @TextLabel2 = QLabel.new(@page2)
   @TextLabel2.setName("TextLabel2")
   @TextLabel2.setText(tr("How to use ui2rb?

2. Install qt2xml module in qt2/modules/qt2xml
 in qt2 package.

ex)
ruby extconf.rb --with-qt-dir=<dir. qt2 lib installed>
make
make install"))
   @TextLabel2.setAlignment(AlignTop|AlignLeft)

   rvbox_1.addWidget(@TextLabel2,0)
   addPage(@page2,tr("Page2"))

   @page3 = QWidget.new(self)
   @page3.setName("page3")

   rvbox_2 = QVBoxLayout.new(@page3)
   rvbox_2.setMargin(11)
   rvbox_2.setSpacing(6)

   @TextLabel3 = QLabel.new(@page3)
   @TextLabel3.setName("TextLabel3")
   @TextLabel3.setText(tr("How to use ui2rb?

3. If you want to icons in designer, install zlib extension for ruby.
   (http://www.blue.sky.or.jp/atelier/)

   And if you want to Qtable or QIconView, you need qt2table and 
   qt2iconview module in qt2 package."))
   @TextLabel3.setAlignment(AlignTop|AlignLeft)

   rvbox_2.addWidget(@TextLabel3,0)
   addPage(@page3,tr("Page3"))

   @page4 = QWidget.new(self)
   @page4.setName("page4")

   rvbox_3 = QVBoxLayout.new(@page4)
   rvbox_3.setMargin(11)
   rvbox_3.setSpacing(6)

   @TextLabel4 = QLabel.new(@page4)
   @TextLabel4.setName("TextLabel4")
   @TextLabel4.setText(tr("How to use ui2rb?

4.  Then, you can translate *.ui file to *.rb such like...
     ui2rb -x (rubyfile.rb) (*.ui file)  

     You can open form by..
     ruby rubyfile.rb

     Or directly open forms in *.ui file by..
     ui2rb -e (*.ui)"))
   @TextLabel4.setAlignment(AlignTop|AlignLeft)

   rvbox_3.addWidget(@TextLabel4,0)
   addPage(@page4,tr("Page4"))

   @page5 = QWidget.new(self)
   @page5.setName("page5")

   rvbox_4 = QVBoxLayout.new(@page5)
   rvbox_4.setMargin(11)
   rvbox_4.setSpacing(6)

   @TextLabel5 = QLabel.new(@page5)
   @TextLabel5.setName("TextLabel5")
   @TextLabel5.setText(tr("How to use ui2rb?

5.  For install ui2rb in your system...
    
    a. copy ui2rb to the directory in PATH.
    ex) /usr/local/bin
    b. copy formmaker.rb to the directory in RUBYLIB.
    ex) /usr/local/lib/ruby/site_ruby

    If you use KDE and bind .ui extension to ui2rb script, 
    you can open *.ui file from filemanager of 
    KDE."))
   @TextLabel5.setAlignment(AlignTop|AlignLeft)

   rvbox_4.addWidget(@TextLabel5,0)
   addPage(@page5,tr("Page5"))

   @page6 = QWidget.new(self)
   @page6.setName("page6")

   rvbox_12 = QVBoxLayout.new(@page6)
   rvbox_12.setMargin(11)
   rvbox_12.setSpacing(6)

   @TextLabel6 = QLabel.new(@page6)
   @TextLabel6.setName("TextLabel6")
   @TextLabel6.setText(tr("Complicated example"))

   rvbox_12.addWidget(@TextLabel6,0)

   @TabWidget2 = QTabWidget.new(@page6)
   @TabWidget2.setName("TabWidget2")

   @tab1 = QWidget.new(@TabWidget2)
   @tab1.setName("tab1")

   rgridlayout_5 = QGridLayout.new(@tab1)
   rgridlayout_5.setMargin(11)
   rgridlayout_5.setSpacing(6)

   @LCDNumber1 = QLCDNumber.new(@tab1)
   @LCDNumber1.setName("LCDNumber1")
   rgridlayout_5.addWidget(@LCDNumber1,1,0)

   @Slider1 = QSlider.new(@tab1)
   @Slider1.setName("Slider1")
   @Slider1.setOrientation(Qt::Horizontal)
   rgridlayout_5.addWidget(@Slider1,0,0)

   @Dial1 = QDial.new(@tab1)
   @Dial1.setName("Dial1")
   rgridlayout_5.addMultiCellWidget(@Dial1,0,1,1,1)

   @tab2 = QWidget.new(@TabWidget2)
   @tab2.setName("tab2")

   rhbox_10 = QHBoxLayout.new(@tab2)
   rhbox_10.setMargin(11)
   rhbox_10.setSpacing(6)

   @IconView1 = QIconView.new(@tab2)
   @IconView1.setName("IconView1")

   riconviewitem_6 = QIconViewItem.new(@IconView1)
   riconviewitem_6.setText(tr("New Item"))
   riconviewitem_6.setPixmap(@image0)

   rhbox_10.addWidget(@IconView1,0)

   @privateLayoutWidget_9 = QWidget.new(@tab2)
   @privateLayoutWidget_9.setName("Layout1")
   @privateLayoutWidget_9.setMaximumSize(80,32767)

   @Layout1 = QVBoxLayout.new(@privateLayoutWidget_9)
   @Layout1.setMargin(0)
   @Layout1.setSpacing(6)

   @PushButton1 = QPushButton.new(@privateLayoutWidget_9)
   @PushButton1.setName("PushButton1")
   @PushButton1.setText(tr("Add"))

   @Layout1.addWidget(@PushButton1,0)

   @PushButton2 = QPushButton.new(@privateLayoutWidget_9)
   @PushButton2.setName("PushButton2")
   @PushButton2.setText(tr("Del"))

   @Layout1.addWidget(@PushButton2,0)

   @Spacer1_7 = QSpacerItem.new( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum )

   @Layout1.addItem(@Spacer1_7)

   rhbox_10.addWidget(@privateLayoutWidget_9,0)

   @tab3 = QWidget.new(@TabWidget2)
   @tab3.setName("tab3")

   rgridlayout_11 = QGridLayout.new(@tab3)
   rgridlayout_11.setMargin(11)
   rgridlayout_11.setSpacing(6)

   @Table1 = QTable.new(@tab3)
   @Table1.setName("Table1")
   @Table1.setNumRows(100)
   @Table1.setNumCols(100)
   rgridlayout_11.addWidget(@Table1,0,0)

   @TabWidget2.insertTab(@tab1,tr("Tab 1"))

   @TabWidget2.insertTab(@tab2,tr("Tab 2"))

   @TabWidget2.insertTab(@tab3,tr("Tab"))

   rvbox_12.addWidget(@TabWidget2,0)
   addPage(@page6,tr("Page Extra"))

#connections of main form
   
   Qt2::connect(@Slider1, QSIGNAL("valueChanged(int)"), @LCDNumber1, QSLOT("display(int)"))   
   Qt2::connect(@Dial1, QSIGNAL("valueChanged(int)"), @Slider1, QSLOT("setValue(int)"))   
   Qt2::connect(@Slider1, QSIGNAL("valueChanged(int)"), @Dial1, QSLOT("setValue(int)"))

#taborders
end

end
#main roop for displaying form

a = QApplication.new([$0]+ARGV)
codec = QTextCodec.codecForName('UTF-8')
a.setDefaultCodec(codec)
#for close to quit program
Qt2::connect(QApplication::qApp,QSIGNAL("lastWindowClosed()"),
   QApplication::qApp,QSLOT("quit()"))
myform = Form1.new
a.setMainWidget(myform)
myform.show()
a.exec
