Advertisement
jsbsan

BarraAplicaciones

Feb 10th, 2014
616
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GAMBAS 2.89 KB | None | 0 0
  1. ' Gambas class file
  2.  
  3. Public Sub _new()
  4.  
  5.   Me.title = "Barra"
  6.  
  7. End
  8.  
  9. Public Sub Form_Open()
  10.  
  11.   'lectura de posicion de la ventana inicial...
  12.   Settings.Read(Me)
  13.  
  14.   'If Settings["ventana/ancho"] = "" Then
  15.   'Else
  16.   '  Me.w = Settings["ventana/ancho"]
  17.   'Endif
  18.   'If Settings["ventana/largo"] = "" Then
  19.   'Else
  20.   '  Me.h = Settings["ventana/largo"]
  21.   'Endif
  22.  
  23.   'If Settings["ventana/x"] = "" Then
  24.   'Else
  25.   '  Me.x = Settings["ventana/x"]
  26.   'Endif
  27.  
  28.   'If Settings["ventana/y"] = "" Then
  29.   'Else
  30.   '  Me.y = Settings["ventana/y"]
  31.   'Endif
  32.  
  33.   '----------------------------------------------------
  34.   'parametros para leer datos del boton 4 y 5
  35.   '-------------------------------------------------
  36.   If Settings["Boton4/icono"] = "" Then
  37.   Else
  38.     ToolButton4.Picture = Picture.Load(Settings["Boton4/icono"])
  39.   Endif
  40.  
  41.   If Settings["Boton4/tag"] = "" Then
  42.     ToolButton4.tag = ""
  43.   Else
  44.     ToolButton4.tag = Settings["Boton4/tag"]
  45.   Endif
  46.  
  47.   If Settings["Boton5/icono"] = "" Then
  48.    
  49.   Else
  50.     ToolButton5.Picture = Picture.Load(Settings["Boton5/icono"])
  51.   Endif
  52.  
  53.   If Settings["Boton5/tag"] = "" Then
  54.     ToolButton5.tag = ""
  55.   Else
  56.     ToolButton5.tag = Settings["Boton5/tag"]
  57.   Endif
  58.  
  59. End
  60.  
  61. Public Sub HPanel1_MouseDown()
  62.   'defino grupo de botones
  63.   'se define en la ventana de propiedades como Group=BarraBotones
  64.  
  65.   ToolButton1.tag = "libreoffice --writer" 'comando al que se va a llamar
  66.   ToolButton2.tag = "evolution"
  67.   ToolButton3.tag = "rhythmbox"
  68.  
  69. End
  70.  
  71. Public Sub Form_Resize()
  72.  
  73.   If Me.w < 42 Then Me.w = 42
  74.   If Me.h < 49 Then Me.h = 49
  75.  
  76.   HPanel1.w = Me.W
  77.   HPanel1.h = Me.h
  78.  
  79. End
  80.  
  81. Public Sub form_Close()
  82.   'guardo los datos de la barra
  83.  
  84.   Settings.Write(Me) 'mejora dada por Shordi: http://www.gambas-es.org/viewtopic.php?f=1&t=3611&highlight=
  85.   'Settings["ventana/ancho"] = Me.w
  86.   ' Settings["ventana/largo"] = Me.h
  87.   'Settings["ventana/x"] = Me.x
  88.   'Settings["ventana/y"] = Me.y
  89.  
  90. End
  91.  
  92. Public Sub BarraBotones_Click()
  93.  
  94.   accionbotones()
  95.  
  96. End
  97.  
  98. Public Sub accionbotones()
  99.  
  100.   Dim lectura As String
  101.  
  102.   If Last.tag <> "" Then
  103.     Shell Last.tag
  104.    
  105.   Endif
  106.  
  107. End
  108.  
  109. Public Sub BarraBotones_Menu()
  110.   'boton izquierdo...
  111.  
  112.   Dim comando As String
  113.  
  114.   If Last = ToolButton4 Or Last = ToolButton5 Then
  115.    
  116.     Message.Info("A continuacion se le pedira el icono de la aplicacion")
  117.    
  118.     Dialog.Filter = ["*.png", "png", "*.jpg", "jpg"]
  119.    
  120.     If Dialog.OpenFile() Then
  121.     Else
  122.       Last.picture = Picture.Load(Dialog.path)
  123.     Endif
  124.    
  125.     comando = InputBox("Comando:")
  126.    
  127.     Last.tag = comando
  128.    
  129.     If Last.name = "ToolButton4" Then
  130.       Settings["Boton4/icono"] = Dialog.path
  131.       Settings["Boton4/tag"] = ToolButton4.Tag
  132.     Else
  133.       Settings["Boton5/icono"] = Dialog.path
  134.       Settings["Boton5/tag"] = ToolButton5.Tag
  135.     Endif
  136.   Endif
  137.  
  138. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement