For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > June 2004 > Can/should children inherit window icon from parent ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Can/should children inherit window icon from parent ?
Dean Arnold

2004-05-24, 10:32 pm

I've been modifying the mainwindow icon, and have to
explicitly modify all child window icons, when it
would seem like they should inherit the icon from
the parent (I'm on AS 5.8.3, Tk804.027, WinXP).

1) Is this another bogus Win32 behavior ?

2) Is there an option to enforce icon inheritance ?

I tried hacking up Toplevel to enforce that behavior,
and it worked on simple windows, but when I fit a few
frames into the mainwindow with the hacked version of
Toplevel, the frames don't get expanded, and the main window
shinks to the smallest possible size to fit the menu
bar labels. My Toplevel hack was pretty simple (
just add an 'icon_image' attribute to the object,
set a $ENV{TK_WIN_ICON} to the icon image,
and keep track if Populate is being called to create
an icon or just the Toplevel).

Any pointers to correct this behavior much appreciated;
having to explicitly set my own icon on every dialog
makes it difficult to use the generic dialogs for
some widgets (eg, Goto Line... popup).

TIA,
Dean Arnold
Presicient Corp.
www.presicient.com

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
Nick Ing-Simmons

2004-06-03, 7:10 pm

Dean Arnold <darnold@presicient.com> writes:
>I've been modifying the mainwindow icon, and have to
>explicitly modify all child window icons, when it
>would seem like they should inherit the icon from
>the parent (I'm on AS 5.8.3, Tk804.027, WinXP).
>
>1) Is this another bogus Win32 behavior ?


In so far as windows shows an icon for a diaglog box I guess you
could say so. Tk's icon concept is really modelled on traditional X.
You got an Icon on the desktop for a minimized application.
(These days even X window managers put those icons into a "task bar"
so want much smaller icons.)

In this model you (normally) only get one icon per app - not one per window.
Dialogs would be marked a "transient" for the application's mainwindow
and would mimimize as a group. In such a case only mainwindow's icon
gets used. DialogBox / Dialog set transient on this basis.


>
>2) Is there an option to enforce icon inheritance ?
>
>I tried hacking up Toplevel to enforce that behavior,


The Object Oriented way would have been to derive a class
from Toplevel which asks at Populate time asks its parent for
the iconimage to use.

>and it worked on simple windows, but when I fit a few
>frames into the mainwindow with the hacked version of
>Toplevel, the frames don't get expanded, and the main window
>shinks to the smallest possible size to fit the menu
>bar labels. My Toplevel hack was pretty simple (
>just add an 'icon_image' attribute to the object,
>set a $ENV{TK_WIN_ICON} to the icon image,
>and keep track if Populate is being called to create
>an icon or just the Toplevel).


The OO scheme avoids need to track that.


>
>Any pointers to correct this behavior much appreciated;
>having to explicitly set my own icon on every dialog
>makes it difficult to use the generic dialogs for
>some widgets (eg, Goto Line... popup).




>
>TIA,
>Dean Arnold
>Presicient Corp.
>www.presicient.com
>
>-++**==--++**==--++**==--++**==--++**==--++**==--++**==
>This message was posted through the Stanford campus mailing list
>server. If you wish to unsubscribe from this mailing list, send the
>message body of "unsubscribe ptk" to majordomo@lists.stanford.edu



-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
Nick Ing-Simmons

2004-06-03, 7:10 pm

Dean Arnold <darnold@presicient.com> writes:
>I've been modifying the mainwindow icon, and have to
>explicitly modify all child window icons, when it
>would seem like they should inherit the icon from
>the parent (I'm on AS 5.8.3, Tk804.027, WinXP).
>
>1) Is this another bogus Win32 behavior ?


In so far as windows shows an icon for a diaglog box I guess you
could say so. Tk's icon concept is really modelled on traditional X.
You got an Icon on the desktop for a minimized application.
(These days even X window managers put those icons into a "task bar"
so want much smaller icons.)

