Hmg4 stylesheet

Moderator: Rathinagiri

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Hmg4 stylesheet

Post by l3whmg »

Hello everyone.
I'm doing some tests to learn how to use the QT library and attempt to understand how to improve the HMG4 library :D

Among the many things I saw, I came across in education ":setStyleSheet" and consequently with the methods "BackColor", "FontColor", etc. I have noticed little problems (I think coming with QT use :?: ).

I would like to propose the :idea: of introduce a new method in the HMG4 library, which could be called "StyleSheet", which would allow several things, for example to define the background color (background-color :#...), text color (color :#... ), the border (border-width :...) and also allow the use of images as background ("background-image: url (':/resources/BACKGROUND')" ). Yes, I remember HMG3 compatibility problem, but I said "introduce a new ...." :mrgreen:
This method should be included twice (unfortunately and read below) inside "control.prg" and "window.prg" :(

This fact made me re-think in general and to test my theories, I have tried to replicate some pieces of HMG4 (can be found here included).
I have found that taking some actions we could improve HMG4 or we can make the code more efficient.
I refer in particular to the classes and their inherit.
If you compare my work with HMG4, you can note that both the sources "lforms" and "llabel" are inherit from "lcorebase", while in HMG4 (other names) is not the same.
Using this concept, I think we have a general container for all data and methods (generalized) and each control (form, label, textbox) can use one or more of them. Other data or methods can be specialized for control (eg. Icon and SetWindowIcon are used by forms not in label)
Some HMG4 source are like I describe, but not to all and this could become a problem in the future.
(Note. If you want to compile my version, you must edit the files: "pgm001.hbc", "pgm001.hbp" and "qt.conf" in accordance with your installation. At this point you can compile with hbmk2 without HMG4 lib ;) )

I would like to clarify that about the code I've written and comments made, I got them in good faith and to contribute to the development of HMG4 that collecting my interest.

Returning to the main reason of my post (stylesheet), I wanted your opinion and than I will try to offer something (but I think with some little problems like described)

Cheers.
Attachments
L3WGui.zip
example
(51.29 KiB) Downloaded 228 times
Luigi from Italy
www.L3W.it
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Hmg4 stylesheet

Post by mrduck »

Luigi,
you are right.

HMG-4 code can be improved with refactoring.

Rathinagiri is doing some refactoring on browse/grid/vgrid, extracting common parts on a base class then build specialized ones deriving from the base.

This study can be repeated for other hmg-4 classes.

If you notice in Qt itself there is a common object (QObject), then for gui widgets QWidget, and from here there are different "trees" depending on class job. For GUI items, there is QFrame and from there QLabel... etc.

About stylesheets: yes, they are really really powerful. You may radically change GUI interface just changing these stylesheets.
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 »

Thanks for your interest and contribution Luigi.

IMHO, the backward compatibility of HMG3 shall not be affected and if at all affected it should be very minimal. Any new introduction to simplify based on xBase principle is welcome.
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.
I want to share some thoughts.
Do you remember my point about assigning a QT object to the controls in the NEW method versus in the CREATE method ?
Ok, the task is not so easy as I expected.
And to me seems that the main reason is:
Why HMG objects do not inherit directly from QT objects ?
If the controls are directly inherited they can do anything QT can without having to program a single line in the HMG classes !
In this way, we would program only the HMG3 compatibility properties and methods and use QT directly.
But I have never used HMG3 and I may be missing something here...
[[]] 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 »

Hi,

Try the samples from c:\hmg\samples\main.demo\demo.prg handling almost all the controls.
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 »

I understand from your words, "why should we have a separate oQTObject inside every hmg control object?"
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Hmg4 stylesheet

Post by l3whmg »

Hi to everyone.

No Rathinagiri. If I understood Concentra, he means (for example) "HMG-textbox-object := QLineEdit".
If Yes, I'm not sure if my explanation is correct, but I hope it can be interpreted by Concentra.

I think, You have to understand the library HMG (3 or 4) as a layer between the low-level operations and a program written with XBASE.

Take a look to the HbIde project. Of course, you can use QT commands directly, but (like I said some times ago) HbIde is a "closed project"; we are writing a library that help us to write more programs.

Another point can be: HMG3 use various C functions, many of them written specifically. HMG4 (now) use QT functions for a lot of reason, but if we need to change?

there are many technical explanations, but I hope you can "interpret" my answer.

Cheers
Luigi from Italy
www.L3W.it
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Hmg4 stylesheet

Post by mrduck »

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.
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: Hmg4 stylesheet

Post by concentra »

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
[[]] 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 !
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 !
Yes, that´s it !
[[]] Mauricio Ventura Faria
Post Reply