Slick Forums

Discuss the Slick 2D Library
It is currently Thu Jun 20, 2013 3:18 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: TreeTable Header
PostPosted: Fri Sep 28, 2012 3:15 pm 
Offline
Oldbie

Joined: Thu Mar 15, 2012 12:38 am
Posts: 270
Hello!

I am now using the TreeTable to display a tree table. I have a simple question. Is there a way to have the header be images rather than text(strings)?

I looked around (in the TreeTable/AbstractTreeTableModel source and the simple.xml theme file). I do not see anything that would allow me to change this.

It looks to me that this takes only Strings because in the TreeTableDemoDialog1 demo, there is a method on the MyModel class that is called: getColumnHeaderText() which returns only a String.

If this support does not exist, I would like to request it :)

Thanks.


Top
 Profile  
 
 Post subject: Re: TreeTable Header
PostPosted: Fri Sep 28, 2012 6:42 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1190
You can implement it the following way:
1) Override getColumnHeaderStates() in the model to return an additional unique StateKey for each column like this:
Code:
   public StateKey[] getColumnHeaderStates() {
        return new StateKey[]{ StateKey.get("column0"), StateKey.get("column1"), StateKey.get("column2") };
    }

2) Override getColumnHeaderState(int column, int stateIdx) to return true for the respective column state like this:
Code:
   public boolean getColumnHeaderState(int column, int stateIdx) {
        return column == stateIdx;
    }

This will result in column 0 having the animation state "column0" active, while column 1 has "column1" active.
Now you can assign the column header buttons a <select> image object (as overlay) which decides based on these states which image/icon to show.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: TreeTable Header
PostPosted: Fri Sep 28, 2012 6:44 pm 
Offline
Oldbie

Joined: Thu Mar 15, 2012 12:38 am
Posts: 270
Thanks! I'll try this out.


Top
 Profile  
 
 Post subject: Re: TreeTable Header
PostPosted: Fri Sep 28, 2012 10:08 pm 
Offline
Oldbie

Joined: Thu Mar 15, 2012 12:38 am
Posts: 270
Ok, I have managed to get it to work - thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group