system.win32.bmx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. SuperStrict
  2. Import BRL.System
  3. Import "system.win32.c"
  4. Import "-lshell32"
  5. Import "-lcomctl32"
  6. Const WM_BBSYNCOP:Int=$7001 'wp=function, lp=arg
  7. Extern
  8. Function bbSystemStartup()
  9. Function bbSystemPoll()
  10. Function bbSystemWait()
  11. Function bbSystemMoveMouse( x:Int,y:Int )
  12. Function bbSystemSetMouseVisible( visible:Int )
  13. Function bbSystemNotify( text:String,serious:Int )
  14. Function bbSystemConfirm:Int( text:String,serious:Int )
  15. Function bbSystemProceed:Int( text:String,serious:Int )
  16. Function bbSystemRequestFile:String( text:String,exts:String,defext:Int,save:Int,file:String,dir:String )
  17. Function bbSystemRequestDir:String( text:String,dir:String )
  18. Function bbOpenURL:Int( url:String )
  19. Function bbSystemEmitOSEvent( hwnd:Byte Ptr,msg:Int,WParam:WParam,LParam:LParam,source:Object )
  20. Function bbSystemPostSyncOp( syncOp( syncInfo:Object,asyncRet:Int ),syncInfo:Object,asyncRet:Int )
  21. Function bbSystemStartAsyncOp( asyncOp( asyncInfo:Int ),asyncInfo:Int,syncOp( syncInfo:Object,asyncRet:Int ),syncInfo:Object )
  22. Function bbSystemDesktopWidth:Int()
  23. Function bbSystemDesktopHeight:Int()
  24. Function bbSystemDesktopDepth:Int()
  25. Function bbSystemDesktopHertz:Int()
  26. End Extern
  27. Type TWin32SystemDriver Extends TSystemDriver
  28. Method New()
  29. bbSystemStartup
  30. End Method
  31. Method Poll() Override
  32. bbSystemPoll()
  33. End Method
  34. Method Wait() Override
  35. bbSystemWait()
  36. End Method
  37. Method MoveMouse( x:Int,y:Int ) Override
  38. bbSystemMoveMouse x,y
  39. End Method
  40. Method SetMouseVisible( visible:Int ) Override
  41. bbSystemSetMouseVisible visible
  42. End Method
  43. Method Notify( Text:String,serious:Int ) Override
  44. bbSystemNotify Text,serious
  45. End Method
  46. Method Confirm:Int( Text:String,serious:Int ) Override
  47. Return bbSystemConfirm( Text,serious )
  48. End Method
  49. Method Proceed:Int( Text:String,serious:Int ) Override
  50. Return bbSystemProceed( Text,serious )
  51. End Method
  52. Method RequestFile:String( Text:String,exts:String,save:Int,path:String ) Override
  53. Local file:String,dir:String
  54. path=path.Replace( "/","\" )
  55. Local i:Int=path.FindLast( "\" )
  56. If i<>-1
  57. dir=path[..i]
  58. file=path[i+1..]
  59. Else
  60. file=path
  61. EndIf
  62. ' calculate default index of extension in extension list from path name
  63. Local ext:String,defext:Int,p:Int,q:Int
  64. p=path.Find(".")
  65. If (p>-1)
  66. ext=","+path[p+1..].toLower()+","
  67. Local exs:String=exts.toLower()
  68. exs=exs.Replace(":",":,")
  69. exs=exs.Replace(";",",;")
  70. p=exs.find(ext)
  71. If p>-1
  72. Local q:Int=-1
  73. defext=1
  74. While True
  75. q=exs.find(";",q+1)
  76. If q>p Exit
  77. If q=-1 defext=0;Exit
  78. defext:+1
  79. Wend
  80. EndIf
  81. EndIf
  82. If exts
  83. If exts.Find(":")=-1
  84. exts="Files~0*."+exts
  85. Else
  86. exts=exts.Replace(":","~0*.")
  87. EndIf
  88. exts=exts.Replace(";","~0")
  89. exts=exts.Replace(",",";*.")+"~0"
  90. EndIf
  91. Return bbSystemRequestFile( Text,exts,defext,save,file,dir )
  92. End Method
  93. Method RequestDir:String( Text:String,dir:String ) Override
  94. dir=dir.Replace( "/","\" )
  95. Return bbSystemRequestDir( Text,dir )
  96. End Method
  97. Method OpenURL:Int( url:String ) Override
  98. Return bbOpenURL( url )
  99. End Method
  100. Method DesktopWidth:Int(display:Int) Override
  101. Return bbSystemDesktopWidth()
  102. End Method
  103. Method DesktopHeight:Int(display:Int) Override
  104. Return bbSystemDesktopHeight()
  105. End Method
  106. Method DesktopDepth:Int(display:Int) Override
  107. Return bbSystemDesktopDepth()
  108. End Method
  109. Method DesktopHertz:Int(display:Int) Override
  110. Return bbSystemDesktopHertz()
  111. End Method
  112. Method Name:String() Override
  113. Return "Win32SystemDriver"
  114. End Method
  115. End Type