kolibrios/programs/develop/fp/examples/example.pp
bw ec5962d52e RTL for FP 2.2.0
git-svn-id: svn://kolibrios.org@643 a494cfbc-eb01-0410-851d-a64ba20cac60
2007-09-28 12:26:28 +00:00

102 lines
2.6 KiB
ObjectPascal
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ FreePascal 2.2.0 ª®¤¨à®¢ª  cp866 ­¥ ॠ«¨§®¢ ­ . }
{-$codepage cp866}
{$mode objfpc}
{$smartlink on}
{$apptype console}
{ <20>  ¤ ­­ë© ¬®¬¥­â à áᬠâਢ ¥âáï ¢ë¯®«­¥­¨¥ ¯à¨«®¤¥­¨ï ⮫쪮 ª ª ª®­á®«ì­®¥,
â.¥. ¤¨à¥ªâ¨¢  console ®¡ï§ â¥«ì­ , ¯®¢¥¤¥­¨¥ ¯à®£à ¬¬ë ¯à¨ ®âáãâá⢨¨ í⮩
¤¨à¥ªâ¨¢ë ¯à¥¤®¯à¥¤¥«¨âì ­¥«ì§ï. ƒ à ­â¨à®¢ ­­® ­¥«ì§ï ¨á¯®«ì§®¢ âì ä㭪樨
Write, WriteLn, Read, ReadLn ®â­®á¨â¥«ì­® áâ ­¤ àâ­®© ª®­á®«¨ ¢¢®¤ /¢ë¢®¤ .
}
program Example;
{ ‚ᥠä㭪樨 ¨¬¥î騥 ¢ ᢮¥¬ ¨¬¥­¨ ¯à¥ä¨ªá 'kos_' ïîâáï ¯« âä®à¬®§ ¢¨á¨¬ë¬¨
¨ ॠ«¨§®¢ ­ë ⮫쪮 ¯®¤ KolibriOS. ˆå ¨á¯®«ì§®¢ ­¨¥ ¢ «î¡ëå ¯à®£à ¬¬­ëå
¯à¨«®¦¥­¨ïå ª â¥£®à¨ç¥áª¨ ­¥ ४®¬¥­¤®¢ ­®, ¢ë­®á¨â¥ ¢á¥ ¬¥â®¤ë, ¨á¯®«ì§ãî騥
í⨠ä㭪樨, ¢ ®â¤¥«ì­ë¥ ¬®¤ã«¨ (¨ ¨á¯®«ì§ã©â¥ ­¥®¡å®¤¨¬ë¥  ¡áâࠪ樨).
}
procedure DoPaint;
{ ‚뢮¤ ᮤ¥à¦¨¬®£® ®ª­  ¯à¨«®¦¥­¨ï }
begin
kos_begindraw();
{®¯à¥¤¥«¥­¨¥ ¯ à ¬¥â஢ ®ª­ }
kos_definewindow(200, 200, 200, 50, $23AABBCC);
{kos_definewindow ­¥ ¨¬¥¥â ¯ à ¬¥âà  ¤«ï ¢ë¢®¤  § £®«®¢ª ,
¤¥« ¥¬ íâ® ®â¤¥«ì­®© ä㭪樥© kos_setcaption}
{®â®¡à ¦¥­¨¥ § £®«®¢ª  ®ª­ }
kos_setcaption('<27><>ˆŒ…<C592> <20><>Žƒ<C5BD>€ŒŒ');
{¢ë¢®¤ á®®¡é¥­¨ï}
kos_drawtext(3, 8, '<27> ¦¬¨â¥ «î¡ãî ª« ¢¨èã...');
kos_enddraw();
end;
procedure DoKey;
{ Ž¡à ¡®âª  ᮡëâ¨ï ­ ¦ â¨ï ª« ¢¨è¨ }
var
Key: DWord;
Notes: array[0..3] of Byte;
begin
Key := kos_getkey();
{­ áâà ¨¢ ¥¬ ¡ãä¥à ¤«ï ­®â}
Notes[0] := $90;
Notes[1] := Key shr 8;
Notes[2] := $00;
{¢®á¯à®¨§¢®¤¨¬}
kos_speaker(@Notes);
end;
function DoButton: Boolean;
{ Ž¡à ¡®âª  ᮡëâ¨ï ­ ¦ â¨ï ª­®¯ª¨ GUI }
var
Button: DWord;
begin
{¯®«ãç¨âì ª®¤ ­ ¦ â®© ª«¨¢¨è¨}
Button := kos_getbutton();
{¥á«¨ [x], â® ¢¥à­ãâì «®¦ì,   §­ ç¨â á¯à®¢®æ¨à®¢ âì § ªàë⨥ ¯à¨«®¦¥­¨ï}
Result := Button <> 1;
end;
function ProcessMessage: Boolean;
{ Ž¦¨¤ ­¨¥ ¨ ®¡à ¡®âª  ᮡë⨩.
@return: ‚®§¢à é ¥â False, ¥á«¨ ¡ë«® ᮡë⨥ ª § ¢¥à襭¨î ¯à¨«®¦¥­¨ï.
@rtype: True ¨«¨ False }
var
Event: DWord;
begin
Result := True;
{®¦¨¤ ¥¬ ᮡëâ¨ï ®â á¨á⥬ë}
Event := kos_getevent();
case Event of
SE_PAINT : DoPaint; {¯¥à¥à¨á®¢ª  ®ª­ }
SE_KEYBOARD: DoKey; {ᮡë⨥ ®â ª« ¢¨ âãàë}
SE_BUTTON : Result := DoButton; {ᮡ먥 ®â ª­®¯ª¨, ¬®¦¥â ®¯à¥¤¥«¨âì
§ ¢¥à襭¨¥ ¯à¨«®¦¥­¨ï, ¥á«¨ ¢¥à­¥â False}
end;
end;
procedure MainLoop;
{ ƒ« ¢­ë© 横« ¯à¨«®¦¥­¨ï }
var
ThreadSlot: TThreadSlot;
begin
{­ áâà ¨¢ ¥¬ ᮡëâ¨ï, ª®â®àë¥ ¬ë £®â®¢ë ®¡à ¡ â뢠âì}
kos_maskevents(ME_PAINT or ME_KEYBOARD or ME_BUTTON);
{®¡à ¡®âª  ᮡë⨩}
while ProcessMessage do;
end;
begin
WriteLn('Look for a new window, I''m just a konsole ;-)');
MainLoop;
end.