Gui

BlitzMax Forums/BlitzMax Programming/Gui

Sarge(Posted 2005) [#1]
All these screenshots are from the early beta of my gui code. [edit] fixed tabs thanks to skn3[ac]






AndyBoy_UK(Posted 2005) [#2]
Hmm, looks interesting, could you post examples of how the forms are put together?


Sarge(Posted 2005) [#3]
This is the WebLink Manager code:

Import Pub.Win32
Include "puremax.bmx"

main:TWindow = New TWindow
edit:TEditBox = New TEditBox
list:TListBox = New TListBox
add:TButton = New TButton
remove:TButton = New TButton
launch:TButton = New TButton

main.Create("WebLink Manager",380,200,200,243,5)
add.create("Add",132,10,50,20,main.hwnd)
edit.create(10,10,119,22,main.hwnd)
list.create(10,35,172,160,main.hwnd)
remove.create("Remove",97,188,80,22,main.hwnd)
launch.create("Launch",14,188,80,22,main.hwnd)

Repeat

Select list.selecteditem()

Case 0
Print "google"
Case 1
Print "yahoo"

End Select

If add.click()
list.additem(edit.gettext())
End If

If remove.click()
list.removeitem(list.selecteditem())
End If

WaitEvent()
Forever


I am using Import Pub.Win32 & Include "puremax.bmx" for myself but at the end you will just have to import it as a module.


ziggy(Posted 2005) [#4]
It looks awesome, and very interesting!!!
I would suggest you to add a function pointer to the events. this way you'll get a functionality closer to .NET applications. I mean:
Type TButton
    Field OnClick()
    Field ....
end Type


inside WaitEvent function:

for each item
    if item.click() =true and item.OnClick <> Null then    
        item.onclick()
    end if
next



so an example could be more or less:

Local MyButton:New TButton
MyButton.OnClick = MyButton_click


repeat
waitevent()
forever

Function MyButton_Click()
   notify ("Pressed!!!")
End Function




Sarge(Posted 2005) [#5]
Ziggy i really like that and i will add it, thank you. Anybody with other suggestions please feel free to say i would like to add what users want.


Dreamora(Posted 2005) [#6]
Interesting although it uses some quite strange naming for example create as method which can't be a constructor because of that.


Sarge(Posted 2005) [#7]
Current Commands

Gadget Create
---------------
Button.Create
CheckBox.Create
GroupBox.Create
ListView.Create
Menu.Create
PopupMenu.Create
RadioBox.Create
RichEdit.Create
ScrollBar.Create
Tab.Create
EditBox.Create
ComboBox.Create
Label.Create
ListBox.Create
Panel.Create
Progress.Create
StatusBar.Create
ToolBar.Create
TrackBar.Create
TreeView.Create
UpDown.Create
Window.Create

Gadget TextBox Commands
---------------
Gadget.PasswordChar
Gadget.CountLines
Gadget.GetLength
Gadget.GetLine
Gadget.AutoSize
Gadget.ReadOnly
Gadget.MultiLine
Gadget.HideSelection
Gadget.AcceptReturn
Gadget.MaxLength
Gadget.Undo
Gadget.Redo
Gadget.Cut
Gadget.Copy
Gadget.Paste
Gadget.Clear

Gadget CheckBox Commands
---------------
Gadget.Checked
Gadget.CheckAlign
Gadget.TextAlign

Gadget RadioBox Commands
---------------
Gadget.Checked
Gadget.CheckAlign
Gadget.TextAlign

Gadget ProgressBar Commands
---------------
Gadget.Range
Gadget.Minimum
Gadget.Maximum
Gadget.StepValue
Gadget.Value

Gadget UpDown Commands
---------------
Gadget.Range
Gadget.Minimum
Gadget.Maximum
Gadget.Value

Window Gadget Commands
---------------
Gadget.Active
Gadget.Maximize
Gadget.Minimize
Gadget.Restore
Gadget.ClientWidth
Gadget.ClientHeight
Gadget.CursorX
Gadget.CursorY

ListBox Gadgets Commands
---------------
Gadget.Addtem
Gadget.InsertItem
Gadget.RemoveItem
Gadget.ClearItems
Gadget.Counttems
Gadget.ModifyItem
Gadget.SelectItem
Gadget.SelectedItem

ComboBox Gadgets Commands
---------------
Gadget.Addtem
Gadget.InsertItem
Gadget.RemoveItem
Gadget.ClearItems
Gadget.Counttems
Gadget.ModifyItem
Gadget.SelectItem
Gadget.SelectedItem
Gadget.AutoSize
Gadget.ItemHeight
Gadget.DropDownWidth

TabControl Gadgets Commands
---------------
Gadget.Addtem
Gadget.InsertItem
Gadget.RemoveItem
Gadget.ClearItems
Gadget.Counttems
Gadget.ModifyItem
Gadget.SelectItem
Gadget.SelectedItem

ToolBar Gadget Commands
---------------
Gadget.AddItem
Gadget.AddBreak
Gadget.AutoSize
Gadget.ButtonSize
Gadget.ImageSize

Menu Gadgets Commands
---------------
Gadget.Create
Gadget.AddItem
Gadget.Free

Default Gadget Commands
---------------
Gadget.Hide
Gadget.Show
Gadget.Free
Gadget.Enable
Gadget.Disable
Gadget.ZOrder
Gadget.Text(txt$)
Gadget.Shape(x,y,w,h)
Gadget.Location(x,y)
Gadget.Size(w,h)
Gadget.Left(x)
Gadget.Top(y)
Gadget.Width(w)
Gadget.Height(h)
Gadget.RightToLeft
Gadget.AllowDrop
Gadget.TabStop
Gadget.Parent
Gadget.GetWidth
Gadget.GetHeight
Gadget.GetLeft
Gadget.GetTop
Gadget.GetText
Gadget.Activate
Gadget.Visible
Gadget.Enabled
Gadget.Font

Button Events
---------------
Gadget.OnClick

Window Events
---------------
Gadget.OnMove
Gadget.OnResize
Gadget.OnClick



Xip(Posted 2005) [#8]
Looks very nice, im looking forward to try this :)
and the function pointer event stuff is a must working with windows(if you ask me) :)


RedRidingHood(Posted 2005) [#9]
It is looking pretty good.

My request is lots of treeview gadget features. I love treeviews. :)


Sarge(Posted 2005) [#10]
TreeView Gadget with alot of features is a must do.

Thanks alot guys


ziggy(Posted 2005) [#11]
Sarge, I'm very interested in this module. I'm working in a plug-in engine for BLIde and I would like to add a GUI interface to allow users build their own plug-ins with blitzMax, I think this module would be great, to integrate with the plug-in SDK engine, becouse this way, plug-ins culd have their own GUI. Please, could you let me know when it's finished? (I think you've got my mail, if not, let me know and I'll give it to you).


ziggy(Posted 2005) [#12]
One question, CREATE is a method or a FUNCTION? And one more thing, have you thougt about adding a 'enabled' property? This would be great for buttons and control containers such as forms, pannels and tabs.


Sarge(Posted 2005) [#13]
Ziggy you will be the first to get it dont worry.

1: Create is a Method
2: Look under "Default Gadget Commands" at the top those commands are for all gadgets and it includes gadget.enabled / gadget.enable / gadget.disable

please give me your email i will send it as soon as its done

Thanks alot mate


Sarge(Posted 2005) [#14]
Ziggy come on mirc or msn some time if you want to ask any questions or want me to add some stuff.

mirc: Server( irc.blitzed.org ) - room: ( BlitzRoom )
MSN: LamasuCreations@...


Why0Why(Posted 2005) [#15]
Looking good Sarge. And as stated above, the events are definitely necessary.


ziggy(Posted 2005) [#16]
Sarge, another suggestion. If you store the handler of the active control (I think this suoldn't be very complicated), you cuold control the lostfocus and getfocus event in the waitevent function. (It's just a suggestion).


Sarge(Posted 2005) [#17]
Yea Ziggy in that example i showed above you can use the handle by doing gadget.hwnd and lostfocus/getfocus are much easier than that i am really liking your suggestions please tell me more if you got any thanks.


ziggy(Posted 2005) [#18]
well then, another suggestion. You can add in a very easy way a timer 'virtual' control. Update a millisecs count in the waitevent, and throw a function pointer when a millisecs count has been reached. This way, you can emulate the .NET timers in a very easy and functional way. No resources associated to this 'virtual' control, and it can be used in a very efficient way to, even, emulate 'threads' in a easy (limitated but data-safe) way.
Can't wait to see this module working. Will it be open source?


Perturbatio(Posted 2005) [#19]
I actually started writing a timer that does just that: http://www.blitzbasic.com/Community/posts.php?topic=45804#509005

(I never got around to fixing the bug).


Sarge(Posted 2005) [#20]
I like your one Perturbatio but i think it is better if i use windows api timers which are the one's like .net but thanks i will keep your one in mind if i end up changing my mind.

Ziggy the module will be open-source and thanks again for all your effort.


Perturbatio(Posted 2005) [#21]
Mine is intended to be platform independant which is why I'm not using API calls.


AndyBoy_UK(Posted 2005) [#22]
So can I have a copy to try :)

I have a GUI App that I want to do some sodding around with and this looks perfect :)

I am also going to get Mr Cowers and have a look at that too.

A


AndyBoy_UK(Posted 2005) [#23]
[edit]

So how does this work then, can I display normal windows over the top of a openGl window, or is it for GUI only. What Im looking for is to have like a blitzPlus canvas gadget and then use the GUI around the edge? Will it be possible with this?

Thanks

[/edit]

Im not too bothered about the platform independance for this app as the thing it works with is Windows only at the moment.

Cheers,
A


Sarge(Posted 2005) [#24]
well i have added one panel which contains the opengl window and can be placed anywhere within a window you can even use the gadget.align(client) to make it the full size of the window. The down side is i am going to have a bit of trouble getting the blitzmax OpenGL 2d commands in my window i will add it soon but i dont think it will be the first release. I will also later add a directx panel for your needs. thanks again guys

[Edit] Andy i will 100% add a canvas gadget it plays a very important role for 2d graphics and the creation of UserControls.


MrCredo(Posted 2005) [#25]
Sarge: do you use winapi for this or do you draw graphics in OpenGL?

do you plan to release this GUI?


Sarge(Posted 2005) [#26]
Hi McCredo

1: The whole gui is done in windows api
2: I will release this open-source as soon as it is done.

Thanks


EOF(Posted 2005) [#27]
Looks very promising. After scanning through the code I thought ... "I'll have some of that!"

Are you planning to release the GUI editor as well?

What about a Blitz+ equivalent to SetGadgetLayout which controls what happens to a gadgets position/size when re-sizing the window.

I do hope you get Max 2D OpenGL working alongside the GUI.

Should you have a FlushMem in the loop?


Sarge(Posted 2005) [#28]
Hi jb

1: What i am doing is im creating the GUI Editor while im creating the gui.
2: I am still fixing my Anchor( 0,0,0,0 ) command which is identical to the SetGadgetLayout in blitz+
3: I will work my best to complete the gui so i can then complete the 2d commands, because when using windows api you create a new window which blitzmax 2d opengl commands dosent regonize it as the default blitzmax window.
4: You will have to use FlushMem because blitzmax's leaks alot, this would be marks job not mine.

[Edit] Gui Editor will be free too

Thanks


EOF(Posted 2005) [#29]
I meant to ask ... What about:

1) tabbing between gadgets
2) keyboard shortcuts to gadgets?

Something like Resi&ze which would underline the 'z' and allow Z ,Alt+Z etc as a shortcut.



3) Drag and drop?

Looks like you have covered a lot of ground already.


Sarge(Posted 2005) [#30]
Hi jb

1: done
2: in the works
3: Gadget.AllowDrop and i will add other commands to communicate with the drop/recive

Thanks


EOF(Posted 2005) [#31]
Wow .. Very interested.