[Gambas-user] Question about object creation ?

Olivier Cruilles linuxos at ...1896...
Sun May 24 10:57:03 CEST 2009


Le 24 mai 09 à 09:52, Doriano Blengino a écrit :

> Olivier Cruilles ha scritto:
>> Hi,
>>
>>
>> I would like to create a new application to learn how to create
>> dynamically object on a Form.
>>
>> All that I created since I know Gambas is by drawing object on the  
>> IDE
>> of Gambas.
>>
>> So, my idea is to create a form and inside the possibility to add new
>> object as a Panel and inside ListView, Buttons and some other.
>> I would like to move this Panel by mouse, resize it.
>>
>> So I think I can find a link to explain me how to code this new  
>> object
>> and how to create it dynamically by a class or a module.
>>
> It is easy. The following sub will create two textboxes each time:
>
>    PUBLIC SUB Button2_Click()
>      DIM tb AS TextBox
>
>      tb = NEW TextBox(FMain)
>      tb.x = 10
>      tb.y = 20
>
>      tb = NEW TextBox(FMain)
>      tb.x = 10
>      tb.y = 60
>    END
>
> The first line, "tb = NEW textBox...." creates a new object into  
> FMain,
> with default values. Then you change properties as you want.  
> Changing X
> or Y moves the item; changing W, its width, Text, its containt, and so
> on. You can change properties of every object, even those you created
> with the IDE GUI editor.
>
> Note then, that the same variable is used again to create another
> textbox. The result will be 2 more textboxes in FMain. You can also  
> use
> a for-next cycle, or other loops, to create many widgets: all the  
> widget
> will be owned by FMain. But, after the second creation, the variable
> "tb" will not be bound anymore to the first textbox, only to the  
> second.
> This means that for dynamically created object, if you want to operate
> on them later, you must retain the variable used to construct them,
> perhaps in an array. There two other methods to do this, if you don't
> want to use an array. First, you can bound events to your items, using
> something like (tb = NEW textBox(FMain) as "DynText"), and then  
> operate
> on the object from an event handler through the LAST variable. Or, you
> can use the Children properties of the container where you put the  
> objects.
>
>> But my question is, if I want to draw between each my new object,
>> lines to links all of then, what kind of solution I can use
>>
>> 	- use a drawarea object, put it on the backgroud of all objects and
>> draw lines to create illusion of links ?
>>
> This is an option, especially suited if there are many lines. But to
> keep track of those lines you will need some data structure (array,
> perhaps).
> If the user can click on lines to operate on them, you must search  
> your
> structures to identify which lines is under editing.
>> 	or
>>
>> 	- create one drawarea for each link and put it between 2 of 'my new
>> object' ?
>>
> This is an options also, but a drawingarea is a rectangular region.  
> You
> could end up with having two or more lines in the same drawingarea,  
> and
> fall again in the problem stated before (the need to search in your
> structures). It depends on what you want to do. May be you want to do
> zoom and pan, like a CAD. In this case, perhaps a single drawing  
> area is
> better. May be your needs are simpler, just a single line between two
> never-overlapping objects, in this case many drawingareas could be
> easier. I don't know for sure, but it seems to me that a single
> drawingarea is better.
>
> Regards,
>
> -- 
> Doriano Blengino
>
> "Listen twice before you speak.
> This is why we have two ears, but only one mouth."
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity  
> professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp asthey present alongside digital heavyweights like  
> Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>


Hi Doriano,

Thank you very much for your answer, it's exactly that I went for my  
application.

I don't need the possibility to click directly on each line to do  
something on, It's just a draw to show a link
between to elements.

I just want to build a version of a part of an other project that is  
not really that I want. I want to do better than this:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Association_panel.png
Type: image/png
Size: 140096 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20090524/a04e6bdf/attachment.png>
-------------- next part --------------





Olivier Cruilles
Mail: linuxos at ...1896...



More information about the User mailing list