Author Topic: Graphic in Inform's Canvas object Picturebox  (Read 5995 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Graphic in Inform's Canvas object Picturebox
« on: December 17, 2019, 08:06:36 pm »
Hi Fellippe
very good advance in developing Inform.
The superlative next (not so next but when you think that it is useful to implement) feature is the possibility to choose a control by a listbox (that can save user when object are on stack) and/or to select multiple objects designing a rectangle or square by mouse (like in Command / Conquer or Age of Empire for your people) and/or to group/ungroup a set of object selected so to move and edit in one time.

In this time I have decided to learn more about graphic, so I have started to use Picturebox control as a canvas and not only like a container of images.
Following the info in the wiki of Inform I find the method BeginDraw PictureID ..... EndDraw PictureID
reading your 2 examples InformFireworks2 and InformSimplePaint you use both the above method both to direct the graphic operation of QB64 to a _DEST canvas(picturebox)... moreover I find this property about that I have found no informations into Inform wiki.
Please tell me where I can get more informations without robbing time to you.
Trying to use PictureBox I have got strange results using VIEW and WINDOW  ( QB64 instructions) to define new cohordinates for Picturebox and to select an area of Picturebox: in summary using method BeginDraw /EndDraw  the instruction WINDOW works while VIEW no. While using the _DEST Control(ID).HelperCanvas method I got result of altering the surface of window of application with moving of all controls on it. The buttons are moved but they react to mouse at the old position.
I attach file to see my experiences. It maybe I have made a bad work.

Thanks for answers!


