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