' Gambas class file Static Private $hHandleH As Picture Static Private $hHandleV As Picture Private $iOrientation As Integer Private $bFixed As Boolean Private $W As Integer Private $H As Integer Private $bVisible As Boolean Private $MX As Integer Private $MY As Integer Private $iMax As Integer Private $iColor As Integer Private $bOpened As Boolean Private BUTTON_H As Integer = Desktop.Scale Private BUTTON_W As Integer = 48 Static Public Sub _init() $hHandleH = Picture["img/handle-h.png"] $hHandleV = Picture["img/handle-v.png"] End Public Sub _new() $bVisible = True $iOrientation = Align.Top End Public Sub Form_Open() $bOpened = True RefreshAll End Private Sub GetLangOrientation(iOrientation As Integer) As Integer If System.RightToLeft Then If iOrientation = Align.Left Then Return Align.Right Else If iOrientation = Align.Right Then Return Align.Left Endif Endif Return iOrientation End Public Function GetOrientation() As Integer Return GetLangOrientation($iOrientation) End Public Sub SetOrientation(iOrientation As Integer) Select Case iOrientation Case Align.Top, Align.Bottom Case Align.Left, Align.Right Case Else Return End Select $iOrientation = GetLangOrientation(iOrientation) RefreshArrow RefreshPanel End Private Sub RefreshPanel() Dim W As Integer Dim W2 As Integer Dim Y As Integer Dim D As Integer 'IF NOT $bVisible THEN panSide.Hide If Not $bOpened Then Return Select Case $iOrientation Case Align.Top, Align.Bottom D = Me.ClientW Case Else D = Me.ClientH End Select 'D = Max(0, D - 8) If D < (BUTTON_W * 2 + 16) Then W = Min(BUTTON_W, D - 16) W2 = 0 Else W = Min(BUTTON_W, D / 2) W2 = Min(BUTTON_W, D - W) Endif Select Case $iOrientation Case Align.Bottom, Align.Right Y = 0 Case Align.Top Y = Me.ClientH - BUTTON_H Case Align.Left Y = Me.ClientW - BUTTON_H End Select Select Case $iOrientation Case Align.Top, Align.Bottom panMove.Move(0, Y, Me.ClientW, BUTTON_H) If W2 Then btnSide.Move(0, 0, W, BUTTON_H) btnSide2.Move(Me.ClientW - W2, 0, W2, BUTTON_H) btnSide2.Show Else btnSide.Move(0, 0, W, BUTTON_H) 'btnSide.Move((D - W) / 2, Y, W, BUTTON_H) btnSide2.Hide Endif ' W2 = ME.ClientW - W - W2 ' IF W2 > 0 THEN ' panMove.Move(W, Y, W2, BUTTON_H) ' panMove.Show ' ELSE ' panMove.Hide ' ENDIF Case Else panMove.Move(Y, 0, BUTTON_H, Me.ClientH) If W2 Then btnSide.Move(0, 0, BUTTON_H, W) btnSide2.Move(0, Me.ClientH - W2, BUTTON_H, W2) btnSide2.Show Else btnSide.Move(0, 0, BUTTON_H, W) 'btnSide.Move(Y, (D - W) / 2, BUTTON_H, W) btnSide2.Hide Endif ' W2 = ME.ClientH - W - W2 ' IF W2 > 0 THEN ' panMove.Move(Y, W, BUTTON_H, W2) ' panMove.Show ' ELSE ' panMove.Hide ' ENDIF End Select Select Case $iOrientation Case Align.Top panSide.Move(0, 0, Me.ClientW, Me.ClientH - BUTTON_H) Case Align.Bottom panSide.Move(0, BUTTON_H, Me.ClientW, Me.ClientH - BUTTON_H) Case Align.Left panSide.Move(0, 0, Me.ClientW - BUTTON_H, Me.ClientH) Case Align.Right panSide.Move(BUTTON_H, 0, Me.ClientW - BUTTON_H, Me.ClientH) End Select 'IF $bVisible THEN panSide.Show 'DEBUG $bVisible;; "(";; ME.X;; ME.Y;; ME.W;; ME.H;; ") (";; btnSide.X;; btnSide.Y;; btnSide.W;; btnSide.H;; btnSide.Visible;; ") (";; panSide.X;; panSide.Y;; panSide.W;; panSide.H;; panSide.Visible;; ")" 'STOP End Public Function GetContainer() As Panel Return panSide End Private Sub GetParent() As SidePanel Return Me.Parent End Public Sub Form_Resize() 'DEBUG ME.X;; ME.Y;; ME.W;; ME.H RefreshPanel GetParent()._Resize End Private Sub RefreshArrow() Dim hPict As Picture Dim hImage As Image Dim sKey As String Dim iType As Integer If Not $bOpened Then Return Select Case $iOrientation Case Align.Top, Align.Bottom If $bVisible Xor ($iOrientation = Align.Bottom) Then sKey = "$side-top" iType = Align.Top 'hPict = Picture["img/8/side-top.png"] Else sKey = "$side-bottom" iType = Align.Bottom 'hPict = Picture["img/8/side-bottom.png"] Endif Case Align.Left, Align.Right If $bVisible Xor ($iOrientation = Align.Right) Then sKey = "$side-left" iType = Align.Left 'hPict = Picture["img/8/side-left.png"] Else sKey = "$align-right" iType = Align.Right 'hPict = Picture["img/8/side-right.png"] Endif End Select hPict = Picture[sKey] If Not hPict Then hPict = New Picture(12, 12) hPict.Fill(Color.White) Draw.Begin(hPict) Draw.Style.Arrow(0, 0, 12, 12, iType) Draw.End hImage = hPict.Image.Stretch(8, 8, True) hImage.MakeTransparent(Color.White) hPict = hImage.Picture Picture[sKey] = hPict Endif btnSide.Picture = hPict btnSide2.Picture = hPict If $bVisible And Not $bFixed And Not Me.Parent.Design Then panMove.Mouse = If(IsVertical(), Mouse.SplitV, Mouse.SplitH) Else panMove.Mouse = Mouse.Default Endif End Private Sub RefreshAll() If Not $bOpened Then Return If $bVisible Then panSide.Show 'Enabled = TRUE If $W And If $H Then Me.Parent.Resize($W, $H) Else 'DEBUG ME.Parent.W;; ME.CLientW panSide.Hide 'Enabled = FALSE Select Case $iOrientation Case Align.Top, Align.Bottom Me.Parent.H = BUTTON_H Case Else Me.Parent.W = BUTTON_H End Select Endif RefreshArrow RefreshPanel End Public Sub btnSide_Click() If Me.Parent.Design Then Return If $bVisible Then GetParent()._Hide $W = Me.Parent.Width $H = Me.Parent.Height $bVisible = False RefreshAll Action.Raise(Me.Parent) Else $bVisible = True RefreshAll Action.Raise(Me.Parent) GetParent()._Show Endif End Private Function IsVertical() As Boolean Return $iOrientation = Align.Top Or $iOrientation = Align.Bottom End Public Sub panMove_MouseDown() If Not $bVisible Then Return If Me.Parent.Design Then Return If $bFixed Then Return $MX = Mouse.ScreenX - Me.Parent.W Select Case $iOrientation Case Align.Top $MY = Mouse.ScreenY - Me.Parent.H $iMax = Me.Parent.Parent.ClientH - Me.Parent.Y Case Align.Bottom $MY = Mouse.ScreenY + Me.H $iMax = Me.Parent.Y + Me.Parent.H Case Align.Left $MX = Mouse.ScreenX - Me.Parent.W $iMax = Me.Parent.Parent.ClientW - Me.Parent.X Case Align.Right $MX = Mouse.ScreenX + Me.W $iMax = Me.Parent.X + Me.Parent.W End Select End Private Function GetDim(H As Integer) As Integer Dim iMin As Integer iMin = Min($iMax, Max(BUTTON_H, 64)) If H < BUTTON_H Then H = BUTTON_H Else If H < iMin Then H = iMin Endif Return H End Public Sub panMove_MouseMove() Dim H As Integer If Not Mouse.Left Then Return If Not $bVisible Then Return If Me.Parent.Design Then Return If $bFixed Then Return Select Case $iOrientation Case Align.Top Me.Parent.H = GetDim(Min($iMax, Mouse.ScreenY - $MY)) Case Align.Bottom H = GetDim(Min($iMax, $MY - Mouse.ScreenY)) 'H = Max(iMin, Min($iMax, $MY - Mouse.ScreenY)) Me.Parent.Move(Me.Parent.X, $iMax - H, Me.Parent.W, H) Case Align.Left Me.Parent.W = GetDim(Min($iMax, Mouse.ScreenX - $MX)) Case Align.Right H = GetDim(Min($iMax, $MX - Mouse.ScreenX)) Me.Parent.Move($iMax - H, Me.Parent.Y, H, Me.Parent.H) End Select RefreshPanel End Public Function IsHidden() As Boolean Return Not $bVisible End Public Sub SetHidden(bHidden As Boolean) If bHidden = $bVisible Then btnSide_Click End Public Function GetDimension() As Integer If IsVertical() Then If Not $bVisible Then Return $H Else Return Me.Parent.Height Endif Else If Not $bVisible Then Return $W Else Return Me.Parent.Width Endif Endif End Public Sub SetDimension(iDim As Integer) If IsVertical() Then If Not $bVisible Then $H = iDim Else Me.Parent.Height = iDim Endif Else If Not $bVisible Then $W = iDim Else Me.Parent.Width = iDim Endif Endif End Public Function IsFixed() As Boolean Return $bFixed End Public Sub SetFixed(bFixed As Boolean) $bFixed = bFixed RefreshArrow End Public Sub panMove_DblClick() If $bVisible Then btnSide_Click End Public Function GetTooltip() As String Return btnSide.ToolTip End Public Sub SetTooltip(Value As String) btnSide.ToolTip = Value btnSide2.ToolTip = Value panMove.ToolTip = Value End Public Sub SetDesign() RefreshArrow RefreshPanel End ' PUBLIC SUB panMove_Draw() ' ' IF IsVertical() THEN ' Draw.FillX = 0 ' Draw.FillY = panMove.H / 2 - 2 ' Draw.Tile($hHandleH, panMove.W * 0.1, panMove.H / 2 - 3, panMove.W * 0.8, 4) ' ELSE ' Draw.FillX = panMove.W / 2 - 2 ' Draw.FillY = 0 ' Draw.Tile($hHandleV, panMove.W / 2 - 3, panMove.H * 0.1, 4, panMove.H * 0.8) ' ENDIF ' ' END Public Sub panMove_Enter() $iColor = panMove.Background If Not $bVisible Then Return If $bFixed Then Return If Me.Parent.Design Then Return panMove.Background = Color.TextBackground 'btnSide.Background = Color.ButtonBackground 'btnSide2.Background = Color.ButtonBackground End Public Sub panMove_Leave() panMove.Background = $iColor 'btnSide.Background = $iColor 'btnSide2.Background = $iColor End