code_table.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. // handle the periodic table jumps
  2. #include <Atomic/UI/UIView.h>
  3. #include <Atomic/UI/UITabContainer.h>
  4. #include "PeriodicApp.h"
  5. void PeriodicApp::setup_table( UIWidget *mylayout )
  6. {
  7. UITabContainer *pgtable = (UITabContainer *)mylayout->GetWidget("pagetable");
  8. PODVector<UIWidget*> dest;
  9. pgtable->SearchWidgetClass( "TBButton", dest );
  10. for (unsigned ii = 0; ii < dest.Size(); ii++) // set bulk event handlers on all buttons -- boom!
  11. SubscribeToEvent(dest[ii], E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleTableEvent));
  12. }
  13. // handle table clicks
  14. void PeriodicApp::HandleTableEvent(StringHash eventType, VariantMap& eventData)
  15. {
  16. using namespace WidgetEvent;
  17. UIWidget* widget = static_cast<UIWidget*>(eventData[P_TARGET].GetPtr());
  18. if ( widget == NULL ) return;
  19. if (eventData[P_TYPE] == UI_EVENT_TYPE_CLICK)
  20. {
  21. UITabContainer *maintb = (UITabContainer *)uiview_->FindWidget("maintabs");
  22. UITabContainer *acttb = (UITabContainer *)uiview_->FindWidget("primarytabs");
  23. UITabContainer *semitb = (UITabContainer *)uiview_->FindWidget("moretabs");
  24. UITabContainer *viewtb = (UITabContainer *)uiview_->FindWidget("supporttabs");
  25. UITabContainer *supporttb = (UITabContainer *)uiview_->FindWidget("atomictabs");
  26. if (widget->GetId() == "A1" )
  27. {
  28. maintb->SetCurrentPage(1);
  29. acttb->SetCurrentPage(0);
  30. }
  31. if (widget->GetId() == "A2" )
  32. {
  33. maintb->SetCurrentPage(1);
  34. acttb->SetCurrentPage(1);
  35. }
  36. if (widget->GetId() == "A3" )
  37. {
  38. maintb->SetCurrentPage(1);
  39. acttb->SetCurrentPage(2);
  40. }
  41. if (widget->GetId() == "A4" )
  42. {
  43. maintb->SetCurrentPage(1);
  44. acttb->SetCurrentPage(3);
  45. }
  46. if (widget->GetId() == "A5" )
  47. {
  48. maintb->SetCurrentPage(1);
  49. acttb->SetCurrentPage(4);
  50. }
  51. if (widget->GetId() == "A6" )
  52. {
  53. maintb->SetCurrentPage(1);
  54. acttb->SetCurrentPage(5);
  55. }
  56. if (widget->GetId() == "A7" )
  57. {
  58. maintb->SetCurrentPage(1);
  59. acttb->SetCurrentPage(6);
  60. }
  61. if (widget->GetId() == "A8" )
  62. {
  63. maintb->SetCurrentPage(1);
  64. acttb->SetCurrentPage(7);
  65. }
  66. if (widget->GetId() == "A9" )
  67. {
  68. maintb->SetCurrentPage(1);
  69. acttb->SetCurrentPage(8);
  70. }
  71. if (widget->GetId() == "B1" )
  72. {
  73. maintb->SetCurrentPage(2);
  74. semitb->SetCurrentPage(0);
  75. }
  76. if (widget->GetId() == "B2" )
  77. {
  78. maintb->SetCurrentPage(2);
  79. semitb->SetCurrentPage(1);
  80. }
  81. if (widget->GetId() == "B3" )
  82. {
  83. maintb->SetCurrentPage(2);
  84. semitb->SetCurrentPage(2);
  85. }
  86. if (widget->GetId() == "B4" )
  87. {
  88. maintb->SetCurrentPage(2);
  89. semitb->SetCurrentPage(3);
  90. }
  91. if (widget->GetId() == "B5" )
  92. {
  93. maintb->SetCurrentPage(2);
  94. semitb->SetCurrentPage(4);
  95. }
  96. if (widget->GetId() == "B6" )
  97. {
  98. maintb->SetCurrentPage(2);
  99. semitb->SetCurrentPage(5);
  100. }
  101. if (widget->GetId() == "B7" )
  102. {
  103. maintb->SetCurrentPage(2);
  104. semitb->SetCurrentPage(6);
  105. }
  106. if (widget->GetId() == "B8" )
  107. {
  108. maintb->SetCurrentPage(2);
  109. semitb->SetCurrentPage(7);
  110. }
  111. if (widget->GetId() == "B9" )
  112. {
  113. maintb->SetCurrentPage(2);
  114. semitb->SetCurrentPage(8);
  115. }
  116. if (widget->GetId() == "C1" )
  117. {
  118. maintb->SetCurrentPage(3);
  119. viewtb->SetCurrentPage(0);
  120. }
  121. if (widget->GetId() == "C2" )
  122. {
  123. maintb->SetCurrentPage(3);
  124. viewtb->SetCurrentPage(1);
  125. }
  126. if (widget->GetId() == "C3" )
  127. {
  128. maintb->SetCurrentPage(3);
  129. viewtb->SetCurrentPage(2);
  130. }
  131. if (widget->GetId() == "C4" )
  132. {
  133. maintb->SetCurrentPage(3);
  134. viewtb->SetCurrentPage(3);
  135. }
  136. if (widget->GetId() == "C5" )
  137. {
  138. maintb->SetCurrentPage(3);
  139. viewtb->SetCurrentPage(4);
  140. }
  141. if (widget->GetId() == "C6" )
  142. {
  143. maintb->SetCurrentPage(3);
  144. viewtb->SetCurrentPage(5);
  145. }
  146. if (widget->GetId() == "C7" )
  147. {
  148. maintb->SetCurrentPage(3);
  149. viewtb->SetCurrentPage(6);
  150. }
  151. if (widget->GetId() == "C8" )
  152. {
  153. maintb->SetCurrentPage(3);
  154. viewtb->SetCurrentPage(7);
  155. }
  156. if (widget->GetId() == "C9" )
  157. {
  158. maintb->SetCurrentPage(3);
  159. viewtb->SetCurrentPage(8);
  160. }
  161. if (widget->GetId() == "D2" )
  162. {
  163. maintb->SetCurrentPage(4);
  164. supporttb->SetCurrentPage(0);
  165. }
  166. if (widget->GetId() == "D3" )
  167. {
  168. maintb->SetCurrentPage(4);
  169. supporttb->SetCurrentPage(1);
  170. }
  171. if (widget->GetId() == "D4" )
  172. {
  173. maintb->SetCurrentPage(4);
  174. supporttb->SetCurrentPage(2);
  175. }
  176. if (widget->GetId() == "D5" )
  177. {
  178. maintb->SetCurrentPage(4);
  179. supporttb->SetCurrentPage(3);
  180. }
  181. if (widget->GetId() == "D6" )
  182. {
  183. maintb->SetCurrentPage(4);
  184. supporttb->SetCurrentPage(4);
  185. }
  186. if (widget->GetId() == "D7" )
  187. {
  188. maintb->SetCurrentPage(4);
  189. supporttb->SetCurrentPage(5);
  190. }
  191. if (widget->GetId() == "D8" )
  192. {
  193. maintb->SetCurrentPage(4);
  194. supporttb->SetCurrentPage(6);
  195. }
  196. if (widget->GetId() == "D9" )
  197. {
  198. maintb->SetCurrentPage(4);
  199. supporttb->SetCurrentPage(7);
  200. }
  201. }
  202. }