Re: Build a text editor
Posted: Mon Aug 18, 2025 12:24 am
Owoowush ! I am alive ! (and tired lil bit...). What about a small concrete scrolling on the (burp...) "Window GUI" ?
3rd simulation, just to see, no problem of speed, except if you see anything boring !
Artefacts ? Freeze ? Anything boring ?
-> Write your misery, I ll try to clear !
3rd simulation, just to see, no problem of speed, except if you see anything boring !
Artefacts ? Freeze ? Anything boring ?
-> Write your misery, I ll try to clear !
Code: Select all
win = OpenWindow(#PB_Any, 0, 0, 1, 1, "", #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_Maximize | #PB_Window_SystemMenu | #PB_Window_SizeGadget)
w = WindowWidth(win)
h = WindowHeight(win)
max = 255
Global Dim img(max)
Global Dim ig(max)
con = ContainerGadget(#PB_Any, 0, 0, w, h)
visibleRowQty = h / 16
font0 = LoadFont(#PB_Any, "courier new", 12)
font1 = LoadFont(#PB_Any, "courier new", 12, #PB_Font_Bold | #PB_Font_Italic)
For i = 0 To max
img(i) = CreateImage(#PB_Any, w, 16)
StartDrawing(ImageOutput(img(i) ) )
Box(0, 0, w, h, RGB(255 - Random(31), 255 - Random(31), 255 - Random(31) ) )
DrawText(0, 0, Str(i) + " line #" + Str(i + 1), RGB(0, 0, 0), RGB(255, 255, 255) )
If Random(1)
DrawingFont(FontID(font0) )
Else
DrawingFont(FontID(font1) )
EndIf
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(100 + Random(w - 200), 0, Str(i) + " line #" + Str(i + 1), RGB(Random(85), Random(85), Random(85) ), RGB(255, 255, 255) )
StopDrawing()
ig(i) = ImageGadget(#PB_Any, 0, 16 * i, 1, 1, ImageID(img(i) ) )
Next
CloseGadgetList()
winC = OpenWindow(#PB_Any, 0, 0, 1, 1, "", #PB_Window_BorderLess)
gadC = CanvasGadget(#PB_Any, 0, 0, 1, 1, #PB_Canvas_Keyboard)
SetActiveGadget(gadC)
Repeat
SetWindowTitle(win, "Wheel the mouse " + Str(WindowMouseX(win) ) + " * " + Str(WindowMouseY(win) ) )
ev = WaitWindowEvent()
SetActiveGadget(gadC)
If WindowMouseX(win) <> -1 And WindowMouseY(win) <> -1
dmx = DesktopMouseX()
dmy = DesktopMouseY()
ResizeWindow(winC, dmx, dmy, 1, 1)
wd = GetGadgetAttribute(gadC, #PB_Canvas_WheelDelta) * 3
While wd
oldOffset = offset
If wd < 0
offset + 1
wd + 1
If offset + visibleRowQty > max
offset = max - visibleRowQty
EndIf
Else
offset - 1
wd - 1
If offset < 0
offset = 0
EndIf
EndIf
If offset <> oldOffset
For i = 0 To visibleRowQty
SetGadgetState(ig(i), ImageID(img(i + offset) ) )
Next
EndIf
Wend
EndIf
Until ev = #PB_Event_CloseWindow