Subversion Repositories Kolibri OS

Rev

Rev 4004 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. //notify 0.7
  2. //SoUrcerer 2010, Leency 2012-2013, GNU GPLv2
  3.  
  4. #define MEMSIZE 0x2F00
  5. #include "..\lib\kolibri.h"
  6. #include "..\lib\strings.h"
  7. #include "..\lib\mem.h"
  8. #include "..\lib\figures.h"
  9.  
  10. ?define PADDING 12;
  11.  
  12. int SCREEN_SIZE_X,
  13.     SCREEN_SIZE_Y;
  14.  
  15. int WIN_X,
  16.         WIN_Y,
  17.     WIN_SIZE_X=256,
  18.     WIN_SIZE_Y=28;
  19.  
  20. int delay = 400;
  21.  
  22. #ifndef AUTOBUILD
  23.         #include "lang.h--"
  24. #endif
  25.  
  26. #ifdef LANG_RUS
  27.         ?define DEFAULT_TEXT "â  ¯à®£à ¬¬  ¯®ª §ë¢ ¥â 㢥¤®¬«¥­¨ï.";
  28. #else
  29.         ?define DEFAULT_TEXT "This program shows notices. Open it with params.";
  30. #endif
  31.  
  32. void PutText(dword x, y) {
  33.         WriteText(x,y, 0x80, 0, #param);
  34. }
  35.  
  36. inline fastcall int GetClientTop()
  37. {
  38.         $mov eax, 48
  39.         $mov ebx, 5
  40.         $int 0x40
  41.     $mov eax, ebx
  42.     $shr eax, 16
  43. }
  44.  
  45. dword shadow_buf, lighter_pixel1, lighter_pixel2;
  46. void GetBackground()
  47. {
  48.         CopyScreen(shadow_buf, WIN_X, WIN_Y, WIN_SIZE_X, WIN_SIZE_Y);
  49.         CopyScreen(lighter_pixel1, WIN_X, WIN_Y, 1, 1);
  50.         CopyScreen(lighter_pixel2, WIN_X, WIN_Y+WIN_SIZE_Y, 1, 1);
  51.         ShadowImage(shadow_buf, WIN_SIZE_X, WIN_SIZE_Y, 6);
  52.         ShadowImage(lighter_pixel1, 1, 1, 2);
  53.         ShadowImage(lighter_pixel2, 1, 1, 2);
  54. }
  55.  
  56.  
  57. void main()
  58. {  
  59.         int TEXT_X=4,
  60.             TEXT_Y=12;
  61.         char drawn;
  62.        
  63.         if (!param)     strcpy(#param, DEFAULT_TEXT);
  64.         if (strlen(#param)*6>WIN_SIZE_X)
  65.         {
  66.                 WIN_SIZE_X=strlen(#param)*6+PADDING;
  67.                 delay = strlen(#param)*10;
  68.         }
  69.  
  70.         SCREEN_SIZE_X=GetScreenWidth()+1;      
  71.         WIN_X = SCREEN_SIZE_X-WIN_SIZE_X-1;
  72.         WIN_Y = GetClientTop();
  73.         TEXT_X = -6*strlen(#param)+WIN_SIZE_X/2;
  74.         TEXT_Y = WIN_SIZE_Y/2-3;
  75.        
  76.         //emulate multithread :)
  77.         while (GetPixelColor(SCREEN_SIZE_X-1, SCREEN_SIZE_X, WIN_Y)==0x333333) WIN_Y+=WIN_SIZE_Y+17;
  78.  
  79.         mem_Init();
  80.         shadow_buf = malloc(WIN_SIZE_X*WIN_SIZE_Y*3);
  81.         lighter_pixel1 = malloc(3);
  82.         lighter_pixel2 = malloc(3);
  83.         GetBackground();
  84.  
  85.         loop()
  86.         {
  87.                 WaitEventTimeout(delay);
  88.                 switch(EAX & 0xFF)
  89.                 {
  90.                 case evButton:
  91.                         ExitProcess();
  92.                         break;
  93.          
  94.                 case evReDraw:
  95.                         DefineAndDrawWindow(WIN_X+1,WIN_Y,WIN_SIZE_X, WIN_SIZE_Y-1, 0x01, 0, 0, 0x01fffFFF);
  96.                         if (drawn==1)
  97.                         {
  98.                                 drawn=2;
  99.                                 MoveSize(0,0,-1,-1);
  100.                                 pause(3);
  101.                                 GetBackground();
  102.                                 MoveSize(WIN_X,WIN_Y,-1,-1);
  103.                                 drawn=1;
  104.                         }
  105.                         DefineButton(0,0, WIN_SIZE_X, WIN_SIZE_Y, 1+BT_HIDE+BT_NOFRAME, 0);
  106.  
  107.                         _PutImage(0,0,WIN_SIZE_X,WIN_SIZE_Y,shadow_buf);
  108.                         PutPixel(0,0,ESDWORD[lighter_pixel1]);
  109.                         PutPixel(0,WIN_SIZE_Y-1,ESDWORD[lighter_pixel2]);
  110.                         DrawBar(WIN_SIZE_X,0, 1, WIN_SIZE_Y, 0x333333);
  111.  
  112.                         PutText(TEXT_X-1,TEXT_Y+1);
  113.                         PutText(TEXT_X-1,TEXT_Y-1);
  114.                         PutText(TEXT_X-1,TEXT_Y  );
  115.                         PutText(TEXT_X+1,TEXT_Y-1);
  116.                         PutText(TEXT_X+1,TEXT_Y  );
  117.                         PutText(TEXT_X+1,TEXT_Y+1);
  118.                         PutText(TEXT_X,  TEXT_Y+1);
  119.                         PutText(TEXT_X,  TEXT_Y-1);
  120.                         WriteText(TEXT_X,  TEXT_Y,   0x80, 0xFFFfff, #param);
  121.                         if (drawn==0) drawn=1;
  122.                         break;
  123.                 default:
  124.                         ExitProcess();
  125.       }
  126.    }
  127. }
  128.  
  129.  
  130. stop:
  131.