testuapp.pas 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. program testuapp;
  2. {$codepage UTF8}
  3. {$h-}
  4. uses
  5. {$ifdef UNIX}fpwidestring,{$endif}
  6. Objects, UDrivers, UViews, UMenus, UDialogs, UApp, UMsgBox, UInpLong, UTabs, SysUtils;
  7. const
  8. cmOrderNew = 200;
  9. cmOrderWin = 201;
  10. cmOrderSave = 202;
  11. cmOrderCancel = 203;
  12. cmOrderNext = 204;
  13. cmOrderPrev = 205;
  14. cmClipShow = 210;
  15. cmAbout = 220;
  16. cmFindOrderWindow = 1002;
  17. cmWindow3 = 1003;
  18. cmOptionsVideo = 1502;
  19. cmOptionsSave = 1503;
  20. cmOptionsLoad = 1504;
  21. type
  22. { TMyUnicodeApp }
  23. TMyUnicodeApp = object(TApplication)
  24. P3 : PGroup;
  25. procedure HandleEvent(var Event : TEvent);virtual;
  26. procedure InitMenuBar; virtual;
  27. procedure InitStatusLine; virtual;
  28. procedure Window3;
  29. procedure ShowAboutBox;
  30. end;
  31. var
  32. MyUnicodeApp: TMyUnicodeApp;
  33. { TMyUnicodeApp }
  34. procedure TMyUnicodeApp.HandleEvent(var Event: TEvent);
  35. begin
  36. inherited HandleEvent(Event);
  37. if Event.What = evCommand then
  38. begin
  39. case Event.Command of
  40. cmWindow3:
  41. Window3;
  42. cmAbout:
  43. ShowAboutBox;
  44. else
  45. Exit;
  46. end;
  47. end;
  48. ClearEvent(Event);
  49. end;
  50. procedure TMyUnicodeApp.InitMenuBar;
  51. var
  52. R: TRect;
  53. begin
  54. GetExtent(R);
  55. R.B.Y := R.A.Y + 1;
  56. MenuBar := new (PMenuBar, Init(R, NewMenu(
  57. NewSubMenu('打开', hcNoContext, NewMenu(NewItem('~Н~ов打тест по пъ́тя', 'Еф2', kbF2, cmNew, hcNew,
  58. NewItem('~O~pen', '💩', kbF3, cmOpen, hcOpen,
  59. NewLine(
  60. NewItem('E~x~it', 'ъ́ъ́ъ́打', kbAltX, cmQuit, hcNoContext, nil))))),
  61. NewSubMenu('~E~dit', hcNoContext, NewMenu(
  62. NewItem('Window ~3~','',kbNoKey,cmWindow3,hcNoContext,nil)),
  63. NewSubMenu('~O~rders', hcNoContext, {NewMenu(GetOrdersMenuItems(nil))}nil,
  64. NewSubMenu('O~p~tions', hcNoContext, {NewMenu(GetOptionsMenuItems(nil))}nil,
  65. NewSubMenu('~W~indow', hcNoContext, {NewMenu(GetWindowMenuItems(nil))}nil,
  66. NewSubMenu('~H~elp', hcNoContext, NewMenu(NewItem('~A~bout...','',kbNoKey,cmAbout,hcNoContext,
  67. nil)), nil)))))))));
  68. end;
  69. procedure TMyUnicodeApp.InitStatusLine;
  70. var
  71. R: TRect;
  72. begin
  73. GetExtent(R);
  74. R.A.Y := R.B.Y - 1;
  75. new(StatusLine, Init(R,
  76. NewStatusDef(0, $EFFF,
  77. NewStatusKey('~F1~ По пъ́тя', kbF1, cmHelp,
  78. NewStatusKey('~F2~ 打开', kbF2, cmOpen,
  79. NewStatusKey('~F3~ Отваряне', kbF3, cmOpen,
  80. NewStatusKey('~F4~ Νέος', kbF4, cmNew,
  81. NewStatusKey('~Alt+F3~ Zavřít', kbAltF3, cmClose,
  82. NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
  83. nil)))))),
  84. NewStatusDef($F000, $FFFF,
  85. NewStatusKey('~F6~ Next', kbF6, cmOrderNext,
  86. NewStatusKey('~Shift+F6~ Pref', kbShiftF6, cmOrderPrev,
  87. nil)),nil))));
  88. end;
  89. procedure TMyUnicodeApp.Window3;
  90. VAR R: TRect; P: PGroup; B: PScrollBar;
  91. List: PUnicodeStringCollection; Lb: PListBox;
  92. begin
  93. { Create a basic dialog box. In it are buttons, }
  94. { list boxes, scrollbars, inputlines, checkboxes }
  95. R.Assign(32, 2, 77, 18); { Assign screen area }
  96. P := New(PDialog, Init(R, '테스트 대화 상자')); { Create dialog }
  97. If (P <> Nil) Then Begin { Dialog valid }
  98. R.Assign(5, 5, 20, 7); { Allocate area }
  99. P^.Insert(New(PCheckBoxes, Init(R,
  100. NewSItem('Test',
  101. NewSITem('Item 2', Nil))))); { Insert check box }
  102. R.Assign(5, 2, 20, 3); { Assign area }
  103. B := New(PScrollBar, Init(R)); { Insert scroll bar }
  104. If (B <> Nil) Then Begin { Scrollbar valid }
  105. B^.SetRange(0, 100); { Set scrollbar range }
  106. B^.SetValue(50); { Set position }
  107. P^.Insert(B); { Insert scrollbar }
  108. End;
  109. R.Assign(5, 10, 20, 11); { Assign area }
  110. P^.Insert(New(PInputLine, Init(R, 60))); { Create input line }
  111. R.Assign(5, 13, 20, 14); { Assign area }
  112. P^.Insert(New(PInputLine, Init(R, 60))); { Create input line }
  113. R.Assign(40, 8, 41, 14); { Assign area }
  114. B := New(PScrollBar, Init(R)); { Create scrollbar }
  115. P^.Insert(B); { Insert scrollbar }
  116. R.Assign(25, 8, 40, 14); { Assign area }
  117. Lb := New(PListBox, Init(R, 1, B)); { Create listbox }
  118. P^.Insert(Lb); { Insert listbox }
  119. List := New(PUnicodeStringCollection, Init(10, 5)); { Create string list }
  120. List^.AtInsert(0, 'Зебра'); { Insert text }
  121. List^.AtInsert(1, '林檎'); { Insert text }
  122. List^.AtInsert(2, 'Third'); { Insert text }
  123. List^.AtInsert(3, 'Peach'); { Insert text }
  124. List^.AtInsert(4, 'За́ек'); { Insert text }
  125. List^.AtInsert(5, 'Item six'); { Insert text }
  126. List^.AtInsert(6, 'Jaguar'); { Insert text }
  127. List^.AtInsert(7, 'Melon'); { Insert text }
  128. List^.AtInsert(8, 'Ninth'); { Insert text }
  129. List^.AtInsert(9, 'Last item'); { Insert text }
  130. Lb^.Newlist(List); { Give list to listbox }
  131. R.Assign(30, 2, 40, 4); { Assign area }
  132. P^.Insert(New(PButton, Init(R, '好的', 100, bfGrabFocus)));{ Create okay button }
  133. R.Assign(30, 15, 40, 17); { Assign area }
  134. Desktop^.Insert(P); { Insert dialog }
  135. P3:=P;
  136. End;
  137. end;
  138. procedure TMyUnicodeApp.ShowAboutBox;
  139. begin
  140. MessageBox(#3'Free Vision TUI Framework'#13 +
  141. #3'Test/Demo Application'#13+
  142. #3'Мога да ям стъкло, то не ми вреди.'#13+
  143. #3'我能吞下玻璃而不伤身体。',
  144. nil, mfInformation or mfOKButton);
  145. end;
  146. begin
  147. MyUnicodeApp.Init;
  148. MyUnicodeApp.Run;
  149. MyUnicodeApp.Done;
  150. end.