[WIKI CGI SCRIPT]
* BUG: Handle public variables like properties. [EXAMPLES] * NEW: A new PhotoTouch example I made so that my father can edit its photo with a simple software. git-svn-id: svn://localhost/gambas/trunk@4665 867c0c6c-44f3-4631-809d-bfa615b0a4ec
|
@ -1,9 +1,9 @@
|
|||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 3.0.0
|
||||
# Compiled with Gambas 3.1.90
|
||||
Title=Gambas documentation CGI script
|
||||
Startup=Main
|
||||
Icon=help.png
|
||||
Version=3.0.0
|
||||
Version=3.1.90
|
||||
VersionFile=1
|
||||
Component=gb.db
|
||||
Component=gb.eval
|
||||
|
@ -11,3 +11,4 @@ TabSize=2
|
|||
Translate=1
|
||||
Language=fr
|
||||
License=General Public Licence
|
||||
Packager=1
|
||||
|
|
|
@ -2515,7 +2515,7 @@ Private Sub GetDefaultSymbolTitle(hSym As CSymbolInfo) As String
|
|||
If Not sName Then
|
||||
sName = $hSym.Class
|
||||
Endif
|
||||
Select Case $hSym.Name
|
||||
Select Case LCase($hSym.Name)
|
||||
Case "_new"
|
||||
sTitle = If($sVersion = "2.0", "NEW ", "New ") & sName
|
||||
Case "_put"
|
||||
|
@ -2866,16 +2866,16 @@ Private Function AutoLink(sStr As String) As String
|
|||
Else
|
||||
|
||||
If aWord[0] = "gb" Then
|
||||
rPage = DB.Find("page", "sPath = &1 AND sLang = &2", "/comp" &/ LCase(sWord), DEFAULT_LANG)
|
||||
rPage = DB.Find("page", "sPath = &1 AND sLang = &2", "/comp" &/ sWord, DEFAULT_LANG)
|
||||
If rPage.Available Then Goto FOUND
|
||||
Endif
|
||||
|
||||
If aWord.Count = 2 Then
|
||||
|
||||
rPage = DB.Find("page", "sTitle = &1 AND sLang = &2 AND sPath LIKE &3", aWord[1], DEFAULT_LANG, "/comp/gb.qt" &/ LCase(aWord[0]) &/ "%")
|
||||
If Not rPage.Available Then
|
||||
rPage = DB.Find("page", "sTitle = &1 AND sLang = &2 AND sPath LIKE &3", aWord[1], DEFAULT_LANG, "/comp/gb%" &/ LCase(aWord[0]) &/ "%")
|
||||
Endif
|
||||
'rPage = DB.Find("page", "sTitle = &1 AND sLang = &2 AND sPath LIKE &3", aWord[1], DEFAULT_LANG, "/comp/gb.qt" &/ LCase(aWord[0]) &/ "%")
|
||||
'If Not rPage.Available Then
|
||||
rPage = DB.Find("page", "sTitle = &1 AND sLang = &2 AND sPath LIKE &3", aWord[1], DEFAULT_LANG, "/comp/gb%." &/ aWord[0] &/ "/%")
|
||||
'Endif
|
||||
sTitle = sWord
|
||||
|
||||
Endif
|
||||
|
@ -4180,8 +4180,8 @@ Private Function GetToDo() As String
|
|||
|
||||
Else
|
||||
|
||||
If sName = "_free" Then Continue
|
||||
If sName = "_new" Then
|
||||
If LCase(sName) = "_free" Then Continue
|
||||
If LCase(sName) = "_new" Then
|
||||
If Not hClass.Creatable Or If hClass.IsVirtual() Then Continue
|
||||
Endif
|
||||
|
||||
|
@ -4329,9 +4329,9 @@ Private Function GetSymbols() As String
|
|||
Endif
|
||||
|
||||
Select Case hSym.Kind
|
||||
Case "r", "p"
|
||||
Case "r", "p", "v"
|
||||
cSymbol[sPrefix & "p"].Add(hSym.Name)
|
||||
Case "R", "P"
|
||||
Case "R", "P", "V"
|
||||
cSymbol[sPrefix & "P"].Add(hSym.Name)
|
||||
Case "C"
|
||||
cSymbol[sPrefix & "C"].Add(hSym.Name)
|
||||
|
@ -4580,7 +4580,7 @@ Private Function GetSymbolSyntax(hSym As CSymbolInfo) As String
|
|||
sName = hSym.Class
|
||||
sVirtual = GetVirtualClass(sName)
|
||||
|
||||
Select Case hSym.Name
|
||||
Select Case LCase(hSym.Name)
|
||||
|
||||
Case "_get"
|
||||
|
||||
|
@ -4679,7 +4679,7 @@ Private Function GetSymbolSyntax(hSym As CSymbolInfo) As String
|
|||
|
||||
Select Case LCase(hSym.Kind)
|
||||
|
||||
Case "p"
|
||||
Case "p", "v"
|
||||
sSyntax = sSyntax & Keyword("Property") & " "
|
||||
Case "r"
|
||||
sSyntax = sSyntax & Keyword("Property Read") & " "
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 3.0.90
|
||||
# Compiled with Gambas 3.1.90
|
||||
Title=Game of Life
|
||||
Startup=FMain
|
||||
Icon=glob2-icon-48x48.png
|
||||
Version=3.0.90
|
||||
Version=3.1.90
|
||||
VersionFile=1
|
||||
Component=gb.image
|
||||
Component=gb.gui
|
||||
|
@ -15,3 +15,4 @@ Maintainer=benoit
|
|||
Vendor=Princeton
|
||||
Address=benoit@localhost
|
||||
License=General Public Licence
|
||||
Packager=1
|
||||
|
|
|
@ -20,8 +20,8 @@ SearchString=True
|
|||
[OpenFile]
|
||||
Active=1
|
||||
File[1]=".src/FMain.form"
|
||||
File[2]=".src/FMain.class:14.8"
|
||||
File[3]=".src/CGameField.class:26.12"
|
||||
File[2]=".src/FMain.class:7.12"
|
||||
File[3]=".src/CGameField.class:74.12"
|
||||
Count=3
|
||||
|
||||
[Watches]
|
||||
|
|
2
examples/examples/Image/PhotoTouch/.directory
Normal file
|
@ -0,0 +1,2 @@
|
|||
[Desktop Entry]
|
||||
Icon=./.icon.png
|
BIN
examples/examples/Image/PhotoTouch/.icon.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
39
examples/examples/Image/PhotoTouch/.info
Normal file
|
@ -0,0 +1,39 @@
|
|||
#CButton
|
||||
DrawingArea
|
||||
C
|
||||
:Click
|
||||
:
|
||||
|
||||
|
||||
Image
|
||||
p
|
||||
Image
|
||||
|
||||
_new
|
||||
m
|
||||
|
||||
|
||||
DrawingArea_Enter
|
||||
m
|
||||
|
||||
|
||||
DrawingArea_Leave
|
||||
m
|
||||
|
||||
|
||||
DrawingArea_MouseDown
|
||||
m
|
||||
|
||||
|
||||
DrawingArea_DblClick
|
||||
m
|
||||
|
||||
|
||||
Timer_Timer
|
||||
m
|
||||
|
||||
|
||||
DrawingArea_Draw
|
||||
m
|
||||
|
||||
|
BIN
examples/examples/Image/PhotoTouch/.lang/fr.mo
Normal file
24
examples/examples/Image/PhotoTouch/.lang/fr.po
Normal file
|
@ -0,0 +1,24 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2002-11-01 04:27+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: FBrightness.form:55
|
||||
msgid "Balance"
|
||||
msgstr "Balance"
|
||||
|
||||
#: FScissors.form:19
|
||||
msgid "Cut"
|
||||
msgstr "Découper"
|
||||
|
||||
#: .project:1
|
||||
msgid "Retouche Photo"
|
||||
msgstr ""
|
||||
|
1
examples/examples/Image/PhotoTouch/.list
Normal file
|
@ -0,0 +1 @@
|
|||
CButton
|
17
examples/examples/Image/PhotoTouch/.project
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 3.1.90
|
||||
Title=Simple Photo Editor
|
||||
Startup=FMain
|
||||
Icon=icon.png
|
||||
Version=3.1.90
|
||||
VersionFile=1
|
||||
Component=gb.image
|
||||
Component=gb.qt4
|
||||
Component=gb.form
|
||||
Component=gb.desktop
|
||||
Component=gb.image.effect
|
||||
Authors="Benoît Minisini"
|
||||
TabSize=2
|
||||
Translate=1
|
||||
Language=fr
|
||||
Packager=1
|
103
examples/examples/Image/PhotoTouch/.src/CButton.class
Normal file
|
@ -0,0 +1,103 @@
|
|||
' Gambas class file
|
||||
|
||||
Export
|
||||
|
||||
Inherits DrawingArea
|
||||
|
||||
Event Click
|
||||
|
||||
Property Image As Image
|
||||
|
||||
Private Const MIN_OPACITY As Float = 0.3
|
||||
Private Const MAX_OPACITY As Float = 0.8
|
||||
|
||||
Private $hObs As Observer
|
||||
Private $hImage As Image
|
||||
Private $hDraw As Image
|
||||
Private $bInside As Boolean
|
||||
Private $hTimer As Timer
|
||||
Private $fOpacity As Float = MIN_OPACITY
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
$hObs = New Observer(Me) As "DrawingArea"
|
||||
$hTimer = New Timer As "Timer"
|
||||
$hTimer.Delay = 50
|
||||
Me.Mouse = Mouse.Pointing
|
||||
|
||||
End
|
||||
|
||||
Public Sub DrawingArea_Enter()
|
||||
|
||||
$bInside = True
|
||||
$hTimer.Start
|
||||
|
||||
End
|
||||
|
||||
Public Sub DrawingArea_Leave()
|
||||
|
||||
$bInside = False
|
||||
$hTimer.Start
|
||||
|
||||
End
|
||||
|
||||
Public Sub DrawingArea_MouseDown()
|
||||
|
||||
Raise Click
|
||||
|
||||
End
|
||||
|
||||
Public Sub DrawingArea_DblClick()
|
||||
|
||||
Raise Click
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub Timer_Timer()
|
||||
|
||||
If $bInside Then
|
||||
$fOpacity = Min(MAX_OPACITY, $fOpacity + 0.1)
|
||||
If $fOpacity >= MAX_OPACITY Then
|
||||
$hTimer.Stop
|
||||
Endif
|
||||
Else
|
||||
$fOpacity = Max(MIN_OPACITY, $fOpacity - 0.1)
|
||||
If $fOpacity <= MIN_OPACITY Then
|
||||
$hTimer.Stop
|
||||
Endif
|
||||
Endif
|
||||
|
||||
SetOpacity
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub DrawingArea_Draw()
|
||||
|
||||
If Not $hImage Then Return
|
||||
|
||||
Draw.Image($hDraw, 0, 0, Me.W, Me.H)
|
||||
|
||||
End
|
||||
|
||||
Private Function Image_Read() As Image
|
||||
|
||||
Return $hImage
|
||||
|
||||
End
|
||||
|
||||
Private Sub Image_Write(Value As Image)
|
||||
|
||||
$hImage = Value
|
||||
SetOpacity
|
||||
|
||||
End
|
||||
|
||||
Private Sub SetOpacity()
|
||||
|
||||
$hDraw = $hImage.Copy()
|
||||
$hDraw.Opacity($fOpacity)
|
||||
Me.Refresh
|
||||
|
||||
End
|
79
examples/examples/Image/PhotoTouch/.src/FBrightness.class
Normal file
|
@ -0,0 +1,79 @@
|
|||
' Gambas class file
|
||||
|
||||
Private $bNoChange As Boolean
|
||||
|
||||
Private $MX As Integer
|
||||
Private $MY As Integer
|
||||
Private $hRect As Rect
|
||||
|
||||
Private btnUndo As CButton
|
||||
Private btnApply As CButton
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
btnUndo = New CButton(Me) As "btnUndo"
|
||||
btnUndo.Move(Me.W - 128 - Desktop.Scale * 3, Desktop.Scale * 3, 64, 64)
|
||||
btnUndo.Image = Image.Load("undo.png")
|
||||
|
||||
btnApply = New CButton(Me) As "btnApply"
|
||||
btnApply.Move(btnUndo.X + btnUndo.W + Desktop.Scale, btnUndo.Y, 64, 64)
|
||||
btnApply.Image = Image.Load("ok.png")
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub Form_Open()
|
||||
|
||||
Me.Center
|
||||
FMain.Begin
|
||||
|
||||
End
|
||||
|
||||
Public Sub Form_Close()
|
||||
|
||||
FMain.End
|
||||
|
||||
End
|
||||
|
||||
Public Sub btnUndo_Click()
|
||||
|
||||
$bNoChange = True
|
||||
sldBrightness.Value = 50
|
||||
sldContrast.Value = 50
|
||||
sldGamma.Value = 50
|
||||
$bNoChange = False
|
||||
Balance_Change
|
||||
|
||||
End
|
||||
|
||||
Public Sub btnApply_Click()
|
||||
|
||||
FMain.Apply
|
||||
Me.Close
|
||||
|
||||
End
|
||||
|
||||
Public Sub Balance_Change()
|
||||
|
||||
If $bNoChange Then Return
|
||||
FMain.Balance(sldBrightness.Value, sldContrast.Value, sldGamma.Value)
|
||||
|
||||
End
|
||||
|
||||
Public Sub panBrightness_MouseDown()
|
||||
|
||||
$MX = Mouse.ScreenX
|
||||
$MY = Mouse.ScreenY
|
||||
$hRect = Rect(Me.X, Me.Y, Me.W, Me.H)
|
||||
|
||||
End
|
||||
|
||||
Public Sub panBrightness_MouseMove()
|
||||
|
||||
Dim X, Y As Integer
|
||||
|
||||
X = Min(Max($hRect.X + Mouse.ScreenX - $MX, 0), FMain.W - $hRect.W)
|
||||
Y = Min(Max($hRect.Y + Mouse.ScreenY - $MY, 0), FMain.H - $hRect.H)
|
||||
Me.Move(X, Y)
|
||||
|
||||
End
|
54
examples/examples/Image/PhotoTouch/.src/FBrightness.form
Normal file
|
@ -0,0 +1,54 @@
|
|||
# Gambas Form File 3.0
|
||||
|
||||
{ Form Form
|
||||
MoveScaled(0,0,74,48)
|
||||
Background = &HFFFFFF&
|
||||
Border = False
|
||||
Stacking = Window.Above
|
||||
SkipTaskbar = True
|
||||
Opacity = 50
|
||||
{ panBrightness Panel
|
||||
MoveScaled(1,1,72,46)
|
||||
Background = &H000000&
|
||||
{ PictureBox1 PictureBox
|
||||
MoveScaled(2,10,10,10)
|
||||
Picture = Picture["luminosity.png"]
|
||||
Stretch = True
|
||||
Alignment = Align.Center
|
||||
}
|
||||
{ PictureBox2 PictureBox
|
||||
MoveScaled(2,22,10,10)
|
||||
Picture = Picture["contrast.png"]
|
||||
Stretch = True
|
||||
Alignment = Align.Center
|
||||
}
|
||||
{ sldBrightness Slider Balance
|
||||
Name = "sldBrightness"
|
||||
MoveScaled(15,13,53,3)
|
||||
Value = 50
|
||||
}
|
||||
{ sldContrast Slider Balance
|
||||
Name = "sldContrast"
|
||||
MoveScaled(15,25,53,3)
|
||||
Value = 50
|
||||
}
|
||||
{ Label1 Label
|
||||
MoveScaled(2,2,52,6)
|
||||
Font = Font["Bold,+5"]
|
||||
Foreground = Color.TextBackground
|
||||
AutoResize = True
|
||||
Text = ("Balance")
|
||||
}
|
||||
{ PictureBox3 PictureBox
|
||||
MoveScaled(2,34,10,10)
|
||||
Picture = Picture["gamma.png"]
|
||||
Stretch = True
|
||||
Alignment = Align.Center
|
||||
}
|
||||
{ sldGamma Slider Balance
|
||||
Name = "sldGamma"
|
||||
MoveScaled(15,37,53,3)
|
||||
Value = 50
|
||||
}
|
||||
}
|
||||
}
|
506
examples/examples/Image/PhotoTouch/.src/FMain.class
Normal file
|
@ -0,0 +1,506 @@
|
|||
' Gambas class file
|
||||
|
||||
Private CACHE_DIR As String = "~/.cache/gambas/PhotoTouch"
|
||||
|
||||
Private $aPath As String[]
|
||||
Private $sPath As String
|
||||
Private $sDir As String
|
||||
Private $iIndex As Integer
|
||||
Private $hImage As Image
|
||||
Private $hZoom As Image
|
||||
Private $hTemp As Image
|
||||
Private $fZoom As Float = 1
|
||||
Private $sInfo As String
|
||||
Private $sMode As String
|
||||
Private $bModify As Boolean
|
||||
|
||||
Private $MX As Integer
|
||||
Private $MY As Integer
|
||||
|
||||
Private btnPrev As CButton
|
||||
Private btnNext As CButton
|
||||
|
||||
Private Sub LoadImage(Optional bReset As Boolean) As Boolean
|
||||
|
||||
Dim hImage As Image
|
||||
|
||||
Inc Application.Busy
|
||||
|
||||
Me.End
|
||||
SaveImage
|
||||
|
||||
If Not bReset Then
|
||||
Try $sPath = CACHE_DIR &/ $aPath[$iIndex]
|
||||
If Exist($sPath) Then Try hImage = Image.Load($sPath)
|
||||
Endif
|
||||
|
||||
If Not hImage Then
|
||||
Try $sPath = $sDir &/ $aPath[$iIndex]
|
||||
If $sPath Then Try hImage = Image.Load($sPath)
|
||||
Endif
|
||||
|
||||
$sInfo = ""
|
||||
Try $sInfo = File.Name($sPath) & " - " & Format(Stat($sPath).LastModified, gb.LongDate)
|
||||
If hImage Then
|
||||
$hImage = hImage
|
||||
svwImage.ResizeContents($hImage.W, $hImage.H)
|
||||
svwImage.Show
|
||||
lblError.Hide
|
||||
Else
|
||||
svwImage.Hide
|
||||
lblError.Show
|
||||
If $aPath.Count = 0 Then
|
||||
lblError.Text = ("No image in directory")
|
||||
$sInfo = ""
|
||||
Else
|
||||
lblError.Text = ("Unable to load image")
|
||||
$sInfo = File.Name($sPath) & " - " & Format(Stat($sPath).LastModified, gb.LongDate)
|
||||
Endif
|
||||
Endif
|
||||
|
||||
$bModify = False
|
||||
SetZoom(0)
|
||||
dwgInfo.Refresh
|
||||
Me.Refresh
|
||||
|
||||
Dec Application.Busy
|
||||
|
||||
End
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
Dim hCtrl As Control
|
||||
Dim sImg As String
|
||||
Dim hButton As CButton
|
||||
Dim hPanel As Panel
|
||||
|
||||
Application.MainWindow = Me
|
||||
|
||||
Try Mkdir File.Dir(File.Dir(cache_dir))
|
||||
Try Mkdir File.Dir(cache_dir)
|
||||
Try Mkdir CACHE_DIR
|
||||
|
||||
For Each sImg In ["usb", "-", "zoom-in", "zoom-out", "zoom-original", "zoom-fit", "-", "rotate-left", "rotate-right", "-", "scissors", "luminosity", "<->", "undo", "quit"]
|
||||
If sImg = "<->" Then
|
||||
hPanel = New Panel(panToolbar)
|
||||
hPanel.Expand = True
|
||||
hPanel.Resize(8, 64)
|
||||
Else If sImg = "-" Then
|
||||
hPanel = New Panel(panToolbar)
|
||||
hPanel.Resize(16, 64)
|
||||
Else
|
||||
hButton = New CButton(panToolbar) As "Button"
|
||||
hButton.Resize(64, 64)
|
||||
hButton.Image = Image.Load(sImg & ".png")
|
||||
hButton.Tag = sImg
|
||||
Endif
|
||||
Next
|
||||
|
||||
btnPrev = New CButton(Me) As "Button"
|
||||
btnPrev.Resize(64, 64)
|
||||
btnPrev.Ignore = True
|
||||
btnPrev.Tag = "previous"
|
||||
btnPrev.Image = Image.Load("previous.png")
|
||||
|
||||
btnNext = New CButton(Me) As "Button"
|
||||
btnNext.Resize(64, 64)
|
||||
btnNext.Ignore = True
|
||||
btnNext.Tag = "next"
|
||||
btnNext.Image = Image.Load("next.png")
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub Form_Open()
|
||||
|
||||
SetDir(User.Home)
|
||||
|
||||
End
|
||||
|
||||
Public Sub svwImage_Draw()
|
||||
|
||||
Dim X As Integer
|
||||
Dim Y As Integer
|
||||
Dim XR As Integer
|
||||
Dim YR As Integer
|
||||
Dim SX, SX2 As Integer
|
||||
Dim SY, SY2 As Integer
|
||||
Dim DX As Integer
|
||||
Dim DY As Integer
|
||||
Dim C As Integer
|
||||
Dim SW, SH As Integer
|
||||
Dim hZoom As Image
|
||||
Dim iZoom As Integer
|
||||
|
||||
If Not $hImage Then Return
|
||||
|
||||
If $fZoom > 1 Then
|
||||
|
||||
iZoom = $fZoom
|
||||
|
||||
Draw.LineStyle = Line.None
|
||||
Draw.FillStyle = Fill.Solid
|
||||
|
||||
DX = Max(0, (Me.W - $hImage.W * iZoom) / 2)
|
||||
DY = Max(0, (Me.H - $hImage.H * iZoom) / 2)
|
||||
|
||||
SX = (Draw.Clip.X - DX) \ iZoom
|
||||
SY = (Draw.Clip.Y - DY) \ iZoom
|
||||
SX2 = (Draw.Clip.X - DX + Draw.Clip.W - 1) \ iZoom
|
||||
SY2 = (Draw.Clip.Y - DY + Draw.Clip.H - 1) \ iZoom
|
||||
|
||||
SX = Max(0, SX)
|
||||
SX2 = Min($hImage.Width - 1, SX2)
|
||||
SW = SX2 - SX + 1
|
||||
|
||||
SY = Max(0, SY)
|
||||
SY2 = Min($hImage.Height - 1, SY2)
|
||||
SH = SY2 - SY + 1
|
||||
|
||||
'If $fZoom > 5 Then
|
||||
' Draw.LineStyle = Line.Solid
|
||||
' Draw.Foreground = &H989898
|
||||
'Else
|
||||
' Draw.LineStyle = Line.None
|
||||
'Endif
|
||||
|
||||
Draw.Zoom($hImage, iZoom, SX * iZoom + DX, SY * iZoom + DY, SX + svwImage.ScrollX \ iZoom, SY + svwImage.ScrollY \ iZoom, SW, SH)
|
||||
|
||||
Else If $fZoom = 1 Then
|
||||
|
||||
If $hImage.W < Me.W Then
|
||||
X = (Me.W - $hImage.W) / 2
|
||||
Else
|
||||
X = - svwImage.ScrollX
|
||||
Endif
|
||||
|
||||
If $hImage.H < Me.H Then
|
||||
Y = (Me.H - $hImage.H) / 2
|
||||
Else
|
||||
Y = - svwImage.ScrollY
|
||||
Endif
|
||||
|
||||
Draw.Image($hImage, X, Y)
|
||||
|
||||
Else
|
||||
|
||||
If $hZoom.W < Me.W Then
|
||||
X = (Me.W - $hZoom.W) / 2
|
||||
Else
|
||||
X = - svwImage.ScrollX
|
||||
Endif
|
||||
|
||||
If $hZoom.H < Me.H Then
|
||||
Y = (Me.H - $hZoom.H) / 2
|
||||
Else
|
||||
Y = - svwImage.ScrollY
|
||||
Endif
|
||||
|
||||
Draw.Image($hZoom, X, Y)
|
||||
|
||||
Endif
|
||||
|
||||
End
|
||||
|
||||
Public Sub Form_Resize()
|
||||
|
||||
panToolbar.Move(0, 0, Me.W, 64 + Desktop.Scale * 2)
|
||||
dwgInfo.Move(8, Me.H - dwgInfo.H, Me.W, dwgInfo.H)
|
||||
btnPrev.Move(8, (Me.H - btnPrev.H) / 2)
|
||||
btnNext.Move(Me.W - 8 - btnNext.W, (Me.H - btnNext.H) / 2)
|
||||
|
||||
End
|
||||
|
||||
Public Sub Button_Click()
|
||||
|
||||
Action(Last.Tag)
|
||||
|
||||
End
|
||||
|
||||
Private Sub UpdateZoom()
|
||||
|
||||
Dim X, Y As Float
|
||||
|
||||
If Not $hImage Then Return
|
||||
|
||||
If $fZoom < 1 Then
|
||||
$hZoom = $hImage.Stretch($hImage.W * $fZoom, $hImage.H * $fZoom)
|
||||
Else
|
||||
$hZoom = Null
|
||||
Endif
|
||||
|
||||
X = (svwImage.ScrollX + svwImage.ClientW / 2) / svwImage.ScrollW
|
||||
Y = (svwImage.ScrollY + svwImage.ClientH / 2) / svwImage.ScrollH
|
||||
|
||||
svwImage.ResizeContents($hImage.W * $fZoom, $hImage.H * $fZoom)
|
||||
svwImage.Scroll(X * svwImage.ScrollW - svwImage.ClientW / 2, Y * svwImage.ScrollH - svwImage.ClientH / 2)
|
||||
|
||||
Me.Refresh
|
||||
|
||||
End
|
||||
|
||||
Private Sub SetZoom(fZoom As Float)
|
||||
|
||||
If Not $hImage Then Return
|
||||
|
||||
If fZoom = 0 Then
|
||||
$fZoom = 0
|
||||
fZoom = Min(Me.W / $hImage.W, Me.H / $hImage.H)
|
||||
fZoom = Min(1, fZoom)
|
||||
Endif
|
||||
|
||||
fZoom = Max(1 / 32, Min(32, fZoom))
|
||||
If fZoom = $fZoom Then Return
|
||||
If fZoom <> 1 Then
|
||||
If ($hImage.W * fZoom) < 96 Or If ($hImage.H * fZoom) < 96 Then Return
|
||||
Endif
|
||||
|
||||
$fZoom = fZoom
|
||||
UpdateZoom
|
||||
|
||||
End
|
||||
|
||||
Public Sub SetMode(sMode As String)
|
||||
|
||||
If $sMode Then
|
||||
Cancel
|
||||
FBrightness.Close
|
||||
FScissors.Close
|
||||
Endif
|
||||
|
||||
If sMode = $sMode Then
|
||||
$sMode = ""
|
||||
Return
|
||||
Endif
|
||||
|
||||
Select Case sMode
|
||||
Case "luminosity"
|
||||
FBrightness.Show
|
||||
Case "scissors"
|
||||
FScissors.Show
|
||||
End Select
|
||||
|
||||
$sMode = sMode
|
||||
|
||||
End
|
||||
|
||||
|
||||
Private Sub Action(sAction As String)
|
||||
|
||||
Select Case sAction
|
||||
|
||||
Case "previous"
|
||||
Dec $iIndex
|
||||
If $iIndex < 0 Then $iIndex = $aPath.Max
|
||||
LoadImage
|
||||
|
||||
Case "next"
|
||||
Inc $iIndex
|
||||
If $iIndex > $aPath.Max Then $iIndex = 0
|
||||
LoadImage
|
||||
|
||||
Case "zoom-in"
|
||||
SetZoom(2 ^ Int(Log2($fZoom)) * 2)
|
||||
|
||||
Case "zoom-out"
|
||||
SetZoom(2 ^ Int(Log2($fZoom) - 0.001))
|
||||
|
||||
Case "zoom-original"
|
||||
SetZoom(1)
|
||||
|
||||
Case "zoom-fit"
|
||||
SetZoom(0)
|
||||
|
||||
Case "rotate-left"
|
||||
If Not $hImage Then Return
|
||||
$hImage = $hImage.Rotate(Pi(0.5))
|
||||
$bModify = True
|
||||
'SaveImage
|
||||
UpdateZoom
|
||||
|
||||
Case "rotate-right"
|
||||
If Not $hImage Then Return
|
||||
$hImage = $hImage.Rotate(Pi(-0.5))
|
||||
$bModify = True
|
||||
'SaveImage
|
||||
UpdateZoom
|
||||
|
||||
Case "quit"
|
||||
SetMode("")
|
||||
SaveImage
|
||||
If Dir(CACHE_DIR).Count Then Desktop.Open(CACHE_DIR)
|
||||
Me.Close
|
||||
|
||||
Case "luminosity", "scissors"
|
||||
If Not $hImage Then Return
|
||||
SetMode(sAction)
|
||||
|
||||
Case "usb"
|
||||
SetMode("")
|
||||
If Dialog.SelectDirectory() Then Return
|
||||
SetDir(Dialog.Path)
|
||||
|
||||
Case "undo"
|
||||
SetMode("")
|
||||
LoadImage(True)
|
||||
RemoveImage
|
||||
|
||||
End Select
|
||||
|
||||
End
|
||||
|
||||
Public Sub svwImage_MouseDown()
|
||||
|
||||
$MX = Mouse.X + svwImage.ScrollX
|
||||
$MY = Mouse.Y + svwImage.ScrollY
|
||||
'Debug $MX;; $MY
|
||||
|
||||
End
|
||||
|
||||
Public Sub svwImage_MouseMove()
|
||||
|
||||
If Mouse.Left Then
|
||||
'Debug Mouse.X - $MX;; Mouse.Y - $MY
|
||||
svwImage.Scroll($MX - Mouse.X, $MY - Mouse.Y)
|
||||
Endif
|
||||
|
||||
End
|
||||
|
||||
Public Sub dwgInfo_Draw()
|
||||
|
||||
Dim X, Y As Integer
|
||||
|
||||
Paint.Font = Font["Bold,+3"]
|
||||
' Paint.Brush = Paint.Color(Color.SetAlpha(Color.White, 128))
|
||||
' For X = -2 To 2
|
||||
' For Y = -2 To 2
|
||||
' If X = 0 And If Y = 0 Then Continue
|
||||
' Paint.Text($sInfo, 8 + X, 8 + Y, dwgInfo.W, dwgInfo.H, Align.Left)
|
||||
' Next
|
||||
' Next
|
||||
' Paint.Fill
|
||||
Paint.LineWidth = 1
|
||||
Paint.Brush = Paint.Color(Color.SetAlpha(Color.White, 192))
|
||||
Paint.DrawText($sInfo, 0, 0, dwgInfo.W, dwgInfo.H, Align.Left)
|
||||
|
||||
End
|
||||
|
||||
Public Sub Form_KeyPress()
|
||||
|
||||
Select Case Key.Code
|
||||
|
||||
Case Key.Esc
|
||||
Action("quit")
|
||||
|
||||
End Select
|
||||
|
||||
End
|
||||
|
||||
Public Sub Begin()
|
||||
|
||||
$hTemp = $hImage.Copy()
|
||||
|
||||
End
|
||||
|
||||
Public Sub End()
|
||||
|
||||
$hTemp = Null
|
||||
UpdateZoom
|
||||
SetMode("")
|
||||
'SaveImage
|
||||
Me.Refresh
|
||||
|
||||
End
|
||||
|
||||
Public Sub Apply()
|
||||
|
||||
$hTemp = $hImage
|
||||
|
||||
End
|
||||
|
||||
Public Sub Cancel()
|
||||
|
||||
If Not $hTemp Then Return
|
||||
$hImage = $hTemp.Copy()
|
||||
UpdateZoom
|
||||
Me.Refresh
|
||||
|
||||
End
|
||||
|
||||
Public Sub GetImage() As Image
|
||||
|
||||
Return $hImage
|
||||
|
||||
End
|
||||
|
||||
Public Sub Balance(iBrightness As Integer, iContrast As Integer, iGamma As Integer)
|
||||
|
||||
$hImage = $hTemp.Copy()
|
||||
$hImage.Balance((iBrightness - 50) / 50, (iContrast - 50) / 50, (iGamma - 50) / 50)
|
||||
$bModify = True
|
||||
UpdateZoom
|
||||
Me.Refresh
|
||||
|
||||
End
|
||||
|
||||
Public Sub Cut()
|
||||
|
||||
Dim X, Y, W, H As Integer
|
||||
Dim hRect As Rect
|
||||
|
||||
W = FScissors.W / $fZoom
|
||||
H = FScissors.H / $fZoom
|
||||
X = (svwImage.ScrollX + FScissors.X) / $fZoom
|
||||
Y = (svwImage.ScrollY + FScissors.Y) / $fZoom
|
||||
|
||||
If $hImage.W * $fZoom <= Me.W Then X -= (Me.W / $fZoom - $hImage.W) / 2
|
||||
If $hImage.H * $fZoom <= Me.H Then Y -= (Me.H / $fZoom - $hImage.H) / 2
|
||||
|
||||
hRect = Rect(X, Y, W, H)
|
||||
hRect = hRect.Intersection(Rect(0, 0, $hImage.W, $hImage.H))
|
||||
|
||||
If Not hRect Then Return
|
||||
|
||||
$hImage = $hImage.Copy(hRect.X, hRect.Y, hRect.W, hRect.H)
|
||||
$bModify = True
|
||||
$hTemp = $hImage
|
||||
Me.End
|
||||
SetZoom(0)
|
||||
|
||||
End
|
||||
|
||||
Private Sub SetDir(sDir As String)
|
||||
|
||||
Inc Application.Busy
|
||||
|
||||
Shell "cd " & Shell(CACHE_DIR) & "; rm -f *" Wait
|
||||
|
||||
$sDir = sDir
|
||||
$aPath = New String[]
|
||||
Try $aPath = Dir(sDir, "*.{jpg,JPG,jpeg,JPEG,png,PNG,bmp,BMP,gig,GIF}").Sort()
|
||||
$iIndex = 0
|
||||
LoadImage
|
||||
|
||||
Dec Application.Busy
|
||||
|
||||
End
|
||||
|
||||
Private Sub SaveImage()
|
||||
|
||||
If Not $hImage Then Return
|
||||
If Not $bModify Then Return
|
||||
|
||||
$hImage.Save(CACHE_DIR &/ File.Name($sPath))
|
||||
$bModify = False
|
||||
|
||||
Catch
|
||||
|
||||
Message.Error(Error.Text)
|
||||
|
||||
End
|
||||
|
||||
Private Sub RemoveImage()
|
||||
|
||||
Try Kill CACHE_DIR &/ File.Name($sPath)
|
||||
|
||||
End
|
35
examples/examples/Image/PhotoTouch/.src/FMain.form
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Gambas Form File 3.0
|
||||
|
||||
{ Form Form
|
||||
MoveScaled(0,0,82,72)
|
||||
Border = False
|
||||
Maximized = True
|
||||
Arrangement = Arrange.Fill
|
||||
{ svwImage ScrollArea
|
||||
MoveScaled(24,24,24,24)
|
||||
Background = &H000000&
|
||||
Mouse = Mouse.SizeAll
|
||||
Border = False
|
||||
ScrollBar = Scroll.None
|
||||
}
|
||||
{ dwgInfo DrawingArea
|
||||
MoveScaled(5,64,66,6)
|
||||
Ignore = True
|
||||
Painted = True
|
||||
}
|
||||
{ panToolbar HBox
|
||||
MoveScaled(1,1,52,13)
|
||||
Ignore = True
|
||||
AutoResize = True
|
||||
Spacing = True
|
||||
Margin = True
|
||||
}
|
||||
{ lblError Label
|
||||
MoveScaled(15,52,46,9)
|
||||
Visible = False
|
||||
Font = Font["Bold,+5"]
|
||||
Background = &H000000&
|
||||
Foreground = &HFFFFFF&
|
||||
Alignment = Align.Center
|
||||
}
|
||||
}
|
154
examples/examples/Image/PhotoTouch/.src/FScissors.class
Normal file
|
@ -0,0 +1,154 @@
|
|||
' Gambas class file
|
||||
|
||||
Private $aScissors As Panel[]
|
||||
|
||||
Private Enum S_N, S_S, S_W, S_E, S_NW, S_NE, S_SW, S_SE
|
||||
Private HANDLE_SIZE As Integer
|
||||
|
||||
Private $aMouse As Integer[]
|
||||
Private $aOpacity As Integer[]
|
||||
|
||||
Private $MX As Integer
|
||||
Private $MY As Integer
|
||||
Private $hRect As Rect
|
||||
|
||||
Private btnCut As CButton
|
||||
|
||||
Private Sub Form_Resize()
|
||||
|
||||
$aScissors[S_NW].Move(0, 0, HANDLE_SIZE, HANDLE_SIZE)
|
||||
$aScissors[S_NE].Move(Me.W - HANDLE_SIZE, 0, HANDLE_SIZE, HANDLE_SIZE)
|
||||
$aScissors[S_SW].Move(0, Me.H - HANDLE_SIZE, HANDLE_SIZE, HANDLE_SIZE)
|
||||
$aScissors[S_SE].Move(Me.W - HANDLE_SIZE, Me.H - HANDLE_SIZE, HANDLE_SIZE, HANDLE_SIZE)
|
||||
$aScissors[S_N].Move(HANDLE_SIZE, 0, Me.W - HANDLE_SIZE * 2, HANDLE_SIZE)
|
||||
$aScissors[S_S].Move(HANDLE_SIZE, Me.H - HANDLE_SIZE, Me.W - HANDLE_SIZE * 2, HANDLE_SIZE)
|
||||
$aScissors[S_W].Move(0, HANDLE_SIZE, HANDLE_SIZE, Me.H - HANDLE_SIZE * 2)
|
||||
$aScissors[S_E].Move(Me.W - HANDLE_SIZE, HANDLE_SIZE, HANDLE_SIZE, Me.H - HANDLE_SIZE * 2)
|
||||
|
||||
btnCut.Move(Me.W - 64 - Desktop.Scale * 3, Desktop.Scale * 3)
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub Form_Open()
|
||||
|
||||
Dim I As Integer
|
||||
|
||||
$aMouse = [Mouse.SizeN, Mouse.SizeS, Mouse.SizeW, Mouse.SizeE, Mouse.SizeNW, Mouse.SizeNE, Mouse.SizeSW, Mouse.SizeSE]
|
||||
HANDLE_SIZE = Desktop.Scale
|
||||
|
||||
$aScissors = New Panel[8]
|
||||
|
||||
For I = 0 To 7
|
||||
$aScissors[I] = New Panel(Me) As "Panel"
|
||||
With $aScissors[I]
|
||||
.Mouse = $aMouse[I]
|
||||
.Background = Color.White 'IIf(I >= S_NW, Color.RGB(192, 192, 192), Color.White)
|
||||
.Tag = I
|
||||
End With
|
||||
Next
|
||||
|
||||
btnCut = New CButton(Me) As "btnCut"
|
||||
btnCut.Resize(64, 64)
|
||||
btnCut.Image = Image.Load("scissors.png")
|
||||
|
||||
Me.Move(FMain.ClientW \ 4, FMain.ClientH \ 4, FMain.ClientW \ 2, FMain.ClientH \ 2)
|
||||
Form_Resize
|
||||
|
||||
End
|
||||
|
||||
Public Sub Panel_MouseDown()
|
||||
|
||||
$MX = Mouse.ScreenX
|
||||
$MY = Mouse.ScreenY
|
||||
$hRect = Rect(Me.X, Me.Y, Me.W, Me.H)
|
||||
|
||||
End
|
||||
|
||||
Public Sub Panel_MouseMove()
|
||||
|
||||
Dim X, Y As Integer
|
||||
Dim iTag As Integer = Last.Tag
|
||||
Dim MIN_HEIGHT As Integer = 64 + Desktop.Scale * 6
|
||||
Dim MIN_WIDTH As Integer = 64 + Desktop.Scale * 6
|
||||
|
||||
Select Case Last.Tag
|
||||
|
||||
Case S_N
|
||||
Y = $hRect.Y + Mouse.ScreenY - $MY
|
||||
Y = Min($hRect.Bottom - MIN_HEIGHT, Max(0, Y))
|
||||
Me.Move(Me.X, Y, Me.W, $hRect.H + $hRect.Y - Y)
|
||||
|
||||
Case S_S
|
||||
Y = $hRect.H + Mouse.ScreenY - $MY
|
||||
Y = Min(FMain.H - $hRect.Y, Max(MIN_HEIGHT, Y))
|
||||
Me.Move(Me.X, Me.Y, Me.W, Y)
|
||||
|
||||
Case S_W
|
||||
X = $hRect.X + Mouse.ScreenX - $MX
|
||||
X = Min($hRect.Right - MIN_WIDTH, Max(0, X))
|
||||
Me.Move(X, Me.Y, $hRect.W + $hRect.X - X, Me.H)
|
||||
|
||||
Case S_E
|
||||
X = $hRect.W + Mouse.ScreenX - $MX
|
||||
X = Min(FMain.W - $hRect.X, Max(MIN_WIDTH, X))
|
||||
Me.Move(Me.X, Me.Y, X, Me.H)
|
||||
|
||||
Case S_NW
|
||||
Y = $hRect.Y + Mouse.ScreenY - $MY
|
||||
Y = Min($hRect.Bottom - MIN_HEIGHT, Max(0, Y))
|
||||
X = $hRect.X + Mouse.ScreenX - $MX
|
||||
X = Min($hRect.Right - MIN_WIDTH, Max(0, X))
|
||||
Me.Move(X, Y, $hRect.W + $hRect.X - X, $hRect.H + $hRect.Y - Y)
|
||||
|
||||
Case S_NE
|
||||
Y = $hRect.Y + Mouse.ScreenY - $MY
|
||||
Y = Min($hRect.Bottom - MIN_HEIGHT, Max(0, Y))
|
||||
X = $hRect.W + Mouse.ScreenX - $MX
|
||||
X = Min(FMain.W - $hRect.X, Max(MIN_WIDTH, X))
|
||||
Me.Move(Me.X, Y, X, $hRect.H + $hRect.Y - Y)
|
||||
|
||||
Case S_SW
|
||||
Y = $hRect.H + Mouse.ScreenY - $MY
|
||||
Y = Min(FMain.H - $hRect.Y, Max(MIN_HEIGHT, Y))
|
||||
X = $hRect.X + Mouse.ScreenX - $MX
|
||||
X = Min($hRect.Right - MIN_WIDTH, Max(0, X))
|
||||
Me.Move(X, Me.Y, $hRect.W + $hRect.X - X, Y)
|
||||
|
||||
Case S_SE
|
||||
Y = $hRect.H + Mouse.ScreenY - $MY
|
||||
Y = Min(FMain.H - $hRect.Y, Max(MIN_HEIGHT, Y))
|
||||
X = $hRect.W + Mouse.ScreenX - $MX
|
||||
X = Min(FMain.W - $hRect.X, Max(MIN_WIDTH, X))
|
||||
Me.Move(Me.X, Me.Y, X, Y)
|
||||
|
||||
End Select
|
||||
|
||||
Form_Resize
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub Form_MouseDown()
|
||||
|
||||
$MX = Mouse.ScreenX
|
||||
$MY = Mouse.ScreenY
|
||||
$hRect = Rect(Me.X, Me.Y, Me.W, Me.H)
|
||||
|
||||
End
|
||||
|
||||
Public Sub Form_MouseMove()
|
||||
|
||||
Dim X, Y As Integer
|
||||
|
||||
X = Min(Max($hRect.X + Mouse.ScreenX - $MX, 0), FMain.W - $hRect.W)
|
||||
Y = Min(Max($hRect.Y + Mouse.ScreenY - $MY, 0), FMain.H - $hRect.H)
|
||||
Me.Move(X, Y)
|
||||
|
||||
End
|
||||
|
||||
Public Sub btnCut_Click()
|
||||
|
||||
FMain.Cut
|
||||
|
||||
End
|
17
examples/examples/Image/PhotoTouch/.src/FScissors.form
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Gambas Form File 3.0
|
||||
|
||||
{ Form Form
|
||||
MoveScaled(0,0,64,64)
|
||||
Background = &H000000&
|
||||
Mouse = Mouse.SizeAll
|
||||
Border = False
|
||||
Stacking = Window.Above
|
||||
SkipTaskbar = True
|
||||
Opacity = 50
|
||||
{ Label1 Label
|
||||
MoveScaled(3,3,52,6)
|
||||
Font = Font["Bold,+5"]
|
||||
Foreground = Color.TextBackground
|
||||
Text = ("Cut")
|
||||
}
|
||||
}
|
12
examples/examples/Image/PhotoTouch/.startup
Normal file
|
@ -0,0 +1,12 @@
|
|||
FMain
|
||||
Simple Photo Editor
|
||||
0
|
||||
0
|
||||
3.1.90
|
||||
|
||||
gb.image
|
||||
gb.qt4
|
||||
gb.form
|
||||
gb.desktop
|
||||
gb.image.effect
|
||||
|
BIN
examples/examples/Image/PhotoTouch/contrast.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
examples/examples/Image/PhotoTouch/control.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
examples/examples/Image/PhotoTouch/delete.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
examples/examples/Image/PhotoTouch/gamma.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
examples/examples/Image/PhotoTouch/icon.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
examples/examples/Image/PhotoTouch/luminosity.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
examples/examples/Image/PhotoTouch/next.png
Normal file
After Width: | Height: | Size: 968 B |
BIN
examples/examples/Image/PhotoTouch/ok.png
Normal file
After Width: | Height: | Size: 862 B |
BIN
examples/examples/Image/PhotoTouch/previous.png
Normal file
After Width: | Height: | Size: 954 B |
BIN
examples/examples/Image/PhotoTouch/quit.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
examples/examples/Image/PhotoTouch/redo.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
examples/examples/Image/PhotoTouch/rotate-left.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
examples/examples/Image/PhotoTouch/rotate-right.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
examples/examples/Image/PhotoTouch/scissors.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
examples/examples/Image/PhotoTouch/undo.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
examples/examples/Image/PhotoTouch/usb.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
examples/examples/Image/PhotoTouch/zoom-fit.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
examples/examples/Image/PhotoTouch/zoom-in.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
examples/examples/Image/PhotoTouch/zoom-original.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
examples/examples/Image/PhotoTouch/zoom-out.png
Normal file
After Width: | Height: | Size: 2.3 KiB |