|
From: Patrick H. <he...@gm...> - 2007-04-27 15:19:39
|
Hello,
I'm currently working on a project where we need to use vertical tabs alongside with horizontal ones. I've been working on a way to provide a better support for this in tile, but since I'm not a very experienced C programmer my solution is probably not the most elegant one. I'd like to invite others to participate and tell their ideas about the issue.
Tile supports changing of the tab layout by setting a "-tabposition" for the desired layout-style. But although the tabs are packed in the right side after this, the orientation of the decoration around the tab is still pointing in the wrong direction.
I propose to use a new style option "-direction" for Tabs to fix this problem.
example:
--------
style layout TNotebookv {
TNotebookv.Tab
}
style configure TNotebookv.Tab -direction w
style configure TNotebookv -tabposition wn
To make use of this option it has to be implemented in the theme files. Since I'm using macos I altered macosxTheme.c
first the Element options have to be defined:
typedef struct {
Tcl_Obj *directionObj;
} TabElement;
static Ttk_ElementOptionSpec TabElementOptions[] = {
{ "-direction", TK_OPTION_ANCHOR,
Tk_Offset(TabElement,directionObj),"1" },
{0,0,0,0}
};
then the TabElementDraw function has to be altered to make use of the new option by adding the following lines:
static void TabElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
// ALTERED CODE
ThemeTabDirection td = kThemeTabNorth;
Tk_Anchor direction;
TabElement *e = elementRecord;
Tk_GetAnchorFromObj(NULL, e->directionObj, &direction);
if (direction == TK_ANCHOR_E) {
td = kThemeTabEast ;
} else if (direction == TK_ANCHOR_W) {
td = kThemeTabWest ;
} else if (direction == TK_ANCHOR_N || direction == TK_ANCHOR_NW || direction == TK_ANCHOR_NE ) {
td = kThemeTabNorth ;
} else { /* TK_ANCHOR_S */
td = kThemeTabSouth ;
}
// ALTERED CODE
Rect bounds = BoxToRect(b);
bounds.bottom += TAB_OVERLAP;
BEGIN_DRAWING(d)
// IN THIS COMMAND 'kThemeTabNorth' has been replaced by 'td'
DrawThemeTab(
&bounds, Ttk_StateTableLookup(TabStyleTable, state), td,
0/*labelProc*/,0/*userData*/);
END_DRAWING
}
At last the TabOptions have to be included in the TabElementSpec by replacing 'NullElementOptions' with 'TabElementOptions'
As I said this approach is not the most elegant one and also leaves a couple of other problems untouched. I'd apprechiate some feedback on how to improve and generalize the solution. I belief tile would benefit a lot from a better tab support.
Cheers
Paddy
--
Patrick Heck
+61432611842
25 Hampton Street
Brooklyn Park
SA, 5032
Australia
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
|