Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2008-09

I need a hack

9 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Paul Ishenin

Hello, Items specific to the Qt widget set

I want to teach qt-lcl return true titlebar color values. I looked at qt sources and found few places where they are requested from windows. I am talking about this colors:
- COLOR_ACTIVECAPTION,
- COLOR_INACTIVECAPTION,
- COLOR_CAPTIONTEXT,
- COLOR_INACTIVECAPTIONTEXT,
- COLOR_GRADIENTACTIVECAPTION,
- COLOR_GRADIENTINACTIVECAPTION

The best palce I see to get them is to call:
QMdiSubWindowPrivate::desktopPalette();

But ofcource I cannot do so since it is a private method, but maybe it is possible to add this method to our bindings library?

Like this:

QPaletteH QLCLGetDesktopPalette() {
  QMdiSubWindowPrivate AMdiSubWindowPrivate = new QMdiSubWindowPrivate();
  QPalette Palette = AMdiSubWindowPrivate.desktopPalette();
  delete AMdiSubWindowPrivate;
  return Palette;
}

Actually I dont know whether our bindings can do so or not but it will be nice to retrieve this colors somehow.

Best regards,
Paul Ishenin.

Reply by email

zeljko
to Paul Ishenin
Paul Ishenin wrote 14 lines
Hello, Items specific to the Qt widget set I want to teach qt-lcl return true titlebar color values. I looked at qt sources and found few places where they are requested from windows. I am talking about this colors: - COLOR_ACTIVECAPTION, - COLOR_INACTIVECAPTION, - COLOR_CAPTIONTEXT, - COLOR_INACTIVECAPTIONTEXT, - COLOR_GRADIENTACTIVECAPTION, - COLOR_GRADIENTINACTIVECAPTION The best palce I see to get them is to call: QMdiSubWindowPrivate::desktopPalette();

