Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Wx::Perl: How to change/set font and size of Wx::ListCtrl column headings?

by HelenCr (Monk)
on Mar 31, 2013 at 17:03 UTC ( #1026370=note: print w/ replies, xml ) Need Help??


in reply to Re: Wx::Perl: How to change/set font and size of Wx::ListCtrl column headings?
in thread Wx::Perl: How to change/set font and size of Wx::ListCtrl column headings?

James: Thank you for this good work.

In fact, like I said in an earlier post, I have realized I have to use "The Grid" (cringe) and I've written a little stand-alone program, which is, in many ways, similar to your example.
Well, there is still something quite strange there: If you look at your example, line 94:

sub GetValue { my( $grid, $y, $x ) = @_; return "($y, $x)"; }
It seems that all cells should contain just
"($y, $x)"
Then,
1. Why are the cells in column 1 empty (with alternating checkboxes - where did these come from)? and
2. Why do we have in column 2:
$r + $c / 1000;
instead of
"($y, $x)"
(looks as if it came from line 122 in your code):
sub GetValueAsDouble { # Row # plus (Col #/1000) my( $grid, $r, $c ) = @_; return $r + $c / 1000; }
It's as if the system is calling GetValueAsDouble instead of GetValue. Why is that? I thought in wxVirtual, the system always calls GetValue?
(I know that CanGetValueAs (line 108 in your code) is a cell accessor, and GetTypeName (line 100 in your code) sets column 1 type as boolean)

Or, in other words, where is the renderer defined?
I've read this wiki: http://wiki.wxperl.nl/Wx::GridTableBase but it doesn't make things much clearer

Many TIA - Helen


Comment on Re^2: Wx::Perl: How to change/set font and size of Wx::ListCtrl column headings?
Select or Download Code
Re^3: Wx::Perl: How to change/set font and size of Wx::ListCtrl column headings?
by jmlynesjr (Pilgrim) on Apr 01, 2013 at 01:21 UTC

    My pure guess is that sub GetTypeName() and sub CanGetValueAs() in defining column 0 as Bool, column 1 as Double and columns 2 through "last" as string is determining which cell renderer gets called for each column. Modify these subs to fit your column layout. Swap 0(bool) and 1(double) in both subs and see if the columns swap, I bet they will. (Tried this and they did swap!)

    Did you look at wxGridTableBase docs? You will probably have to create sub SetValue(), sub SetValueAsBool(), and sub SetValueAsDouble() subs to get your data into the Grid and possibly others to fit your specific data.

    I am out of ideas until there are specific questions to look into. I think you are close at this point.

    Update1: Swapped versions for completeness:

    sub GetTypeName { my( $grid, $r, $c ) = @_; return $c == 0 ? 'double' : # Col 0 Double $c == 1 ? 'bool' : # Col 1 Boolean 'string'; # All others String } sub CanGetValueAs { my( $grid, $r, $c, $type ) = @_; return $c == 0 ? $type eq 'double' : $c == 1 ? $type eq 'bool' : $type eq 'string'; }

    James

    There's never enough time to do it right, but always enough time to do it over...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026370]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2014-10-24 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (132 votes), past polls