Code: Select all
; Basic ProjectNotepad for use in the new Editor Tools menu
; takes 1 parameter the %FILE
; Take a look at the Code Below for Further Explanations :)
ProjectName.s = ProgramParameter()
#TODO = 0 : TODOH = 60
#BUGS = 1 : BUGSH = 60
#NOTES = 2 : NOTESH = 20
#CollapseButton = 3
#SaveButton = 4
If OpenPreferences("projectnotepad.prefs")
width = ReadPreferenceLong("WindowWidth",200)
height = ReadPreferenceLong("WindowHeight",170)
winposx = ReadPreferenceLong("WindowPositionX",0)
winposy = ReadPreferenceLong("WindowPositionY",0)
collapsed = ReadPreferenceLong("Collapsed",0)
If Collapsed
lastheight = height : lastwidth = width
height = 24
EndIf
ClosePreferences()
Else
width = 200 : height = 170
winposx = GetSystemMetrics_(#SM_CXSCREEN)-width
winposy = GetSystemMetrics_(#SM_CYMENU)
EndIf
If ReadFile(0,ProjectName+".pjnf") ; (r)ro(j)ect (n)otes (f)ile
ReadString() ; move it to the second line
Repeat
ToDoContents.s = ToDoContents.s + ReadString() + Chr(13) + Chr(10)
Until Eof(0) Or Right(ToDoContents,9) = ";- Bugs"+Chr(13)+Chr(10)
ToDoContents = Left(ToDoContents,Len(ToDoContents)-11)
Repeat
BugsContents.s = BugsContents.s + ReadString() + Chr(13)+ Chr(10)
Until Eof(0) Or Right(BugsContents,10) = ";- Notes"+Chr(13)+Chr(10)
BugsContents = Left(BugsContents,Len(BugsContents)-12)
Repeat
NotesContents.s = NotesContents.s + ReadString() + Chr(13)+ Chr(10)
Until Eof(0)
NotesContents = Left(NotesContents,Len(NotesContents)-2)
CloseFile(0)
Else:ToDoContents.s = "ToDo List" :BugsContents.s = "Bugs List" :NotesContents.s = "Notes"
EndIf
;- MAIN PROGRAM
OpenWindow(0,winposx,winposy,width,height,#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget,"ProjectNotepad")
CreateGadgetList(WindowID())
ButtonGadget(#CollapseButton,width-72,2,70,20,"Collapse /\")
ButtonGadget(#SaveButton,2,2,70,20,"Save")
StringGadget(#TODO ,2, 24,width-4,TODOH,ToDoContents,#ES_MULTILINE|#ES_AUTOVSCROLL|#WS_VSCROLL)
StringGadget(#BUGS ,2,24+TODOH,width-4,BUGSH,BugsContents,#ES_MULTILINE|#ES_AUTOVSCROLL|#WS_VSCROLL)
StringGadget(#NOTES,2,24+TODOH+BUGSH,width-4,NOTESH,NotesContents,#ES_MULTILINE|#ES_AUTOVSCROLL|#WS_VSCROLL)
Repeat
wevent = WaitWindowEvent()
Gosub CheckEvent
Until wevent = #PB_EventCloseWindow
Gosub SaveLists
End
;- CheckEvent
CheckEvent:
Select wevent
Case #PB_EventGadget
Select EventGadgetID()
Case #CollapseButton
If WindowHeight() = 24
ResizeWindow(lastwidth,lastheight)
SetGadgetText(#CollapseButton,"Collapse /\")
Else
lastwidth = WindowWidth():lastheight=WindowHeight()
ResizeWindow(lastwidth,24)
SetGadgetText(#CollapseButton,"Expand \/")
EndIf
Case #SaveButton
Gosub SaveLists
EndSelect
Case #WM_SIZE
temp = WindowHeight()
TODOH = ((temp/17)*6)
BUGSH = ((temp/17)*6)
NOTESH = (temp-(29+TODOH+BUGSH))
ResizeGadget(#TODO,2,27,WindowWidth()-4,TODOH)
ResizeGadget(#BUGS,2,27+TODOH,WindowWidth()-4,BUGSH)
ResizeGadget(#NOTES,2,27+TODOH+BUGSH,WindowWidth()-4,NOTESH)
ResizeGadget(#CollapseButton,WindowWidth()-72,2,70,20)
EndSelect
If CreatePreferences("projectnotepad.prefs")
WritePreferenceLong("WindowWidth",WindowWidth())
If WindowHeight() = 24
Collapsed = 1 :
WritePreferenceLong("WindowHeight",lastHeight)
Else
Collapsed = 0
WritePreferenceLong("WindowHeight",WindowHeight())
EndIf
WritePreferenceLong("WindowPositionX",WindowX())
WritePreferenceLong("WindowPositionY",WindowY())
WritePreferenceLong("Collapsed",Collapsed)
EndIf
Return
;- SaveLists
SaveLists:
If CreateFile(0,ProjectName+".pjnf")
WriteStringN(";- Todo")
WriteStringN(GetGadgetText(#TODO))
WriteStringN(";- Bugs")
WriteStringN(GetGadgetText(#BUGS))
WriteStringN(";- Notes")
WriteStringN(GetGadgetText(#NOTES))
EndIf
Return