Page loading

Share your opinion
What do you think about gambaslinux.fr?
 
Interesting
It miss some informations
Excellent website
Results
WIDGETS GAMBAS
GAMBAS 3 SOFTWARES
TUTORIALS
Library
Component creation - Diode
CREATE GAMBAS 3 COMPONENT


To create a component, we have to understand oriented object conception(OOP) : Public, Private, Create, etc... herit, inherit...


A)OOP basic lesson


'Class Quadruped

Property footnumber
Property mouthsize


'Class dog
Inherit Quadruped

Property race
property colour

Donc au final la classe dog

dog.footnumber
dog.mouthsize
dog.race
dog.colour


It's the same thing for containers, you create a console project and, you put in Two or three class and you see how they interreac themselves. For example, if I code this :

'Class mylabel
Inherit Label

Property Text as string

Private Sub Text_Read() as String

return SUPER.Text & astring

end

Private Function Text_Write(Value as string)

SUPER.Text = Value

end

I "change" or "turn away" the label property... "Super" call a parent class property
Well if I write this :

 label.text = "mystring"

print label.text

the result is :

mystringastring

Why use this example ? nothing ! :)



sometimes, you want to call a class without instance :

I instance with New:

hmyClass = new Myclass


I put Create Static .we can write as Report :

report.myfonction

Because Gambas instance a report and affect to the Reported variable, well report go from class to a reported variable.

What is a instance ? It's a copy of work in memory. may be you have as instance far as you xant. A module is a class with statics elements, that's why, it doesn't instanciable and accessible since maclass.mafonctionstatique.

I use it in gb.report to, for example, put objects references in a collection.
Well I call report._collection[valeur]

where _collection is declared static.public

"_" symbol  mean this function is cached in the IDE... yes there is a lot of cached things.. usable, but cached because dangerous for a direct use, or simply to not surcharge the interface...
Now we try to create own first gambas 3 components or widget.

B) Fisrt component

Here you find the fisrt demonstration of a new component : the Diodes

Just one or two points :
1) you have to check  that this project is a component(general properties window with ctrl+p). Well, you have to check if your project has graphics components (gb.gui, gb.qt4 or gb.gtk)

2) Now to test or to use your new component, you have to create gambas binary(don't create binary in your project path !) and put checkbox "install component" to true.
validate by OK button and miracle ! your new widget is listed in your toolbox :) :)

Be carrefull : Your component is installed on your local hardisk.(in /home/user...)

The end.

C) difference with a component and a control.

A control is a class type... in this example, I have explained to you how to make a graphic component... this is not the same thing for gb.chart or gb.report because they draw on device given by the class paint.
A component is a set of classes and controls.

gb.qt for example is a component who have : button, listbox,(they are controls), timer(is a class usable as a control), paint(is a class)

regards

Creation date : 08/04/2010 @ 22:44
Last update : 15/05/2011 @ 12:59
Category : Component creation
Page read 6635 times


Print the article Print the article


react.gifReactions to this article


Reaction #2 

by didier18 22/05/2016 @ 09:08

Bonjour Spheris

Pour l'installation du composant, tu dis :"faire générer l'exécutable (ne pas le générer dans le dossier du projet !) et cocher la case installer le composant...".
Ne pas générer dans le dossier du projet,  je veux bien mais pourquoi ?
Ou se trouve la case à cocher installer le composant (gambas3_3.8.4) ? 
Merci.Bonne journée.

Reaction #2 

by spheris 13/02/2011 @ 18:52

Helloworld, as-tu essayé de télécharger l'exemple diode sur la page? Que n'as-tu pas compris ?
J'ai rien compris ,c'est un peu vague, ne trouves-tu pas ?
wink

QUICK MENU
SEARCH




LANGUAGE
COMPONENTS
Other
LANGUAGE
Where, who?
VISITS

   visitors

   visitors online

ARCHIVES GAMBAS 1/2
^ Top ^