HMG OOP?... WHY NOT?... ;) [UPDATED]
Moderator: Rathinagiri
- karweru
- Posts: 220
- Joined: Fri Aug 01, 2008 1:51 pm
- DBs Used: DBF,mysql,mariadb,postgresql,sqlite,odbc
- Contact:
Re: HMG OOP?... WHY NOT?... ;) [UPDATED]
Roberto,
To say I'm happy about this development would be an understatement. I've struggled in the past to implement OOP by using the alternate syntax but it has been rather difficult, especially with the window class. I'm extremely impressed with your style of calling :new() without parameters....you have such an exciting way of doing things. Thank you very much ad may God bless you abundantly!
To say I'm happy about this development would be an understatement. I've struggled in the past to implement OOP by using the alternate syntax but it has been rather difficult, especially with the window class. I'm extremely impressed with your style of calling :new() without parameters....you have such an exciting way of doing things. Thank you very much ad may God bless you abundantly!
Kind regards,
Gilbert.
Gilbert.
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: HMG OOP?... WHY NOT?... ;) [UPDATED]
Exactly the same, but you must add the 'Create()' method (it calls _Define* function).sistemascvc wrote:the best way is that you choose.
I agree with you
if i need add a control after the window has been activated
how you do it? (the syntax)
best regards
Ciro
ie:
Code: Select all
* Frame Definition *
With Object oFrame := Frame():New()
:Parent := oWindow
:Row := 10
:Col := 10
:Width := 350
:Height := 340
:Caption := 'This is an OOP Frame!!!'
:Create()
End With
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: HMG OOP?... WHY NOT?... ;) [UPDATED]
Thanks. The idea is to give to HMG an alternate personality, so, those wanting to use a GUI in the Clipper OOP style, can do it.rathinagiri wrote:Nice implementation Roberto. Go ahead.
Now that the hard work is done, the rest of the controls will be easy, since most properties, events and methods will inherit from CONTROL class already created.
Besides that, event when not necessary, xBase command directives can be created to meet Clipper style.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: HMG OOP?... WHY NOT?... ;) [UPDATED]
Thanks.karweru wrote:I'm extremely impressed with your style of calling :new() without parameters....you have such an exciting way of doing things. Thank you very much ad may God bless you abundantly!
Anyway, this is not a particularly original idea
Clipper's GetNew() function used to create a GET object can be called without parameters.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
Re: HMG OOP?... WHY NOT?... ;) [UPDATED]
Simplemente Maravilloso!
Ahora quién se quedará fuera de HMG ( oficial, por supuesto ) ?
Gracias porque realmente no manejo la programación OOP, esto me ayudará a comprenderla y utilizarla.
Simply Wonderful!
Now who will be out of HMG (official, of course)?
Thank you because I do not use OOP programming, this will help me understand and use.
Ahora quién se quedará fuera de HMG ( oficial, por supuesto ) ?
Gracias porque realmente no manejo la programación OOP, esto me ayudará a comprenderla y utilizarla.
Simply Wonderful!
Now who will be out of HMG (official, of course)?
Thank you because I do not use OOP programming, this will help me understand and use.
Saludos, Fernando Chirico.
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: HMG OOP?... WHY NOT?... ;) [UPDATED]
I'm thinking same as Fernando, so many thanks for this important enhancementfchirico wrote: Simply Wonderful!
Now who will be out of HMG (official, of course)?
Thank you because I do not use OOP programming, this will help me understand and use.
Sorry my ignorance; in this way does we will build our own controls ?
Saludos, regards
--
Esgici
Viva INTERNATIONAL HMG
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: HMG OOP?... WHY NOT?... ;) [UPDATED]
Not necessarily, but it could be do the things easier.esgici wrote:I'm thinking same as Fernando, so many thanks for this important enhancementfchirico wrote: Simply Wonderful!
Now who will be out of HMG (official, of course)?
Thank you because I do not use OOP programming, this will help me understand and use.
Sorry my ignorance; in this way does we will build our own controls ?
Saludos, regards
--
Esgici
Take a look at the sources.
FRAME class is very compact because it inherits most properties, events and methods from CONTROL class.
So, If you want to create a new control, your class could inherit from CONTROL class too, saving you a lot of work.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
Re: HMG OOP?... WHY NOT?... ;) [UPDATED]
OOPS? WHY NOT?!
Please go ahead and see if anything could be done in this regard.........
Please go ahead and see if anything could be done in this regard.........
- dhaine_adp
- Posts: 457
- Joined: Wed Aug 06, 2008 12:22 pm
- Location: Manila, Philippines
Re: HMG OOP?... WHY NOT?... ;) [UPDATED]
Hi Roberto,
Your OOP code is very elegant and very simple and yet very powerful. You have established the base class of the controls for which all controls can inherit. I tried to experiment with your sample. I modified Test1 and added grid on it.
Unfortunately I am not successful. On the first try, while running the program, the supposed to be window does not display at all. No error log, it simply exit. A little later I added an altd() debugger call and inserted oGrid1:Hide() right before oWindow.Activate. It gives me this error message:
Control: _HMG_OBJECT_3 Of _HMG_OBJECT_1 Not defined. Program Terminated
Called from DOMETHOD(7426)
Called from GRID:HIDE(128)
Called from MAIN(58)
In the OOPLIB.PRG I added this line: Set Procedure To lib\grid
In the spirit of learning I followed the FRAME Class and the GRID Class source code looks like this:
This is the test source code including my altd() call:
My intention in doing this is to see how the exe file would grow, if HMG and OOPLib could run side by side (I believed it would because classes have their own separate space) and the application performance in terms of speed and stability.
Your OOP experimental code is a new world to be explore and it's thrilling to play with.
I have a feeling that my problem lies on the class DATA initialization of the GRID & of course those bugs on my code.
Congrats and thank you very much for drafting a new toy for us!
Regards,
Danny
Your OOP code is very elegant and very simple and yet very powerful. You have established the base class of the controls for which all controls can inherit. I tried to experiment with your sample. I modified Test1 and added grid on it.
Unfortunately I am not successful. On the first try, while running the program, the supposed to be window does not display at all. No error log, it simply exit. A little later I added an altd() debugger call and inserted oGrid1:Hide() right before oWindow.Activate. It gives me this error message:
Control: _HMG_OBJECT_3 Of _HMG_OBJECT_1 Not defined. Program Terminated
Called from DOMETHOD(7426)
Called from GRID:HIDE(128)
Called from MAIN(58)
In the OOPLIB.PRG I added this line: Set Procedure To lib\grid
In the spirit of learning I followed the FRAME Class and the GRID Class source code looks like this:
Code: Select all
#include "hbclass.ch"
#include "common.ch"
*..............................................................................*
* Class Grid ..................................................................*
*..............................................................................*
CLASS GRID FROM CONTROL
* Internal Data
DATA Tooltip INIT NIL
DATA aHeaders INIT {}
DATA aWidths INIT {}
DATA aRows INIT {}
DATA value INIT {0,0}
DATA nogrid INIT .F.
DATA aImage INIT {}
DATA aJust INIT {}
DATA break INIT .F.
DATA HelpId INIT NIL
DATA bold INIT .F.
DATA italic INIT .F.
DATA underline INIT .F.
DATA strikeout INIT .F.
DATA ownerdata INIT .T.
DATA ondispinfo INIT {}
DATA itemcount INIT 0
DATA available0 INIT .T.
DATA available1 INIT .T.
DATA available2 INIT .T.
DATA multiselec INIT .F.
DATA available3 INIT .F.
DATA backcolor INIT {}
DATA fontcolor INIT {}
DATA inplace INIT .F.
DATA editcontrols INIT NIL
DATA dynamicbackcolor INIT {}
DATA dynamicforecolor INIT {}
DATA columnvalid INIT {}
DATA columnwhen INIT {}
DATA columnheaders INIT {}
DATA aHeaderImages INIT NIL
DATA cellnavigation INIT .T.
DATA recordsource INIT NIL
DATA columnfields INIT NIL
DATA append INIT .F.
DATA buffered INIT .T.
DATA allowdelete INIT .F.
DATA dynamicdisplay INIT NIL
DATA OnChange INIT NIL
DATA DblClick INIT NIL
DATA aHeadClick INIT NIL
DATA GotFocus INIT NIL
DATA LostFocus INIT NIL
DATA OnSave INIT NIL
* Methods
METHOD Create()
* Events
METHOD Onchange INLINE EVAL ( ::OnChange )
METHOD Ondblclick INLINE EVAL ( ::DblClick )
METHOD OnaHeadClick INLINE EVAL ( ::aHeadClick )
METHOD Ongotfocus INLINE EVAL ( ::GotFocus )
METHOD Onlostfocus INLINE EVAL ( ::LostFocus )
METHOD Onsave INLINE EVAL ( ::OnSave )
ENDCLASS
*..............................................................................*
* Methods .....................................................................*
*..............................................................................*
METHOD Create() CLASS GRID
_DefineGrid ( ::cName, ;
::cParent, ;
::nRow, ;
::nCol, ;
::nWidth,;
::nHeight, ;
::aHeaders , ;
::aWidths , ;
::aRows , ;
::value , ;
::fontname , ;
::fontsize , ;
::tooltip , ;
::Onchange , ;
::DblClick , ;
::aHeadClick , ;
::GotFocus , ;
::LostFocus , ;
::nogrid , ;
::aImage , ;
::aJust , ;
::break , ;
::HelpId , ;
::bold , ;
::italic , ;
::underline , ;
::strikeout , ;
::ownerdata , ;
::ondispinfo , ;
::itemcount , ;
::available0 , ;
::available1 , ;
::available2 , ;
::multiselect , ;
::available3 , ;
::backcolor , ;
::fontcolor , ;
::inplace , ;
::editcontrols , ;
::dynamicbackcolor ,;
::dynamicforecolor ,;
::columnvalid , ;
::columnwhen , ;
::columnheaders , ;
::aHeaderImages , ;
::cellnavigation , ;
::recordsource , ;
::columnfields , ;
::append , ;
::buffered , ;
::allowdelete , ;
::dynamicdisplay , ;
::OnSave )
::lCreated := .T.
RETURN Self
Code: Select all
#include "include\hmgoop.ch"
Set Procedure To lib\OopLib
Function Main
Local oFrame
Local oWindow
local oGrid1
PRIVATE aRows_ := ARRAY( 20 )
_HMG_SYSDATA [ 323 ] := 0
SetTestData()
* 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 and Grid!!!'
End With
with object oGrid1 := Grid():New()
:Parent := oWindow
:Row := 15
:Col := 15
:Width := 330
:Height := 320
:aHeaders := { "Last Name", "First Name", "Phone" }
:aWidths := { 100, 200, 100 }
:aRows := aRows_
:Value := {1,1}
End with
altd()
oGrid1:Hide()
oWindow:Activate()
Return
static function SetTestData()
aRows_[1] := {'Simpson','Homer','555-5555'}
aRows_[2] := {'Mulder','Fox','324-6432'}
aRows_[3] := {'Smart','Max','432-5892'}
aRows_[4] := {'Grillo','Pepe','894-2332'}
aRows_[5] := {'Kirk','James','346-9873'}
aRows_[6] := {'Barriga','Carlos','394-9654'}
aRows_[7] := {'Flanders','Ned','435-3211'}
aRows_[8] := {'Smith','John','123-1234'}
aRows_[9] := {'Pedemonti','Flavio','000-0000'}
aRows_[10] := {'Gomez','Juan','583-4832'}
aRows_[11] := {'Fernandez','Raul','321-4332'}
aRows_[12] := {'Borges','Javier','326-9430'}
aRows_[13] := {'Alvarez','Alberto','543-7898'}
aRows_[14] := {'Gonzalez','Ambo','437-8473'}
aRows_[15] := {'Batistuta','Gol','485-2843'}
aRows_[16] := {'Vinazzi','Amigo','394-5983'}
aRows_[17] := {'Pedemonti','Flavio','534-7984'}
aRows_[18] := {'Samarbide','Armando','854-7873'}
aRows_[19] := {'Pradon','Alejandra','???-????'}
aRows_[20] := {'Reyes','Monica','432-5836'}
return
Your OOP experimental code is a new world to be explore and it's thrilling to play with.
I have a feeling that my problem lies on the class DATA initialization of the GRID & of course those bugs on my code.
Congrats and thank you very much for drafting a new toy for us!
Regards,
Danny
Regards,
Danny
Manila, Philippines
Danny
Manila, Philippines
- luisvasquezcl
- Posts: 1258
- Joined: Thu Jul 31, 2008 3:23 am
- Location: Chile
- Contact:
Re: HMG OOP?... WHY NOT?... ;) [UPDATED]
Estimado Roberto
Mis felicitaciones, nuevamente me sorprendes con tus novedades.
sigues en un camino muy interesante, espero poder serte de utilidad.
saludos cordiales,
Luis Vasquez
Mis felicitaciones, nuevamente me sorprendes con tus novedades.
sigues en un camino muy interesante, espero poder serte de utilidad.
saludos cordiales,
Luis Vasquez