Hmg4 stylesheet

Moderator: Rathinagiri

User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: Hmg4 stylesheet

Post by concentra »

mrduck wrote: I also would like to move object creation from :create to :new, so that a lot of code may be removed, but it is necessary to do it very carefully.
I gave up...
To me this task seems to involve a change in the conception and a rewrite of almost all classes.
But, in the other hand, there is still very few code in the lib ( in my opinion ) and if this is the way to go, the sooner the easier.
[[]] Mauricio Ventura Faria
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Hmg4 stylesheet

Post by mrduck »

concentra wrote:
mrduck wrote: I also would like to move object creation from :create to :new, so that a lot of code may be removed, but it is necessary to do it very carefully.
I gave up...
To me this task seems to involve a change in the conception and a rewrite of almost all classes.
Yes, it's true. All methods of all classes. And you have to keep track of each one and decide how to rewrite them.

In the process you have to keep compatibility with hmg-3 syntax, expecially it's "command like" syntax (1 of the 3 syntaxes you may use to write hmg-4 programs)
But, in the other hand, there is still very few code in the lib ( in my opinion ) and if this is the way to go, the sooner the easier.
Ok, since you are already thinking about this change, I ask you to please write a message explaining the changes you have in mind and how they adapt to hmg-4 and qt.

I have some commits to do to some hmg-4 parts. I had to to the changes exactly for the new()/create() double step.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Hmg4 stylesheet

Post by Rathinagiri »

mrduck wrote:Inheriting directly from hbQt will give us a "qt way" of accessing the objects. Then you will add hmg way... in the end you will have 2 ways to do the same things !

Some times we need to have a layer because we need to keep track of the stored values, or we sat a hmg property that is translated to 5 Qt properties... if you can change one of them without telling hmg it can be a problem !!!!

I also would like to move object creation from :create to :new, so that a lot of code may be removed, but it is necessary to do it very carefully.
Thanks a lot for your understanding Francesco.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Hmg4 stylesheet

Post by Rathinagiri »

concentra wrote:Hi.

I may have mixing things here. Sorry.
I need to take a closer look in HMG4 itself and fully understand it´s inner working.
And I gave up the idea I had in creating the controls objects in the NEW method because in the point NEW is called it is not possible to know who is the parent control. This is only known when a WINDOW object calls it´s CREATE method, cascading the CREATE methods in the WINDOW child controls.

The approach I used to program is:
- create a new window
- create the controls in this window
- change what I need in the controls or window
- show the window

But in HMG4 I have to
- define a new window
- define the controls in this window
- show the window, what create the window and the inner controls.
- change what I need in the controls or window
- refresh the window to get the desired behavior in the above changes
Hi Concentra,

This is because, up to HMG3 we had this syntax. It is very easy for many of us. Many projects are created and live in HMG. Already it was a huge task for us to change our existing Clipper codes to HMG. If you see HMG3 samples and sources you can see that they are all just Win32API calls and no OOP concept is used either at programmer level or at HMG level.

Now, we can't rewrite all our programs again for QT/HMG4. That's why Roberto had created this define window...end window concept which is the base for HMG 1 to 3. Even now, if you want to directly handle QT object, you can get it from oControl:oQTObject. Then you can call any QT function directly.

IMHO HMG's basic objective is to cover OS/GUI related calls by xBase commands with basic parameters. A HMG user is not required to know about "a window handle" up to HMG3. The same should hold good in HMG4 also. He needs not know about what a QT object is.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: Hmg4 stylesheet

Post by concentra »

