Last active
May 4, 2023 03:52
-
-
Save aliustaoglu/697f10b36aa2da143928cc7427f6c26e to your computer and use it in GitHub Desktop.
PureBasic macOS Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Procedure OnFilesDropped() | |
Protected files.s, count, i | |
files = EventDropFiles() | |
count = CountString(files, Chr(10)) | |
For i = 0 To count | |
Debug StringField(files, i + 1, Chr(10)) | |
Next | |
EndProcedure | |
If OpenWindow(0, 0, 0, 350, 250, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) | |
EnableWindowDrop(0, #PB_Drop_Files, #PB_Drag_Copy) | |
BindEvent(#PB_Event_WindowDrop, @OnFilesDropped(), 0) | |
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow | |
EndIf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;-TOP | |
#ProgramTitle = "Main Window" | |
#ProgramVersion = "v1.01.2" | |
Enumeration Windows | |
#Main | |
EndEnumeration | |
Enumeration MenuBar | |
#MainMenu | |
EndEnumeration | |
Enumeration MenuItems | |
#MainMenuAbout | |
#MainMenuExit | |
EndEnumeration | |
Enumeration Gadgets | |
EndEnumeration | |
Enumeration StatusBar | |
#MainStatusBar | |
EndEnumeration | |
Procedure UpdateWindow() | |
Protected dx, dy | |
dx = WindowWidth(#Main) | |
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight() | |
; Resize gadgets | |
EndProcedure | |
Procedure Main() | |
Protected dx, dy | |
#MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | |
If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, #ProgramTitle , #MainStyle) | |
; Menu | |
CreateMenu(#MainMenu, WindowID(#Main)) | |
MenuTitle("&File") | |
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS | |
MenuItem(#PB_Menu_About, "") | |
CompilerElse | |
MenuItem(#MainMenuAbout, "About") | |
CompilerEndIf | |
; Menu File Items | |
CompilerIf Not #PB_Compiler_OS = #PB_OS_MacOS | |
MenuBar() | |
MenuItem(#MainMenuExit, "E&xit") | |
CompilerEndIf | |
; StatusBar | |
CreateStatusBar(#MainStatusBar, WindowID(#Main)) | |
AddStatusBarField(#PB_Ignore) | |
; Gadgets | |
dx = WindowWidth(#Main) | |
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight() | |
; Bind Events | |
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main) | |
; Event Loop | |
Repeat | |
Select WaitWindowEvent() | |
Case #PB_Event_CloseWindow | |
Select EventWindow() | |
Case #Main | |
Break | |
EndSelect | |
Case #PB_Event_Menu | |
Select EventMenu() | |
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS | |
Case #PB_Menu_About | |
PostEvent(#PB_Event_Menu, #Main, #MainMenuAbout) | |
Case #PB_Menu_Preferences | |
Case #PB_Menu_Quit | |
PostEvent(#PB_Event_CloseWindow, #Main, #Null) | |
CompilerEndIf | |
Case #MainMenuAbout | |
MessageRequester("About", #ProgramTitle + #LF$ + #ProgramVersion, #PB_MessageRequester_Info) | |
Case #MainMenuExit | |
PostEvent(#PB_Event_CloseWindow, #Main, #Null) | |
EndSelect | |
Case #PB_Event_Gadget | |
Select EventGadget() | |
EndSelect | |
EndSelect | |
ForEver | |
EndIf | |
EndProcedure : Main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment