Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. // simple sample by Ghost
  3.  
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <kolibrisys.h>
  7.  
  8. #define FONT0           0
  9. #define FONT1           0x10000000
  10.  
  11. #define BT_NORMAL       0
  12. #define BT_DEL          0x80000000
  13. #define BT_HIDE         0x40000000
  14. #define BT_NOFRAME      0x20000000
  15.  
  16. char header[]={" -= C demo programm. Compiled whith KTCC halyavin and andrew_programmer port =-   "};
  17.  
  18. void rotate_str(char *str){
  19.         char tmp;
  20.         int i;
  21.         tmp = str[0];
  22.         for(i = 1; str[i]; i++)str[i - 1] = str[i];
  23.         str[i - 1] = tmp;
  24. }
  25.  
  26. void draw_window(){
  27.         static int offs = 0;
  28.         static int fcolor = 0;
  29.         static int col = 0;
  30.  
  31.         _ksys_window_redraw(1);
  32.         _ksys_draw_window(100, 100, 300, 120, 0xaabbcc, 2, 0x5080d0, 0, 0x5080d0);
  33.         _ksys_write_text(6 - offs, 8, fcolor | FONT0, header, strlen(header));
  34.         _ksys_draw_bar(1, 6, 5, 13, 0x05080d0);
  35.         _ksys_draw_bar(274, 6, 26, 13, 0x05080d0);
  36.         _ksys_make_button(300 - 19, 5, 12, 12, 1 | BT_NORMAL, 0x6688dd);
  37.         _ksys_window_redraw(2);
  38.  
  39.         offs = (offs + 1) % 6;
  40.         if(!offs)rotate_str(header);
  41.  
  42.         fcolor += (col)?-0x80808:0x80808;
  43.         if(fcolor > 0xf80000 || fcolor == 0)col = !col;
  44. }
  45.  
  46. int main(int argc, char **argv){
  47.  
  48.         while(!0){
  49.                 switch(_ksys_wait_for_event(10)){
  50.                 case 2:return 0;
  51.  
  52.                 case 3:
  53.                         if(_ksys_get_button_id() == 1)return 0;
  54.                         break;
  55.  
  56.                 default:
  57.                         draw_window();
  58.                         break;
  59.                 }
  60.         }
  61. }
  62.