Subversion Repositories Kolibri OS

Rev

Rev 7806 | Rev 7989 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #define MEMSIZE 0x2EE80
  2.  
  3. #include "../lib/kfont.h"
  4. #include "../lib/gui.h"
  5.  
  6. #define PANELH 28
  7. #define WIN_W 490
  8. #define WIN_H 315
  9. #define BASE_TAB_BUTTON_ID 97
  10. proc_info Form;
  11.  
  12. _tabs tabs = { WIN_W-130, 0, NULL, BASE_TAB_BUTTON_ID };
  13.  
  14. block preview = { 0, PANELH, WIN_W, WIN_H - PANELH };
  15. checkbox bold = { "Bold", false };
  16. checkbox smooth = { "Smooth", true };
  17. checkbox colored = { "Colored", true };
  18.  
  19. void main()
  20. {  
  21.         int btn;
  22.         char title[4196];
  23.         if (!param) strcpy(#param, DEFAULT_FONT);
  24.         kfont.init(#param);
  25.         strcpy(#title, "Font preview: ");
  26.         strcat(#title, #param);
  27.  
  28.         tabs.add("Phrase", #DrawPreviewPhrase);
  29.         tabs.add("Chars", #DrawPreviewChars);
  30.  
  31.         loop() switch(WaitEvent())
  32.         {
  33.                 case evButton:
  34.                         btn = GetButtonID();
  35.                         if (btn==1) ExitProcess();
  36.                         bold.click(btn);
  37.                         smooth.click(btn);
  38.                         colored.click(btn);
  39.                         tabs.click(btn);
  40.                         goto _DRAW_WINDOW_CONTENT;
  41.                 case evReDraw:
  42.                         sc.get();
  43.                         DefineAndDrawWindow(215,100,WIN_W+9,WIN_H+skin_height+5,0x74,0xFFFFFF,#title,0);
  44.                         GetProcessInfo(#Form, SelfInfo);
  45.                         if (Form.status_window>2) break;
  46.                         _DRAW_WINDOW_CONTENT:
  47.  
  48.                         kfont.bold = bold.checked;
  49.                         kfont.smooth = smooth.checked;
  50.  
  51.                         DrawBar(0, 0, Form.cwidth, PANELH-1, sc.work);
  52.                         DrawBar(0, PANELH-1,Form.cwidth,1,sc.work_graph);
  53.                         bold.draw(10, 8);
  54.                         smooth.draw(83,8);
  55.                         colored.draw(170,8);
  56.  
  57.                         tabs.draw();
  58.                         tabs.draw_active_tab();
  59.  
  60.                         if (!kfont.font)
  61.                         {
  62.                                 DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff);
  63.                                 WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
  64.                                 break;
  65.                         }
  66.         }
  67. }
  68.  
  69. dword pal[] = { 0x4E4153, 0x57417C, 0x89633B, 0x819156, 0x00CCCC, 0x2AD266,
  70.         0xE000CC, 0x0498F9, 0xC3A9F5, 0xFFC200, 0xFF5836, 0xA086BA,
  71.         0,0,0,0,0 };
  72.  
  73. void DrawPreviewPhrase()
  74. {
  75.         dword i, y;
  76.         dword c;
  77.         char line[256];
  78.         kfont.raw_size = free(kfont.raw);
  79.         for (i=10, y=12; i<22; i++, y+=kfont.height+3;) //not flexible, need to calculate font count and max line length
  80.         {
  81.                 if (colored.checked) c = pal[i-10]; else c=0;
  82.                 strcpy(#line, " §¬¥à èà¨äâ /forn size is ");
  83.                 strcat(#line, itoa(i));
  84.                 strcat(#line, " ¯¨ªá¥«¥©/px.");
  85.                 kfont.WriteIntoBuffer(14,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, c, i, #line);
  86.         }
  87.         if (kfont.smooth) kfont.ApplySmooth();
  88.         kfont.ShowBuffer(preview.x, preview.y);
  89. }
  90.  
  91. void DrawPreviewChars()
  92. {
  93.         dword i, x=20, y=0;
  94.         char line[2];
  95.         line[1]=NULL;
  96.         kfont.raw_size = free(kfont.raw);
  97.         for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length
  98.         {
  99.                 line[0]=i;
  100.                 kfont.WriteIntoBuffer(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line);
  101.                 x+= kfont.height+2;
  102.                 if (x>=preview.w-30) {
  103.                         x=20;
  104.                         y+=kfont.height+2;
  105.                 }
  106.         }
  107.         if (kfont.smooth) kfont.ApplySmooth();
  108.         kfont.ShowBuffer(preview.x, preview.y);
  109. }
  110.