Post Reply 
HP 48GX - Center Text in the Display Area
09-03-2023, 03:27 PM (This post was last modified: 09-03-2023 08:59 PM by Giuseppe Donnini.)
Post: #8
RE: HP 48GX - Center Text in the Display Area
In my demo, I used the graphics screen (PICT) as a quick means to show the final picture, because, in User RPL, graphics objects can only be pasted directly into PICT, not into the text screen (TEXT). However, if you want to use the DISP command together with pixel-precise methods, I would suggest using the text screen, which has the additional advantage of not disturbing a plot or other picture currently in PICT.

Since User RPL does not allow us to paste single graphics objects directly into the text screen, we have to use the following strategy:

1. Use DISP to put the different text elements on the text screen, except for those elements that need pixel-precise positioning.
2. Use LCD\-> to put a copy of the current text screen on the stack.
3. Use \->GROB to convert the remaining text elements (those needing pixel-precise treatment) to graphics objects.
4. Use REPL to paste them into the (copy of the) text screen.
5. Use \->LCD (together with FREEZE) to put everything back and display the result.

For instance:

Code:

\<<
  RCLF STD           @ Save current modes, activate STD.
  CLLCD              @ Clear text screen.
  1 6 FOR n          @ For n from 1 to 6:
    n \->STR         @ - Convert (real number) n to text string.
    n 1 + DISP       @ - Display it on the (n+1)th line.
  NEXT
  LCD\->             @ Get copy of entire text screen.
  "Test String"      @ Use arbitrary title string for test purposes.
  2 \->GROB          @ Convert title text to grob using medium font.
  DUP SIZE DROP      @ Get size of title grob; drop height, keep width.
  #131d SWAP - 2 /   @ Compute #x-coordinate so that title will be horizontally centered.
  #0                 @ Use 0 as #y-coordinate (top row).
  2 \->LIST          @ Build pixel coordinate pair.
  SWAP REPL          @ Paste title grob into copy of text screen.
  \->LCD             @ Overwrite text screen with new copy.
  3 FREEZE           @ Freeze status and stack areas.
  STOF               @ Restore initial modes.
\>>
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 48GX - Center Text in the Display Area - Giuseppe Donnini - 09-03-2023 03:27 PM



User(s) browsing this thread: 2 Guest(s)