colorLogic.cc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. #pragma once
  2. #include "uart/ProtocolSender.h"
  3. /*
  4. *此文件由GUI工具生成
  5. *文件功能:用于处理用户的逻辑相应代码
  6. *功能说明:
  7. *========================onButtonClick_XXXX
  8. 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[ID值]名称,
  9. 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK.
  10. *========================onSlideWindowItemClick_XXXX(int index)
  11. 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
  12. 如slideWindow1;index 代表按下图标的偏移值
  13. *========================onSeekBarChange_XXXX(int progress)
  14. 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
  15. 如SeekBar1;progress 代表当前的进度值
  16. *========================ogetListItemCount_XXXX()
  17. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[ID值]名称,
  18. 如List1;返回值为当前列表的总条数
  19. *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index)
  20. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[ID值]名称,
  21. 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明
  22. *========================常用接口===============
  23. *LOGD(...) 打印调试信息的接口
  24. *mTextXXXPtr->setText("****") 在控件TextXXX上显示文字****
  25. *mButton1Ptr->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色
  26. *mSeekBarPtr->setProgress(12) 在控件mSeekBar上将进度调整到12
  27. *mListView1Ptr->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用
  28. *mDashbroadView1Ptr->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度
  29. *
  30. * 在Eclipse编辑器中 使用 “alt + /” 快捷键可以打开智能提示
  31. */
  32. int color = 0;
  33. bool contactShow = false;
  34. /**
  35. * 注册定时器
  36. * 填充数组用于注册定时器
  37. * 注意:id不能重复
  38. */
  39. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  40. //{0, 6000}, //定时器id=0, 时间间隔6秒
  41. //{1, 1000},
  42. };
  43. /**
  44. * 当界面构造时触发
  45. */
  46. static void onUI_init(){
  47. //Tips :添加 UI初始化的显示代码到这里,如:mText1Ptr->setText("123");
  48. mColorPainterPtr->setLineWidth(1);
  49. mColorPainterPtr->setSourceColor(0xFF000000);
  50. }
  51. /**
  52. * 当切换到该界面时触发
  53. */
  54. static void onUI_intent(const Intent *intentPtr) {
  55. if (intentPtr != NULL) {
  56. //TODO
  57. }
  58. }
  59. /*
  60. * 当界面显示时触发
  61. */
  62. static void onUI_show() {
  63. EASYUICONTEXT->hideNaviBar();
  64. EASYUICONTEXT->hideStatusBar();
  65. color = 0;
  66. contactShow = false;
  67. }
  68. /*
  69. * 当界面隐藏时触发
  70. */
  71. static void onUI_hide() {
  72. }
  73. /*
  74. * 当界面完全退出时触发
  75. */
  76. static void onUI_quit() {
  77. }
  78. /**
  79. * 串口数据回调接口
  80. */
  81. static void onProtocolDataUpdate(const SProtocolData &data) {
  82. }
  83. /**
  84. * 定时器触发函数
  85. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  86. * 参数: id
  87. * 当前所触发定时器的id,与注册时的id相同
  88. * 返回值: true
  89. * 继续运行当前定时器
  90. * false
  91. * 停止运行当前定时器
  92. */
  93. static bool onUI_Timer(int id){
  94. switch (id) {
  95. default:
  96. break;
  97. }
  98. return true;
  99. }
  100. /**
  101. * 有新的触摸事件时触发
  102. * 参数:ev
  103. * 新的触摸事件
  104. * 返回值:true
  105. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  106. * false
  107. * 触摸事件将继续传递到控件上
  108. */
  109. static bool oncolorActivityTouchEvent(const MotionEvent &ev) {
  110. switch (ev.mActionStatus) {
  111. case MotionEvent::E_ACTION_DOWN://触摸按下
  112. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  113. if (contactShow) {
  114. mColorPainterPtr->fillRect(ev.mX - 4, ev.mY - 4, 8, 8);
  115. }
  116. break;
  117. case MotionEvent::E_ACTION_MOVE://触摸滑动
  118. if (contactShow) {
  119. mColorPainterPtr->fillRect(ev.mX - 4, ev.mY - 4, 8, 8);
  120. }
  121. break;
  122. case MotionEvent::E_ACTION_UP: //触摸抬起
  123. break;
  124. default:
  125. break;
  126. }
  127. return false;
  128. }
  129. static bool onButtonClick_ColorButton(ZKButton *pButton) {
  130. LOGD(" ButtonClick ColorButton !!!\n");
  131. if (color == 1) {
  132. color += 1;
  133. mColorButtonPtr->setBgStatusColor(ZK_CONTROL_STATUS_NORMAL, 0xFFFFFF00);
  134. }
  135. else if (color == 2) {
  136. color += 1;
  137. mColorButtonPtr->setBgStatusColor(ZK_CONTROL_STATUS_NORMAL, 0xFFFF0000);
  138. }
  139. else if (color == 3) {
  140. color += 1;
  141. mColorButtonPtr->setBgStatusColor(ZK_CONTROL_STATUS_NORMAL, 0xFF0000FF);
  142. }
  143. else if (color == 4) {
  144. color += 1;
  145. mColorButtonPtr->setBgStatusColor(ZK_CONTROL_STATUS_NORMAL, 0xFF00FFFF);
  146. }
  147. else if (color == 5) {
  148. color += 1;
  149. mColorButtonPtr->setBgStatusColor(ZK_CONTROL_STATUS_NORMAL, 0xFF008000);
  150. }
  151. else if (color == 6) {
  152. color += 1;
  153. mColorButtonPtr->setBgStatusColor(ZK_CONTROL_STATUS_NORMAL, 0xFF800080);
  154. }
  155. else if (color == 7) {
  156. color = 0;
  157. mColorButtonPtr->setBgStatusColor(ZK_CONTROL_STATUS_NORMAL, 0xFF000000);
  158. }
  159. else {
  160. color += 1;
  161. mColorButtonPtr->setBgStatusColor(ZK_CONTROL_STATUS_NORMAL, 0xFFFFFFFF);
  162. }
  163. return false;
  164. }
  165. static bool onButtonClick_ContactButton(ZKButton *pButton) {
  166. LOGD(" ButtonClick ContactButton !!!\n");
  167. mContactWindowPtr->showWnd();
  168. contactShow = true;
  169. return false;
  170. }
  171. static bool onButtonClick_sys_back(ZKButton *pButton) {
  172. LOGD(" ButtonClick sys_back !!!\n");
  173. return false;
  174. }
  175. static bool onButtonClick_BackButton(ZKButton *pButton) {
  176. LOGD(" ButtonClick BackButton !!!\n");
  177. mContactWindowPtr->hideWnd();
  178. mColorPainterPtr->erase(0, 0, 1024,600);
  179. contactShow = false;
  180. return false;
  181. }