View Poll Results: Do you like new concise syntax?

Voters
7. You may not vote on this poll
  • Yes

    6 85.71%
  • No

    1 14.29%
  • Do not know

    0 0%
Results 1 to 4 of 4

Thread: thinBasic 1.10.5 UI is becoming more easier and more clean (I hope)

  1. #1
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,197
    Blog Entries
    2
    Rep Power
    10

    thinBasic 1.10.5 UI is becoming more easier and more clean (I hope)

    Another new set of features you will get in next thinBasic 1.10.5 is the ability to specify shorter sentences for creating windows and controls and later, when it's the right time, specify the missing information using a simple <object>.<property> notation. This is possible using the new "Name" option that will allow to give a name to Windows and Controls and use that name to reference to specific windows or controls without the need to know windows handle and control IDs

    Of course remaining 100% compatible with previous notation.
    No need to change anything in your scripts if you do not want.

    A script example and a bundled exe can show you how.
    uses "ui"
    
    
    begin ControlID
      %lbl
      %txt
      %btnClose
      %stBar
      %listbox
      %progressbar
    end ControlID
    
    
    '---Create Window and controls using new shot notations
    '---All the rest of properties can be defined later during window events
    DIALOG New Pixels, Name frmMain, 0, "Window to demonstrate Named Controls"
      control add label     , name lbl      , frmMain.Handle, %lbl      , "This is a label"
      control add textbox   , name txt      , frmMain.Handle, %txt      , "This is a textbox"
      control add Button    , name btnClose , frmMain.Handle, %btnClose , "Close"
      Control Add Statusbar , name stBar    , frmMain.Handle, %stBar    , ""
    
    
    DIALOG SHOW MODAL frmMain.Handle
    
    
    
    
    '--------------------------------------------
    callBack function frmMain_OnCallback() As Long
    '--------------------------------------------
    
    
    end Function
    
    
    '--------------------------------------------
    callBack function frmMain_OnInit() As Long
    '--------------------------------------------
    
    
      long dW, dH
    
    
      '---Define window style
      frmMain.Style = %WS_DLGFRAME | %DS_CENTER | %WS_CAPTION | %WS_SYSMENU | %WS_OVERLAPPEDWINDOW
    
    
      '---Get desktop size
      DESKTOP GET SIZE TO dW, dH
      
      '---Set Window client size
      frmMain.cw = 800
      frmMain.ch = 600
    
    
      '---Set window minimum size
      frmMain.MinSize = 640, 480
      
      '---Center window
      frmMain.x  = (dW - frmMain.cw)/ 2
      frmMain.y  = (dH - frmMain.ch)/ 2
    
    
    end Function
    
    
    '--------------------------------------------
    callBack function frmMain_OnSize() As Long
    '--------------------------------------------
    
    
      '---Set controls locations and size
      lbl.x = 5:      lbl.y =  5:  lbl.w = 200:  lbl.h = 20
      txt.x = 5:      txt.y = 25:  txt.w = 200:  txt.h = 25
    
    
      btnClose.x = frmMain.cw - 110
      btnClose.y = frmMain.ch - 50 - stBar.h
      btnClose.w = 100
      btnClose.h = 40
    
    
    end function
    
    
    '--------------------------------------------
    callback function btnClose_OnClick()
    '--------------------------------------------
    
    
      frmMain.End
      
    end Function
    
    Attached Files Attached Files
    Last edited by ErosOlmi; 30-11-2017 at 00:49.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,800
    Blog Entries
    3
    Rep Power
    694
    I consider this to be the jump to the right direction - it makes the creation of dialogs and controls simple.
    With less code more done while it does not compromise the clarity and meaning.

    My wish is to get rid of those evil DIALOG and CONTROL commands.

    If we look at:
    control add label , name lbl , frmMain.Handle, %lbl , "This is a label"
    
    ...BASICally, the %lbl is redunant and the same could be done in a way similar to:
    add label "lbl", "This is a label" to frmMain
    
    (handle known to frmMain, no need for ctrlId, which could be autogenerated internally)

    ...or maybe more standard:
    lbl = new Label("This is a label")
    frmMain.addControl(lbl)
    

    Petr
    Last edited by Petr Schreiber; 30-11-2017 at 21:32.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  3. #3
    Hi Eros,
    Great changes !. Please consider function syntax like this;
    FunctionName(Param1, Param2....,ParamN)
    Here is an example of window creation;
    Window_Handle = CreateWindow(Location=(x,y), Size=(x,y), Title="String", WindowStyles=(List_Of_Styles))
    
    And here is one for control creation;

    Control_Handle = CreateButton(Parent=Window_Handle, Location=(x,y), Size=(x,y), Text="String", ButtonStyles=(List_Of_Styles))
    Control_Handle = CreateLabel(Parent = Window_Handle, Location=(x,y), Size=(x,y), Text="String", LabelStyles=(List_Of_Styles))
    Control_Handle = CreateTextBox(Parent = Window_Handle, Location=(x,y), Size=(x,y), Text="String", TextBoxlStyles=(List_Of_Styles))
    
    And bind events like this;
    BindEvent(Control_Handle, EventName = TB_EVENT_MOUSE_HOVER, CallBackFunction = "NameOfFunction")
    
    looks like python style. But its an easy one.
    Last edited by kcvinu; 01-12-2017 at 17:10.

  4. #4
    i agree with Petr:
    add label "lbl", "This is a label" to frmMain
    we will never forget this syntax, or may be :
    add label "lbl", w,h, x,y, "This is a label", to frmMain

    so it is a kind of a wrapper to the complex syntax, which will stay available (as i understand from Eros reply somewhere) .

Similar Threads

  1. Cool and Clean, safe to use?
    By kryton9 in forum Suggestions/Ideas discussions
    Replies: 3
    Last Post: 05-05-2017, 14:01
  2. Computer hope
    By ErosOlmi in forum Shout Box Area
    Replies: 1
    Last Post: 02-07-2010, 14:25
  3. Pirates of the Mediterranean (fixed - I hope)
    By danbaron in forum Shout Box Area
    Replies: 11
    Last Post: 25-06-2010, 01:15
  4. clean(ish) Energy
    By Michael Clease in forum Science
    Replies: 12
    Last Post: 20-10-2008, 19:37

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •