Hi All,
Can rows in a ListPresenter (ListView) have differents colors ? I have a ListPresenter with a lot of attributes, one of them is a Number, if that Number is > 0 I want that row in green, otherwise I want it in red. Is this possible in Dolphin ? Best Regards Bruno |
Hi Bruno,
You can do this with Custom Drawing which has been implemented in V4. Have a look at the block saved into the third column of the resource 'Class browser method list' in the class MethodBrowser (Copied here) [:ctx | ctx item isLoose ifTrue: [ ctx forecolor: ClassBrowserShell looseMethodColor]. ctx := nil] receiver: nil; yourself This is how OA are changing the color of loose methods in the CHB. For a ListView, ctx is an instance of NMLVCUSTOMDRAW. You can set the forecolor, the backcolor, the font, as well as get status information, or draw the whole thing yourself. You can do this by row, by setting the customDrawBlock aspect in the ListView istself, or you can do it by row/column by setting the aspect in the ListViewColumns. I would do what you want by including a method which is sent by #onViewOpened; setCustomDrawBlock myListPresenter view customDrawBlock: [:ctx | ctx backcolor: ctx item numberColor. ctx := nil]. where you include a method in your "item class" that returns RGB red if number<0 or RGB green otherwise. Hope this helps, Steve "Bruno Buzzi" <[hidden email]> wrote in message news:90qggi$1vubo$[hidden email]... > Hi All, > > Can rows in a ListPresenter (ListView) have differents colors ? > > I have a ListPresenter with a lot of attributes, one of them is a Number, if > that Number is > 0 I want that row in green, otherwise I want it in red. > > Is this possible in Dolphin ? > > Best Regards > Bruno > > > > > |
Thanks Steve
Now I can set the forecolor for a row. But I can not set the backcolor because an ExternalAddress error appears. This is the code that I have on the customDrawBlock: [:ctx | (ctx item positive) ifTrue:[ctx forecolor: (RGB green: 125)] ifFalse:[ctx forecolor: (RGB red: 200)]. ctx backcolor: (ColorAdministrator actual next). ctx := nil] receiver: nil;yourself ColorAdministrator actual next aswer aRGB(192,192,192). but if you evalute this again ColorAdministrator actual next answer aRGB(255,255,255) and if you evalute this again ColorAdministrator actual next answer aRGB(192,192,192) is a cycle. That I'm try to do is that an even row (the number of the row is even) on ListView must have backcolor gray and an odd row must have backcolor white. Best Regards Bruno |
Hi Bruno,
> > Now I can set the forecolor for a row. > > But I can not set the backcolor because an ExternalAddress error appears. I think you found a bug, try backcolor: aColor self clrTextBk: aColor asParameter > > ColorAdministrator actual next aswer aRGB(192,192,192). > but if you evalute this again ColorAdministrator actual next answer > aRGB(255,255,255) > and if you evalute this again ColorAdministrator actual next answer > aRGB(192,192,192) > is a cycle. The problem here is that windows does not ask for the items information in order. It is not part of the customDrawContext protocol, but you could get the row number by accessing #itemHandle, and testing that for odd/even. Good luck with it! Steve |
Steve
You wrote in message news:7G8Y5.5209$[hidden email]... > >... > > But I can not set the backcolor because an ExternalAddress error appears. > > I think you found a bug, try > > backcolor: aColor > self clrTextBk: aColor asParameter > Well spotted, it should be as attached (note that conversion to an RGB is also necessary since a COLORREF is expected). > > > > ColorAdministrator actual next aswer aRGB(192,192,192). > > but if you evalute this again ColorAdministrator actual next answer > > aRGB(255,255,255) > > and if you evalute this again ColorAdministrator actual next answer > > aRGB(192,192,192) > > is a cycle. > > The problem here is that windows does not ask for the items information in > order. It is not part of the customDrawContext protocol, but you could get > the row number by accessing #itemHandle, and testing that for odd/even. Indeed. The "itemHandle" in the case of a ListView is in fact the row index. Regards Blair begin 666 NMLVCUSTOMDRAW_backcolor.st M(D)51SH@0V]N=F5R<VEO;B!O9B!#;VQO<B!O8FIE8W1S('1O($-/3$]24D5& M<R!I;B!.33]60U535$]-1%)!5R!I<R!N;W0@8V]R<F5C="(A#0H-"B%.34Q6 M0U535$]-1%)!5R!M971H;V1S1F]R(0T*#0IB86-K8V]L;W(Z(&%#;VQO<@T* M"2)3971S('1H92!B86-K9W)O=6YD(#Q#;VQO<CXN#0H)26UP;&5M96YT871I M;VX@3F]T93H@5V4@;75S="!C;VYV97)T('1O(&%N(%)'0B!B96-A=7-E(&$@ M0T],3U)2148@:7,@;F5E9&5D+B(-"@T*"7-E;&8@8VQR5&5X=$)K.B!A0V]L M;W(@87-21T(@87-087)A;65T97(A#0H-"F9O<F5C;VQO<CH@84-O;&]R#0H) M(E-E=',@=&AE('1E>'0@9F]R96=R;W5N9" \0V]L;W(^+B(-"@T*"7-E;&8@ M8VQR5&5X=#H@84-O;&]R(&%S4D="(&%S4&%R86UE=&5R(2 A#0HA3DU,5D-5 M4U1/341205<@8V%T96=O<FEE<T9O<CH@(V)A8VMC;VQO<CHA86-C97-S:6YG M(7!U8FQI8R$@(0T*(4Y-3%9#55-43TU$4D%7(&-A=&5G;W)I97-&;W(Z("-F M;W)E8V]L;W(Z(6%C8V5S<VEN9R%P=6)L:6,A("$-"@T*(4Y-5%9#55-43TU$ M4D%7(&UE=&AO9'-&;W(A#0H-"F)A8VMC;VQO<CH@84-O;&]R#0H)(E-E=',@ M=&AE(&)A8VMG<F]U;F0@/$-O;&]R/BXB#0H-"@ES96QF(&-L<E1E>'1":SH@ M84-O;&]R(&%S4D="(&%S4&%R86UE=&5R(0T*#0IF;W)E8V]L;W(Z(&%#;VQO M<@T*"2)3971S('1H92!T97AT(&9O<F5G<F]U;F0@/$-O;&]R/BXB#0H-"@ES M96QF(&-L<E1E>'0Z(&%#;VQO<B!A<U)'0B!A<U!A<F%M971E<B$@(0T*(4Y- M5%9#55-43TU$4D%7(&-A=&5G;W)I97-&;W(Z("-F;W)E8V]L;W(Z(6%C8V5S M<VEN9R%P=6)L:6,A("$-"B%.35160U535$]-1%)!5R!C871E9V]R:65S1F]R E.B C8F%C:V-O;&]R.B%A8V-E<W-I;F<A<'5B;&EC(2 A#0H-"@`` ` end |
Free forum by Nabble | Edit this page |