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. Since that was nothing similar in the Harbour world, I've took some things of those products and put it toghether in HMG.

But I've must admit that was a missconception 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 tagets were:

1. Hide all standard HMG windows and control handling pecualiarities to the OOP programmers, in such way that their experience be similar to the one using Clipper predefined objects.

2. Keep the things simple in such way that preprocessor directives be not necessary. 

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 tradicionalists, 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()

	*-------------------------------------------------------*

At the moment the code must be considered experimental and contains a complete OOP implementation for Window and Frame.


Enjoy!