9de02c9cac
* BUG: The informer algorithm was redesigned. Now a sub-process is launched for each component that should be analyzed, and LD_PRELOAD is used to load the component shared library before the process is launched. Otherwise, some component may crash. [GB.DRAW] * BUG: Correctly initialize color properties of the Draw class at Draw.Begin(). * NEW: Draw.FillRect() is a new method to draw a filled rectangle with the specified color. * NEW: Draw.Clear() is a new method that clears the drawing device with its background color. [GB.FORM.MDI] * NEW: Do not use BackColor and ForeColor properties anymore. [GB.GTK] * NEW: Control.Backcolor and Control.Forecolor properties were removed. * BUG: Desktop.Resolution now uses the accurate GTK+ API. * BUG: Setting the ListBox.List to NULL property does not lock the ListBox control anymore. * BUG: Fix the Font object management. Using Font properties should not crash anymore. * BUG: Image.Save() and Picture.Save() now understand the "~" shortcut in path names. [GB.QT] * NEW: Control.Backcolor and Control.Forecolor properties were removed. * NEW: Do not check if we should quit too often. * NEW: Allow windows to be closed during a WAIT instruction as in other components. I do not know why it was forbidden before. * NEW: Prevent a crash in arrangement routines if a child widget is not associated with a Gambas control anymore. [GB.QT4] * NEW: Control.Backcolor and Control.Forecolor properties were removed. * NEW: The source code is now up to date with gb.qt. But many things do not work as expected! [GB.QT4.EXT] * NEW: The source code is now up to date with gb.qt.ext. But many things do not work as expected! git-svn-id: svn://localhost/gambas/trunk@1776 867c0c6c-44f3-4631-809d-bfa615b0a4ec
180 lines
3 KiB
Text
180 lines
3 KiB
Text
' Gambas class file
|
|
|
|
Property Enabled As Boolean
|
|
Property ToolTip As String
|
|
Property Foreground As Integer
|
|
|
|
Public Tag As String
|
|
|
|
Private $hPanel As Panel
|
|
Private $hImage As PictureBox
|
|
Private $hLabel As Label
|
|
Private $iColor As Integer
|
|
|
|
Event Click()
|
|
|
|
|
|
Public Sub _new(hContainer As Container, X As Integer, Y As Integer, W As Integer, H As Integer, sText As String, vIcon As Variant, Optional sFont As String)
|
|
|
|
Dim hPict As Picture
|
|
|
|
$hPanel = New Panel(hContainer) As "Panel"
|
|
$hPanel.Move(X, Y, W, H)
|
|
$hPanel.Mouse = Mouse.Pointing
|
|
$hPanel.Arrangement = Arrange.Horizontal
|
|
$hPanel.Padding = 2
|
|
$hPanel.Spacing = 8
|
|
|
|
If TypeOf(vIcon) = gb.String Then
|
|
hPict = Picture[vIcon]
|
|
Else
|
|
hPict = vIcon
|
|
Endif
|
|
|
|
$hImage = New PictureBox($hPanel) As "Panel"
|
|
If hPict Then
|
|
$hImage.Resize(hPict.Width + 4, H - 8)
|
|
$hImage.Alignment = Align.Right
|
|
$hImage.Picture = hPict
|
|
Else
|
|
$hImage.Resize(32, H - 8)
|
|
Endif
|
|
|
|
$hLabel = New Label($hPanel) As "Panel"
|
|
'$hLabel.AutoResize = FALSE
|
|
$hLabel.Expand = True
|
|
If sFont Then $hLabel.Font = Font[sFont]
|
|
$hLabel.Text = sText
|
|
|
|
End
|
|
|
|
Public Sub Panel_Enter()
|
|
|
|
If Object.Type(Last) <> "Panel" Then Return
|
|
$iColor = Last.Foreground
|
|
Last.Background = Color.SelectedBackground '&88D5FF&
|
|
Last.Foreground = Color.SelectedForeground '&88D5FF&
|
|
|
|
End
|
|
|
|
Public Sub Panel_Leave()
|
|
|
|
If Object.Type(Last) <> "Panel" Then Return
|
|
Last.Background = Last.Parent.Background
|
|
Last.Foreground = $iColor
|
|
|
|
End
|
|
|
|
Private Function GetPanel() As Panel
|
|
|
|
Dim hPanel As Panel
|
|
|
|
Try hPanel = Last
|
|
If Error Then
|
|
hPanel = Last.Parent
|
|
Endif
|
|
|
|
Return hPanel
|
|
|
|
End
|
|
|
|
|
|
Public Sub Panel_MouseDown()
|
|
|
|
With GetPanel()
|
|
.Border = Border.Sunken
|
|
End With
|
|
|
|
'$hLabel.Move($hLabel.X + 1, $hLabel.Y + 1)
|
|
'$hImage.Move($hImage.X + 1, $hImage.Y + 1)
|
|
|
|
End
|
|
|
|
|
|
Public Sub Panel_MouseUp()
|
|
|
|
Dim hPanel As Panel
|
|
Dim X As Integer
|
|
Dim Y As Integer
|
|
|
|
hPanel = GetPanel()
|
|
hPanel.Border = Border.None
|
|
|
|
X = Mouse.X
|
|
Y = Mouse.Y
|
|
|
|
If Last <> hPanel Then
|
|
X = X + Last.X
|
|
Y = Y + Last.Y
|
|
Endif
|
|
|
|
'$hLabel.Move($hLabel.X - 1, $hLabel.Y - 1)
|
|
'$hImage.Move($hImage.X - 1, $hImage.Y - 1)
|
|
|
|
|
|
If (X >= 0 AND Y >= 0 AND X < hPanel.W AND Y < hPanel.H) Then
|
|
|
|
Raise Click()
|
|
|
|
Else
|
|
|
|
'PRINT "Pas Click !"; X; " "; Y; " "; hPanel.W; " "; hPanel.H
|
|
|
|
Endif
|
|
|
|
End
|
|
|
|
|
|
Private Function Enabled_Read() As Boolean
|
|
|
|
Return $hPanel.Enabled
|
|
|
|
End
|
|
|
|
Private Sub Enabled_Write(bEnabled As Boolean)
|
|
|
|
$hPanel.Enabled = bEnabled
|
|
|
|
End
|
|
|
|
|
|
Public Sub Move(X As Integer, Y As Integer)
|
|
|
|
$hPanel.Move(X, Y)
|
|
|
|
End
|
|
|
|
|
|
Public Sub Resize(W As Integer, H As Integer)
|
|
|
|
$hPanel.Resize(W, H)
|
|
'$hLabel.Resize(W - ($hImage.X + $hImage.W + 8) - 8, H - 8)
|
|
|
|
End
|
|
|
|
Private Function ToolTip_Read() As String
|
|
|
|
Return $hPanel.ToolTip
|
|
|
|
End
|
|
|
|
Private Sub ToolTip_Write(sToolTip As String)
|
|
|
|
$hPanel.ToolTip = sToolTip
|
|
'$hImage.ToolTip = sToolTip
|
|
'$hLabel.ToolTip = sToolTip
|
|
|
|
End
|
|
|
|
|
|
Private Function Foreground_Read() As Integer
|
|
|
|
Return $hPanel.Foreground
|
|
|
|
End
|
|
|
|
Private Sub Foreground_Write(Value As Integer)
|
|
|
|
$hPanel.Foreground = Value
|
|
|
|
End
|