* window_inform.rar (Filesize: 5.59 KB, Downloads: 332)
Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Graphic in Inform's Canvas object Picturebox
« Reply #1 on: December 30, 2019, 07:19:09 pm »
Errata corrige:
if you use in this manner BEGINDRAW canvas1 and ENDDRAW canvas1 both VIEW both WINDOW  work.
Code: QB64: [Select]
  1. ': This program uses
  2. ': InForm - GUI library for QB64 - v1.1
  3. ': Fellippe Heitor, 2016-2019 - fellippe@qb64.org - @fellippeheitor
  4. ': https://github.com/FellippeHeitor/InForm
  5. '-----------------------------------------------------------
  6.  
  7. ': Controls' IDs: ------------------------------------------------------------------
  8. DIM SHARED PictureBox1 AS LONG
  9. DIM SHARED SetAreaBT AS LONG
  10. DIM SHARED LineBT AS LONG
  11. DIM SHARED ChangeCohordinatesBT AS LONG
  12.  
  13. col = _RGBA32(0, 200, 200, 255)
  14. col2 = _RGBA32(0, 0, 0, 255) 'black
  15. col3 = _RGBA32(0, 200, 0, 255)
  16. '$INCLUDE:'InForm\InForm.ui'
  17. '$INCLUDE:'InForm\xp.uitheme'
  18. '$INCLUDE:'window_test.frm'
  19.  
  20. ': Event procedures: ---------------------------------------------------------------
  21. SUB __UI_BeforeInit
  22.  
  23.  
  24. SUB __UI_OnLoad
  25.  
  26.  
  27. SUB __UI_BeforeUpdateDisplay
  28.     'This event occurs at approximately 30 frames per second.
  29.     'You can change the update frequency by calling SetFrameRate DesiredRate%
  30.  
  31.  
  32. SUB __UI_BeforeUnload
  33.     'If you set __UI_UnloadSignal = False here you can
  34.     'cancel the user's request to close.
  35.  
  36.  
  37. SUB __UI_Click (id AS LONG)
  38.  
  39.     SELECT CASE id
  40.         CASE Form1
  41.  
  42.         CASE PictureBox1
  43.  
  44.         CASE SetAreaBT
  45.             BeginDraw PictureBox1
  46.             IF Caption(SetAreaBT) = "Set Area" THEN
  47.                 VIEW (20, 20)-(100, 100), , col
  48.                 Caption(SetAreaBT) = "RestoreArea"
  49.             ELSE
  50.                 VIEW
  51.                 Caption(SetAreaBT) = "Set Area"
  52.             END IF
  53.             EndDraw PictureBox1
  54.  
  55.  
  56.         CASE clsBT
  57.             BeginDraw PictureBox1
  58.             CLS , col
  59.  
  60.             EndDraw PictureBox1
  61.         CASE LineBT
  62.             BeginDraw PictureBox1
  63.             LINE (1, 1)-(100, 100), col2
  64.  
  65.             EndDraw PictureBox1
  66.  
  67.  
  68.         CASE ChangeCohordinatesBT
  69.             BeginDraw PictureBox1
  70.             IF Caption(ChangeCohordinatesBT) = "Change cohordinates" THEN
  71.                 WINDOW (1, 1)-(150, 250)
  72.  
  73.                 Caption(ChangeCohordinatesBT) = " Restore Cohor"
  74.             ELSE
  75.                 WINDOW
  76.  
  77.                 Caption(ChangeCohordinatesBT) = "Change cohordinates"
  78.             END IF
  79.             EndDraw PictureBox1
  80.     END SELECT
  81.  
  82. SUB __UI_MouseEnter (id AS LONG)
  83.     SELECT CASE id
  84.         CASE Form1
  85.  
  86.         CASE PictureBox1
  87.  
  88.         CASE SetAreaBT
  89.  
  90.         CASE clsBT
  91.  
  92.         CASE LineBT
  93.  
  94.         CASE ChangeCohordinatesBT
  95.  
  96.     END SELECT
  97.  
  98. SUB __UI_MouseLeave (id AS LONG)
  99.     SELECT CASE id
  100.         CASE Form1
  101.  
  102.         CASE PictureBox1
  103.  
  104.         CASE SetAreaBT
  105.  
  106.         CASE clsBT
  107.  
  108.         CASE LineBT
  109.  
  110.         CASE ChangeCohordinatesBT
  111.  
  112.     END SELECT
  113.  
  114. SUB __UI_FocusIn (id AS LONG)
  115.     SELECT CASE id
  116.         CASE SetAreaBT
  117.  
  118.         CASE clsBT
  119.  
  120.         CASE LineBT
  121.  
  122.         CASE ChangeCohordinatesBT
  123.  
  124.     END SELECT
  125.  
  126. SUB __UI_FocusOut (id AS LONG)
  127.     'This event occurs right before a control loses focus.
  128.     'To prevent a control from losing focus, set __UI_KeepFocus = True below.
  129.     SELECT CASE id
  130.         CASE SetAreaBT
  131.  
  132.         CASE clsBT
  133.  
  134.         CASE LineBT
  135.  
  136.         CASE ChangeCohordinatesBT
  137.  
  138.     END SELECT
  139.  
  140. SUB __UI_MouseDown (id AS LONG)
  141.     SELECT CASE id
  142.         CASE Form1
  143.  
  144.         CASE PictureBox1
  145.  
  146.         CASE SetAreaBT
  147.  
  148.         CASE clsBT
  149.  
  150.         CASE LineBT
  151.  
  152.         CASE ChangeCohordinatesBT
  153.  
  154.     END SELECT
  155.  
  156. SUB __UI_MouseUp (id AS LONG)
  157.     SELECT CASE id
  158.         CASE Form1
  159.  
  160.         CASE PictureBox1
  161.  
  162.         CASE SetAreaBT
  163.  
  164.         CASE clsBT
  165.  
  166.         CASE LineBT
  167.  
  168.         CASE ChangeCohordinatesBT
  169.  
  170.     END SELECT
  171.  
  172. SUB __UI_KeyPress (id AS LONG)
  173.     'When this event is fired, __UI_KeyHit will contain the code of the key hit.
  174.     'You can change it and even cancel it by making it = 0
  175.     SELECT CASE id
  176.         CASE SetAreaBT
  177.  
  178.         CASE clsBT
  179.  
  180.         CASE LineBT
  181.  
  182.         CASE ChangeCohordinatesBT
  183.  
  184.     END SELECT
  185.  
  186. SUB __UI_TextChanged (id AS LONG)
  187.     SELECT CASE id
  188.     END SELECT
  189.  
  190. SUB __UI_ValueChanged (id AS LONG)
  191.     SELECT CASE id
  192.     END SELECT
  193.  
  194. SUB __UI_FormResized
  195.  
  196.  
Programming isn't difficult, only it's  consuming time and coffee

FellippeHeitor

  • Guest
Re: Graphic in Inform's Canvas object Picturebox
« Reply #2 on: December 30, 2019, 07:32:29 pm »
I'm sorry I missed this post when you originally wrote it.

I'm glad you figured it out :-)

Fellippe.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Graphic in Inform's Canvas object Picturebox
« Reply #3 on: January 02, 2020, 06:30:28 pm »
Thanks Fellippe

about
Quote
While using the _DEST Control(ID).HelperCanvas method I got result of altering the surface of window of application with moving of all controls on it. The buttons are moved but they react to mouse at the old position.
I have found no solution or more documentations about this.
So it lasts to you in the future development of Inform to choose what and how can survive and what must go away.

Happy New Year to QB64 and also Inform & vWatch.
Programming isn't difficult, only it's  consuming time and coffee

FellippeHeitor

  • Guest
Re: Graphic in Inform's Canvas object Picturebox
« Reply #4 on: January 02, 2020, 06:39:02 pm »
Yeah. You’re not supposed to alter _dest manually especially not to a control’s helper surface, which is why I added Begin/EndDraw.