Linking graphically two gadgets .[Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Linking graphically two gadgets .[Resolved]

Post by Kwai chang caine »

Hello at all

This is my first question of the year, but surrely not the last :oops:

I try to make a very simple and little "ChartFLow" with gadgets.
ARTIC FOX give to me a great link for a real freeware ChartFLOW and i thanks again him 8)
http://logicnet.dk/DiagramDesigner/
I use now this freeware, but,for learning more in programming, i want to continue the mine :D

It's simple, i use basically the code of PATRICK88
http://www.purebasic.fr/english/viewtop ... 84#p310584

And the look is like this:

Image

Like you see, i use image gadget for made short arrow :D
But i want to add an additional function : The long arrow

And i have not idea, how can i create this long arrow :oops:

The top is, if i can resize the gadget, and the arrow inside, and by miracle change the color and the layer of the arrow inside :roll:
But is it possible ?????

Or perhaps, give the coordonate of the two gadget, and draw automatically a line between them ??? :roll:

Image

Heve you another idea, or a tips for help me ??? :roll:

Thanks at all and good day
Last edited by Kwai chang caine on Mon Jan 04, 2010 6:04 pm, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Linking graphically two gadgets ...

Post by Rook Zimbabwe »

I suggest you use vectors to draw your Flowchart and possibly the decisions tree items as well.

Problem is... can you use vectors in 2D or do you have to be using 3D? :D

Drawing arcs: http://www.purebasic.fr/english/viewtop ... ector+draw

Use of vectors there!

Likewise I could create a few Corel Draw primatives but I have no idea how you would recolor them or scale them in PB 8)

There is a SVG library out there: http://www.purebasic.fr/english/viewtop ... ilit=corel

Good luck!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Linking graphically two gadgets ...

Post by Kwai chang caine »

Thanks ROOK for your answer 8)
In fact, i want the more simple possible :roll:
Don't forget, it's KCC who speak to you :lol:

I go to search in the direction you show to me 8)
Again thanks 8)
ImageThe happiness is a road...
Not a destination
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: Linking graphically two gadgets ...

Post by Arctic Fox »

You can also draw the arrows directly onto the window using WindowOutput().
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Linking graphically two gadgets ...

Post by Kwai chang caine »

Hello ARTIC FOX, glad to talk you :D

Yes i believe it's surelly the more simple way for me :roll:
In the link of ROOK, i have see this :

Code: Select all

