
HMG OBJECTS
-----------

HMG OOP?... WHY NOT?... ;)


The number one question across my eight years dedicated to HMG is: Why HMG is 
not *True* OOP?

I've answered that question hundred times...

Most OOP implementations at the time that I've started MiniGUI library, were 
ugly, obscure, difficult and clumsy. Writing simple programs using such tools 
could be a terrible nightmare.

By the other hand I've had good experiences with VB, VFP and RapidQ and since 
that was nothing similar in the Harbour world, I've took some things of those 
products and put it together in HMG.

But I must admit that was a misconception from my part.

Harbour OOP implementation is very powerful and flexible enough to allow the 
creation of a simple and easy to use OOP layer for any purpose (including a 
GUI library).

My main goals was to hide all standard HMG windows and control handling 
peculiarities to the OOP programmers, in such way that their experience 
be similar to the one using Clipper predefined classes.

Here is a sample that creates a main window and a frame inside it:


	Local oFrame
	Local oWindow

	* Window Definition *

	With Object oWindow := Window():New()
		:Row		:= 10
		:Col		:= 10
		:Width		:= 400
		:Height		:= 400
		:Title		:= 'Nice OOP Demo!!!'
		:WindowType	:= WND_MAIN
		:OnInit		:= { || oWindow:Center() }
	End With

	* Frame Definition *

	With Object oFrame := Frame():New()
		:Parent		:= oWindow
		:Row		:= 10
		:Col		:= 10
		:Width		:= 350
		:Height		:= 340
		:Caption	:= 'This is an OOP Frame!!!'
	End With

	oWindow:Activate()


For traditionalists, the same thing can be achieved using the following code:


	Local oFrame
	Local oWindow

	* Window Definition *

	oWindow := Window():New()

	oWindow:Row		:= 10
	oWindow:Col		:= 10
	oWindow:Width		:= 400
	oWindow:Height		:= 400
	oWindow:Title		:= 'Nice OOP Demo!!!'
	oWindow:WindowType	:= WND_MAIN
	oWindow:OnInit		:= { || oWindow:Center() }

	* Control Definition *

	oFrame := Frame():New()

	oFrame:Parent	:= oWindow
	oFrame:Row	:= 10
	oFrame:Col	:= 10
	oFrame:Width	:= 350
	oFrame:Height	:= 340
	oFrame:Caption	:= 'Hi OOP!!!'

	oWindow:Activate()


Windows and its controls are created at window activation unless 'Create()'
method is invoked (Create() method is available for both).

Control's 'Parent' property is optional. If not specified, the last window 
defined is its default value.

xBase and alternate syntax can be used. 

At control creation, an instance variable is dynamically added to its
parent window object. The name of this instance variable is the control's 
name (optional property) and its content is the control object.

So, you could access a particular control (ie) in the following way:

	oWindow:Frame_1:Caption := 'New Caption'

Look at \samples\button for working samples.


At the moment the code must be considered experimental. It contains a complete 
OOP implementation for Window, Frame, Button, Label, CheckBox, TextBox, 
Spinner, Grid and Tab.



OOP programmers... Welcome to HMG too :)


Enjoy!
