Code: Select all
;=================FakeProcedure for Multiline Note==================
;PB 5.22
; Rewritten version - 23.04.2014/2
; Lubos Svoboda. 2014
; Free for using and improving
;Parameters:
;x, y: coordinates of procedure window
;H = height W=width
;Tx$=text of note
; This procedure is a little fake, because it cannot be used for two (or more) notes in one Window. :(
; However, I hope that that one Note for one Window is enough.
Procedure TinyNote(x,y, W, H,Tx$)
FF1= LoadFont(0, "Times New Roman", 11)
If CreateImage(4, W, H,32,RGB(255,255,255)) And StartDrawing(ImageOutput(4))
NewList Noteline.s()
DrawingFont(FF1)
BackColor(RGB(255,255,255))
;Colors for choice - Barva je globální proměnná
If Barva=1
FrontColor(RGB(0,0,0)) ; black
ElseIf Barva=2
FrontColor(RGB(45,68,210)) ; blue
Else
FrontColor (RGB(250, 19, 5)) ; red
EndIf
R=0
St=1
Repeat
A$=""
Lastspace=St
For i=St To Len(Tx$)
If Asc(Mid(Tx$,i,1))=32
Lastspace=i
EndIf
A$= (Mid(Tx$,St,i-St))
If TextWidth(A$)>=W-15
Break
EndIf
Next i
B$= Mid(Tx$,St, Lastspace-St)
A$=Mid(Tx$,St,1+Len(Tx$)-St)
If TextWidth(A$)<W-15
B$=A$
EndIf
AddElement (NoteLine())
Noteline()=B$
St=St+Len(B$)+1
Until St>Len(Tx$)
EndIf
ForEach Noteline()
If R*15>H-15
Break
EndIf
DrawText(3,R*15,Noteline())
R=R+1
Next
StopDrawing()
ImageGadget(4, x, y, W, H, ImageID(4))
FrameGadget(#PB_Any, x-10, y-15, W+20, H+20, N$)
EndProcedure
;----------------------------------------------------------------------------------------------------
;DEMO:
Demo$="Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua."
D2$=" Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat."
D3$= " Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."
D4$=" Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Demo$=Demo$+d2$+D3$+D4$
Demo2$="V tom latinském textu aby se prase vyznalo. Bude lépe použít češtinu i za cenu úplného blábolu, který bude hustokrutopřísný a nakonec hodí alespoň ty tři řádky potřebné k vyhodnocení účinnosti."
If OpenWindow(0, 0, 0, 400, 400, "Tiny Note", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TinyNote(20,25,375,75,Demo$)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
;----------------------------------------------------------------------------------------------------