I made this for my wife in 20 minutes. This is only possible with purebasic.
It is a simple but effective shopping list.
Right button show the popup menu.
Updated to version cukilinda!! Now with hearts animation.
Code: Select all
Now the hearts are in a thread to dont stop!-Add new elements.
-Modify units.
-Edit the element.
-Delete elements.
-Check to include or not in the final list. (copied to clipboard)
-Copy to clipboard. Easy to print or send.
-Maximize and minimize.
-Save and load list items automatically.
Moral: Happy wife, calm husband.
@sergey: Solved problem pos > 0, thanks sergey! Don't give her ideas!!
@Denis: Thanks, share the french version please. Merci!
@Infratec: Nice idea, i will do it, But if you prefer to do it yourself, it would be perfect. Thank you very much! (I got many apps create for phones, but hate program for phones, Kotlin... etc, security level out of date and a lot of crazy things. Google drop 20 updates/minute. I am loyal to Purebasic
This is an example of the pasted list:
Code: Select all
1 Caja 6 tetrabrick de Leche sin lactosa desnatada
1 Caja 12 botellines de cerveza especial
3 Caja 6 botellas de agua de 1.5L

Code: Select all
LoadFont(0,"Arial",12)
LoadFont(1,"Segoe UI Emoji",12)
Procedure save()
Protected p
If CreateFile(0,"milistadelacompra")
For p= 0 To CountGadgetItems(0)-1
WriteStringN(0,GetGadgetItemText(0,p,0)+"|"+GetGadgetItemText(0,p,1))
Next p
CloseFile(0)
EndIf
EndProcedure
Procedure load()
Protected t.s
ClearGadgetItems(0)
If ReadFile(0,"milistadelacompra")
While Eof(0)=0
t= ReadString(0)
If t<>""
t= ReplaceString(t,"|",Chr(10))
AddGadgetItem(0,-1, t)
EndIf
Wend
CloseFile(0)
EndIf
EndProcedure
Procedure kukilinda(a)
Protected.s ss="💘"
Protected t=50, p
Static Dim c.vector3(50)
Static Dim a.f(50)
Static Dim s.f(50)
Static Dim d.l(50)
Repeat
StartVectorDrawing(CanvasVectorOutput(1))
w= VectorOutputWidth():h=VectorOutputHeight()
VectorSourceColor(RGBA(255,200,200,255))
FillVectorOutput()
cx=w/2:cy=h/2
For p= 0 To t
If c(p)\x <= 0 Or c(p)\x >= w Or c(p)\y <= 0 Or c(p)\y >= h
c(p)\z= Random(30,10):a(p)= Radian(Random(360)):s(p)= Random(50,10)/100:d(p)=RGBA(Random(255),Random(255),Random(255),255)
EndIf
c(p)\x= cx + Cos(a(p)) * c(p)\z
c(p)\y= cy + Sin(a(p)) * c(p)\z
c(p)\z + s(p)
VectorSourceColor(d(p))
VectorFont(FontID(1), c(p)\z / 10)
MovePathCursor(c(p)\x-(VectorTextWidth(ss)/2),c(p)\y-(VectorTextHeight(ss)/2))
DrawVectorText(ss)
Next p
StopVectorDrawing()
Delay(1)
ForEver
EndProcedure
OpenWindow(0,0,0,960,540,"Shopping list - For my little wife, the prettiest!!",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
CanvasGadget(1,0,0,WindowWidth(0),50)
ListIconGadget(0,0,50,WindowWidth(0),WindowHeight(0)-50,"Units",90,#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines|#PB_ListIcon_CheckBoxes)
SetGadgetFont(0,FontID(0))
AddGadgetColumn(0,1,"Article",960)
CreatePopupMenu(0)
MenuItem(0,"Add Item")
MenuItem(1,"Change Item Units")
MenuItem(2,"Delete Item")
MenuItem(3,"Edit the article")
MenuItem(4,"Copy the list to the clipboard")
kuki= CreateThread(@kukilinda(),1)
t1.s="":t2.s="":t.s=""
load()
;{
Repeat
ev= WindowEvent()
Select ev
Case #PB_Event_Menu
em= EventMenu()
Select em
Case 0
t1= InputRequester("Add Article","Article Name. Empty cancels","")
If t1<>""
t2= InputRequester("Quantity","Number of units.","1")
t= t2+Chr(10)+t1
AddGadgetItem(0,-1,t)
EndIf
Case 1
pos= GetGadgetState(0)
If pos >= 0
t2= InputRequester("Quantity","Number of units.",GetGadgetItemText(0,pos,0))
SetGadgetItemText(0,pos,t2,0)
Else
MessageRequester("Attention","You must choose the item for which you are going to modify the units, before selecting this option.",#PB_MessageRequester_Info)
EndIf
Case 2
pos= GetGadgetState(0)
If pos >= 0
resp=MessageRequester("Delete article","Do you want to delete article?",#PB_MessageRequester_YesNo|#PB_MessageRequester_Warning)
If resp= #PB_MessageRequester_Yes
RemoveGadgetItem(0,pos)
EndIf
Else
MessageRequester("Attention","You must choose the item to delete from the list, before selecting this option.",#PB_MessageRequester_Info)
EndIf
Case 3
pos= GetGadgetState(0)
If pos >= 0
t1= InputRequester("Add Article","Article Name. Empty cancels","")
If t1<>""
SetGadgetItemText(0,pos,t1,1)
EndIf
Else
MessageRequester("Attention","You must choose the item you are going to rename, before selecting this option.",#PB_MessageRequester_Info)
EndIf
Case 4
If CountGadgetItems(0) > 0
t= ""
For p= 0 To CountGadgetItems(0)-1
If GetGadgetItemState(0,p) & #PB_ListIcon_Checked
t+ GetGadgetItemText(0,p,0)+" "+GetGadgetItemText(0,p,1)+#LF$
EndIf
Next p
SetClipboardText(t)
MessageRequester("Attention","List copied to clipboard."+#LF$+#LF$+"Use Ctrl+V to paste into another application (mail).",#PB_MessageRequester_Info)
Else
MessageRequester("Attention","The list is empty. You must add something.",#PB_MessageRequester_Info)
EndIf
EndSelect
Case #PB_Event_Gadget
eg= EventGadget()
et= EventType()
Select eg
Case 0
Select et
Case #PB_EventType_Change
save()
Case #PB_EventType_RightClick
DisplayPopupMenu(0,WindowID(0), DesktopMouseX(),DesktopMouseY())
EndSelect
EndSelect
Case #PB_Event_SizeWindow
ResizeGadget(0,0,50,WindowWidth(0),WindowHeight(0)-50)
ResizeGadget(1,0,0,WindowWidth(0),50)
Case #PB_Event_CloseWindow
save()
Break
EndSelect
; kk+1:If kk%10=0:kukilinda():EndIf
Delay(1)
ForEver
KillThread(kuki)
;}



