Page 1 of 3

sgx - includefile for screen gagdets

Posted: Fri Feb 29, 2008 1:10 am
by #NULL
sgx is a library for creating simple GUI stuff in a screen..
sgx is a screen-gadget library for PureBasic programmers to create and manage simple GUI-elements in a fullscreen or windowed screen.

it's available as sourcecode to be included in your projects. it's currently only available for Windows Operating Systems (though the code is pretty straight PB code). there are two versions: a single-file version that only contains the necessary files to just use sgx and a multi-file version in case you want to make changes to the sgx code, including the gimp files for the image files and some tools to build a single-file version from that.

with this library you can create simple GUI objects statically or dynamically of different type and appearance, modify them, display them easily, examine user actions and process events. sgx elements are accessed by ID (index-like, starting with index 1). the appearance is defined by designs, whereas you can create own designs with sets of images (there is also an instant design "lowbudget" which does not need any image files). currently there is no event queue, you will recognize events by checking for fields of your sgx elements.

currently available gadget types:
- sgxCursor
- sgxButton (including toggle buttons and buttons with a user sprite)
- sgxText
- sgxCheckbox
- sgxCombo
- sgxScrollbar
- sgxTrackbar
- sgxEdit
- sgxWin
- sgxTable
- sgxSpriteGadget
- sgxArea
- option gadgets / radio buttons are available through grouping


the documentation includes
- a quick start (sgxDoc\sgx.html)
- a full reference (sgxDoc\sgxDocFull.html)
- a smaller reference (sgxDoc\sgxDoc.html) without sgx internals (some links to sgx internals may not work in that document thought!)
- examples in the directory 'sgxDoc\'
- _README.TXT contains further informations

[...]
thanks to the PureBasic team and the community / the forums.
for the last update see this post

<screenshot>

<download> (1,3mb) ..you should start with the introduction 'sgxDoc\sgx.html'

Posted: Fri Feb 29, 2008 1:20 am
by Inf0Byt3
Excellent code! This will be very usefull!

Posted: Fri Feb 29, 2008 1:41 am
by #NULL
thanks, you're welcome!
btw: if someone is interested further into the code, i could also make a devel-package, where sgx comes in multiple sources as i'm coding it myself.

Posted: Fri Feb 29, 2008 3:01 am
by Dare
Very nice. Thank you.

Posted: Fri Feb 29, 2008 7:19 am
by thyphoon
Very great code !
it's only available for Windows
Do you think add Linux and MacOsX support ?

Posted: Fri Feb 29, 2008 10:44 am
by srod
Excellent. Thank you.

Posted: Fri Feb 29, 2008 12:10 pm
by Num3
Found a small bug in the sxeditor... When you press capslock, and type, it repeats twice the capitalized letter...

Code: Select all

Ii there
BRILLIANT STUFF btw :D

Posted: Fri Feb 29, 2008 4:56 pm
by #NULL
thank you guys.
@num3
that edit issue should work now. (updated)
@thyphoon
i have no MacOsX programming experience at all neither that OS, so i cannot do something about that.
i could compile and run it under linux already after taking out some things, but performance was quite bad, some colors were distored, and there is a pb TextHeight() bug. so alltogether it wasn't nice to look at :P .
i never got 2dddrawing/screen stuff working under linux without problems or loss of performance, but i have only humble linux expierence i must admid.

Posted: Fri Feb 29, 2008 4:58 pm
by gnozal
Very impressive, thanks !

Posted: Fri Feb 29, 2008 5:14 pm
by #NULL
thanks, you're welcome too!

i forgot to say:
i just changed the order of parameters for sgxCellAssign(). i/k comes first now.

Posted: Wed Mar 05, 2008 4:19 pm
by #NULL
added some infos to the quickstart (sgx.html) about useful functions / variables :)
- you can use sgxSetGroup() to goup togglebuttons and/or checkboxes, so that only one element of that group will be toggled/checked at a time:
[...]
- sgxTipDelay defines the delay (in milliseconds) for showing tooltips
- sgxWinAnimSpeed defines the speed of min/maximizing windows ect.
- sgxHoldDelay defines the delay (in milliseconds) until hold events occur
- sgxHoldStep defines the interval (in frames) for hold events.
- iterate through all valid sgx-IDs with EACHSGX()
[...]
- get the ID of a table cell with sgxCellID()
- free elements with sgxFree() and sgxFreeChildsOf()
- move elements with sgxMove()
- bring up windows and elements in z-order with sgxMoveOnTop()
- refresh elements with sgxRefresh()
- use sgxSetText() and sgxSetState() for field-modifications that need a refresh to be visible (type dependent)
- let sgx access your general timer-variable using sgxSetEmsContainer()

Posted: Sat Jun 14, 2008 5:42 pm
by Raybarg
Hey there, I chose to pick this screengadgetry for the game I have been working on. I had it planned I write something like this (although alot simpler) by myself but I can skip that part :)

Very nice code.

What I have already changed to better implement this code in my game UI is how sgxExamine() returns hovering information which I can use to avoid making mouse actions within the game field when user is clicking gadgets instead. It was just addinitonal variable which sgxExamine() returns as true/false if mouse is over a gadget.

I will list any bugs I come up with instead of just dirty fixing them ;)

Posted: Wed Aug 13, 2008 10:20 pm
by X
This was linked to from the other GUI thread ...

To the poster above ... could you post your changes here? That would be nice ..

Also, to the person who created this. Have you made any chances since posting this code? How is the devel-package coming along?

Posted: Thu Aug 14, 2008 10:25 am
by #NULL
i think it schould be enough to add this line at the end of the procedure sgxExamine:

Code: Select all

Procedure sgxExamine(...
  
  ; [...]
  
  ProcedureReturn topID
EndProcedure
so it will return the gadget-id under the mouse, or -1 if none is there. you could also adapt it to return 0 for no hover istead of -1 if that suits you more.

besides there is the function sgxGetTopWindow(), which is used in sgxExamine() to get the value for 'topID' anyway.

i will see how i can make the devel-package. (i need to include tools, change *.bat scripts and tidy up the directory a bit..)

Posted: Thu Aug 14, 2008 11:03 pm
by #NULL
i added a download for the complete project directory (see first post).
also some changes (some where possibly uploaded already undocumented):
- sgxCloseLevel() got a parameter to close all levels.
- sgxExamine() returns hover information like sgxGetTopWindow().
- sgxSpriteGadget() added.
- (toggle)buttons can have an additional user sprite to be displayed.
there is also one more design, but it's only slightly different from 'outdoor'.