Hi,
I'm implementing an application shell with a cardcontainer. I wanted to change the label of each item of the tabview of the cardcontainer dynamically so that I can change different image of each label according the contents of each card ( e.g. I can show a red heart before the label of the tab when the contents of the related card are not empty). I study the codes in TabView class and noted that it set the new item's image when the new item was added by sending the message #basicAdd:atIndex: , but it change all of them via "(self getImageBlock value: anObject) " . If it is right to code via this way, then , how to get each TabView's item at specific index ( i.e. what message to send) so I can modify its image on the fly ( maybe via using the method #onItemUpdatedAtIndex: ) ? Or, is it possible using the getImageBlock: to change each item's image index per object base when the tabview was invalidated, i.e. 1. By default, it's calling a class method #value: that will answer the object class icon imageindex. 2. create an overloaded instance method #icon to answer specific icon, but what is the object for the tabview's item when new card was added in the cardcontainer? how to wire them together? Best regards, Tk Kuo |
On Mon, 15 Nov 2004 21:34:42 +0800, kuo <[hidden email]> wrote:
> 2. create an overloaded instance method #icon to answer specific > icon, > but what is the object for the tabview's item when new card was added in > the > cardcontainer? how to wire them together? The object is the #arrangement aspect of the tab's container view. You can set the #arrangement aspect of each tab to be an appropriate object that understands, say, #statusIcon: and set the #getImageBlock aspect to an appropriate block (or course you can just use #icon). CardContainer>>refreshTabs seems to does the refreshing, but its private. -- Regards HweeBoon MotionObj |
On Mon, 15 Nov 2004 22:49:04 +0800, Yar Hwee Boon <[hidden email]>
wrote: > The object is the #arrangement aspect of the tab's container view. You > can set the #arrangement aspect of each tab to be an appropriate object > that understands, say, #statusIcon: and set the #getImageBlock aspect to > an appropriate block (or course you can just use #icon). > CardContainer>>refreshTabs seems to does the refreshing, but its private. Opps, that should be #statusIcon instead of #statusIcon: -- Regards HweeBoon MotionObj |
In reply to this post by Yar Hwee Boon-3
Hi, Yar Hwee Boon
"Yar Hwee Boon" <[hidden email]> wrote: > The object is the #arrangement aspect of the tab's container view. You can > set the #arrangement aspect of each tab to be an appropriate object that > understands, say, #statusIcon: and set the #getImageBlock aspect to an > appropriate block (or course you can just use #icon). > CardContainer>>refreshTabs seems to does the refreshing, but its private. Thanks for your reply. I probe via "arrangement" that you mentioned, found that it is a selector, #arrangement of a view instance, which call the layoutManager>>#arrangementOf:. This method is implemented in the CardLayout in the way that will answer the card of a CardLayout not the tab item. ( see: CardLayout>>cards) not the object for the tab item that was wanted. So, in the method, CardContainer>>refreshTabs, the arrangements that were set as the list of the tabs model, were indeed cards only. Therefore, the test following won't work.. ( self view viewNamed: 'card1') tabs model list at: 2 put: Object. "which supposed, will use Object class>>icon for the image index" ( self view viewNamed: 'card1') refreshTabs. "the tab's image was not changed at all" Do I miss something? Best regards, Tk Kuo |
On Tue, 16 Nov 2004 00:46:58 +0800, kuo <[hidden email]> wrote:
> I probe via "arrangement" that you mentioned, found that it is a > selector, > #arrangement of a view instance, which call the > layoutManager>>#arrangementOf:. This method is implemented in the > CardLayout > in the way that will answer the card of a CardLayout not the tab item. ( > see: CardLayout>>cards) not the object for the tab item that was wanted. > > So, in the method, CardContainer>>refreshTabs, the arrangements that were > set as the list of the tabs model, were indeed cards only. Not sure I understand what you mean, but see below. > Therefore, the test following won't work.. > ( self view viewNamed: 'card1') tabs model list at: 2 put: Object. > "which supposed, will use Object class>>icon for the image index" > ( self view viewNamed: 'card1') refreshTabs. > "the tab's image was not changed at all" Somehow if you change the list directly, the change seems to get lost. Change ( self view viewNamed: 'card1') tabs model list at: 2 put: Object. to: ( self view viewNamed: 'card1') tabs model at: 2 put: Object. and it works without needing #refreshTabs manually (because it is called in #onListChanged). This seems ok, but I'm not sure if its there's any implication with changing the list on the fly like this. What I suggested was a status object that keeps track or have access to the status and would return an appropriate icon. But either way, it seems to work :) -- Regards HweeBoon MotionObj |
"Yar Hwee Boon" <[hidden email]> wrote:
> Somehow if you change the list directly, the change seems to get lost. > Change > ( self view viewNamed: 'card1') tabs model list at: 2 put: Object. > to: > ( self view viewNamed: 'card1') tabs model at: 2 put: Object. > > and it works without needing #refreshTabs manually (because it is called > in #onListChanged). This seems ok, but I'm not sure if its there's any > implication with changing the list on the fly like this. What I suggested > was a status object that keeps track or have access to the status and > would return an appropriate icon. But either way, it seems to work :) > My test failed because I forgot to set the cardcontainer's viewmode from #noIcons to #smallIcons or #largeIcons. And I've written a small test package in my ftp: ftp://tgkuo.dyndns.org/n-all/TkCardContainerTest/tgk-Test.pac with the test codes in the class comment to prove that it is ok. But I still didn't get your point of using status object, is it a kind of design pattern of proxy? I guessed you might change Object to this status object that "monitor" ( dependent?) on the status of the target ( the emptyOrNot status of the contents of the container of each card in this example) and then it would change its icon accordingly ( + triggering a tabRefresh) when the target status changed. Can you describe it more materially the way that you implement it to let me know this good coding skills? Best regards, Tk Kuo |
On Tue, 16 Nov 2004 19:45:14 +0800, kuo <[hidden email]> wrote:
> Can you describe it more materially the way that you implement it to let > me > know this good coding skills? I've put up what I think at http://motionobj.com/temp/ChangeTabIcons.zip . I'm using a boolean to store the status, if you have many different status maybe you can use a lookup table instead. I'm still exploring so I doubt this is very good code :) Welcome any comments. -- Regards HweeBoon MotionObj |
On Tue, 16 Nov 2004 22:43:56 +0800, Yar Hwee Boon
<[hidden email]> wrote: >I've put up what I think at http://motionobj.com/temp/ChangeTabIcons.zip . >I'm using a boolean to store the status, if you have many different status >maybe you can use a lookup table instead. I'm still exploring so I doubt >this is very good code :) Welcome any comments. That's good. I just learned that the arrangement aspect of each card , card1 and card2 , in the VC could be set by evaluating ( actually doing Ctrl-S) "self arrangement: HBStatus new label: 'abc'" in its PublishedAspectInspector' workspace. The view's arrangement aspect is the key and was stored in the layout manager as an association with the view as the value in the variable names of the CardLayout. I also modify my test package's test codes to be more accurate according to this. Best regards, Tk Kuo |
On Wed, 17 Nov 2004 00:33:07 +0800, kuo <[hidden email]> wrote:
> I just learned that the arrangement aspect of each card , card1 and > card2 , in the VC could be set by evaluating ( actually doing Ctrl-S) > "self arrangement: HBStatus new label: 'abc'" in its > PublishedAspectInspector' workspace. If you are in an aspect's workspace, you can just Ctrl-S with "HBStatus new label: 'abc'". This works in "normal" inspectors too. -- Regards HweeBoon MotionObj |
Free forum by Nabble | Edit this page |