Sign in to follow this  
Followers 0
sshrum

Want to create user-definable GUI profiles

3 posts in this topic

#1 ·  Posted (edited)

I'm writing yet another multimedia player...however, this one is mainly tailored for my own use with touch screens and my extensive media library.

I'd like the ability to create GUI profiles; simple, text based config files that I could parse and have create a GUI and associate commands and interact with the various controls that get created.

I just started thinking about this and figured I'd ask to see what kind of issues I'd run into if anyone else has tried to do this. My first concern is control creation and then command association

Off the top, I'm figuring on a INI styled text file with entries like this:

[1024x768]
1=picture,10,10,100,100,play,play.gif
2=picture,10,130,100,100,next,next.gif
3=button,130,10,100,100,open,Open
n=etc.

<control#>=<control type>,<top>,<left>,<width>,<height>,<command assignment>,<control specifics>

I guess what I'm trying to ask is if this is a sensible way to deal with customizable GUIs? Are their any other ideas or ways to accomplish this sort of thing.

TIA

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Share this post


Link to post
Share on other sites



This is what I just whipped up as a initial test that seems to work so far:

; User definable GUI Test

#include <Array.au3>
#include <GUIConstants.au3>

$iGuiWidth=860+2
$iGuiHeight=1280 + 2

$oGUI = GUICreate("Build-A-GUI", $iGuiWidth, $iGuiHeight, -1, -1); , $WS_POPUP)

GuiCtrlSetState(-1,$GUI_DISABLE)

$sSkin = "label,,Some text" & @crlf & "button,play,Play" & @crlf & "button,stop,Halt that thing" & @crlf & "button,exit,Ba-bye" & @crlf & "button,foobar,I don't work"
$aSkin = StringSplit($sSkin, @lf)

Dim $aGUI[$aSkin[0]+1][4]
$aGUI[0][0] = $aSkin[0]

for $i = 1 to $aSkin[0]
    $aControl = StringSplit($aSkin[$i],",")
    for $j = 1 to $aControl[0]
        $aGUI[$i][$j-1] = $aControl[$j]
    Next
Next

For $i = 1 to $aSkin[0]
    Switch $aGUI[$i][0]
        case "label"
            $iResult = GUICtrlCreatelabel($aGUI[$i][2], 100 * $i, 100, 100, 100)
            $aGUI[$i][3] = $iResult
            Consolewrite("creating label -> $aGUI[" & $i & "][3] = " & $iResult & @crlf)
        case "button"
            $iResult = GUICtrlCreateButton($aGUI[$i][2], 100 * $i, 100, 100, 100)
            $aGUI[$i][3] = $iResult
            Consolewrite("creating button -> $aGUI[" & $i & "][3] = " & $iResult & @crlf)
    EndSwitch
Next

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()  
    if $msg > 0 Then
        Consolewrite("$msg = " & $msg & @crlf)
        for $i = 1 to $aGUI[0][0]
            If $msg = $aGUI[$i][3] then 
                Consolewrite("command = " & $aGUI[$i][1] & @crlf)
                _Command($aGUI[$i][1])
                ExitLoop
            EndIf
        next
    EndIf
WEnd

func _Command($sCommand)
    Switch $sCommand 
        case "play"
            msgbox(0,"","Play")
        case "stop"
            msgbox(0,"","Stop")
        case "exit"
            Exit
        case Else
            msgbox(0,"","Unknown command: '" & $sCommand & "'")
    EndSwitch
EndFunc

Any input would be appreciated.


Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Share this post


Link to post
Share on other sites

It seems one of the only ways to do it. An alternitave could be parsing an XML stylesheet, although both methods would work around the same speed and give you the same results.

Do a search for Dynamic GUI's and you might be able to find something. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0