Hi
mrduck wrote: In the process you have to keep compatibility with hmg-3 syntax, expecially it's "command like" syntax (1 of the 3 syntaxes you may use to write hmg-4 programs)
I will assume that this is the syntax preprocessed with the hmg.ch and converted to the "with object" statements .
mrduck wrote: Ok, since you are already thinking about this change, I ask you to please write a message explaining the changes you have in mind and how they adapt to hmg-4 and qt.
The major difficulty I found is that, the way the lib is written, when a NEW() is called to create a control the parent isn´t known, it will be known only when the CREATE() method is called in the container window.
In QT controls, the first parameter is almost always the parent object.
In HMG4 the NEW() method should be called passing the parent as the first parameter NEW( parent ), just as in QT.
But I don´t know if there is a direct way to reference the upper parent in a nested WITH / END WITH structure.
Anyone ?
If not, a control heap needs to be used, probably as a public var. If I could understand the code in window.prg, this is the way the relation between parent / child is managed, and this will ned to be moved from the CREATE() to the NEW() methods.
[[]] Mauricio Ventura Faria
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: Hmg4 stylesheet

Post by concentra »

Hi Rathinagiri
rathinagiri wrote: Now, we can't rewrite all our programs again for QT/HMG4. That's why Roberto had created this define window...end window concept which is the base for HMG 1 to 3. Even now, if you want to directly handle QT object, you can get it from oControl:oQTObject. Then you can call any QT function directly.
Ok, but I suspect that if the control is a QT object directly this can be also achieved.
For example, the button class could be something like this:

Code: Select all

#include "hbclass.ch"
#include "common.ch"

/*----------------------------------------------------------------------*/

CLASS BUTTON FROM QPushButton

   // Internal Data
   DATA nPictAlignment                            INIT   0

   // Properties
   METHOD PictAlignment                           SETGET

   // Methods
   METHOD NEW( oParent )

ENDCLASS

/*----------------------------------------------------------------------*/

METHOD PictAlignment( nValue ) CLASS BUTTON

      IF Pcount() == 0
         RETURN ::nPictAlignment
      ELSEIF Pcount() == 1
         IF   nValue == 0 // Top
         ELSEIF   nValue == 1 // Bottom
         ELSEIF   nValue == 2 // Left
            ::SetLayoutDirection( 0 )
         ELSEIF   nValue == 3 // Right
            ::SetLayoutDirection( 1 )
         ENDIF
         ::nPictAlignment := nValue
      ENDIF

   RETURN NIL

/*----------------------------------------------------------------------*/

METHOD AnyCompat() CLASS BUTTON

// Add any other methods needed for compatibility with HMG3
.
.
.
.
//

/*----------------------------------------------------------------------*/

METHOD NEW( oParent ) CLASS BUTTON

 super:NEW( oParent )
 
 // Set here anything needed for compatibility with HMG3
 .
 .
 .
 .
 //
 
   RETURN Self

/*----------------------------------------------------------------------*/

I think this should work and maintains the HMG3 compatibility.
And all the ::lCreated flaf is not necessary anymore...
[[]] Mauricio Ventura Faria
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Hmg4 stylesheet

Post by Rathinagiri »

Nice implementation.

Now, in this case, we need to re-write the code for common properties for all the controls like row, col etc., which is defined now in control.prg. Isn't it?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: Hmg4 stylesheet

Post by concentra »

Hi.
rathinagiri wrote:Nice implementation.

Now, in this case, we need to re-write the code for common properties for all the controls like row, col etc., which is defined now in control.prg. Isn't it?
Yes, this is the HMG3 compatibility layer, as also is the PictAlignment() method.
[[]] Mauricio Ventura Faria
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Hmg4 stylesheet

Post by l3whmg »

Hy friends,
today I work a lot :shock: to give you my POV.
I feel HMG4 philosopy, but...
I hope can be one help for everyone, zipped file downloadable and complete :roll: .
Take a look at pgm001.hbp and pgm001.hbc and modify path.

I have a probem with SetWindowIcon :twisted:

Cheers
Attachments
MyHMGui.zip
Hmg4 libtest
(55.99 KiB) Downloaded 224 times
Luigi from Italy
www.L3W.it
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Hmg4 stylesheet

Post by l3whmg »

Hi guys, I solved problem about setWindowIcon :D
The problems come from QT dll. :x

Take a look this viewtopic.php?f=32&t=1922

Cheers
Luigi from Italy
www.L3W.it
Post Reply