Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 972 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
LBGUI - A helper script #351016
12/21/10 02:20
12/21/10 02:20
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
Hey there,

Firstly, all credits to Lukas for his awesome LBGUI contribution. grin

I posted this here because I've been using this code in a lot of my tests
and things I've been doing lately, so I thought someone else might like it too smile

Anyway, A couple of weeks ago I made a little header (a wrapper-for-a-wrapper,
so to speak) from various bits of Lukas's demo code, and also some of my own.

I think the best way to describe it is with a script:
Code:
#include <acknex.h>

#include "lbgui_simple.h" //this header automatically includes lbgui.h, so don't worry about that

LBG_WINDOW* a_window = NULL;

void button_ok()
{
	LBG_destroy_window(a_window);
}

void create_window()
{
	a_window = //We're making a window
		LBG_create_window_d(NULL, 128, 128, 256, 256, 2, 2, "A Window", 1, NULL, WF_SHOW | WF_DISABLEGUI);
		
	LBG_BUTTON* button_ok =
		LBG_create_button_d(a_window, 100, 100, 20, 2, "OK?", button_ok, BF_SHOW); 
}

void main()
{
	init_gui(WINDOWS_DEFAULT); // Can also be 'BITMAP_DEFAULT'
	
	wait(3); //Need to wait 'till the engine's ready..
	
	LBG_BUTTON* a_button = //Create a button with the default bitmaps
		LBG_create_button_d(NULL, 100, 100, 20, 2, "Create", create_window, BF_SHOW); 
	
	LBG_INFOBOX* infbox = //Then we can create an infobox for that button
		LBG_create_infobox_d(a_button, 0.1, 10, 10, 5, 5, "This will (hopefully) create a window", IF_SHOW);
}



'What's this wierd '_d' at the end of Lukas's beautiful functions?!' you may ask.

Well, my good sir, those functions with '_d' at the end do not
need bitmap definitions, as they sImply use defaults, defined in the header,
and placed in a folder called 'gui' into the project folder.

Here are the prototypes:
Code:
LBG_BUTTON* LBG_create_button_d(LBG_WINDOW* _parent, var pos_x, var pos_y, var tpos_x, var tpos_y, STRING* caption, void *Event, long flags)
LBG_WINDOW* LBG_create_window_d(LBG_WINDOW* _parent, var pos_x, var pos_y, var size_x, var size_y, var tpos_x, var tpos_y, STRING* caption, var ctype, void* content,long flags)
LBG_CHECKBOX* LBG_create_checkbox_d(LBG_WINDOW* _parent, var pos_x, var pos_y, var tpos_x, var tpos_y, STRING* caption, long flags)
LBG_INFOBOX* LBG_create_infobox_d(LBG_WINDOW* _target, var time, var pos_x, var pos_y, var tpos_x, var tpos_y, STRING* caption, long flags)
LBG_PROGRESSBAR* LBG_create_progressbar_d(LBG_WINDOW* _parent, var pos_x, var pos_y, var width, var barpos_x, var barpos_y, var tpos_x, var tpos_y, STRING* format, long flags, var maximum, var progress)
LBG_SLIDER* LBG_create_slider_d(LBG_WINDOW* _parent, var pos_x, var pos_y, var width, var minimum, var maximum, var value, long flags)
LBG_LISTBOX* LBG_create_listbox_d(LBG_WINDOW* _parent, var pos_x, var pos_y, var size_x, var size_y, var ipos_x, var ipos_y, var isize_x, var isize_y, long flags)
LBG_HSCROLLBAR* LBG_create_hscrollbar_d(LBG_WINDOW* _target, long flags)
LBG_VSCROLLBAR* LBG_create_vscrollbar_d(LBG_WINDOW* _target, long flags)
LBG_RIGHTCLICK* LBG_create_rightclick_d(LBG_WINDOW* _target, var size_x, var ipos_x, var ipos_y, var isize_x, long flags)
LBG_COMBOBOX* LBG_create_combobox_d(LBG_WINDOW* _parent, var pos_x, var pos_y, var width, var tpos_x, var tpos_y, STRING* caption, var ipos_x, var ipos_y, var isize_x, long flags)
LBG_EDITBOX* LBG_create_editbox_d(LBG_WINDOW* _parent, var pos_x, var pos_y, var width, var tpos_x, var tpos_y, STRING* caption, long flags)



Other than this, the functions perform and return things exactly the same as their LBGUI counterparts.

The function of 'init_gui()' is pretty obvious I think, and you can use either the WINDOWS_DEFAULT or BITMAP_DEFAULT
flags to determine the mouse behavior, WINDOWS being standard
arrows and things, BITMAP being a bitmap mouse respectively.

So, what the script does, in a very easy sense, is to just load a ton of defaults, so that if
you're doing a test, or simply need a placeholder GUI, 'lbgui_simple.h' should do the trick.


You can download it here. (I might change file-host later) done.

(This also includes a demo, and the 'real' LBGUI in the same package)

Also, all the bitmaps are defined at the top of 'lbgui_simple.h',
so they should be pretty easy to edit if you like.

Any questions? feel free to ask smile


Last edited by the_mehmaster; 12/21/10 02:37. Reason: Changed filehost..
Re: LBGUI - A helper script [Re: the_mehmaster] #351035
12/21/10 07:50
12/21/10 07:50
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Ah I did the same grin it is useful and maintains overview when using the much shorter functions (without all the -sometimes needed- arguments). Nice work and thanks for sharing laugh.


Click and join the 3dgs irc community!
Room: #3dgs
Re: LBGUI - A helper script [Re: Joozey] #351056
12/21/10 13:59
12/21/10 13:59
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Nice. grin

I actually did something similiar in demo.c, with the functions create_standard_button, create_standard_checkbox and create_standard_radiobutton.
I actually expected each user to do this for his own needs, depending on the parameters that stay the same and those that vary. wink
Cool to see someone doing this for each gui element and sharing it. laugh


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1