componentevent.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. #ifndef CALLBACKEVENT_H
  2. #define CALLBACKEVENT_H
  3. #include <jni.h>
  4. #include <QWidget>
  5. #include <QEvent>
  6. #include <QColor>
  7. #include <QCursor>
  8. #include <QFont>
  9. #include <QPoint>
  10. #include <QWidget>
  11. #include <QSize>
  12. #include "mainthreadinterface.h"
  13. class AWTInitEvent : public AWTEvent {
  14. private:
  15. JavaVM* vm;
  16. jobject target;
  17. public:
  18. AWTInitEvent(JNIEnv *env, jobject obj);
  19. void runEvent();
  20. };
  21. class AWTDestroyEvent : public AWTEvent {
  22. private:
  23. QWidget *widget;
  24. public:
  25. AWTDestroyEvent(QWidget *w)
  26. {
  27. widget = w;
  28. }
  29. void runEvent()
  30. {
  31. if( widget != NULL )
  32. delete widget;
  33. }
  34. };
  35. class AWTFontEvent : public AWTEvent {
  36. private:
  37. QWidget *widget;
  38. QFont *font;
  39. public:
  40. AWTFontEvent(QWidget *w, QFont *f)
  41. {
  42. widget = w;
  43. font = f;
  44. }
  45. void runEvent()
  46. {
  47. widget->setFont( *font );
  48. }
  49. };
  50. class AWTUpdateEvent : public AWTEvent {
  51. private:
  52. QWidget *widget;
  53. int x,y,w,h;
  54. bool updateAll;
  55. public:
  56. AWTUpdateEvent(QWidget *src, bool all, int x0, int y0, int w0, int h0)
  57. {
  58. widget = src;
  59. updateAll = all;
  60. x = x0; y = y0; w = w0; h = h0;
  61. }
  62. void runEvent()
  63. {
  64. if(updateAll)
  65. widget->update();
  66. else
  67. widget->update(x,y,w,h);
  68. }
  69. };
  70. class AWTShowEvent : public AWTEvent {
  71. private:
  72. QWidget *widget;
  73. bool visible;
  74. public:
  75. AWTShowEvent(QWidget *w, bool v);
  76. void runEvent();
  77. };
  78. class AWTEnableEvent : public AWTEvent {
  79. private:
  80. QWidget *widget;
  81. bool enabled;
  82. public:
  83. AWTEnableEvent(QWidget *w, bool v);
  84. void runEvent();
  85. };
  86. class AWTCursorEvent : public AWTEvent {
  87. private:
  88. QWidget *widget;
  89. Qt::CursorShape shape;
  90. public:
  91. AWTCursorEvent(QWidget *w, Qt::CursorShape s);
  92. void runEvent();
  93. };
  94. class AWTResizeEvent : public AWTEvent {
  95. private:
  96. QWidget *widget;
  97. int x, y, w, h;
  98. public:
  99. AWTResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0);
  100. void runEvent();
  101. };
  102. class AWTBackgroundEvent : public AWTEvent {
  103. private:
  104. QWidget *widget;
  105. bool foreground;
  106. QColor *color;
  107. public:
  108. AWTBackgroundEvent(QWidget *wid, bool fg, QColor *clr);
  109. void runEvent();
  110. };
  111. class AWTReqFocusEvent : public AWTEvent {
  112. private:
  113. QWidget *widget;
  114. public:
  115. AWTReqFocusEvent(QWidget *w) : AWTEvent()
  116. {
  117. widget = w;
  118. }
  119. void runEvent()
  120. {
  121. widget->setFocus();
  122. }
  123. };
  124. class AWTGetOriginEvent : public AWTEvent {
  125. private:
  126. JavaVM* vm;
  127. jobject target;
  128. QWidget *widget;
  129. public:
  130. AWTGetOriginEvent(QWidget *w, JNIEnv *env, jobject obj);
  131. void runEvent();
  132. };
  133. class GetSizeEvent : public AWTEvent {
  134. private:
  135. JavaVM* vm;
  136. jobject target;
  137. QWidget *widget;
  138. bool pref;
  139. public:
  140. GetSizeEvent(QWidget *w, JNIEnv *env, jobject obj, bool p);
  141. void runEvent();
  142. };
  143. class AWTReparent : public AWTEvent {
  144. private:
  145. QWidget *widget;
  146. QWidget *parent;
  147. public:
  148. AWTReparent(QWidget *w, QWidget *p) : AWTEvent()
  149. {
  150. widget = w;
  151. parent = p;
  152. }
  153. void runEvent()
  154. {
  155. widget->setParent( parent );
  156. }
  157. };
  158. #endif