Author Topic: SBIUP-Q  (Read 2460 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
SBIUP-Q
« on: May 12, 2014, 10:55:33 PM »
I was playing around with the Rapid-Q IDE and created a simple form. Here is the code.



Code: [Select]
CREATE Form AS QFORM
    Caption = "Form1"
    Width = 320
    Height = 240
    CREATE Label1 AS QLABEL
        Caption = "Customer"
        Left = 19
        Top = 19
        Width = 55
        Height = 13
    END CREATE
    CREATE Edit1 AS QEDIT
        Left = 72
        Top = 16
        Width = 121
        Height = 21
    END CREATE
    CREATE Button1 AS QBUTTON
        Caption = "Quit"
        Left = 107
        Top = 164
        Width = 75
        Height = 25
    END CREATE
END CREATE

Form.ShowModal

Here is the Script BASIC IUP equivalent.

     

Code: [Select]
' Script BASIC Rapid-Q form conversion

IMPORT iup.bas

' SBIUP-Q INIT

Iup::Open()
Iup::SetGlobal("DEFAULTFONT", "Sans, 7.5")

' CREATE FORM

Form = Iup::Create("dialog")
       Iup::SetAttributes(Form, "RASTERSIZE=320x240, TITLE=\"Form1\"")

     vbx     = Iup::Create("vbox")
               Iup::Append(Form, vbx)

     Label1  = Iup::Create("label")
               Iup::SetAttributes(Label1, "TITLE=\"Customer\", RASTERSIZE=55x13, FLOATING=YES, POSITION=\"19,19\"")
               Iup::Append(vbx, Label1)

     Edit1   = Iup::Create("text")
               Iup::SetAttributes(Edit1, "RASTERSIZE=121x21, FLOATING=YES, POSITION=\"72,16\"")
               Iup::Append(vbx, Edit1)

     Button1 = Iup::Create("button")
               Iup::SetAttributes(Button1, "TITLE=\"&Quit\", RASTERSIZE=75x25, FLOATING=YES, POSITION=\"107,164\"")
               Iup::Append(vbx, Button1)
               
' SET CALLBACKS

Iup::SetCallback(Form, "CLOSE_CB", ADDRESS(Win_exit()))


' CALLBACKS FUNCTIONS

SUB Win_exit
  Iup::ExitLoop = TRUE
END SUB

' MAIN

Iup::Show(Form)
Iup::MainLoop
Iup::Close

« Last Edit: May 14, 2014, 04:52:27 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
Re: SBIUP-Q
« Reply #1 on: May 13, 2014, 04:44:10 PM »
The IupLayoutDialog function is an in-line interface to your GUI application. Changes you make in the IDE are immediately reflected in the running application. You can create a dialog from scratch or use a SB script that has IUP in code.


 

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
Re: SBIUP-Q
« Reply #2 on: May 17, 2014, 11:49:29 PM »
It seems the Script BASIC multi-line string feature works with IUP attribute strings. This gives the code more of a Rapid-Q look. Using the multi-line string doesn't require escaping the quoted strings within it.

Code: [Select]
' Script BASIC Rapid-Q form conversion

IMPORT iup.bas

' SBIUP-Q INIT

Iup::Open()
Iup::SetGlobal("DEFAULTFONT", "Sans, 7.5")

' CREATE FORM

Form = Iup::Create("dialog")
       Iup::SetAttributes(Form, _
       """
            RASTERSIZE = 320x240,
            TITLE = "Form1"
       """)

     vbx     = Iup::Create("vbox")
               Iup::Append(Form, vbx)

     Label1  = Iup::Create("label")
               Iup::SetAttributes(Label1, _
               """
                    TITLE = "Customer",
                    RASTERSIZE = 55x13,
                    FLOATING = YES,
                    POSITION = "19,19"
               """)
               Iup::Append(vbx, Label1)

     Edit1   = Iup::Create("text")
               Iup::SetAttributes(Edit1, _
               """
                    RASTERSIZE = 121x21,
                    FLOATING = YES,
                    POSITION = "72,16"
               """)
               Iup::Append(vbx, Edit1)

     Button1 = Iup::Create("button")
               Iup::SetAttributes(Button1, _
               """
                    TITLE = "&Quit",
                    RASTERSIZE = 75x25,
                    FLOATING = YES,
                    POSITION = "107,164"
               """)
               Iup::Append(vbx, Button1)
               
' SET CALLBACKS

Iup::SetCallback(Form, "CLOSE_CB", ADDRESS(Win_exit()))


' CALLBACKS FUNCTIONS

SUB Win_exit
  Iup::ExitLoop = TRUE
END SUB

' MAIN

' Iup::Show(Iup::LayoutDialog(Form))
Iup::Show(Form)
Iup::MainLoop
Iup::Close
               
« Last Edit: May 18, 2014, 12:18:45 PM by John »