Subversion Repositories Kolibri OS

Rev

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

  1. #define MEMSIZE 0x2EE80
  2.  
  3. #include "../lib/font.h"
  4. #include "../lib/gui.h"
  5.  
  6. #define PANELH 30
  7.  
  8. void main()
  9. {  
  10.         proc_info Form;
  11.         FONT font_title = 0;
  12.         FONT font_option = 0;
  13.         word i, y, btn;
  14.         char line[256], title[4196];
  15.         font.no_bg_copy = true;
  16.         font.color = 0;
  17.         font.bg_color = 0xFFFFFF;
  18.         font.left = 5;
  19.         font.top = SKIN.height+PANELH;
  20.         if (!param) strcpy(#param, "/sys/fonts/Tahoma.kf");
  21.         font.load(#param);
  22.        
  23.         font_title.no_bg_copy = true;
  24.         font_title.load("/sys/fonts/Tahoma.kf");
  25.         font_title.size.text = 12;
  26.         font_title.color = 0x444444;
  27.         font_title.weight = 1;
  28.         font_title.use_smooth = 1;
  29.         font_title.bg_color = 0xE1E1E1;
  30.        
  31.         font_option.no_bg_copy = true;
  32.         font_option.load("/sys/fonts/Tahoma.kf");
  33.         font_option.size.text = 13;
  34.         font_option.color = 0x222222;
  35.         font_option.use_smooth = 1;
  36.         font_option.bg_color = 0xDADADA;
  37.        
  38.         strcpy(#title, "Font preview: ");
  39.         strcat(#title, #param);
  40.         font_title.prepare(5, 4, #title);
  41.         loop()
  42.         {
  43.           switch(WaitEvent())
  44.       {
  45.                 case evButton:
  46.                         btn = GetButtonID();
  47.                         if (btn==1) ExitProcess();
  48.                         if (btn==2) font.weight ^=1;
  49.                         if (btn==3) font.italic ^=1;
  50.                         if (btn==4) font.smooth ^=1;
  51.                         goto _DRAW_WINDOW_CONTENT;
  52.                 case evReDraw:
  53.                         DefineAndDrawWindow(215,100,500,320,0x04,0xFFFFFF,"");
  54.                         font_title.show();
  55.                         GetProcessInfo(#Form, SelfInfo);
  56.                         _DRAW_WINDOW_CONTENT:
  57.                         DrawBar(5, SKIN.height, Form.cwidth, PANELH, 0xDADADA);
  58.                        
  59.                         font_option.italic = font_option.smooth = 0;
  60.                         font_option.weight = 1;
  61.                         font_option.prepare(30, SKIN.height+7, "Bold");
  62.                         CheckBox2(10, SKIN.height+8, 2, "",  font.weight);
  63.                         font_option.show();
  64.                        
  65.                         font_option.weight = font_option.smooth = 0;
  66.                         font_option.italic = 1;
  67.                         font_option.prepare(90, SKIN.height+7, "Italic");
  68.                         CheckBox2(70, SKIN.height+8, 3, "",  font.italic);
  69.                         font_option.show();
  70.                        
  71.                         font_option.weight = font_option.italic = 0;
  72.                         font_option.smooth = 1;
  73.                         font_option.prepare(160, SKIN.height+7, "Smooth");
  74.                         CheckBox2(140, SKIN.height+8, 4, "Smooth",  font.smooth);
  75.                         font_option.show();
  76.                        
  77.                         IF(font.buffer)font.buffer_size = 0;
  78.                        
  79.                         if (!font.data)
  80.                         {
  81.                                 DrawBar(5, SKIN.height+PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
  82.                                 WriteText(15, 50, 0x82, 0xFF00FF, "Font is not loaded.");
  83.                         }
  84.                         else for (i=10, y=5; i<22; i++, y+=font.height;) //not flexible, need to calculate font count and max line length
  85.                         {
  86.                                 font.size.text = i;
  87.                                 sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
  88.                                 font.prepare_buf(15,SKIN.height+y,Form.cwidth,Form.cheight-PANELH, #line);
  89.                         }
  90.                         if (font.smooth) SmoothFont(font.buffer, font.size.width, font.size.height);
  91.                         font.show();
  92.           }
  93.         }
  94. }
  95.  
  96. void CheckBox2(dword x, y, id, text, byte value) {
  97.         CheckBox(x, y, 14, 14, id, text, system.color.work_graph, system.color.work_text, value);
  98. }