Subversion Repositories Kolibri OS

Rev

Rev 5981 | 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.         word i, y, btn;
  12.         char line[256], title[4196];
  13.         font.color = 0;
  14.         font.bg_color = 0xFFFFFF;
  15.         if (!param) strcpy(#param, DEFAULT_FONT);
  16.         font.load(#param);
  17.         strcpy(#title, "Font preview: ");
  18.         strcat(#title, #param);
  19.         loop()
  20.         {
  21.           switch(WaitEvent())
  22.       {
  23.                 case evButton:
  24.                         btn = GetButtonID();
  25.                         if (btn==1) ExitProcess();
  26.                         if (btn==2) font.bold ^=1;
  27.                         if (btn==3) font.italic ^=1;
  28.                         if (btn==4) font.smooth ^=1;
  29.                         goto _DRAW_WINDOW_CONTENT;
  30.                 case evReDraw:
  31.                         DefineAndDrawWindow(215,100,500,320,0x74,0xFFFFFF,#title);
  32.                         GetProcessInfo(#Form, SelfInfo);
  33.                         _DRAW_WINDOW_CONTENT:
  34.                         DrawBar(0, 0, Form.cwidth, PANELH, 0xCCCccc);
  35.                         CheckBox2(10, 8, 2, "Bold",  font.bold);
  36.                         CheckBox2(70, 8, 3, "Italic",  font.italic);
  37.                         CheckBox2(140, 8, 4, "Smooth",  font.smooth);
  38.                         font.buffer_size = free(font.buffer);
  39.                         if (!font.data)
  40.                         {
  41.                                 DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
  42.                                 WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
  43.                         }
  44.                         else for (i=10, y=5; i<22; i++, y+=font.height;) //not flexible, need to calculate font count and max line length
  45.                         {
  46.                                 font.size.text = i;
  47.                                 sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
  48.                                 font.write_buf(10,y,Form.cwidth,Form.cheight-PANELH, #line);
  49.                         }
  50.                         if (font.smooth) font.apply_smooth();
  51.                         font.show_buf(0, PANELH);
  52.           }
  53.         }
  54. }
  55.  
  56. void CheckBox2(dword x, y, id, text, byte value) {
  57.         CheckBox(x, y, 14, 14, id, text, system.color.work_graph, system.color.work_text, value);
  58. }