Width  = 500
  Height = 300
  If OpenWindow(0, 0, 0, Width, Height+1, "Rotations-Ellipse", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If StartDrawing(WindowOutput(0))
      i = 1
      x = Width/2
      y = Height/2
      
       For w = 0 To 360
         If w <= 90 Or w>=270
           col = 1234
          Else
           col = 123456
         EndIf 

          Ellipse(x, y, x*Cos(w*#PI/180), y, col+i)
          FillArea(0, 0, col+i, RGB(212, 208, 200))
         
          i = ~i
          Delay(10)
      
       Next
      StopDrawing()
    EndIf
    
    Repeat : Event = WaitWindowEvent() : Until  Event = #PB_Event_CloseWindow
  EndIf
And in the same time, you post to me...i say to me that if a round can be drawing ...a line can be drawing more easyly :D
I try to search in this simple way ..

For simple program....KCC must search simple solution :mrgreen:
A best way, it's if i clic the start...and i clic the end...."Pof"...a line is drawing between the two points :D
Like in the soft of draw ...
Perhaps a code already exist like this :roll:
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Linking graphically two gadgets ...

Post by Kwai chang caine »

I move a little bit..but just a little :oops:

I have an arrow like "APACHE"....but the resize is not good :(
And i don't know how i can augment the layer of the arrow :roll:

Code: Select all

Enumeration
 #Fenetre
 #Image
 #FondBlanc
 #ImageGadget
EndEnumeration

Hauteur = 200
Largeur = 400

Procedure DessineFleche(x, y)
 
 If IsImage(#Image)
 
  ;ResizeImage(#Image, x, y) 
  ; ResizeGadget(#ImageGadget, #PB_Ignore, #PB_Ignore, x, y)
;   Debug x
;   Debug y
  StartDrawing(ImageOutput(#Image))
   Box(0, 0, x, y, RGB(255, 255, 255))
   LineXY(0, 10, x - 10, 10, RGB(226, 23, 29)) ; Horizontale
   LineXY(x - 10, 10, x - 10, y - 10, RGB(226, 23, 29)) ; Verticale
   LineXY(x - 10, y - 10, x - 15, y - 20, RGB(226, 23, 29))
   LineXY(x - 10, y - 10, x - 5, y - 20, RGB(226, 23, 29))
  StopDrawing()
   
  RedrawWindow_(ImageID(#Image), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)
  RedrawWindow_(GadgetID(#ImageGadget), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)
  RedrawWindow_(WindowID(#Fenetre), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)
   
 EndIf
   
EndProcedure
 
OpenWindow(#Fenetre, 417, 181, 600, 500, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
CreateImage(#Image, Largeur, Hauteur)
ImageGadget(#ImageGadget,100, 100, 0, 0, ImageID(#Image))
DessineFleche(Largeur, Hauteur)
   
Repeat  
 
 Evenement = WaitWindowEvent()
 
 Select Evenement
  
  Case #WM_MOUSEMOVE
  
   MouseX = WindowMouseX(#Fenetre)
			MouseY = WindowMouseY(#Fenetre)
   
			If GetAsyncKeyState_(#VK_LBUTTON)
    
    DessineFleche(mousex - GadgetX(#ImageGadget), mousey - GadgetY(#ImageGadget))
   	
  	EndIf			
 
 EndSelect
 
Until Evenement = #PB_Event_CloseWindow
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Linking graphically two gadgets ...

Post by Kwai chang caine »

A friend in French forum KERNADEC found my error, and fix it 8)
I give the solution, if somebody need it :wink:

Code: Select all

Enumeration
#Fenetre
#Image_0
#Image_1
#FondBlanc
#ImageGadget
EndEnumeration
hdc.l=0
Hauteur = 200
Largeur = 400
CreateImage(#Image_0, Largeur,Hauteur) 
CreateImage(#Image_1, Largeur,Hauteur)
Procedure DessineFleche(x, y)
StartDrawing(ImageOutput(#Image_1))
  DrawImage(ImageID(#Image_0), 0, 0)
  LineXY(0, 10, x - 10, 10, RGB(226, 23, 29)) ; Horizontale
  LineXY(x - 10, 10, x - 10, y - 10, RGB(226, 23, 29)) ; Verticale
  LineXY(x - 10, y - 10, x - 15, y - 20, RGB(226, 23, 29))
  LineXY(x - 10, y - 10, x - 5, y - 20, RGB(226, 23, 29))
  StopDrawing()
SetGadgetState(#ImageGadget,ImageID(#Image_1))
RedrawWindow_(WindowID(#Fenetre), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)
EndProcedure

OpenWindow(#Fenetre, 417, 181, 600, 500, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
ImageGadget(#ImageGadget, 100, 100, Largeur,Hauteur, ImageID(#Image_1))
StartDrawing(ImageOutput(#Image_0))
FillArea(0,0,RGB(255,255,255),RGB(255,255,255))
StopDrawing()
DessineFleche(Largeur, Hauteur)
      
Repeat  

Evenement = WaitWindowEvent()

  Select Evenement
   
   Case #WM_MOUSEMOVE
   
      MouseX = WindowMouseX(#Fenetre)
      MouseY = WindowMouseY(#Fenetre)
      
      If GetAsyncKeyState_(#VK_LBUTTON)
      
      DessineFleche(mousex - GadgetX(#ImageGadget), mousey - GadgetY(#ImageGadget))
            
      EndIf         

   EndSelect

Until Evenement = #PB_Event_CloseWindow
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Linking graphically two gadgets .[Resolved]

Post by Kwai chang caine »

I'm put off :cry:
There is 5 hours that i fighting against this code to try to modify it.

I search that the white square follow the arrow, if the mouse go out the square up, down, left, right and that don't works
When the resizing is upper thats works with bug, but when it's lower that crash, because i don't know how create the image in the other sense :(

Code: Select all

Enumeration
#Fenetre
#Image_0
#Image_1
#FondBlanc
#ImageGadget
EndEnumeration
hdc.l=0
Hauteur = 200
Largeur = 400
CreateImage(#Image_0, Largeur,Hauteur) 
CreateImage(#Image_1, Largeur,Hauteur)

Procedure DessineFleche(x, y)
 
 If x > GadgetWidth(#ImageGadget) Or y > GadgetHeight(#ImageGadget) Or x < GadgetX(#ImageGadget) Or y < GadgetY(#ImageGadget) 
  ResizeImage(#Image_1, x, y)
  ResizeImage(#Image_0, x, y)
 EndIf
  
 StartDrawing(ImageOutput(#Image_1))
  DrawImage(ImageID(#Image_0), 0, 0)
  LineXY(0, 10, x - 10, 10, RGB(226, 23, 29)) ; Horizontale
  LineXY(x - 10, 10, x - 10, y - 10, RGB(226, 23, 29)) ; Verticale
  LineXY(x - 10, y - 10, x - 15, y - 20, RGB(226, 23, 29))
  LineXY(x - 10, y - 10, x - 5, y - 20, RGB(226, 23, 29))
 StopDrawing()
 
 SetGadgetState(#ImageGadget,ImageID(#Image_1))
 RedrawWindow_(WindowID(#Fenetre), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)
 
EndProcedure

OpenWindow(#Fenetre, 417, 181, 600, 500, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
ImageGadget(#ImageGadget, 100, 100, 0, 0, ImageID(#Image_1))
StartDrawing(ImageOutput(#Image_0))
FillArea(0,0,RGB(255,255,255),RGB(255,255,255))
StopDrawing()
DessineFleche(Largeur, Hauteur)
      
Repeat  

Evenement = WaitWindowEvent()

  Select Evenement
   
   Case #WM_MOUSEMOVE
   
      MouseX = WindowMouseX(#Fenetre)
      MouseY = WindowMouseY(#Fenetre)
      
      If GetAsyncKeyState_(#VK_LBUTTON)
      
      DessineFleche(mousex - GadgetX(#ImageGadget), mousey - GadgetY(#ImageGadget))
            
      EndIf         

   EndSelect

Until Evenement = #PB_Event_CloseWindow
If someone can help me i thank him by advance :roll
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4955
Joined: Sun Apr 12, 2009 6:27 am

Re: Linking graphically two gadgets .[Resolved]

Post by RASHAD »

Hi KCC
I only prevented the crash ,I do't know what do you want exactly
And remove Resolved will you?

Code: Select all

Enumeration
#Fenetre
#Image_0
#Image_1
#FondBlanc
#ImageGadget
EndEnumeration
hdc.l=0
Hauteur = 200
Largeur = 400
CreateImage(#Image_0, Largeur,Hauteur) 
CreateImage(#Image_1, Largeur,Hauteur)

Procedure DessineFleche(x, y)

If x > GadgetWidth(#ImageGadget) Or y > GadgetHeight(#ImageGadget) Or x < GadgetX(#ImageGadget) Or y < GadgetY(#ImageGadget)
  ResizeImage(#Image_1, x, y)
  ResizeImage(#Image_0, x, y)
EndIf
  
StartDrawing(ImageOutput(#Image_1))
  DrawImage(ImageID(#Image_0), 0, 0)
  LineXY(0, 10, x - 10, 10, RGB(226, 23, 29)) ; Horizontale
  LineXY(x - 10, 10, x - 10, y - 10, RGB(226, 23, 29)) ; Verticale
  LineXY(x - 10, y - 10, x - 15, y - 20, RGB(226, 23, 29))
  LineXY(x - 10, y - 10, x - 5, y - 20, RGB(226, 23, 29))
StopDrawing()

SetGadgetState(#ImageGadget,ImageID(#Image_1))
RedrawWindow_(WindowID(#Fenetre), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)

EndProcedure

OpenWindow(#Fenetre, 417, 181, 600, 500, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
ImageGadget(#ImageGadget, 100, 100, 0, 0, ImageID(#Image_1))
StartDrawing(ImageOutput(#Image_0))
FillArea(0,0,RGB(255,255,255),RGB(255,255,255))
StopDrawing()
DessineFleche(Largeur, Hauteur)
      
Repeat  

Evenement = WaitWindowEvent()

  Select Evenement
   
   Case #WM_MOUSEMOVE
   
      MouseX = WindowMouseX(#Fenetre)
      MouseY = WindowMouseY(#Fenetre)
      
      If GetAsyncKeyState_(#VK_LBUTTON) And MouseX > GadgetX(#ImageGadget) And MouseY > GadgetY(#ImageGadget)
      
      DessineFleche(mousex - GadgetX(#ImageGadget), mousey - GadgetY(#ImageGadget))
            
      EndIf         

   EndSelect

Until Evenement = #PB_Event_CloseWindow
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Linking graphically two gadgets .[Resolved]

Post by Kwai chang caine »

Hello RASHAD glad to talk to you :D

I have working on this arrow, again all the day, and that not works again.
It's very difficult for me, what i want like usually :(

I want an arrow like this

Code: Select all

Enumeration
 #Fenetre
 #Image_0
 #Image_1
 #FondBlanc
 #ImageGadget
EndEnumeration

Largeur = 300
Hauteur = 200
Global DepartX = 570
Global DepartY = 100
CreateImage(#Image_0, Largeur, Hauteur) 
CreateImage(#Image_1, Largeur, Hauteur)

Procedure DessineFleche(x, y)
  
 StartDrawing(ImageOutput(#Image_1))
  DrawImage(ImageID(#Image_0), 0, 0)
  LineXY((DepartX - 30) - x - 230, 10, x - 10, 10, RGB(226, 23, 29)) ; Horizontale
  LineXY(x - 10, 10, x - 10, y - 10, RGB(226, 23, 29)) ; Verticale
  LineXY(x - 10, y - 10, x - 15, y - 20, RGB(226, 23, 29)) ; Fleche gauche
  LineXY(x - 10, y - 10, x - 5, y - 20, RGB(226, 23, 29)) ; Fleche droite
 StopDrawing()
 
 SetGadgetState(#ImageGadget,ImageID(#Image_1))
 RedrawWindow_(WindowID(#Fenetre), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)

EndProcedure

OpenWindow(#Fenetre, 417, 181, 600, 500, "Fleche multisens", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered|#PB_Window_TitleBar)
ImageGadget(#ImageGadget, 100, DepartY, 0, 0, ImageID(#Image_1))

StartDrawing(ImageOutput(#Image_0))
 FillArea(0,0,RGB(255,255,255),RGB(255,255,255))
StopDrawing()

DessineFleche(Largeur, Hauteur)
      
Repeat  

Evenement = WaitWindowEvent()

 Select Evenement
  
  Case #WM_MOUSEMOVE
  
   MouseX = WindowMouseX(#Fenetre)
   MouseY = WindowMouseY(#Fenetre)
   
   If GetAsyncKeyState_(#VK_LBUTTON)
    DessineFleche(MouseX - GadgetX(#ImageGadget), MouseY - GadgetY(#ImageGadget))
   EndIf         

  EndSelect

Until Evenement = #PB_Event_CloseWindow
The end of the arrow follow the mouse
But i want can move it up, down, right, left, out of the white square and never change the place and the size of the white square

This is a picture of the different position possible of the arrow :

Image

In fact for obtain only one of this image always at the same place and size
And the lenght of the arrow is without limit, because the image gagdet resize with the arrow automaticaly


Image Image
Image Image

I know it's very difficult, because i have try 2 day with ten hour by day, and without success :(

Again thanks RASHAD, for your help, very very needed :wink:
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4955
Joined: Sun Apr 12, 2009 6:27 am

Re: Linking graphically two gadgets .[Resolved]

Post by RASHAD »

Kwai
See the next if it is OK
You can repeat for the other three rect. of course you must take into your consideration the directions

Code: Select all


Enumeration
#Fenetre
#Image_0
#Image_1
#FondBlanc
#ImageGadget
EndEnumeration
hdc.l=0
Hauteur = 200
Largeur = 400
CreateImage(#Image_0, Largeur,Hauteur) 
CreateImage(#Image_1, Largeur,Hauteur)

Procedure DessineFleche(x, y)
  
StartDrawing(ImageOutput(#Image_1))
  DrawImage(ImageID(#Image_0), 0, 0)
  LineXY(0, 10, x - 10, 10, RGB(226, 23, 29)) ; Horizontale
  LineXY(x - 10, 10, x - 10, y - 10, RGB(226, 23, 29)) ; Verticale
  LineXY(x - 10, y - 10, x - 15, y - 20, RGB(226, 23, 29))
  LineXY(x - 10, y - 10, x - 5, y - 20, RGB(226, 23, 29))
StopDrawing()

  ResizeImage(#Image_1, x, y)
  ResizeImage(#Image_0, x, y)

SetGadgetState(#ImageGadget,ImageID(#Image_1))

EndProcedure

OpenWindow(#Fenetre, 417, 181, 600, 500, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
ImageGadget(#ImageGadget, 100, 100, 0, 0, ImageID(#Image_1))
StartDrawing(ImageOutput(#Image_0))
FillArea(0,0,RGB(255,255,255),RGB(255,255,255))
StopDrawing()
DessineFleche(Largeur, Hauteur)
      
Repeat  

Evenement = WaitWindowEvent()

  Select Evenement
   
   Case #WM_MOUSEMOVE
   
      MouseX = WindowMouseX(#Fenetre)
      MouseY = WindowMouseY(#Fenetre)
      
      If GetAsyncKeyState_(#VK_LBUTTON) And MouseX > GadgetX(#ImageGadget) And MouseY > GadgetY(#ImageGadget)
      
      DessineFleche(mousex - GadgetX(#ImageGadget), mousey - GadgetY(#ImageGadget))
            
      EndIf         

   EndSelect

Until Evenement = #PB_Event_CloseWindow
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Linking graphically two gadgets .[Resolved]

Post by Kwai chang caine »

Thanks RASHAD but that i not can do, it's the same arrow for the four direction
I have also do this code, with two arrow in the same picture, but i search to create the same with four direction and the gadget resize automaticaly like your code for the four :oops:

Code: Select all

Enumeration
#Fenetre
#Image_0
#Image_1
#ImageGadget
EndEnumeration

Hauteur = 200
Largeur = 200
Epaisseur = 10
Couleur = RGB(34, 54, 221)

Procedure DessineFleche(x, y, Epaisseur, Couleur)
     
StartDrawing(ImageOutput(#Image_1))

  DrawImage(ImageID(#Image_0), 0, 0)
     
  For i = 1 To Epaisseur
           
   LineXY(GadgetWidth(#ImageGadget) / 2, 10 + i, x - 40, 10 + i, Couleur) ; Horizontale
   LineXY(x - 40 + i, 11, x - 40 + i, y - 30, Couleur) ; Verticale
   LineXY(x - 40 + i, y - 30, x - 60 + i, y - 60, Couleur) ; Bord fleche gauche
   LineXY(x - 40 + i, y - 30, x - 20 + i, y - 60, Couleur) ; Bord fleche droit
   
  Next
    
StopDrawing()
SetGadgetState(#ImageGadget,ImageID(#Image_1))
RedrawWindow_(WindowID(#Fenetre), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)

EndProcedure

CreateImage(#Image_0, Largeur * 2, Hauteur) ; Image de ce qui est fixe
CreateImage(#Image_1, Largeur * 2, Hauteur) ; image de ce qui est en cours dêtre dessiné

OpenWindow(#Fenetre, 0, 0, Largeur * 3, Hauteur * 2, "Fleche et souris", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_TitleBar)
ImageGadget(#ImageGadget, Largeur / 2 , Hauteur / 2, 0, 0, ImageID(#Image_1))

StartDrawing(ImageOutput(#Image_0))
FillArea(0, 0, RGB(255,255,255), RGB(255,255,255))
StopDrawing()

DessineFleche(Largeur / 2, Hauteur, Epaisseur, Couleur)
      
Repeat  

Evenement = WaitWindowEvent()

  Select Evenement
   
   Case #WM_MOUSEMOVE
   
    MouseX = WindowMouseX(#Fenetre)
    MouseY = WindowMouseY(#Fenetre)
    
    If GetAsyncKeyState_(#VK_LBUTTON)
     DessineFleche(MouseX - GadgetX(#ImageGadget) + 39, MouseY - GadgetY(#ImageGadget) + 39, Epaisseur, Couleur)
    EndIf         

  EndSelect

Until Evenement = #PB_Event_CloseWindow
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4955
Joined: Sun Apr 12, 2009 6:27 am

Re: Linking graphically two gadgets .[Resolved]

Post by RASHAD »

Kwai
Do you want the four rect. to be resized to the same size from the center if you are resizing any one of them ?
Like your picture ?
Egypt my love
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: Linking graphically two gadgets .[Resolved]

Post by Arctic Fox »

Kwaï chang caïne wrote:Thanks RASHAD but that i not can do, it's the same arrow for the four direction
Does this solve that problem?

Code: Select all

Enumeration
#Fenetre
#Image_0
#Image_1
#ImageGadget
EndEnumeration

Hauteur = 200
Largeur = 200
Epaisseur = 10
Couleur = RGB(34, 54, 221)

Procedure DessineFleche(x, y, Epaisseur, Couleur)
     
StartDrawing(ImageOutput(#Image_1))

  DrawImage(ImageID(#Image_0), 0, 0)
     
  For i = 1 To Epaisseur
           
   LineXY(GadgetWidth(#ImageGadget) / 2, 10 + i, x - 40, 10 + i, Couleur) ; Horizontale
   LineXY(x - 41 + i, 11, x - 41 + i, y - 30, Couleur) ; Verticale
   
   If y > 40
   LineXY(x - 41 + i, y - 30, x - 60 + i, y - 60, Couleur) ; Bord fleche gauche
   LineXY(x - 41 + i, y - 30, x - 20 + i, y - 60, Couleur) ; Bord fleche droit
   Else
   LineXY(x - 41 + i, y - 30, x - 60 + i, y, Couleur) ; Bord fleche gauche
   LineXY(x - 41 + i, y - 30, x - 20 + i, y, Couleur) ; Bord fleche droit
   EndIf
   
  Next
   
StopDrawing()
SetGadgetState(#ImageGadget,ImageID(#Image_1))
RedrawWindow_(WindowID(#Fenetre), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)

EndProcedure

CreateImage(#Image_0, Largeur * 2, Hauteur) ; Image de ce qui est fixe
CreateImage(#Image_1, Largeur * 2, Hauteur) ; image de ce qui est en cours dêtre dessiné

OpenWindow(#Fenetre, 0, 0, Largeur * 3, Hauteur * 2, "Fleche et souris", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_TitleBar)
ImageGadget(#ImageGadget, Largeur / 2 , Hauteur / 2, 0, 0, ImageID(#Image_1))

StartDrawing(ImageOutput(#Image_0))
FillArea(0, 0, RGB(255,255,255), RGB(255,255,255))
StopDrawing()

DessineFleche(Largeur / 2, Hauteur, Epaisseur, Couleur)
     
Repeat 

Evenement = WaitWindowEvent()

  Select Evenement
   
   Case #WM_MOUSEMOVE
   
    MouseX = WindowMouseX(#Fenetre)
    MouseY = WindowMouseY(#Fenetre)
   
    If GetAsyncKeyState_(#VK_LBUTTON)
     DessineFleche(MouseX - GadgetX(#ImageGadget) + 39, MouseY - GadgetY(#ImageGadget) + 39, Epaisseur, Couleur)
    EndIf         

  EndSelect

Until Evenement = #PB_Event_CloseWindow
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Linking graphically two gadgets .[Resolved]

Post by Kwai chang caine »

Thanks at you two. 8)
Arctic Fox wrote:Does this solve that problem?
Excuse me but not really :oops:
Rashad wrote:Kwai
Do you want the four rect. to be resized to the same size from the center if you are resizing any one of them ?
Like your picture ?
I try to explain...but it's difficult
In fact i try to create a ChartFlow with gadget like this

Image

I have nearly finish, but i want to create a gadget with an arrow inside for linking the other elements.
So the arrow can be in several senses.

Start to left and go up
Image

Start to right and go up
Image

Start to left and go down
Image

Start to right and go down
Image

It's the 4 direction possible with this type of arrow
So i want create just one gadget for this 4 different arrow.

At the start, i want create one of this four arrow
And when i move the mouse, the arrow change of sense.

If i go up the mouse and in the same time move the mouse left, i have this arrow

Image

If i go own the mouse and in the same time move the mouse to the right, i have this arrow

Image

But all with the same gadgetimage

Look at my code ...in the same gadgetimage i have two arrow different possible
The blue arrow right and down, and the blue arrow left and down :D
Just with the move of the mouse ....

But i have two problems.

1/ For example, if i move the mouse by the left and go out the imagegadget, the image gadget don't resize itself anf the end of the arrow disappear :(
Exactely the same thing, when i move the mouse by down
Exactely the same for the right :(
And obviously the same problem when i move the mouse up
See this picture the end of arrow is cut, because the imagegadget don't resize more big for see the arrow full :(

Image

2/ And the second problem, is when i move the arrow by left or right, the other side is empty and white.
The gadgetimage not resize too, for hide this big part of white
Like this, the left part is empty, and i don't want this, i want the imagegadget resize for not see white at the left

Image

For answer to RASHAD, yes the more simple is perhaps the arrow begin to the center, and go in all the direction :roll:
But when i go left and up, the down and right of white image must disappears
The imagegadget must to be resizing exactely around the arrow, not big white must appears, just a little bit arround for not cut the arrow :D

Excuse me for this hard question, but i'm tired to write hundred lines, and i don't know where i am now :(
ImageThe happiness is a road...
Not a destination
Post Reply