QMdiSubWindow/private is not a place to ask such things. Let's study a bit qt docs, besides I'm trolltech customer so I can ask such questions w/o problems. (I'll be out of here next few days ...so I can send an email to trolltech ... about thursday/friday )
Something comes on my mind is to ask QStyleOptionTitleBarH somehow about it, I mean ask QStyleOption_palette(handle : QStyleOptionH; retval : QPaletteH );

eg.
so := QStyleOptionTitleBar_create();
QStyleOption_palette(so, MyPalette);
QStyleOptionTitleBar_destroy(so);

don't know now exact solution, but I think that making such hack isn't good idea. And what if your app is not MDI ? Crash ?
What about Linux/Mac ?

zeljko

Reply by email

Paul Ishenin
to Den Jean
Den Jean wrote 16 lines
On Sunday 21 September 2008 17:32:10 zeljko wrote: >> I want to teach qt-lcl return true titlebar color values. I looked at qt >> sources and found few places where they are requested from windows. I am >> they actually use this call in an ifdef windows part: GetSysColor http://msdn.microsoft.com/en-us/library/ms724371(VS.85).aspx fpc: ./rtl/win/wininc/func.inc function GetSysColor(nIndex:longint):DWORD; external 'user32' name 'GetSysColor';

No, you dont understand. Yes, on windows it works through an ifdef. But if they found a linux, osx solution they'll add it near with the same ifdef. In any case GetDesktopPalette() will return colors I need.

And I think it is worse to use windows calls inside qt widgetset than using a hack around qt since last guaranty we will get working cross-platform solution.

Best regards,
Paul Ishenin.

Reply by email

Paul Ishenin
to zeljko: QMdiSubWindow/private is not a place to ask such things. Let's study a bit qt docs,…
zeljko wrote
QMdiSubWindow/private is not a place to ask such things.

We can use another place if it more safe:
QWorkspaceTitleBarPrivate::readColors() reads colors to QWorkspaceTitleBarPrivate palette. Can we create internally such private widget and request its palette?

Show quoted text 14 lines
Let's study a bit qt docs, besides I'm trolltech customer so I can ask such questions w/o problems. (I'll be out of here next few days ...so I can send an email to trolltech ... about thursday/friday ) Something comes on my mind is to ask QStyleOptionTitleBarH somehow about it, I mean ask QStyleOption_palette(handle : QStyleOptionH; retval : QPaletteH ); eg. so := QStyleOptionTitleBar_create(); QStyleOption_palette(so, MyPalette); QStyleOptionTitleBar_destroy(so); don't know now exact solution, but I think that making such hack isn't good idea. And what if your app is not MDI ? Crash ? What about Linux/Mac

Ofcource having an non-hackish solution will be nice.

Best regards,
Paul Ishenin.

Reply by email

zeljko
to Paul Ishenin
Paul Ishenin wrote 7 lines
zeljko wrote: > QMdiSubWindow/private is not a place to ask such things. We can use another place if it more safe: QWorkspaceTitleBarPrivate::readColors() reads colors to QWorkspaceTitleBarPrivate palette. Can we create internally such private widget and request its palette?

That's possible, write C class and embbed it into bindings, I can do that, that's not a problem .... QLCLDesktopColors_palette() ....

Reply by email

Den Jean
to Paul Ishenin: No, you dont understand. Yes, on windows it works through an ifdef. But if they found a…
Paul Ishenin wrote
No, you dont understand. Yes, on windows it works through an ifdef. But

? :-)

if they found a linux, osx solution they'll add it near with the same

I was not verbose enough. There is no linux/darwin solution, just fixed colors from palette not related to titlebar. Actually palette colors enumerate does not even have an entries for titlebar active/inactive, gradient active/inactive. They overwrite other enum functionality. All functionality is in getsyscolor and the DesktopPalette code is from an mdi -> do you want to create an mdi widget to be able to call this code ?? The palette is initialized with the palette from the mdi widget BTW.

Show quoted text 5 lines
ifdef. In any case GetDesktopPalette() will return colors I need. And I think it is worse to use windows calls inside qt widgetset than using a hack around qt since last guaranty we will get working cross-platform solution.

-> it is not cross platform. There is none.
I needed to read/set titlebar color on Linux, all I could find was : read.write kde config file -> call dcop -Hhome -u user dcop kwin KWinInterface reconfigure (usable for my controlled clients, not usable as a general solution)

Everything in mdi::desktoppalette can done directly qt/pascal. In a procedure that is provided with a widget to initialize the palette from (no mdi):

http://users.telenet.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html X11 (V1.65) Temp Release for Mailing List

-> demo windowflags.pas has some new code (temporarily) just copy this file over to windows, compile and run it there -> tested on XP. on linux it does what it reads (return selection color)

....
Palette:=GetDesktopPalette(Handle);
Color:=QPalette_Color(Palette,QPaletteActive,QPaletteHighLight)^;
writeln('Active Title Bar=Active Highlight:','r:',QColor_red(@Color):3,'  g:',QColor_green(@Color):3,'  b:',QColor_blue(@Color):3);
Color:=QPalette_Color(Palette,QPaletteActive,QPaletteBase)^;
writeln('Active Gradient=Active Base:','r:',QColor_red(@Color):3,'  g:',QColor_green(@Color):3,'  b:',QColor_blue(@Color):3);
....

regards,

Den Jean

Reply by email

Paul Ishenin
to Den Jean
Den Jean wrote 16 lines
-> it is not cross platform. There is none. I needed to read/set titlebar color on Linux, all I could find was : read.write kde config file -> call dcop -Hhome -u user dcop kwin KWinInterface reconfigure (usable for my controlled clients, not usable as a general solution) Everything in mdi::desktoppalette can done directly qt/pascal. In a procedure that is provided with a widget to initialize the palette from (no mdi): http://users.telenet.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html X11 (V1.65) Temp Release for Mailing List -> demo windowflags.pas has some new code (temporarily) just copy this file over to windows, compile and run it there -> tested on XP. on linux it does what it reads (return selection color)

Why not to use {$ifdef windows} in all qt-lcl code? Ofcource - we dont want a windows only solution - we want to write cross-platform code. In case of retrieving title bar colors we should not folow another rules. If qt code contains a way of retrieving this values - we must use it. Just imagine in next version qt guys will add a carbon/cocoa ifdefs to their code to get correct title bar values. What will we do? Add another ifdef to our code?

In case of using a method from qt library we guaranty that in future we dont need to review that code and correct it.

Best regards,
Paul Ishenin.

Reply by email

Den Jean
to Paul Ishenin
Paul Ishenin wrote 9 lines
Why not to use {$ifdef windows} in all qt-lcl code? Ofcource - we dont want a windows only solution - we want to write cross-platform code. In case of retrieving title bar colors we should not folow another rules. If qt code contains a way of retrieving this values - we must use it. Just imagine in next version qt guys will add a carbon/cocoa ifdefs to their code to get correct title bar values. What will we do? Add another ifdef to our code? In case of using a method from qt library we guaranty that in future we

I would agree for a public method that is supposed to stay supported (until deprecated), not for a private method.

Anyway if someone provides some C++ code, I will integrate it. Look at other qlclxxx. The generator (c++ to flat c and pascal) needs a header with a class that has some public methods (implementation in the header). The method needed can be a static one for convenience. Note that QWorkspace is obsolete.

regards,

Den Jean

Reply by email