Browse Source

palmunits: updated hello example, so no coordinates are hardwired. added a copyright header

git-svn-id: trunk@37923 -
Károly Balogh 7 years ago
parent
commit
d04a4f3ec3
1 changed files with 25 additions and 2 deletions
  1. 25 2
      packages/palmunits/examples/hello.pas

+ 25 - 2
packages/palmunits/examples/hello.pas

@@ -1,24 +1,47 @@
+{
+    Copyright (c) 2018 Karoly Balogh
+
+    Simple "Hello, World!" alike program for PalmOS
+    Example program for Free Pascal's PalmOS bindings
+
+    This example program is in the Public Domain under the terms of
+    Unlicense: http://unlicense.org/
+
+ **********************************************************************}
+
 {$APPID FPHL}
 {$APPNAME Hello, FPC}
 program hello;
 
 uses
-  event_, sysevent, systemmgr, window;
+  event_, sysevent, systemmgr, window, font;
 
 const
   message = 'FPC says: Hello, Palm!';
 
+procedure PaintMessage;
+var
+  w, h: smallint;
+  tw, th: smallint;
+begin
+  tw:=FntCharsWidth(message, length(message));
+  th:=FntLineHeight;
+  WinGetWindowExtent(w, h);
+
+  WinDrawChars(message, length(message), (w-tw) div 2, (h-th) div 2);
+end;
+
 procedure EventLoop;
 var
   event: EventType;
 begin
   repeat
+    PaintMessage;
     EvtGetEvent(event, evtWaitForever);
     SysHandleEvent(event);
   until (event.eType = appStopEvent);
 end;
 
 begin
-  WinDrawChars(message, length(message), 35, 74);
   EventLoop;
 end.