Σάββατο 5 Σεπτεμβρίου 2020

Happy Window

This is an example of using graphics in a window layer. First we set Pen to 14 (yellow) and background to 5 (magenta). Also we set to row 0 the split screen, so we have all rows to belong to the lower part, which can scroll (setting to 3 we preserve 3 charater rows above row 3, eg 0, 1 and 2). These statements direct to current layer, the console layer. From another layer we can use Layer { statements here }. The Layer statement may have or not a parameter.  See some code lines below we set the window layer using statements which are common for all layers. After the two first statements Pen and Cls (clear screen) we put a "smooth on" statement to enable the GDI+ (by default is the GDI32 the faster method for drawing).


To declare a form is easy. We can use only a line; declare form1 form. M2000 window manager prepare a window, using a default schema, using Form1 as title and standard width and heihgt. So here we use Layer Form1 { } to change the form to display a graphic face, a happy one;

All coordinates are in twips. Width block get a parameter of pixel unit, so 4 is for 4 pixels.

Step statement use relative positions to move the graphic cursror. Move statement move graphic cursor (hidden always) to absolute positions.

Circle can give ellipse utilizing the ratio (by default is 1 for circle). Also we ca use Circle Fill to fill the circle.

See the Pen numeric_expression { } is a block which change the current layer's pen, and restore it when exit from block.

We make a thread inside the layer. When we make a thread, the threat get a reference to a layer structure, so in each interval 1000/120 (in miliseconds) the layer for this thread switch to windows layer.

We have to erase all threads using Threads Erase, before destroy actuall Window.

We want to hide console and that happen with Title "", 0

Then we we want to open window as modal, using Method Form1, "Show", 1

After we close the window (double clik the square in the title of window) we want to restore the console using Title "A title...here", 1







\\ enable GDI+ for smooth lines for graphics
Pen 14
Cls 5, 0
smooth on
declare Form1 Form
with Form1, "title", "My Happy Window"
layer Form1 {
      Rem Font "Verdana"
      linespace 60
      window 18, 8000,8000;
      Gradient #2255FF, 5
      move scale.x div 2, scale.y div 2
      width 4 {circle Fill #8833aa, scale.x div 2.5}
      width 4 {circle scale.x div 3.5,0.5, pen, pi,0}
      width 4 {circle scale.x div 3.5,0.9, pen, pi,0}
      Pen #33aacc {
            step -scale.x div 5.5, - scale.y div 6.5
            circle fill #33aacc, scale.x div 12.5
            step 2*scale.x div 5.5
            circle fill #33aacc, scale.x div 12.5
      }
      circle fill pen, scale.x div 22.5, 1.5
      step -2*scale.x div 5.5
      circle fill pen, scale.x div 22.5, 1.5
      thread {
            Cursor 0, Height-1
            Print Over $(6),"Current Time: "+str$(now,"long time")
      } as K interval 1000/120
}
\\ hide console
title "", 0
method Form1, "Show", 1
threads Erase
\\ Set a title and restore console
title "M2000 Console", 1
declare Form1 Nothing


Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.