/* MODULE "imageweb" - part CLIENT author : iri - http://www.irizone.net version 1.0 - june 2004 */ typeof win = ObjWin;; /* --- */ typeof image = ObjBitmap;; /* bitmap */ typeof flagBMP = I;; /* étiré (0) centré (1) en haut à gauche (2) ou mosaïque (3) */ typeof connexion = INET;; /* requête web */ typeof datatmp = S;; /* données partielles en reponse du serveur lors de la requête web */ /* fun [DMI S S [User r1] Tag] I */ fun hide(from, action, param, others, tag)= _SHOWwindow win WINDOW_HIDDEN; _DMSevent this "hidden" nil nil; 0;; /* fun [] I */ fun displaybmp()= let _GETwindowPositionSize win -> [_ _ wwin hwin] in let _GETbitmapSize image -> [wbmp hbmp] in if flagBMP == 0 then (_STBLTbitmap win 0 0 wwin hwin image 0 0 wbmp hbmp; 0) else if flagBMP == 1 then (_BLTbitmap win image (wwin-wbmp)/2 (hwin-hbmp)/2; 0) else if flagBMP == 2 then (_BLTbitmap win image 0 0; 0) else if flagBMP == 3 then let 0 -> i in (while i < wwin do (let 0 -> j in while j < hwin do (_BLTbitmap win image i j; set j = j+hbmp); set i = i+wbmp); 0) else 0;; /* fun [DMI S S [User r1] Tag] I */ fun show(from, action, param, others, tag)= _SHOWwindow win WINDOW_UNHIDDEN; if image == nil then (_TXTout win _CRfont _channel 16 0 0 "Arial" 10 10 TD_BASELINE|TD_LEFT make_rgb 255 0 0 "Error Network"; 0) else displaybmp; _PAINTwindow win; _DMSevent this "shown" nil nil; 0;; /* fun [] I */ fun destroyBMP()= let _GETwindowPositionSize win -> [_ _ w h] in let _CRbitmap _channel w h -> tmp in (_BLTbitmap win _FILLbitmap tmp make_rgb 255 255 255 0 0; _PAINTwindow win; _DSbitmap tmp); _DSbitmap image; set datatmp = nil; INETStopURL connexion; set connexion = nil; 0;; /* fun [S] ObjBitmap */ fun loadBMP(path)= let _LDbitmap _channel _checkpack path -> tmp in if tmp == nil then let _LDjpeg _channel _checkpack path -> tmp in if tmp == nil then nil else tmp else tmp;; /* fun [INET I S I] I */ fun cbNet(http, u, data, code)= if code == 0 then /* transfert en cours */ ( set datatmp = strcat datatmp data; 0 ) else if code == 1 then /* transfert terminé */ ( _storepack datatmp "tmp/imageweb/image.tmp"; set image = loadBMP "tmp/imageweb/image.tmp"; _DMSevent this "loaded" nil nil; set connexion = nil; show nil nil nil nil nil; 0 ) else /* erreur lors du transfert */ ( set connexion = nil; _DMSevent this "error" itoa code nil; 0 );; /* fun [S] I */ fun loadNet(url)= if connexion == nil then set connexion = INETGetURL _channel url 0 @cbNet 0 else nil; 0;; /* fun [DMI S S [User r1] Tag] I */ fun new(from, action, param, others, tag)= destroyBMP; let lineextr param -> [url[flag _]] in (loadNet url; if flag != nil then set flagBMP = atoi flag else 0); 0;; /* fun [[ObjWin I I I I] S] I */ fun _resize(x, s)= let x->[_ x y w h] in ( _SIZEwindow win w h x y; if image != nil then show nil nil nil nil nil else nil ); 0;; /* fun [S] I */ fun _end(zone)= _DMSdelete this;; /* fun [ObjWin I] I */ fun _destroyevent(w, u)= _DMSdelete this;; /* fun [ObjWin I] I*/ fun _paint(a, b)= _PAINTwindow a;; /* fun [S] I */ fun IniDMI(param)= let lineextr param -> [url[flag _]] in (loadNet url; if flag != nil then set flagBMP = atoi flag else set flagBMP = 0); let _DMSgetZone this "Image" nil @_resize @_end ->[wn x y w h] in ( set win = if wn == nil then _CRwindow _channel DMSwin nil nil 80 50 WN_MENU+WN_MINBOX+WN_SIZEBOX _DMSgetName this else _CRwindow _channel wn x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER _DMSgetName this; _CBwinPaint win @_paint 0; _CBwinDestroy win @_destroyevent 0 ); _DMSdefineActions this ["show" @show]:: ["hide" @hide]:: ["new" @new]:: nil; 0;; /* fun [S] I */ fun __newAll(param)= destroyBMP; let lineextr param -> [url[flag _]] in (loadNet url; if flag != nil then set flagBMP = atoi flag else 0); 0;;