Commits (48)
app/examples/Misc/SystemTray/.icon.png

3.38 KB | W: | H:

app/examples/Misc/SystemTray/.icon.png

17.2 KB | W: | H:

app/examples/Misc/SystemTray/.icon.png
app/examples/Misc/SystemTray/.icon.png
app/examples/Misc/SystemTray/.icon.png
app/examples/Misc/SystemTray/.icon.png
  • 2-up
  • Swipe
  • Onion skin
# Gambas Project File 3.0
# Compiled with Gambas 3.6.90
Title=SystemTray
Startup=FMain
Icon=icon.png
......@@ -7,9 +6,11 @@ Version=1.0.0
Component=gb.image
Component=gb.gui
Component=gb.form
Component=gb.desktop
Component=gb.desktop.x11
Description="X11 System tray example.\n\nThis example shows how to create a system tray with the gb.desktop.x11 component."
TabSize=2
Translate=1
Language=fr
Vendor=Example
Packager=1
Translate=1
......@@ -10,22 +10,16 @@ End
Public Sub Form_Open()
X11Systray.Show(dwgSystemTray.Handle)
X11Systray.Show(dwgSystemTray.Handle, dwgSystemTray.Background)
End
Static Public Sub X11Systray_Arrange()
FMain.ArrangeTray
End
Public Sub ArrangeTray()
Dim I As Integer
Dim X, Y, H As Integer
Debug
Debug X11Systray.Count
X = 2
Y = 2
For I = 0 To X11Systray.Count - 1
......@@ -44,21 +38,8 @@ Public Sub ArrangeTray()
End
' Public Sub DrawingArea1_Draw()
'
' Paint.DrawImage($hImage, 0, 0)
'
' End
Public Sub dwgSystemTray_Arrange()
Public Sub Form_Resize()
' Dim DH As Integer
'
' Paint.Begin(draSystemTray)
' DH = 1 + draSystemTray.H / $hImage.H
' Paint.DrawImage($hImage, 0, - DH, draSystemTray.W, draSystemTray.H + DH * 2)
' Paint.End
ArrangeTray
X11Systray.Move(0, 0, dwgSystemTray.Width, dwgSystemTray.Height)
End
This diff is collapsed.
......@@ -896,6 +896,7 @@ Private Sub Start(sCmd As String)
Dim sPort As String
Dim iPos As Integer
Dim I As Integer
Dim aProg As String[]
If Project.Running Then Return
......@@ -1067,31 +1068,35 @@ Private Sub Start(sCmd As String)
If Not sProg Or If Project.CheckProgram(sProg) Then
Select Case Desktop.Type
Case Like "KDE*"
sProg = "konsole"
Case "GNOME"
sProg = "gnome-terminal"
Select Case Desktop.Types[0]
Case "KDE", "KDE4", "KDE5"
aProg = ["konsole"]
Case "GNOME", "UNITY", "UBUNTU:GNOME"
aProg = ["gnome-terminal"]
Case "MATE", "CINNAMON"
aProg = ["mate-terminal", "gnome-terminal"]
Case "XFCE"
sProg = "Terminal"
aProg = ["xfce4-terminal", "gnome-terminal"]
Case "LXDE"
sProg = "lxterminal"
Default
sProg = "xterm"
aProg = ["lxterminal"]
Case "CYGWIN"
aProg = ["mintty.exe"]
Case Else
aProg = New String[]
End Select
If Project.CheckProgram(sProg) Then
sProg = "xterm"
If Project.CheckProgram(sProg) Then
FMain.ShowWarning(("No terminal emulator found."))
sProg = ""
Endif
aProg.Add("xterm")
For Each sProg In aProg
If System.Exist(sProg) Then Break
sProg = ""
Next
If Not sProg Then
FMain.ShowErrorWith(("Unable to start project."), ("No terminal emulator found."))
Return
Endif
Endif
......@@ -1107,14 +1112,13 @@ Private Sub Start(sCmd As String)
Select Case sProg
Case "konsole"
' "--caption", sTitle
aExec = ["konsole", "--nofork", "--hold", "--name", Project.Name & "-output", "-e", aExec.Join(" ")]
Case "gnome-terminal"
' gnome terminal cannot hold at end
aExec.Insert(["gnome-terminal", "--hide-menubar", "--maximize", "--title=" & sTitle, "-x"], 0)
Case "Terminal"
Case "Terminal", "xfce4-terminal"
aExec.Insert(["Terminal", "--hide-menubar", "--hide-toolbars", "--title=" & sTitle, "--hold", "-x"], 0)
Case "lxterminal"
......@@ -1169,7 +1173,7 @@ Private Sub Start(sCmd As String)
'PRINT "Debug.Start -> OK"
'Signal
End
' Public Sub Browser_Kill()
......
......@@ -920,7 +920,7 @@ Public Sub OnProjectChange()
$aTask = Null
UpdateTask
SetCompilation
SetCompilation()
CloseSearch
trmVersionControl.Clear
trmTest.Clear
......@@ -939,22 +939,21 @@ Public Sub ShowError(sMsg As String)
End
Public Sub SetCompilation(Optional sOutput As String)
Public Sub SetCompilation(Optional aOutput As String[])
Dim aOutput As String[]
Dim sLine As String
Dim aLine As String[]
Dim I As Integer
Dim aPos As String[]
gvwCompilation.Clear
If Not sOutput Then
If Not aOutput Or If aOutput.Count = 0 Then
HideTab(TAB_COMPILATION)
'GotoConsole
Return
Endif
aOutput = Split(Trim(sOutput), "\n").Sort(gb.Natural)
aOutput.Sort(gb.Natural)
gvwCompilation.Rows.Count = aOutput.Count
For Each sLine In aOutput
......
......@@ -4506,16 +4506,20 @@ Private Sub FindLocation(hResult As CSearchResult)
Dim sText As String
Dim iPos2 As Integer
sText = GetText()
If hResult.OnDisk Then
sText = File.Load(Path)
Else
sText = GetText()
Endif
iPos = RInStr(sText, "\n", hResult.Pos) + 1
iPos = RInStr(sText, "\n", hResult.Pos + 1) + 1
iPos2 = InStr(sText, "\n", iPos + 1)
If iPos2 = 0 Then iPos2 = Len(sText) + 1
sLine = Mid$(sText, iPos, iPos2 - iPos)
hResult.Column = hResult.Pos - iPos + 1
hResult.Column = String.Len(Left$(sLine, hResult.Pos - iPos)) + 1 'hResult.Pos - iPos + 1
hResult.Text = sLine
sLine = Trim(sLine)
......
......@@ -2198,6 +2198,12 @@ Public Sub ShowError(sMsg As String, Optional sKey As String)
End
Public Sub ShowErrorWith(sTitle As String, sMsg As String, Optional sKey As String)
ShowMessage("<b>" & sTitle & "</b>\n\n" & sMsg, "error", sKey)
End
Public Sub ShowWarning(sMsg As String, Optional sKey As String)
ShowMessage(sMsg, "warning", sKey)
......
......@@ -352,7 +352,7 @@ Public Sub Main()
'Print Application.Theme
OUTPUT_FILE = Temp$()
OUTPUT_FILE = Temp$("output")
EXAMPLES_DIR = System.Path &/ "share/gambas" & Split(System.Version, ".")[0] & "/examples"
Application.ShowTooltips = Settings["/ShowTooltip", True]
......@@ -2547,8 +2547,6 @@ End
Public Function Compile(Optional bAll As Boolean, Optional bNoDebug As Boolean, Optional bNoMessage As Boolean, Optional bMakeExecutable As Boolean) As Boolean
Dim sExec As String
Dim sOutput As String
Dim sRes As String
Dim sDir As String
Dim sPath As String
Dim iPos As Integer
......@@ -2556,6 +2554,10 @@ Public Function Compile(Optional bAll As Boolean, Optional bNoDebug As Boolean,
Dim sBefore, sAfter As String
Dim bGotError As Boolean
Dim fTimer As Float
Dim aOutput As String[]
Dim I As Integer
Dim sLine As String
Dim sError As String
If Project.ReadOnly Then Return
If Project.Running Then Return 'TRUE
......@@ -2604,26 +2606,26 @@ Public Function Compile(Optional bAll As Boolean, Optional bNoDebug As Boolean,
bGotError = Process.LastValue
sOutput = Trim(File.Load(OUTPUT_FILE))
iPos = RInStr(sOutput, "\n")
If iPos Then
sRes = Mid$(sOutput, iPos + 1)
sOutput = Left(sOutput, iPos - 1)
Else
If sOutput <> "OK" Then
sRes = sOutput
aOutput = Split(File.Load(OUTPUT_FILE), "\n", "", True)
I = 0
While I < aOutput.Count
sLine = aOutput[I]
If sLine Like "*: warning: *" Then
Inc I
Continue
Endif
sOutput = ""
Endif
FDebugInfo.SetCompilation(sOutput)
If sLine Like "*: error: *" Then sError = sLine
aOutput.Remove(I)
Wend
FDebugInfo.SetCompilation(aOutput)
'FDebugInfo.GotoFirstWarning()
If bGotError And If sRes Then
If bGotError And If sError Then
UnlockIt()
If Not bNoMessage Then CompileError(sRes)
If Not bNoMessage Then CompileError(sError)
Return True
Else
......
......@@ -8,12 +8,13 @@ Public Column As Integer
Public Text As String
Public Bytes As Integer
Public Length As Integer
Public Dark As Boolean
Public Control As String
Public {Property} As String
Public (Highlight) As String
Public RichText As String
Public Location As String
Public Dark As Boolean
Public OnDisk As Boolean
Public Sub InitFromLine(sLine As String) As Boolean
......
......@@ -37,6 +37,7 @@ Private Enum SEARCH_STRING, SEARCH_REPLACE, SEARCH_AFTER_REPLACE, SEARCH_UPDATE
Private $hTask As CSearchTask
Private $sTaskBuffer As String
Private $sTaskPath As String
Private $bTaskOnDisk As Boolean
Private $aResult As New CSearchResult[]
Private $iTaskIndex As Integer
Private $sTaskFullPath As String
......@@ -1426,6 +1427,12 @@ Public Sub timFillList_Timer()
Else
$iTaskIndex = -1
Endif
hFile = Project.Files[$sTaskFullPath]
If hFile And If hFile.IsModified() Then
$bTaskOnDisk = False
Else
$bTaskOnDisk = True
Endif
hFile = Null
Else
......@@ -1436,6 +1443,7 @@ Public Sub timFillList_Timer()
hResult = New CSearchResult
hResult.Path = $sTaskPath
hResult.File = hFile.Name
hResult.OnDisk = $bTaskOnDisk
If hResult.InitFromLine(sLine) Then
Error "gambas3: warning: incorrect search result: "; sLine
......@@ -1507,6 +1515,7 @@ Private Sub Search(iMode As Integer, Optional aPath As String[])
$sTaskBuffer = ""
$sTaskPath = ""
$bTaskOnDisk = False
$iTaskIndex = -1
$bTaskUpdate = iMode = SEARCH_UPDATE
......
......@@ -9,7 +9,7 @@ Component=gb.gui
Component=gb.form
Component=gb.settings
Authors="Benoît Minisini\nDavid Villalobos Cambronero"
Environment="GB_GUI=gb.gtk3"
Environment="GB_GUI=gb.qt5"
TabSize=2
Translate=1
Language=en
......
......@@ -37,9 +37,13 @@ Public Sub Form_Open()
fchChoose.Filter = Dialog.Filter
fchChoose.ShowHidden = Dialog.ShowHidden
If Component.IsLoaded("gb.settings") And If Dialog.Key Then
Settings.Read(Me, "gb.form.dialog" &/ Dialog.Key)
Settings.Read(fchChoose, "/gb.form.dialog" &/ Dialog.Key &/ "fchChoose")
If Component.IsLoaded("gb.settings") Then
If Dialog.Key Then
Settings.Read(Me, "gb.form.dialog" &/ Dialog.Key)
Settings.Read(fchChoose, "/gb.form.dialog" &/ Dialog.Key &/ "fchChoose")
Else
Settings.Read(Me, "gb.form.dialog/FFileDialog")
Endif
Endif
If Dialog.Path Then fchChoose.SelectedPath = Dialog.Path
......@@ -49,8 +53,6 @@ Public Sub Form_Open()
chkAutoExt.Value = AutoExt
Endif
If Component.IsLoaded("gb.settings") Then Settings.Read(Me, "gb.form.dialog/FFileDialog")
fchChoose.SetFocus
End
......@@ -122,9 +124,13 @@ End
Public Sub Form_Close()
If Component.IsLoaded("gb.settings") And If Dialog.Key Then
Settings.Write(Me, "gb.form.dialog" &/ Dialog.Key)
Settings.Write(fchChoose, "/gb.form.dialog" &/ Dialog.Key &/ "fchChoose")
If Component.IsLoaded("gb.settings") Then
If Dialog.Key Then
Settings.Write(Me, "gb.form.dialog" &/ Dialog.Key)
Settings.Write(fchChoose, "/gb.form.dialog" &/ Dialog.Key &/ "fchChoose")
Else
Settings.Write(Me, "gb.form.dialog/FFileDialog")
Endif
Endif
Dialog.Key = ""
......
......@@ -3,7 +3,8 @@
Public Sub Main()
Dialog.SelectFont
Dialog.Key = "test-the-key"
Dialog.OpenFile()
End
......
......@@ -889,8 +889,6 @@ Fast Private Sub DrawHighlightedText(Row As Integer, sText As String, aColor As
If P + iLen >= iNextBreak Then
bBreak = True
iRest = P + iLen - iNextBreak
iLen = iNextBreak - P
......@@ -902,9 +900,11 @@ Fast Private Sub DrawHighlightedText(Row As Integer, sText As String, aColor As
iNextBreak = Len(sText) + 1
Endif
If iLen <= 0 Then Goto NEXT_PATTERN
If iRest Then I -= 2
If iLen = 0 Then Goto NEXT_PATTERN
bBreak = True
Endif
......
......@@ -339,7 +339,7 @@ End
Public Sub ResizeTimer_Timer()
If $hProcess Then $hProcess.Term.Resize($hScreen.Width, $hScreen.Height)
If $hProcess Then Try $hProcess.Term.Resize($hScreen.Width, $hScreen.Height)
$hResizeTimer.Stop
End
......
' Gambas class file
' Gambas class file
Export
Inherits TextBox
Public Const _Properties As String = "*,-Password,-MaxLength,Action,Filter,Mask,ShowDefault"
'Public Const _DefaultEvent As String = "Click"
'Public Const _DefaultSize As String = "24,4"
Public Const _Similar As String = "TextBox"
Public Const _DrawWith As String = "TextBox"
Event Filter(Char As String)
Event Validate
Property Mask As String
Property Filter As String
Property ShowDefault As Boolean
Property Text As String
Private $hObserver As Observer
Private Const MASK_CHARACTER As String = "90A6?"
Private Const MASK_DEFAULT As String = "_0___"
Private Const UNMASKED_CHAR As String = "\r"
Private Const DIGIT_SPACE As String = "\xE2\x80\x87" ' Unicode 2007
Private $sSaveText As String
Private $iSavePos As Integer
Private $iSaveLength As Integer
'Private $bCursorBackward As Boolean
Private $sMaskOrg As String
Private $aMask As New String[]
Private $sDefault As String
Private $sSeparator As String
Private $sAlign As String
Private $iPosFocus As Integer
Private $bShowDefault As Boolean
Private $sFilter As String
Public Sub _new()
End
Private Function Mask_Read() As String
Return $sMaskOrg
End
Private Sub GetDefaultCharacter(iPos As Integer) As String
Dim sCar As String = String.Mid$($sDefault, iPos + 1, 1)
If sCar = "." Then sCar = String.Mid$($sSeparator, iPos + 1, 1)
Return sCar
End
Private Sub MakeDefault() As String
Dim sDefault As String
Dim iPos As Integer
For iPos = 0 To $aMask.Max
sDefault &= GetDefaultCharacter(iPos)
Next
Return sDefault
End
Private Sub GetFirstCharacterPos() As Integer
Dim iPos As Integer
For iPos = 0 To $aMask.Max
If $aMask[iPos] Then Return iPos
Next
End
Private Sub GetLastCharacterPos() As Integer
Dim iPos As Integer
For iPos = $aMask.Max DownTo 0
If $aMask[iPos] Then Return iPos + 1
Next
End
Private Sub UpdateMaskAndSeparator(sMask As String)
Dim iPos, iPos2 As Integer
Dim sCar As String
Dim iLen As Integer
Dim aMask As New String[]
Dim sSeparator As String
Dim sAlign As String
Dim sDefault As String
Dim iPosFocus As Integer
iPosFocus = -1
iLen = String.Len(sMask)
For iPos = 1 To iLen
sCar = String.Mid$(sMask, iPos, 1)
If sCar = "[" Then
iPos2 = String.InStr(sMask, "]", iPos)
If iPos2 = 0 Then Error.Raise("Bad mask")
aMask.Add(String.Mid$(sMask, iPos, iPos2 - iPos + 1))
iPos = iPos2
sSeparator &= " "
sDefault &= " "
Continue
Else If sCar = "<" Then
If aMask.Count And If aMask[aMask.Max] Then
sAlign &= Space$(aMask.Count - 1 - Len(sAlign)) & "<"
Endif
Else If sCar = "!" Then
iPosFocus = aMask.Count
Else If sCar = "?" Then
aMask.Add(sCar)
sSeparator &= " "
sDefault &= " "
' Else If sCar = "0" Then
' aMask.Add("[0-9]")
' sSeparator &= " "
' sDefault &= "0"
Else If sCar = "0" Then
aMask.Add("[0-9]")
sSeparator &= " "
sDefault &= "0"
Else If sCar = "#" Or If sCar = "9" Then
aMask.Add("[0-9]")
sSeparator &= " "
sDefault &= DIGIT_SPACE
Else If sCar = "A" Then
aMask.Add("[A-Za-z]")
sSeparator &= " "
sDefault &= " "
Else If sCar = "\\" And If iPos < iLen Then
aMask.Add("")
Inc iPos
sSeparator &= String.Mid$(sMask, iPos, 1)
sDefault &= "."
Else
aMask.Add("")
sSeparator &= sCar
sDefault &= "."
Endif
Next
$sMaskOrg = sMask
$aMask = aMask
$sSeparator = sSeparator
$sAlign = sAlign
$sDefault = sDefault
$iPosFocus = iPosFocus
'If $sMaskChar Then $sDefault = Replace($sDefault, "_", $sMaskChar)
End
Private Sub Mask_Write(Value As String)
UpdateMaskAndSeparator(Value)
If Not $sMaskOrg Then Return
If Not $hObserver Then $hObserver = New Observer(Me) As "TextBox"
If Not IsValid(Super.Text) Then
Clear()
Endif
Me.Pos = GetFirstCharacterPos()
End
' Private Sub IsMaskCharacter(sCar As String) As Boolean
'
' Return InStr(MASK_CHARACTER, sCar)
'
' End
Private Sub GetPreviousSeparator(iPos As Integer, Optional sSep As String) As Integer
Dim sCar As String
If iPos < 0 Then Return -1
While iPos >= 0
sCar = $aMask[iPos]
If Not sCar Then
If Not sSep Then Break
If sSep = String.Mid$($sSeparator, iPos + 1, 1) Then Break
Endif
Dec iPos
Wend
Return iPos
End
Private Sub GetNextSeparator(iPos As Integer, Optional sSep As String) As Integer
Dim sCar As String
If iPos < 0 Then Return 0
While iPos < $aMask.Count
sCar = $aMask[iPos]
If Not sCar Then
If Not sSep Then Break
If sSep = String.Mid$($sSeparator, iPos + 1, 1) Then Break
Endif
Inc iPos
Wend
Return iPos
End
Private Sub GetNextCharacter(sText As String, iPos As Integer) As Integer
Dim iLen As Integer = String.Len(sText)
If iPos < 0 Then Return 0
While iPos < iLen
If $aMask[iPos] Then Break
Inc iPos
Wend
Return iPos
End
Private Sub IsRightAlign(iPos As Integer) As Boolean
iPos = GetNextSeparator(iPos)
If iPos = 0 Then Return
Return Mid$($sAlign, iPos, 1) = "<"
End
Private Sub UnmaskText(sText As String) As String
Dim iPos As Integer
Dim sResult As String
Dim sCar As String
For iPos = 1 To String.Len(sText)
sCar = String.Mid$(sText, iPos, 1)
If $aMask[iPos - 1] And If sCar = GetDefaultCharacter(iPos - 1) Then sCar = UNMASKED_CHAR
sResult &= sCar
Next
Return sResult
End
Private Sub MaskText(sText As String) As String
Dim iPos As Integer
Dim sResult As String
Dim sCar As String
Dim sMask As String
Dim bNumber As Boolean
Dim sDefault As String
For iPos = 1 To String.Len(sText)
sCar = String.Mid$(sText, iPos, 1)
sDefault = GetDefaultCharacter(iPos - 1)
sMask = $aMask[iPos - 1]
If sMask = "[0-9]" Then
If sCar = "0" And If sDefault <> "0" And If Not bNumber Then
sCar = UNMASKED_CHAR
Else If IsDigit(sCar) Then
bNumber = True
Else If sCar = UNMASKED_CHAR And If bNumber And If IsRightAlign(iPos) Then
sCar = "0"
Endif
Else
bNumber = False
Endif
If sCar = UNMASKED_CHAR Then sCar = sDefault
sResult &= sCar
Next
Return sResult
End
Private Sub GotoCursor(iPos As Integer) As Boolean
Dim sText As String = Super.Text
Dim sCar As String
If iPos < 0 Then Return
If IsRightAlign(iPos) Then
While iPos < Me.Length
sCar = String.Mid$(sText, iPos + 1, 1)
If sCar <> " " And If sCar <> "0" Then
Break
Endif
Inc iPos
Wend
Endif
If Me.Pos <> iPos Then
Me.Pos = iPos
Return True
Endif
End
Public Sub TextBox_KeyPress()
Dim sText, sTextOrg As String
Dim iPos, iPosPrev, iPosNext As Integer
Dim sCar As String
Dim sInsert As String
Dim bDelete As Boolean
Dim bBefore As Boolean
Dim bChange As Boolean
If Not $sMaskOrg Then Return
If Me.ReadOnly Then Return
sText = UnmaskText(Super.Text)
sTextOrg = sText
If Me.Selected Then
iPos = GetNextCharacter(sText, Me.Selection.Start)
Else
iPos = Me.Pos
Endif
Select Key.Code
Case Key.Left, Key.Right, Key.Home, Key.End
Return
' Case Key.Right
'
' Case Key.Home
' iPos = GetFirstCharacterPos()
'
' Case Key.End
' iPos = GetLastCharacterPos()
Case Key.Delete
If iPos < Me.Length
bDelete = True
bBefore = IsRightAlign(iPos + 1)
Endif
Case Key.BackSpace
If iPos > 0 Then
bDelete = True
bBefore = IsRightAlign(iPos)
Dec iPos
Endif
Case Key.Tab, Key.BackTab, Key.Up, Key.Down, Key.Enter, Key.Return, Key.ControlKey, Key.AltKey, Key.ShiftKey, Key.AltGrKey
Return
Case Else
If Key.Control Then Return
If Key.Text Then
bBefore = IsRightAlign(iPos)
If bBefore Then
If iPos > 0 Then
sCar = $aMask[iPos - 1]
Else
sCar = ""
Endif
If sCar And If Key.Text Like sCar Then
sInsert = Key.Text
Endif
Else If iPos < $aMask.Count Then
sCar = $aMask[iPos]
If sCar And If Key.Text Like sCar Then
sInsert = Key.Text
Endif
Endif
If Not sInsert Then
iPosNext = GetNextSeparator(iPos, Key.Text)
While iPosNext < Me.Length
If iPosNext < $aMask.Max And If $aMask[iPosNext + 1] Then Break
Inc iPosNext
Wend
If iPosNext >= Me.Length Then Goto DO_NOTHING
iPos = iPosNext + 1
Endif
Endif
End Select
If sInsert Or If Key.Code = Key.Delete Or If Key.Code = Key.BackSpace Then
If Me.Selected Then
If Me.Selection.Length = Me.Length Then sText = MakeDefault()
'sText = String.Left$(sText, Me.Selection.Start) & String.Mid$(sDefault, Me.Selection.Start + 1, Me.Selection.Length) & String.Mid$(sText, Me.Selection.Start + Me.Selection.Length + 1)
iPos = GetNextCharacter(sText, Me.Selection.Start)
Me.Selection.Hide
Endif
Endif
If sInsert Then
If Not bBefore Then
sText = String.Left(sText, iPos) & sInsert & String.Mid$(sText, iPos + 2)
iPos += String.Len(sInsert)
Else
iPosNext = iPos
While iPos > 0
If Not $aMask[iPos - 1] Then Break
Dec iPos
Wend
If String.Mid$(sText, iPos + 1, 1) = UNMASKED_CHAR Then
sText = String.Left(sText, iPos) & String.Mid$(sText, iPos + 2, iPosNext - iPos - 1) & sInsert & String.Mid$(sText, iPosNext + 1)
Endif
iPos = iPosNext
Endif
Endif
If bDelete Then
iPosNext = GetNextSeparator(iPos)
If iPosNext > iPos Then
If bBefore Then
iPosPrev = GetPreviousSeparator(iPos)
sText = String.Left(sText, iPosPrev + 1) & UNMASKED_CHAR & String.Mid$(sText, iPosPrev + 2, iPos - iPosPrev - 1) & String.Mid$(sText, iPos + 2)
Inc iPos
Else
sText = String.Left(sText, iPos) & String.Mid$(sText, iPos + 2, iPosNext - iPos - 1) & UNMASKED_CHAR & String.Mid$(sText, iPosNext + 1)
Endif
Endif
Endif
Object.Lock(Me)
If sText <> sTextOrg Then
sText = MaskText(sText)
If Super.Text <> sText Then
Super.Text = sText
bChange = True
Endif
If IsRightAlign(iPos) Then
While iPos < Me.Length
If String.Mid$(sText, iPos + 1, 1) <> " " Then Break
Inc iPos
Wend
Endif
Endif
Object.Unlock(Me)
Me.Pos = iPos
If bChange Then Raise Change
'Me.Select(iPos, 1)
DO_NOTHING:
Stop Event
End
' Private Function MaskChar_Read() As String
'
' Return $sMaskChar
'
' End
'
' Private Sub MaskChar_Write(Value As String)
'
' Dim sText As String
' Dim iPos As Integer
' Dim sCar As String
' Dim aPos As New Integer[]
'
' Value = String.Left(Value)
' sText = Super.Text
'
' For iPos = 0 To $aMask.Max
' sCar = $aMask[iPos]
' If Not sCar Or If String.Mid$($sDefault, iPos + 1, 1) <> "_" Then Continue
' If String.Mid$(sText, iPos + 1, 1) = GetDefaultCharacter(iPos) Then aPos.Add(iPos)
' Next
'
' $sMaskChar = Value
' UpdateMaskAndSeparator($sMaskOrg)
'
' For Each iPos In aPos
' sText = String.Left(sText, iPos) & GetDefaultCharacter(iPos) & String.Mid$(sText, iPos + 2)
' Next
'
' Super.Text = RTrim(sText)
' Me.Pos = GetFirstCharacterPos()
'
' End
Public Sub TextBox_GotFocus()
If Not $sMaskOrg Then Return
TextBox_Change
If $iPosFocus > 0 Then Me.Pos = $iPosFocus
End
Public Sub TextBox_LostFocus()
If Not $sMaskOrg Then Return
TextBox_Change
GotoCursor($iPosFocus)
End
Private Sub RestorePosition()
Me.Pos = $iSavePos
If $iSaveLength Then Me.Select($iSavePos, $iSaveLength)
End
Public Sub TextBox_Cursor()
Dim iPos As Integer
Dim sDefault As String
Dim sText As String
Dim sLeft As String
Dim sRight As String
Dim bValid As Boolean
iPos = Me.Pos
sDefault = MakeDefault()
sText = Super.Text
Do
If iPos > 0 Then
sLeft = String.Mid$(sText, iPos, 1)
Else
sLeft = ""
If Not IsRightAlign(iPos) Then sLeft = "^"
Endif
If iPos < String.Len(sText) Then
sRight = String.Mid$(sText, iPos + 1, 1)
Else
sRight = ""
If IsRightAlign(iPos) Then sRight = "$"
Endif
bValid = True
If Not sLeft Or If sLeft = " " Or If sLeft = DIGIT_SPACE Then
If Not sRight Or If sRight = " " Or If sRight = DIGIT_SPACE Then
bValid = False
Endif
Endif
If bValid And If iPos > 0 And If iPos < String.Len(sText) Then
If String.Mid$($sSeparator, iPos, 1) <> " " And If String.Mid$($sSeparator, iPos + 1, 1) <> " " Then
bValid = False
Endif
Endif
If bValid Then Break
If iPos = $iSavePos Then Goto CANCEL_MOVE
If IsRightAlign(iPos) Then
Inc iPos
Else
Dec iPos
Endif
If iPos < 0 Or If iPos > String.Len(sText) Then Goto CANCEL_MOVE
Loop
$iSavePos = iPos
$iSaveLength = Me.Selection.Length
Me.Pos = iPos
Return
CANCEL_MOVE:
Object.Lock(Me)
RestorePosition
Object.Unlock(Me)
End
' Public Sub TextBox_Menu()
'
' If Not $sMaskOrg Then Return
' Stop Event
'
' End
Public Sub TextBox_Change()
' Dim I As Integer
' Dim sText As String
' Dim sCar As String
' Dim sNewText As String
' Dim iPos As Integer
' Dim iDec As Integer
'Dim bCanRaise As Boolean
Dim bStop As Boolean
' bCanRaise = Object.CanRaise(Me, "Filter")
'
' If $sFilter Or If bCanRaise Then
'
' sText = Super.Text
' iPos = Me.Pos
' For I = 1 To String.Len(sText)
' sCar = String.Mid$(sText, I, 1)
' If $sFilter And If sCar Like $sFilter Then
' sNewText &= sCar
' Continue
' Endif
' If bCanRaise Then
' bStop = Raise Filter(sCar)
' If Not bStop Then
' sNewText &= sCar
' Continue
' Endif
' Endif
'
' If I <= iPos Then Inc iDec
'
' Next
'
' If sNewText <> sText Then
' Object.Lock(Me)
' Super.Text = sNewText
' Me.Pos = iPos - iDec
' Object.Unlock(Me)
' Endif
'
' Endif
If Not IsValid(Super.Text) Then
bStop = True
Else 'If Object.CanRaise(Me, "Validate") Then
bStop = Raise Validate
Endif
If bStop Then
Object.Lock(Me)
Super.Text = $sSaveText
Me.Select($iSavePos, $iSaveLength)
Object.Unlock(Me)
Else
$sSaveText = Super.Text
$iSavePos = Me.Pos
$iSaveLength = Me.Selection.Length
Endif
If $sMaskOrg Then
Object.Lock(Me)
If Me.HasFocus Or If $bShowDefault Then
If Super.Text = "" Then Super.Text = MakeDefault()
Else
If Super.Text = MakeDefault() Then Super.Text = ""
Endif
RestorePosition
Object.Unlock(Me)
Endif
TextBox_Cursor()
End
Private Function ShowDefault_Read() As Boolean
Return $bShowDefault
End
Private Sub ShowDefault_Write(Value As Boolean)
$bShowDefault = Value
TextBox_Change
End
Private Sub IsValid(sText As String) As Boolean
Dim I As Integer
Dim sMask As String
Dim sCar As String
Dim bStop As Boolean
Dim bCanRaise As Boolean
bCanRaise = Object.CanRaise(Me, "Filter")
If $sFilter Or If bCanRaise Then
For I = 1 To String.Len(sText)
sCar = String.Mid$(sText, I, 1)
If $sFilter And If sCar Like $sFilter Then Continue
If bCanRaise Then
bStop = Raise Filter(sCar)
If Not bStop Then Continue
Endif
Return False
Next
Endif
If $sMaskOrg Then
If String.Len(sText) > $aMask.Count Then Return False
For I = 1 To String.Len(sText)
sCar = String.Mid$(sText, I, 1)
sMask = $aMask[I - 1]
If sMask Then
If sCar <> String.Mid$($sDefault, I, 1) Then
If sCar Not Like sMask Then Return False
Endif
Else
If sCar <> String.Mid$($sSeparator, I, 1) Then Return False
Endif
Next
Endif
Return True
End
Public Sub Clear()
If Me.HasFocus Then
Super.Text = MakeDefault()
Else
Super.Text = ""
Endif
End
Private Function Filter_Read() As String
Return $sFilter
End
' Private Sub MakeFilter()
'
' Dim aFilter As New String[]
' Dim sFilter As String
' Dim iPos As Integer
'
' sFilter = $sFilterOrg
' $sFilter = ""
'
' While sFilter
'
' If Left(sFilter) = "[" Then
' iPos = InStr(sFilter, "]")
' If iPos Then
' aFilter.Add(Mid$(sFilter, 2, iPos - 2))
' sFilter = Mid$(sFilter, iPos + 1)
' Continue
' Endif
' Endif
'
' $sFilter &= String.Left(sFilter)
' sFilter = String.Mid$(sFilter, 2)
'
' Wend
'
' $sFilterLike = "[" & aFilter.Join("") & "]"
'
' End
Private Sub Filter_Write(Value As String)
$sFilter = Value
If Not IsValid(Super.Text) Then
Clear()
Endif
End
Private Function Text_Read() As String
Return Trim(Replace(Super.Text, String.Chr(&H2007), " "))
End
Private Sub Text_Write(Value As String)
Super.Text = Value
End
# Gambas Project File 3.0
Title=More controls for graphical components
Startup=FTestColorChooser
Startup=FTestValueBox
Icon=.hidden/icon.png
Version=3.16.90
VersionFile=1
......@@ -10,7 +10,7 @@ Component=gb.form
Component=gb.settings
Component=gb.form.stock
Authors="Benoît Minisini"
Environment="GB_GUI=gb.gtk3\n GB_STOCK_DEBUG=1\n LANG=zh_CN.UTF-8\n LC_ALL=en_US.UTF-8\n LC_ALL=zh_CN.UTF-8\n GTK_DEBUG=interactive"
Environment="GB_GUI=gb.qt5\n GB_STOCK_DEBUG=1\n LANG=zh_CN.UTF-8\n LC_ALL=en_US.UTF-8\n LC_ALL=zh_CN.UTF-8\n GTK_DEBUG=interactive"
TabSize=2
Translate=1
Language=en
......
......@@ -141,16 +141,22 @@ End
Public Sub Background_Draw()
'Dim FW, FH As Integer
Dim iBg As Integer = Color.Default
If Me.Background <> Color.Default Then iBg = Me.Background
If $bBorder Then
Style.PaintBox(0, 0, Me.W, Me.H, Style.StateOf($hTextBox), iBg)
Dim iCol As Integer
Dim iState As Integer
iCol = Style.BackgroundOf($hTextBox)
If $bBorder Then
iState = Style.StateOf($hBackground)
If $hTextBox.HasFocus Then iState = iState Or Style.HasFocus
If $hBackground.Hovered Then iState = iState Or Style.Hovered
Style.PaintBox(0, 0, Paint.W, Paint.H, iState, iCol)
Else
If iBg = Color.Default Then iBg = Color.TextBackground
Paint.FillRect(0, 0, Me.W, Me.H, iBg)
Paint.FillRect(0, 0, Paint.W, Paint.H, iCol)
Endif
End
......@@ -219,8 +225,10 @@ Public Sub Background_Arrange()
Dim aCtrl As New Control[]
Dim X, H As Integer
FW = If($bBorder, Style.FrameWidth, 0)
FH = If($bBorder, Style.FrameWidth, 0)
If $bBorder Then
FW = Style.BoxFrameWidth
FH = Min(3, Style.BoxFrameHeight)
Endif
For Each hCtrl In $hBackground.Children
If hCtrl Is ToolButton And If hCtrl.Visible Then aCtrl.Add(hCtrl)
......
......@@ -88,25 +88,32 @@ Private Sub Text_Write(Value As String)
$iShortcutPos = 0
Do
iPos = String.InStr($sText, "&", iPos + 1)
If iPos = 0 Then Break
If String.Mid$($sText, iPos + 1, 1) = "&" Then
Inc iPos
Continue
Endif
If Not $hButton Then
$hButton = New Button(Me) As "Button"
$hButton.Ignore = True
$hButton.Border = False
$hButton.AutoResize = True
'S = Desktop.Scale * 3
$hButton.Move(0, 0, 1, 1)
$hButton.Lower()
Endif
$hButton.Text = String.Mid$($sText, iPos, 2)
$hButton.Enabled = Not Me.Design
$iShortcutPos = iPos
$sActualText = String.Left($sText, iPos - 1) & String.Mid($sText, iPos + 1)
$hButton.Y = -$hButton.H
Break
Loop
$sActualText = Replace($sActualText, "&&", "&")
......@@ -318,6 +325,7 @@ End
Public Sub DrawingArea_GotFocus()
If $hButton And If Not Me.Design Then $hButton.Enabled = False
_SetLastFocus
$hDrawingArea.Refresh
......@@ -325,6 +333,7 @@ End
Public Sub DrawingArea_LostFocus()
If $hButton And If Not Me.Design Then $hButton.Enabled = True
$hDrawingArea.Refresh
End
......