Subversion Repositories Kolibri OS

Rev

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

  1. //notify 0.8
  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\gui.h"
  9.  
  10. dword shadow_buf_24, shadow_buf_32, lighter_pixel1, lighter_pixel2;
  11.  
  12. ?define PADDING 15;
  13.  
  14. int SCREEN_SIZE_X,
  15.     SCREEN_SIZE_Y;
  16.  
  17. int WIN_X,
  18.         WIN_Y,
  19.     WIN_SIZE_X=256,
  20.     WIN_SIZE_Y=28;
  21.  
  22. int TEXT_X=PADDING,
  23.         TEXT_Y;
  24.  
  25. int delay = 400;
  26.  
  27. #ifndef AUTOBUILD
  28.         #include "lang.h--"
  29. #endif
  30.  
  31. #ifdef LANG_RUS
  32.         ?define DEFAULT_TEXT "â  ¯à®£à ¬¬  ¯®ª §ë¢ ¥â 㢥¤®¬«¥­¨ï.";
  33. #else
  34.         ?define DEFAULT_TEXT "This program shows notices. Open it with params.";
  35. #endif
  36.  
  37. void PutText(dword x, y) {
  38.         WriteBufText(x,y, 0x88, 0, #param, shadow_buf_32);
  39. }
  40.  
  41. void Text()
  42. {
  43.         PutText(TEXT_X-1,TEXT_Y+1);
  44.         PutText(TEXT_X-1,TEXT_Y-1);
  45.         PutText(TEXT_X-1,TEXT_Y  );
  46.         PutText(TEXT_X+1,TEXT_Y-1);
  47.         PutText(TEXT_X+1,TEXT_Y  );
  48.         PutText(TEXT_X+1,TEXT_Y+1);
  49.         PutText(TEXT_X,  TEXT_Y+1);
  50.         PutText(TEXT_X,  TEXT_Y-1);
  51.         WriteBufText(TEXT_X, TEXT_Y, 0x88, 0xFFFfff, #param, shadow_buf_32);
  52. }
  53.  
  54. void from24to32(ESI, EDI, EAX, EBX) //src,dst,w,h
  55. {
  56. conv24to32:
  57.         $mul ebx
  58.         $mov ecx, eax
  59.         $xor al, al
  60. _next: 
  61.         $movsw
  62.         $movsb
  63.         $stosb  
  64.         $loop _next
  65. }
  66.  
  67. void DrawBackground()
  68. {
  69.         PutPaletteImage(shadow_buf_32+8,WIN_SIZE_X,WIN_SIZE_Y,0,0,32,0);
  70.         PutPixel(0,0,ESDWORD[lighter_pixel1]);
  71.         PutPixel(0,WIN_SIZE_Y-1,ESDWORD[lighter_pixel2]);      
  72. }
  73.  
  74. void GetBackground()
  75. {
  76.         int i;
  77.         static int was_once;
  78.  
  79.         if (was_once)
  80.         {
  81.                 DrawBackground();
  82.                 return;
  83.         }
  84.         for (i=1; i<=6; i++)
  85.         {
  86.                 was_once = 1;
  87.                 ShadowImage(shadow_buf_24, WIN_SIZE_X, WIN_SIZE_Y, 1);
  88.                 if (i%2 == 0) ShadowImage(lighter_pixel1, 1, 1, 1);
  89.                 if (i%2 == 0) ShadowImage(lighter_pixel2, 1, 1, 1);
  90.                 from24to32(shadow_buf_24, shadow_buf_32+8, WIN_SIZE_X, WIN_SIZE_Y);
  91.                 Text();
  92.                 DrawBackground();
  93.                 pause(5);
  94.         }
  95. }
  96.  
  97. void Exit()
  98. {
  99.         ExitProcess();
  100. }
  101.  
  102.  
  103. void main()
  104. {      
  105.         if (!param)     strcpy(#param, DEFAULT_TEXT);
  106.         if (strlen(#param)*6>WIN_SIZE_X)
  107.         {
  108.                 WIN_SIZE_X=strlen(#param)*6+PADDING;
  109.                 delay = strlen(#param)*10;
  110.         }
  111.  
  112.         SCREEN_SIZE_X=GetScreenWidth()+1;      
  113.         WIN_X = SCREEN_SIZE_X-WIN_SIZE_X-1;
  114.         WIN_Y = GetClientTop();
  115.         TEXT_X = -6*strlen(#param)+WIN_SIZE_X/2+1;
  116.         TEXT_Y = WIN_SIZE_Y/2-4;
  117.        
  118.         //emulate multithread :)
  119.         while (GetPixelColor(SCREEN_SIZE_X-1, SCREEN_SIZE_X, WIN_Y)==0x333333) WIN_Y+=WIN_SIZE_Y+17;
  120.  
  121.         mem_Init();
  122.         shadow_buf_24 = malloc(WIN_SIZE_X*WIN_SIZE_Y*3);
  123.         shadow_buf_32 = malloc(WIN_SIZE_X*WIN_SIZE_Y*4+8);
  124.         lighter_pixel1 = malloc(3);
  125.         lighter_pixel2 = malloc(3);
  126.         CopyScreen(shadow_buf_24, WIN_X, WIN_Y, WIN_SIZE_X, WIN_SIZE_Y);
  127.         CopyScreen(lighter_pixel1, WIN_X, WIN_Y, 1, 1);
  128.         CopyScreen(lighter_pixel2, WIN_X, WIN_Y+WIN_SIZE_Y, 1, 1);
  129.         ESDWORD[shadow_buf_32] = WIN_SIZE_X;
  130.         ESDWORD[shadow_buf_32+4] = WIN_SIZE_Y;
  131.  
  132.         loop()
  133.         {
  134.                 WaitEventTimeout(delay);
  135.                 switch(EAX & 0xFF)
  136.                 {
  137.                 case evButton:
  138.                         Exit();
  139.                         break;
  140.          
  141.                 case evReDraw:
  142.                         DefineAndDrawWindow(WIN_X+1,WIN_Y,WIN_SIZE_X, WIN_SIZE_Y-1, 0x01, 0, 0, 0x01fffFFF);
  143.                         DrawBar(WIN_SIZE_X,0, 1, WIN_SIZE_Y, 0x333333);
  144.                         DefineButton(0,0, WIN_SIZE_X, WIN_SIZE_Y, 1+BT_HIDE+BT_NOFRAME, 0);
  145.                         GetBackground();
  146.                         break;
  147.  
  148.                 default:
  149.                         Exit();
  150.       }
  151.    }
  152. }
  153.  
  154.  
  155. stop:
  156.