00001
00011 #ifndef DEFINE_H_YWINDOW
00012 #define DEFINE_H_YWINDOW
00013
00014 #include <basic.h>
00015 #include <bstdlib.h>
00016 #include <tcode.h>
00017 #include <errcode.h>
00018 #include <btron/btron.h>
00019 #include <btron/dp.h>
00020 #include <btron/hmi.h>
00021 #include <btron/vobj.h>
00022 #include <btron/tip.h>
00023 #include <btron/libapp.h>
00024 #include <tstring.h>
00025 #include "ystring.h"
00026 #include "ygraphic.h"
00027 #include "yrect.h"
00028 #include "ypoint.h"
00029 #include "yexception.h"
00030
00035 class YWindowException : public YException {
00036 public:
00037 YWindowException(W n = 0) : YException(n) {}
00038 YWindowException(const YString& str, W n = 0)
00039 : YException(str, n) {}
00040 };
00041
00048 class YWindow {
00049
00050 public:
00056 YWindow(const YRect& rect) {
00057 windowID = -1;
00058 winAttr = WA_STD;
00059 pictogram = 2;
00060 toBeKilled = False;
00061 setPosition(rect);
00062 }
00063
00069 YWindow() {
00070 windowID = -1;
00071 winAttr = WA_STD;
00072 pictogram = 2;
00073 toBeKilled = False;
00074 YRect rect(20, 20, 420, 320);
00075 }
00076
00078 virtual ~YWindow() {
00079 closeWindow();
00080 }
00081
00083 virtual void openWindow();
00084
00086 virtual void closeWindow();
00087
00089 W getWindowID(){
00090 return windowID;
00091 }
00092
00094 void setTitle(const YString& tcstr);
00095
00101 void setPosition(const YRect& rect) {
00102 position = rect;
00103 }
00104
00105
00106
00107
00113 void getClientRect(YRect *rect){
00114 wget_wrk(windowID, (RECT*)rect);
00115 }
00116
00118 void setAttributes(UW wa);
00119
00125 YGraphic* createGraphic() {
00126 W graphID = wget_gid(windowID);
00127 return new YGraphic(graphID);
00128 }
00129
00131 virtual void onRepaint();
00133
00134
00135 virtual void onDraw(YGraphic *gr) {}
00137
00138 virtual void onMouseButtonDown(WEVENT *ev);
00140
00141 virtual void onMouseButtonUp(WEVENT *ev){};
00143
00144 virtual void onIdle(WEVENT *ev){};
00146
00147 virtual void onKeyDown(WEVENT *ev){};
00149
00150 virtual void onKeyTyped(WEVENT *ev){};
00152
00153 virtual void onKeyUp(WEVENT *ev){};
00155
00156 virtual void onMouseWheel(WEVENT *ev){};
00157
00159 const static W ACK = 0;
00160
00162 const static W NACK = 1;
00163
00164 protected:
00166 W windowID;
00168
00169 W pictogram;
00171
00172 YRect position;
00173
00174 private:
00176
00177 UW winAttr;
00179
00180 YString title;
00182
00183 W err;
00185
00186 BOOL toBeKilled;
00187
00188 };
00189
00190 #endif // DEFINE_H_YWINDOW