[Kde-games-devel] K or Qt includes ?

Ian Wadham ianw at netspace.net.au
Mon Aug 25 22:11:06 CEST 2003


----- Original Message ----- I've put the smaller points first ...
From: "Rob Kaper" <cap at capsi.com>
Sent: Monday, August 25, 2003 1:43 AM
> > 5. Many applications don't implement "What's This?" ...
> >
> You can disable it with GUI merging (XML GUI).
>
I don't understand your terms here.  Please can you elaborate.

> Oh, are you using PNGs? (I'd assume so?)
>
No, mostly XPMs ... see below.

> You can configure the preferred icon size from kcontrol as well as
> individually per toolbar (rmb+configure).
>
Yes, that works (when you can find the place in KDE Control Center
to do the settings) and it makes toolbars a lot more readable ... BUT ...
the pictures on the icon-based buttons increase in size and the pictures
on my pixmap buttons stay small (and mangled): only the button-top
increases in size :-(  And how do you increase button or toolbar size
from your program?  KToolbar hides button properties and methods.

> > 3. KToolbar sometimes does not display the button
> >     pixmaps correctly.
> Are you using the KIconLoader class and related stuff? (BarIcon, etc)

Thereby hangs a tale ... but in short, no.  KGoldrunner was originally
written as alpha for KDE 1 and used a kiconloader application to load
pixmaps for painting the game graphics.  However it often failed to
find them and then of course nothing worked.  Worse still, it would spit out
some general message with no indication of where it was looking
for them and I could not find any KDE documentation anywhere.  I
wrote to the original author, but he said a guy had emailed him some
scripts and examples which worked for him (the author).

Finally, in desperation, I compiled the .xpm files into KGoldrunner
(#include "hero.xpm", etc.) and deleted all references to kiconloader.
That way they can never get lost and that's where they've stayed ;-).
BTW .xpm files are compileable arrays of C-language string constants
and Qt accepts the compiled version when constructing a pixmap.

The same pixmaps are used to label buttons in the game Editor toolbar
(wysiwyg principle).  In KToolbar, I use "insertButton (pixmap, etc.)"
instead of "insertButton (icon-name, etc.)" or "ui.rc" definition, on the
principle that the pixmaps are already available and the less additional
stuff you have, the less there is to go wrong at installation time.

Well, Eureka !!!  I have now found and fixed the problem.  If in doubt,
I read the library source code, which fortunately is cross-referenced to
the KDE library doco.  "insertButton (pixmap, etc.)" internally calls
QIconSet, to generate a set of 12 icons from the pixmap (large/small,
on/off and Normal/Active/Inactive), then takes the default (small) icon
and displays it.  If the pixmap was 16x16 you get a perfect 16x16
picture on your button (4x4mm on my screen).  If it was 32x32, "Small"
is 22x22 (but gets mangled).  To get around that I use static function
"QIconSet::setIconSize" (to get in first, before insertButton) and define
"Small" to be 32x32 (which it is on a high-res screen), then all my
buttons come out perfectly :-)  I do love a good hack !!!

BTW isn't it time GUIs joined the real world and started defining
sizes in mm, leaving KDE and Qt to work out numbers of pixels?

Well, I guess I've been a bit unconventional in my approach, but
I have been working alone here in Melbourne, Australia.  I don't
even know anybody else in this city who uses Linux ... :-( ... so
I have to resort to a bit of "bush programming" sometimes.

Regards, Ian W.



More information about the kde-games-devel mailing list