Announcement

Collapse
No announcement yet.

Add a text to a specific place.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Add a text to a specific place.

    Hi,

    I'd like to print a text in specific place on my screen.
    In this rectangle -> Top: 205 / Left: 5 / Bottom: 235 / Right: 250.

    My problem is that my string is print from (5p) to the end of the screen (320p) and not to the end of my rectangle (250p).


    Code:
        gfx_MoveTo(5, 205);
        colorRGB := gfx_RGBto565(0, 174, 239);
        txt_BGcolour(colorRGB);
        txt_FGcolour(BLACK);
        gfx_ClipWindow(5, 205, 250, 235);
        gfx_Clipping(ON);
        gfx_RectangleFilled(5, 205, 250, 235, RED);
        putstr(macro);
        gfx_Clipping(OFF);
    Best regards,
    Toragan.
    Last edited by Toragan; 24th May 2019, 02:22 AM.

  • #2

    Hi,

    Thank you for sharing your code.

    I tried the code and worked with me. it's normal.


    If you have time, please check the attached ViSi demo project (based on your code) which shows how to print the string with the limit.

    For your reference, please refer with the application note here: Designer or ViSi Word Addressing Architecture


    Can you send a picture here to what you have printed?

    Best regards,
    Kayven
    Attached Files
    Last edited by kayven@4d; 24th May 2019, 04:41 PM.

    Comment


    • #3
      Hi Kayven,

      You can try this code, you wil see that my string is print to the end of the screen but I'd like print her only to the end of the red box and continue to the line.

      Code:
      #platform "Gen4-uLCD-28DT"
      
      
      #inherit "4DGL_16bitColours.fnc"
      
      var colorRGB;
      
      func main()
      
          gfx_ScreenMode(LANDSCAPE) ; // change manually if orientation change
          var i := 0;
          repeat
          if (i < 2)
              var macro := "Hello World I'm trying to print this string in the box" ;
      
              gfx_MoveTo(5, 205);
              colorRGB := gfx_RGBto565(0, 174, 239);
              txt_BGcolour(colorRGB);
              txt_FGcolour(BLACK);
              gfx_ClipWindow(5, 205, 250, 235);
              gfx_Clipping(ON);
              gfx_RectangleFilled(5, 205, 250, 235, RED);
              putstr(macro);
              gfx_Clipping(OFF);
              i++;
          endif
          forever
      endfunc

      Comment


      • #4
        Hi,

        Thanks for the code

        Have you tried the attached demo project?


        I changed your code to show my point. I think this is what you want to achieve.

        Here's the code:

        Code:
         func main()
        
            var colorRGB;
            gfx_ScreenMode(LANDSCAPE) ; // change manually if orientation change
            var i := 0;
        
            ///************************* added
            var buffer[100];
            var myvar;
            var n;
            var c;
            var byteToggle;
            var string_limit := 30;
            var nn;
            var string_length;
            var ptr;
           //***************************/ added
        
            repeat
        
            if (i < 2)
        
                var macro := "Hello World I'm trying to print this string in the box" ;
        
                gfx_MoveTo(5, 205);
                colorRGB := gfx_RGBto565(0, 174, 239);
                txt_BGcolour(colorRGB);
                txt_FGcolour(BLACK);
                //gfx_ClipWindow(5, 205, 250, 235);
                //gfx_Clipping(ON);
                gfx_RectangleFilled(5, 205, 250, 235, RED);
        
             ///*********************** added
        
             to(buffer);
             print([STR]macro);
             ptr := str_Ptr(buffer);
             string_length := strlen(ptr);
        
             while(n<=string_length)
        
               if(byteToggle == 0) myvar := LObyte(buffer[n]);
               if(byteToggle == 1)
                    myvar := HIbyte(buffer[n]);
                    n++;
                endif
        
                nn := c%string_limit;
                print([CHR]myvar);  /// print character
                if(nn == string_limit-1 ) print("\n");
                byteToggle++;
                byteToggle := byteToggle%2;
                pause(50);  /// delay
                c++;
            wend
            //*********************/ added
        
        
                //putstr(macro);
               //gfx_Clipping(OFF);
                i++;
        
            endif
            forever
        endfunc
        Best regards,
        Kayven

        Comment


        • #5
          Hi,

          Yes I tried this demo, it's close to what I expect.
          Only a properly carriage return before or after words.
          I know how to do that, but I thought because he exist a gfx_MoveTo, there could have been a function to set the end of printing.

          Thanks

          Best regards,
          Toragan
          Last edited by Toragan; 24th May 2019, 06:37 PM.

          Comment


          • #6
            Hi Toragan,

            Have you explored the txt_Wrap function?

            I hope this helps.

            Best regards,
            Michael

            Comment


            • #7
              Hi Michael,

              It's not exactly what i'm looking for, but I created my own function to do that.
              Click image for larger version

Name:	Capture texte wrap.PNG
Views:	13
Size:	2.8 KB
ID:	68468
              Last edited by Toragan; 29th May 2019, 06:27 PM.

              Comment

              Working...
              X