webcit_before_automake is now the trunk
[citadel.git] / webcit / tabs.c
1 /*
2  * $Id:  $
3  */
4 /**
5  * \defgroup TabUtils Utility functions for creating tabbed dialogs
6  * \ingroup WebcitDisplayItems
7  */
8 /*@{*/
9 #include "webcit.h"
10
11 /**
12  * \brief print tabbed dialog
13  * \param num_tabs how many tabs do we have?
14  * \param tabnames the headers of the tables
15  */
16 void tabbed_dialog(int num_tabs, char *tabnames[]) {
17         int i;
18
19         wprintf("<script type=\"text/javascript\">                                              "
20                 "var previously_selected_tab = '0';                                             "
21                 "function tabsel(which_tab) {                                                   "
22                 "       if (which_tab == previously_selected_tab) {                             "
23                 "               return;                                                         "
24                 "       }                                                                       "
25                 "       $('tabtd'+previously_selected_tab).style.backgroundColor = '#cccccc';   "
26                 "       $('tabdiv'+previously_selected_tab).style.display = 'none';             "
27                 "       $('tabtd'+which_tab).style.backgroundColor = '#ffffff';                 "
28                 "       $('tabdiv'+which_tab).style.display = 'block';                          "
29                 "       previously_selected_tab = which_tab;                                    "
30                 "}                                                                              "
31                 "</script>                                                                      \n"
32         );
33
34         wprintf("<table id=\"TheTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%%\">"
35                 "<tr align=\"center\" style=\"cursor:pointer\"><td>&nbsp;</td>"
36         );
37
38         for (i=0; i<num_tabs; ++i) {
39                 wprintf("<td id=\"tabtd%d\" bgcolor=\"#%s\" "
40                         "onClick='tabsel(\"%d\");'"
41                         ">"
42                         "<span class=\"tablabel\">",
43                         i,
44                         ( (i==0) ? "ffffff" : "cccccc" ),
45                         i,
46                         i
47                 );
48                 wprintf("%s", tabnames[i]);
49                 wprintf("</span></td>");
50
51                 wprintf("<td>&nbsp;</td>\n");
52         }
53
54         wprintf("</tr></table>\n");
55         wprintf("<table border=\"0\" width=\"100%%\" bgcolor=\"#ffffff\"><tr><td>");
56 }
57
58 /**
59  * \brief print the tab-header
60  * \param tabnum number of the tab to print
61  * \param num_tabs total number oftabs to be printed
62  */
63 void begin_tab(int tabnum, int num_tabs) {
64         wprintf("<div id=\"tabdiv%d\" style=\"display:%s\">",
65                 tabnum,
66                 ( (tabnum == 0) ? "block" : "none" )
67         );
68 }
69
70 /**
71  * \brief print the tab-footer
72  * \param tabnum number of the tab to print
73  * \param num_tabs total number oftabs to be printed
74  */
75 void end_tab(int tabnum, int num_tabs) {
76         wprintf("</div>\n");
77         wprintf("<!-- end tab %d of %d -->\n", tabnum, num_tabs);
78
79         if (tabnum == num_tabs-1) {
80                 wprintf("</td></tr></table>\n");
81                 wprintf("<script type=\"text/javascript\">"
82                         " Nifty(\"table#TheTabs td\", \"small transparent top\");"
83                         "</script>"
84                 );
85                         //" Nifty(\"td#tabtd1\", \"small transparent top\");"
86         }
87 }
88
89
90 /*@}*/