HMG OBJECTS - Harbour GUI library

(version date: 22-May-2010)



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.

Other important design goal was to make it portable. So, different backend GUI frameworks (GTK, QT, wxWindows, etc.) could be easily 'pluged-in'.

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 it's parent window object. The name of this instance variable is the control's name ('Name' property; optional for control itself) and it's content is the control object.

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

        oWindow:Frame_1:Caption := 'New Caption'

        MsgInfo ( oWindow:Frame_1:Caption )

Look at '\samples\button\' for working samples.

(BTW: every '\samples' subfolder contains at least 3 samples: demo1.prg - full OOP syntax; demo2.prg - xBase syntax; demo3.prg - alternate syntax. - A.L.G.)

At the moment the code must be considered experimental. It contains a complete OOP implementation for:

OOP programmers... Welcome to HMG too :)

Enjoy!

Roberto Lopez


HMG OBJECTS - Harbour GUI library source code

Copyright 2002-2010 Roberto Lopez
< mail.box.hmg@gmail.com > < http://sites.google.com/site/hmgweb/ >

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this software; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).

As a special exception, you have permission for additional uses of the text contained in this release of HMG.

The exception is that, if you link the HMG library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License.

Your use of that executable is in no way restricted on account of linking the HMG library code into it.


© 2010 Roberto Lopez < mail.box.hmg@gmail.com > < http://sites.google.com/site/hmgweb/ >

© 2010 Alexey L. Gustow < gustow33 @ mail.ru > (HTML-design)
This page last changed: 23-May-2010