In this model you (normally) only get one icon per app - not one per window.
Dialogs would be marked a "transient" for the application's mainwindow
and would mimimize as a group. In such a case only mainwindow's icon
gets used. DialogBox / Dialog set transient on this basis.


>
>2) Is there an option to enforce icon inheritance ?
>
>I tried hacking up Toplevel to enforce that behavior,


The Object Oriented way would have been to derive a class
from Toplevel which asks at Populate time asks its parent for
the iconimage to use.

>and it worked on simple windows, but when I fit a few
>frames into the mainwindow with the hacked version of
>Toplevel, the frames don't get expanded, and the main window
>shinks to the smallest possible size to fit the menu
>bar labels. My Toplevel hack was pretty simple (
>just add an 'icon_image' attribute to the object,
>set a $ENV{TK_WIN_ICON} to the icon image,
>and keep track if Populate is being called to create
>an icon or just the Toplevel).


The OO scheme avoids need to track that.


>
>Any pointers to correct this behavior much appreciated;
>having to explicitly set my own icon on every dialog
>makes it difficult to use the generic dialogs for
>some widgets (eg, Goto Line... popup).




>
>TIA,
>Dean Arnold
>Presicient Corp.
>www.presicient.com
>
>-++**==--++**==--++**==--++**==--++**==--++**==--++**==
>This message was posted through the Stanford campus mailing list
>server. If you wish to unsubscribe from this mailing list, send the
>message body of "unsubscribe ptk" to majordomo@lists.stanford.edu



-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
Dean Arnold

2004-06-03, 7:10 pm

Nick Ing-Simmons wrote:
> Dean Arnold <darnold@presicient.com> writes:
>
>
>
> In so far as windows shows an icon for a diaglog box I guess you
> could say so. Tk's icon concept is really modelled on traditional X.
> You got an Icon on the desktop for a minimized application.
> (These days even X window managers put those icons into a "task bar"
> so want much smaller icons.)
>
> In this model you (normally) only get one icon per app - not one per window.
> Dialogs would be marked a "transient" for the application's mainwindow
> and would mimimize as a group. In such a case only mainwindow's icon
> gets used. DialogBox / Dialog set transient on this basis.
>
>
>
>
>
> The Object Oriented way would have been to derive a class
> from Toplevel which asks at Populate time asks its parent for
> the iconimage to use.
>
>


I'd considered that, but couldn't figure a way to solve the
initial problem: how to use existing DialogBox's that rely
on the existing Toplevel behavior. (Esp. wrt to default Text
popup menus). if I derive my own toplevel, then I have to replace
the toplevel references everywhere with MyToplevel.

For that matter, my hack to Toplevel actually did what you're
describing (except wo/ deriving, for the reasons stated). And
things worked for simple cases, but (as stated in the OP) it
seemed to induce bizarre behavior when several frames/adjusters
were pack'd into the mainwindow.

FWIW, heres the code I added to Toplevel (now commented out):

sub Populate
{
my ($cw,$arg) = @_;
$cw->SUPER::Populate($arg);
$cw->ConfigSpecs('-title',['METHOD',undef,undef,$cw->class]);
#
# DAA added to support inherited window icon
# NOTE: since the icon creation also generates a toplevel,
# we have to use a flag to stop infinite recursion here
#
# $cw->{_making_icon} = 1,
# $cw->Icon(-image => $ENV{'TK_WIN_ICON'}),
# delete $cw->{_making_icon}
# if ($ENV{'TK_WIN_ICON'} &&
# (! ($cw->Parent && $cw->Parent->{_making_icon})));
}

So anyway, I'll probably hack the DialogBox widget to add a class
variable that is populated w/ the icon image at startup, and
then (hopefully) every default use of that will inherit it
the "hard" way.

Regards,
Dean Arnold
Presicient Corp.
www.presicient.com
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com