wxMax

BlitzMax Forums/Brucey's Modules/wxMax

FBEpyon(Posted 2011) [#1]
Hell All,

Can you please help me I am programmign a application for my work, but I have ran into a issue.. well looking at the examples I show alot of Types being used.. I don't understand why they are using this code... "btnMain:CreatButton = CreateButton(New CreateButton.Create(......))", I don't understand the perpose of this I have never seen any of the type in other programs used like this can someone explain this to me thanks...

FBEPYON---


Ole JR(Posted 2011) [#2]
It Creates a New object of a CreateButton type,
and call the Create() method of that object.

Probably CreateButton is extended from wxButton.
Then Create(..) returns a wxButton type,
so you cast that return to a CreateButton Type.


Brucey(Posted 2011) [#3]
Making BlitzMax types that wrap underlying libraries, and making them flexible (so that you can extend these types yourself, for example) can lead to some complex looking code at times.

However it is not too complex when you break it down into its smaller parts and understand what it is trying to achieve :-)

JR is correct in his explanation, but it might not help you to understand the concept.

Here is a complete example (button) from the provided tutorials :
SuperStrict
 
Framework wx.wxApp
Import wx.wxFrame
Import wx.wxPanel
Import wx.wxButton
 
New MyApp.Run()
 
Type MyApp Extends wxApp

	Method OnInit:Int()
	
		Local btn:Button = Button(New Button.Create(Null, wxID_ANY, ..
			"Button", -1, -1, 270, 150))
		btn.Show(True)
 
		Return True
	End Method

End Type

Type Button Extends wxFrame
 
	Method OnInit()
				
		Local panel:wxPanel = New wxPanel.Create(Self, wxID_ANY)
		
		Local button:wxButton = New wxButton.Create(panel, wxID_EXIT, "Quit", 20, 20)
		
		Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED, OnQuit)
		button.SetFocus()

		Centre()
 
	End Method
	
	Function OnQuit(event:wxEvent)
		wxWindow(event.parent).Close(True)
	End Function
	
End Type


It creates a custom window called "Button", adds a Quit button to it, and exits when the button is clicked.

Specifically, we'll look at this line :
Local btn:Button = Button(New Button.Create(Null, wxID_ANY, "Button", -1, -1, 270, 150))

This creates an instance of our custom wxFrame type, and assigns it to a variable of the same type.

"New Button" creates an instance of the Button type only. For the wrapper library to work, we also need to call the Create() method, which internally creates an instance of the real wxFrame object.
Since Create() is defined as returning a wxFrame object, we need to cast up to our own type if we wish to use specific functionality that we also have in our own type.
If you want to create a custom type but not call or use any custom methods or fields you could in fact do this :
Local btn:wxFrame = New Button.Create(Null, wxID_ANY, "Button", -1, -1, 270, 150)

This means that locally, the btn object would be visible as a wxFrame, but in reality it is still your custom object. If you want to use any custom fields or methods with btn, you would still need to explicitly cast to Button().

Another option is to add a Create method to your custom type that returns your custom object instead. In this custom method, you would still need to have cast the call to Super.Create() with your custom type.

You may also notice that there are Create Functions in each type too. This simply adds the ability to create a generic instance of a particular widget - i.e. one that you don't need to add any customisation to.


FBEpyon(Posted 2011) [#4]
Thanks, that helped alot make me understand how wxMax works now, and btw I love it, it gives me everything I need, but one thing.. I have been trying to get the Window XP and Vista theme to work with out a manifest file, is there any built in way of combinding this into the exe or anything..?


Brucey(Posted 2011) [#5]
I believe it's possible to do something similar with MaxGUI, or perhaps even with BlitzMax already. I am pretty sure Seb had something working at one point. Not sure on its status or how you might do it - it may be as simple as importing a file or something...


Brucey(Posted 2011) [#6]
There's some stuff about creating a .o file that you can import, here.

Windows isn't my main platform, so there are probably many more folks about who can give you more useful information. :-)

Last edited 2011


FBEpyon(Posted 2011) [#7]
Thanks Brucey,

That also help alot, I primarily work with windows only, and this will help with my program alot, being that I don't like the old style of windows..

Also one other thing I would like to mention SORRY :(

When I try and rebuild my modules there is a conflict with the standard Max2d module with the wxMax module.. is there something I need to do.. or do I just remove the wxMax if I have to compile anything else..

:edit:

Also is there any plans on adding wxAUI?

Thanks..

Last edited 2011

Last edited 2011


FBEpyon(Posted 2011) [#8]
Hello Brucey,

I have a favior to ask you, I was seeing if you had planned or if you could get the wxMySQL module built into wxMax, I know you already have the BAH.Database, but I was looking at the MYSQL for wxWidget and it seems to be quite good.. anyways let me know what you have plan.. thanks

FBEPYON


Brucey(Posted 2011) [#9]
AUI is already there, if you dig around a bit. See the aui sample in the samples folder :-)

As for database stuff... I don't see any need to have TWO sets of database frameworks in my collections. (or three, if you count Qt too).
The current database stuff works pretty well, and covers most general usage, I think.