00001
00016 #ifndef _FRAME_H_
00017 #define _FRAME_H_
00018
00019 #include <stdlib.h>
00020
00021 #include "../jnilib.h"
00022 #include "listeners.h"
00023 #include "../graphic/color.h"
00024 #include "../graphic/shape.h"
00025 #include "menubar.h"
00026
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030
00032 #define CLS_FRAME "at/fhv/sgr/guilib/Frame"
00033
00034 #define FRAME_STATE_NORMAL 1
00035 #define FRAME_STATE_MINIMIZED 2
00036 #define FRAME_STATE_MAXIMIZED 3
00037
00038 struct Frame_;
00039
00040 struct FrameCPP_;
00041
00042 #ifdef __cplusplus
00043 typedef FrameCPP_ Frame;
00044 #define createFrame createFrameCPP
00045 #define deleteFrame deleteFrameCPP
00046 #else
00047 typedef struct Frame_ Frame;
00048 #define createFrame createFrameC
00049 #define deleteFrame deleteFrameC
00050 #endif
00051
00053 #define WAIT_UNTIL_TRUE(b) while (!b) { jnisleep(100); }
00054
00058 typedef struct FrameData {
00059 jclass clsframe;
00060 jobject frame;
00061 jmethodID mshow;
00062 jmethodID mhide;
00063 jmethodID mclose;
00064 jmethodID msetTitle;
00065 jmethodID mgetTitle;
00066 jmethodID msetState;
00067 jmethodID mgetState;
00068 jmethodID msetMenuBar;
00069 jmethodID misSameWindow;
00070 jmethodID mdrawLine;
00071 jmethodID mdrawRectangle;
00072 jmethodID mdrawEllipse;
00073 jmethodID mdrawString;
00074 jmethodID mclearScreen;
00075 jmethodID maddDrawable;
00076 } FrameData;
00077
00081 typedef struct Frame_ {
00082 FrameData frame;
00083 void (*show)(Frame* frame);
00084 void (*hide)(Frame* frame);
00085 void (*close)(Frame* frame);
00086 void (*setTitle)(Frame* frame, const char* title);
00087 char* (*getTitle)(Frame* frame);
00088 void (*setSize)(Frame* frame, jint width, jint height);
00089 jint (*getHeight)(Frame* frame);
00090 jint (*getWidth)(Frame* frame);
00091 void (*setLocation)(Frame* frame, jint x, jint y);
00092 jint (*getX)(Frame* frame);
00093 jint (*getY)(Frame* frame);
00094 void (*setForegroundColor)(Frame* frame, Color c);
00095 Color (*getForegroundColor)(Frame* frame);
00096 void (*setBackgroundColor)(Frame* frame, Color c);
00097 Color (*getBackgroundColor)(Frame* frame);
00098 void (*setState)(Frame* frame, jint state);
00099 jint (*getState)(Frame* frame);
00100 void (*setMenuBar)(Frame* frame, MenuBar* menubar);
00101
00102 jboolean (*isSameWindow)(Frame* frame, Window window);
00103
00104 WindowListener (*addWindowListener)(Frame* frame, void (*func)(jint, Window));
00105 void (*removeWindowListener)(Frame* frame, WindowListener wl);
00106 MouseListener (*addMouseListener)(Frame* frame, void (*func)(jint, Component, jint, jint, jint, jint));
00107 void (*removeMouseListener)(Frame* frame, MouseListener ml);
00108 ComponentListener (*addComponentListener)(Frame* frame, void (*func)(jint, Component));
00109 void (*removeComponentListener)(Frame* frame, ComponentListener cl);
00110
00111 void (*drawLine)(Frame* frame, jfloat x1, jfloat y1, jfloat x2, jfloat y2, const Color* c);
00112 void (*drawRectangle)(Frame* frame, jfloat x, jfloat y, jfloat width, jfloat height, jboolean filled, const Color* c);
00113 void (*drawEllipse)(Frame* frame, jfloat x, jfloat y, jfloat width, jfloat height, jboolean filled, const Color* c);
00114 void (*drawString)(Frame* frame, const char* text, jfloat x, jfloat y, const Color* c);
00115 void (*clearScreen)(Frame* frame);
00116 void (*drawShape)(Frame* frame, const Shape* s);
00117
00118 void (*setLayout)(Frame* frame, jobject layoutmanager);
00119 void (*addComponent)(Frame* frame, jobject comp);
00120 void (*addComponentWithConstraint)(Frame* frame, jobject comp, jobject constraint);
00121 } Frame_;
00122
00126 typedef struct FrameCPP_ {
00127 FrameData frame;
00128 struct Frame_ *functions;
00129
00130 #ifdef __cplusplus
00131 void show() {
00132 functions->show(this);
00133 }
00134
00135 void hide() {
00136 functions->hide(this);
00137 }
00138
00139 void close() {
00140 functions->close(this);
00141 }
00142
00143 void setTitle(const char* title) {
00144 functions->setTitle(this, title);
00145 }
00146
00147 char* getTitle() {
00148 return functions->getTitle(this);
00149 }
00150
00151 void setSize(jint width, jint height) {
00152 functions->setSize(this, width, height);
00153 }
00154
00155 jint getHeight() {
00156 return functions->getHeight(this);
00157 }
00158
00159 jint getWidth() {
00160 return functions->getWidth(this);
00161 }
00162
00163 void setLocation(jint x, jint y) {
00164 functions->setLocation(this, x, y);
00165 }
00166
00167 jint getX() {
00168 return functions->getX(this);
00169 }
00170
00171 jint getY() {
00172 return functions->getY(this);
00173 }
00174
00175 void setForegroundColor(Color c) {
00176 functions->setForegroundColor(this, c);
00177 }
00178
00179 Color getForegroundColor() {
00180 return functions->getForegroundColor(this);
00181 }
00182
00183 void setBackgroundColor(Color c) {
00184 functions->setBackgroundColor(this, c);
00185 }
00186
00187 Color getBackgroundColor() {
00188 return functions->getBackgroundColor(this);
00189 }
00190
00191 void setState(jint state) {
00192 functions->setState(this, state);
00193 }
00194
00195 jint getState() {
00196 return functions->getState(this);
00197 }
00198
00199 void setMenuBar(MenuBar* menubar) {
00200 functions->setMenuBar(this, menubar);
00201 }
00202
00203 jboolean isSameWindow(Window window) {
00204 return functions->isSameWindow(this, window);
00205 }
00206
00207 WindowListener addWindowListener(void (*func)(jint, Window)) {
00208 return functions->addWindowListener(this, func);
00209 }
00210
00211 void removeWindowListener(WindowListener wl) {
00212 functions->removeWindowListener(this, wl);
00213 }
00214
00215 MouseListener addMouseListener(void (*func)(jint, Component, jint, jint, jint, jint)) {
00216 return functions->addMouseListener(this, func);
00217 }
00218
00219 void removeMouseListener(MouseListener ml) {
00220 functions->removeMouseListener(this, ml);
00221 }
00222
00223 ComponentListener addComponentListener(void (*func)(jint, Component)) {
00224 return functions->addComponentListener(this, func);
00225 }
00226
00227 void removeComponentListener(ComponentListener cl) {
00228 functions->removeComponentListener(this, cl);
00229 }
00230
00231 void drawLine(jfloat x1, jfloat y1, jfloat x2, jfloat y2, const Color* c) {
00232 functions->drawLine(this, x1, y1, x2, y2, c);
00233 }
00234
00235 void drawRectangle(jfloat x, jfloat y, jfloat width, jfloat height, jboolean filled, const Color* c) {
00236 functions->drawRectangle(this, x, y, width, height, filled, c);
00237 }
00238
00239 void drawEllipse(jfloat x, jfloat y, jfloat width, jfloat height, jboolean filled, const Color* c) {
00240 functions->drawEllipse(this, x, y, width, height, filled, c);
00241 }
00242
00243 void drawString(const char* text, jfloat x, jfloat y, const Color* c) {
00244 functions->drawString(this, text, x, y, c);
00245 }
00246
00247 void clearScreen() {
00248 functions->clearScreen(this);
00249 }
00250
00251 void drawShape(const Shape* s) {
00252 functions->drawShape(this, s);
00253 }
00254
00255 void setLayout(jobject layoutmanager) {
00256 functions->setLayout(this, layoutmanager);
00257 }
00258
00259 void addComponent(jobject comp) {
00260 functions->addComponent(this, comp);
00261 }
00262
00263 void addComponentWithConstraint(jobject comp, jobject constraint) {
00264 functions->addComponentWithConstraint(this, comp, constraint);
00265 }
00266 #endif
00267
00268 } FrameCPP_;
00269
00270
00271 void createFrameC(Frame_* frame);
00272 void createFrameCPP(FrameCPP_* frame);
00273 void deleteFrameC(Frame_* frame);
00274 void deleteFrameCPP(FrameCPP_* frame);
00275
00276 #ifdef __cplusplus
00277 }
00278 #endif
00279
00280 #endif
00281
00282