Mostrando las entradas con la etiqueta Eventos. Mostrar todas las entradas
Mostrando las entradas con la etiqueta Eventos. Mostrar todas las entradas

viernes, 7 de julio de 2017

Control personalizado


Aquí les dejo mi experimento en la creación de una clase o control personalizado, a medida para un fin x. El código esta en la granja.


' gambas class file

Export

Inherits UserControl

Public Const _Properties As String = "*,Texto,Seleccion,Hombre=True"
Public Const _DefaultEvent As String = "Eleccion"
Public Const _DefaultSize As String = "36,4"

Event Eleccion

Property Seleccion As Boolean
Property Texto As String
Property Hombre As Boolean

Private $Seleccion As Boolean
Private $Texto As String
Private $Hombre As Boolean

Private $hFondo As DrawingArea
Private $TextLabel As TextLabel
Private $CheckBox As CheckBox
Private $Persona As PictureBox

Public Sub _new()

$hFondo = New DrawingArea(Me) As "Fondo"
$hFondo.Background = &HFFEFBF
$hFondo.Arrangement = Arrange.Horizontal

$CheckBox = New CheckBox($hFondo) As "Check"
$CheckBox.Width = 20
$CheckBox.AutoResize = True
$CheckBox.Background = &HD2DFC3

$TextLabel = New TextLabel($hFondo) As "TexLabel"
$TextLabel.Alignment = Align.Center
$TextLabel.Expand = True
$TextLabel.Background = &HFFEFBF

$Persona = New PictureBox($hFondo) As "Persona"
Hombre_Write(True)
$Persona.Width = 40
$Persona.Stretch = True
$Persona.AutoResize = True

End

Public Sub Fondo_Enter()

$hFondo.Background = &H00FFFF

End

Public Sub Fondo_Leave()

$hFondo.Background = &HFFEFBF

End


Public Sub TexLabel_Enter()

$TextLabel.Tooltip = Me.Name

End

Public Sub TexLabel_MouseUp()

$CheckBox.Value = Not $CheckBox.Value

End

Public Sub Persona_MouseUp()

$CheckBox.Value = Not $CheckBox.Value

End


Public Sub Check_Click()

$Seleccion = $CheckBox.Value
Raise Eleccion

End

Private Function Seleccion_Read() As Boolean

Return $Seleccion

End

Private Sub Seleccion_Write(Value As Boolean)

$Seleccion = Value

End

Private Function Texto_Read() As String

$Texto = $TextLabel.Text
Return $Texto

End

Private Sub Texto_Write(Value As String)

$Texto = Value
$TextLabel.Text = $Texto

End

Private Function Hombre_Read() As Boolean

Return $Hombre

End

Private Sub Hombre_Write(Value As Boolean)

$Hombre = Value

If $Hombre Then
$Persona.Picture = Picture.Load("hombre.png")
Else
$Persona.Picture = Picture.Load("mujer.png")
Endif

End


jueves, 19 de enero de 2017

Control FontName by postapase


Control pensado para seleccionar tipo de fuente rapidamente y comodamente, con la opción de poner fuente predeterminada con un solo clic.

parte gráfica del control (ffontname) formulario

' gambas class file

'by postapase 18 de enero 2017
'http://novatocodegambas.blogspot.com.uy/
'control FontName

Event Reset
Event Seleccion
Event Enter

Public Sub Form_Open()

End

Public Sub btnFontDefault_Click()

Raise Reset

End

Public Sub cbxNombreFuentes_Click()

Raise Seleccion

End

Public Sub btnFontDefault_Enter()

Raise Enter

End



clase fontname

' gambas class file

'by postapase 18 de enero 2017
'http://novatocodegambas.blogspot.com.uy/
'control FontName

Export

Inherits UserControl

Public Const _Properties As String = "*,Predeterminada,Seleccionada,Index"
Public Const _DefaultEvent As String = "Seleccion"
Public Const _DefaultSize As String = "32,4"
Public Const _Group As String = "Chooser"

Event Seleccion
Event Reseteo ''Selecciona la fuente predeterminada de la aplicación

Property Predeterminada As String
Property Seleccionada As String
Property Index As Integer

Private $xfontname As Ffontname
Private $Predeterminada As String
Private $Seleccionada As String
Private $Index As Integer
Private $ListaFuentes As New String[]

Public Sub _new()

$xfontname = New Ffontname(Me) As "Ev"
$Predeterminada = Application.Font.Name
$Seleccionada = $Predeterminada
Me.Proxy = $xfontname.cbxNombreFuentes
ActualizarFuentes()

End

Public Sub Ev_Reset()

Reinicio()

Raise Reseteo

End

Public Sub Ev_Seleccion()

$Seleccionada = $xfontname.cbxNombreFuentes.Current.Text
$Index = $xfontname.cbxNombreFuentes.Index

Raise Seleccion

End

Public Sub EV_Enter()

$xfontname.btnFontDefault.Tooltip = "Seleccionar fuente predeterminada [ " & $Predeterminada & " ]"

End

Public Sub ActualizarFuentes()

Dim NombreFuente As String

For Each NombreFuente In Fonts
$ListaFuentes.Add(NombreFuente)
Next

$xfontname.cbxNombreFuentes.List = $ListaFuentes
$xfontname.cbxNombreFuentes.Add($Predeterminada, 0)

End

Private Function Predeterminada_Read() As String

Return $Predeterminada

End

Private Sub Predeterminada_Write(Value As String)

$Predeterminada = Value

End

Private Function Seleccionada_Read() As String

Return $Seleccionada

End

Private Sub Seleccionada_Write(Value As String)

$Seleccionada = Value

End

Private Function Index_Read() As Integer

Return $Index

End

Private Sub Index_Write(Value As Integer)

$Index = Value
$xfontname.cbxNombreFuentes.Index = $Index

End

Public Sub Reinicio()

$xfontname.cbxNombreFuentes.Index = 0
$Index = 0

En


Saludos y espero sus opiniones.

Necesario estar registrado en  https://www.gambas-es.org/
Descargar 

Dropbox:  fontname-0.1.2.tar.gz

martes, 10 de mayo de 2016

Animación de botones



Esta animación se logra con las propiedades de los botones,
AutoResize: lo que hace es ajustar el perímetro del control al contenido, en este caso un icono que cambiara de tamaño de 22 a 32

Border a false

Los eventos involucrados son  Enter y Leave

Enter: sucede cuando el puntero del ratón entra en el área del control en este caso el control button.

Leave: es lo contrario cuando detecta que el puntero del ratón sale del área del control.

cuando entra el raton en el área del boton (evento enter) le asignamos el icono mas grande y cuando sale el mas pequeño de esta forma logramos el efecto.

también tiene que ver el contenedor de los botones, ver el código fuente.



Código fuente

lunes, 25 de abril de 2016

Evento Arrangement y Función Min





' gambas class file

Public Ancho As Integer
Public Alto As Integer

Public Sub DrawingArea1_Arrange()

Ancho = DrawingArea1.Width
Alto = DrawingArea1.Height
Print "Ancho=" & Ancho
Print "Alto=" & Alto

DrawingArea1_Draw()

End

Public Sub Form_Open()



End

Public Sub DrawingArea1_Draw()

dibuja()

End

Public Sub dibuja()
DrawingArea1.Clear

Paint.Begin(DrawingArea1)
Paint.LineWidth = 2
Paint.Brush = Paint.Color(Color.Black)
Paint.Arc(Ancho / 2, Alto / 2, Min(Ancho / 2, Alto / 2))
Paint.Stroke
Paint.End
End