https://foro.gambas-es.org/viewtopic.php?f=4&t=7957&p=47860#p47860
-----------------------------------
v3ctor
Jueves, 09 Abril 2020, 22:12

Foco (clase)
-----------------------------------
[img]https://foro.gambas-es.org/files/images/2261/foco1.png[/img] 

buenas, esta en la granja..

[code linenumbers=false syntax=gambas]' Gambas class file

' by postapase 09 abr 2020

Export

Inherits UserControl

Public Const _Properties As String = "*,Ancho{Range:16;128}=32,Orientacion{Arrange.Vertical;Horizontal}=Horizontal,Borde=True,Iconos,IconoUno,IconoMas,IconoMenos"
Public Const _IsControl As Boolean = True '28 feb 2018

' Public Const _DefaultEvent As String = "Cli"
Public Const _DefaultSize As String = "4,4"
Public Const _Group As String = "Chooser"

Property Orientacion As Integer
Property Ancho As Integer

Property Borde As Boolean
Property Iconos As Boolean
Property IconoUno As Picture
Property IconoMas As Picture
Property IconoMenos As Picture

Event ClicUno
Event ClicMas
Event ClicMenos

Event EntroUno
Event EntroMas
Event EntroMenos

Event SalioUno
Event SalioMas
Event SalioMenos

Private $focoX As Ffoco
Private $Borde As Boolean
Private $Iconos As Boolean
Private $IconoUno As Picture
Private $IconoMas As Picture
Private $IconoMenos As Picture
Private $Orientacion As Integer
Private $Ancho As Integer

Public Sub _new()
  
  $focoX = New Ffoco(Me) As "Ffoco"
  $focoX.Proxy = Me
  
  ActualizarFuente()
  
End


Private Sub ActualizarFuente()
  
  $focoX.btnUno.Font = Me.Font
  $focoX.btnMenos.Font = Me.Font
  $focoX.btnMas.Font = Me.Font
  
End


Public Sub Ffoco_Arrange()
  
  ActualizarOrientacion()
  
End

Public Sub _ClicUno()
  
  Raise ClicUno
  
End

Public Sub _ClicMas()
  
  Raise ClicMas
  
End

Public Sub _ClicMenos()
  
  Raise ClicMenos
  
End

Public Sub _EntroUno()
  
  Raise EntroUno
  
End

Public Sub _EntroMas()
  
  Raise EntroMas
  
End

Public Sub _EntroMenos()
  
  Raise EntroMenos
  
End

Public Sub _SalioUno()
  
  Raise SalioUno
  
End

Public Sub _SalioMas()
  
  Raise SalioMas
  
End

Public Sub _SalioMenos()
  
  Raise SalioMenos
  
End

Private Function Borde_Read() As Boolean
  
  Return $Borde
  
End

Private Sub Borde_Write(Value As Boolean)
  
  $Borde = Value
  $focoX.btnUno.Border = Value
  $focoX.btnMas.Border = Value
  $focoX.btnMenos.Border = Value
  
End

Private Function Iconos_Read() As Boolean
  
  Return $Iconos
  
End

Private Sub Iconos_Write(Value As Boolean)
  
  $Iconos = Value
  
  If Value Then
    $focoX.btnUno.Text = ""
    $focoX.btnMas.Text = ""
    $focoX.btnMenos.Text = ""
  Else
    $focoX.btnUno.Text = "1"
    $focoX.btnMas.Text = "+"
    $focoX.btnMenos.Text = "-"
  Endif
  
End

Private Function IconoUno_Read() As Picture
  
  Return $IconoUno
  
End

Private Sub IconoUno_Write(Value As Picture)
  
  $IconoUno = Value
  $focoX.btnUno.Picture = $IconoUno
  
End

Private Function IconoMas_Read() As Picture
  
  Return $IconoMas
  
End

Private Sub IconoMas_Write(Value As Picture)
  
  $IconoMas = Value
  $focoX.btnMas.Picture = $IconoMas
  
End

Private Function IconoMenos_Read() As Picture
  
  Return $IconoMenos
  
End

Private Sub IconoMenos_Write(Value As Picture)
  
  $IconoMenos = Value
  $focoX.btnMenos.Picture = $IconoMenos
  
End

Private Function Orientacion_Read() As Integer
  
  Return $Orientacion
  
End

Private Sub Orientacion_Write(Value As Integer)
  
  $Orientacion = Value
  
  ActualizarOrientacion
  
End

Private Sub ActualizarOrientacion()
  
  Print "antes $Ancho=" & $Ancho
  
  If $Ancho = 0 Then 
    $Ancho = 32
  Endif
  
  Print "despues $Ancho=" & $Ancho
  
  If $Orientacion = Arrange.Vertical Then
    Me.Width = $Ancho
    Me.Height = $Ancho * 3
    $focoX.Arrangement = Arrange.Vertical
  Else 'si es horizontal  
    Me.Width = $Ancho * 3
    Me.Height = $Ancho
    $focoX.Arrangement = Arrange.Horizontal
  Endif
  
End

Private Function Ancho_Read() As Integer
  
  Return $Ancho
  
End

Private Sub Ancho_Write(Value As Integer)
  
  $Ancho = value  ' 
  
  $focoX.btnUno.Width = $Ancho
  $focoX.btnMas.Width = $Ancho
  $focoX.btnMenos.Width = $Ancho
  
  $focoX.btnUno.Height = $Ancho
  $focoX.btnMas.Height = $Ancho
  $focoX.btnMenos.Height = $Ancho
  
  ActualizarOrientacion()
  
End[/code]


