To be honest, I'm not very agile with object oriented programming , although I can work thru it, if I had code to run. In your case, from reading the description of your classes, it seems that you could define all the ItemStyles in your B base class, if B.pm is derived from Tk::Tree, then make all your D1 , D2, etc. classes as Derived from B. See perldoc Tk::Derived. That way they all inherit the settings. You might want to look at Using the Option Database. Possibly setting the the Option Database is the way to avoid the memory gain problems. Possibly in B.pm you could access the $mw with the SUPER. Something along the lines of
sub ClassInit
{
my ($class, $mw) = @_;
$class->SUPER::ClassInit($mw);
$mw->optionAdd("*tree*font", $text_font);
$mw->optionAdd("*tree*foreground", $fgcolor);
return $class;
}
I'm sorry I can't help you further, maybe some Object Oriented monk can help you, but I'm totally non-OO in my thinking style. :-)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|