I'm making a simple paper based shopping list, much like the one my wife uses and although there is more i have to do to it down the track, it's good enough for a start.
It uses code from that insufferably brainless baboon srod, which you will find here: http://www.purebasic.fr/english/viewtopic.php?t=27012 to allow you to edit the cells of the listicongadget directly and you inlude it the way I did at the top,. :evil: :twisted: :evil: :twisted: :evil: :twisted:
Saves the list on program exit, loads the list at program start. Click on a cell to edit it. That's it!
NOTE: As usual, find your own images:):)
[code];===========================================================================================================================
;
;===========================================================================================================================
XIncludeFile "\Development\Resources\Modules\_EditableListIconGadget.pbi"
;===========================================================================================================================
;
;===========================================================================================================================
Enumeration 1
#Window_paperlist
EndEnumeration
#WindowIndex = #PB_Compiler_EnumerationValue
Enumeration 1
#Gadget_paperlist_items
#Gadget_paperlist_load
#Gadget_paperlist_save
#Gadget_paperlist_print
#Gadget_paperlist_ilogo
#Gadget_paperlist_lfilename
#Gadget_paperlist_exit
EndEnumeration
#GadgetIndex = #PB_Compiler_EnumerationValue
Enumeration 1
#Image_paperlist_load
#Image_paperlist_save
#Image_paperlist_print
#Image_paperlist_ilogo
#Image_paperlist_exit
EndEnumeration
#ImageIndex = #PB_Compiler_EnumerationValue
;===========================================================================================================================
;
;===========================================================================================================================
CatchImage(#Image_paperlist_load, ?_OPT_paperlist_load)
CatchImage(#Image_paperlist_save, ?_OPT_paperlist_save)
CatchImage(#Image_paperlist_print,?_OPT_paperlist_print)
CatchImage(#Image_paperlist_ilogo,?_OPT_paperlist_ilogo)
CatchImage(#Image_paperlist_exit, ?_OPT_paperlist_exit)
;===========================================================================================================================
;
;===========================================================================================================================
DataSection
_OPT_paperlist_load : IncludeBinary "Images\open32x32.ico"
_OPT_paperlist_save : IncludeBinary "Images\save32x32.ico"
_OPT_paperlist_print : IncludeBinary "Images\printer32x32.ico"
_OPT_paperlist_ilogo : IncludeBinary "Images\shoppinglist32x32.ico"
_OPT_paperlist_exit : IncludeBinary "Images\exit32x32.ico"
EndDataSection
;===========================================================================================================================
;
;===========================================================================================================================
Declare.l Window_paperlist()
Declare WindowCallback(WindowID, Message, wParam, lParam)
Declare LoadLastList()
Declare SaveCurrentList()
;===========================================================================================================================
;
;===========================================================================================================================
Procedure.l Window_paperlist()
If OpenWindow(#Window_paperlist,74,67,640,610,"<°)))o><²³ Your personal, paper based shopping list",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
If CreateGadgetList(WindowID(#Window_paperlist))
ListIconGadget(#Gadget_paperlist_items,0,0,640,568,"Column 0",0,#PB_ListIcon_GridLines|#LVS_NOCOLUMNHEADER|#PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(#Gadget_paperlist_items,1,"Column 1",212)
AddGadgetColumn(#Gadget_paperlist_items,1,"Column 2",212)
AddGadgetColumn(#Gadget_paperlist_items,2,"Column 3",212)
SetGadgetFont(#Gadget_paperlist_items,LoadFont(#Gadget_paperlist_items,"Comic Sans MS",8,0))
ButtonImageGadget(#Gadget_paperlist_load,0,570,45,40,ImageID(#Image_paperlist_load))
ButtonImageGadget(#Gadget_paperlist_save,45,570,45,40,ImageID(#Image_paperlist_save))
ButtonImageGadget(#Gadget_paperlist_print,90,570,45,40,ImageID(#Image_paperlist_print))
ImageGadget(#Gadget_paperlist_ilogo,140,575,32,32,ImageID(#Image_paperlist_ilogo))
TextGadget(#Gadget_paperlist_lfilename,175,575,420,30,"")
SetGadgetColor(#Gadget_paperlist_lfilename,#PB_Gadget_FrontColor,16777215)
SetGadgetFont(#Gadget_paperlist_lfilename,LoadFont(#Gadget_paperlist_lfilename,"Comic Sans MS",16,768))
ButtonImageGadget(#Gadget_paperlist_exit,595,570,45,40,ImageID(#Image_paperlist_exit))
HideWindow(#Window_paperlist,0)
ProcedureReturn WindowID(#Window_paperlist)
EndIf
EndIf
EndProcedure
;===========================================================================================================================
;
;===========================================================================================================================
Procedure LoadLastList()
If FileSize("ShoppingList.txt") <> -1
FileId.l = ReadFile(#PB_Any, "ShoppingList.txt")
If FileId.l <> 0
For ListLines = 0 To 34
LineIn.s = ReadString(FileId.l)
SetGadgetItemText(#Gadget_paperlist_items, ListLines.l, StringField(LineIn.s, 1, "|"), 1)
SetGadgetItemText(#Gadget_paperlist_items, ListLines.l, StringField(LineIn.s, 2, "|"), 2)
SetGadgetItemText(#Gadget_paperlist_items, ListLines.l, StringField(LineIn.s, 3, "|"), 3)
Next
CloseFile(FileId.l)
EndIf
EndIf
EndProcedure
;===========================================================================================================================
;
;===========================================================================================================================
Procedure SaveCurrentList()
FileId.l = CreateFile(#PB_Any, "ShoppingList.txt")
If FileId.l <> 0
For ListLines = 0 To 34
Column1.s = GetGadgetItemText(#Gadget_paperlist_items, ListLines.l, 1)
Column2.s = GetGadgetItemText(#Gadget_paperlist_items, ListLines.l, 2)
Column3.s = GetGadgetItemText(#Gadget_paperlist_items, ListLines.l, 3)
WriteStringN(FileId.l, Column1.s + "|" + Column2.s + "|" + Column3.s)
Next
CloseFile(FileId.l)
EndIf
EndProcedure
;===========================================================================================================================
; Load the default shopping list if available
;===========================================================================================================================
LoadLastList()
;===========================================================================================================================
;
;===========================================================================================================================
If Window_paperlist()
For Row = 1 To 35
AddGadgetItem(#Gadget_paperlist_items, -1, "")
Next
SetListIconEditable(#Gadget_paperlist_items) ; Using baboon's code to set the lsiticon editable
LoadLastList()
quitpaperlist = 0
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Window_paperlist : quitpaperlist = 1
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #Gadget_paperlist_load
Case #Gadget_paperlist_save
Case #Gadget_paperlist_print
Case #Gadget_paperlist_exit : quitpaperlist = 1
EndSelect
EndSelect
Until quitpaperlist
SaveCurrentList()
CloseWindow(#Window_paperlist)
EndIf
End
[/code]
Paper shopping list
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
means that the tags will be used, so [code] will build the codebox.
in another posting of yours I noticed your smilies are disabled, too.
disable the disable checkers attached to your posting,
and check your profile for the default settings.
(aw.. I luv such sentences.. disable² and check²)
in another posting of yours I noticed your smilies are disabled, too.
disable the disable checkers attached to your posting,
and check your profile for the default settings.
(aw.. I luv such sentences.. disable² and check²)
oh... and have a nice day.
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Code: Select all
;**********************************
[code]
;**********************************

{{ EDIT: Well... that didn't work! It serves me right for making a smartass comment!!! }}
