Home

Add

Edit

Without Linenumbers

Code in Textfield

Download

  1. '##############################################################################################################
    
  2. Dim Shared G_Screen_ReDraw  As Ubyte
    
  3. 
    
  4. 
    
  5. 
    
  6. '--------------------------------------------------------------------------------------------------------------
    
  7. Type Vektor_2D_Type
    
  8.     X   As Integer
    
  9.     Y   As Integer
    
  10. End Type
    
  11. 
    
  12. 
    
  13. 
    
  14. '--------------------------------------------------------------------------------------------------------------
    
  15. Type Debug_Type
    
  16.     V_FPS_Calc  As Integer
    
  17.     V_FPS_Draw  As Integer
    
  18. End Type
    
  19. 
    
  20. 
    
  21. 
    
  22. '--------------------------------------------------------------------------------------------------------------
    
  23. Type Form_Mouse_Type
    
  24.     V_BV        As Integer
    
  25.     V_X         As Integer
    
  26.     V_Y         As Integer
    
  27.     V_Z         As Integer
    
  28.     V_Button    As Integer
    
  29. End Type
    
  30. '--------------------------------------------------------------------------------------------------------------
    
  31. Type Form_Control_Type
    
  32.     V_InUse         As Ubyte
    
  33.     
    
  34.     V_Type          As Uinteger
    
  35.     V_Pos           As Vektor_2D_Type
    
  36.     V_Dimension     As Vektor_2D_Type
    
  37.     V_Visible       As Ubyte
    
  38.     V_Enable        As Ubyte
    
  39.     
    
  40.     T_DrawMem       As Any Ptr
    
  41.     T_Redraw        As Ubyte
    
  42. End Type
    
  43. '--------------------------------------------------------------------------------------------------------------
    
  44. Type Form_Color_Type
    
  45.     V_Back          As Uinteger
    
  46.     V_Border        As Uinteger
    
  47.     V_BorderFill    As Uinteger
    
  48.     V_Text          As Uinteger
    
  49.     V_BarBack       As Uinteger
    
  50.     V_BarText       As Uinteger
    
  51. End Type
    
  52. Type Form_Style_Type
    
  53.     V_Bar           As Ubyte
    
  54.     V_Border        As Ubyte
    
  55.     V_ButtonMax     As Ubyte
    
  56.     V_ButtonMin     As Ubyte
    
  57.     V_ButtonExit    As Ubyte
    
  58. End Type
    
  59. Type Form_Type
    
  60.     V_InUse         As Ubyte
    
  61.     
    
  62.     V_FID           As Uinteger
    
  63.     V_Pos           As Vektor_2D_Type
    
  64.     V_Dimension     As Vektor_2D_Type
    
  65.     V_Visible       As Ubyte
    
  66.     V_Enable        As Ubyte
    
  67.     V_Color         As Form_Color_Type
    
  68.     V_Style         As Form_Style_Type
    
  69.     V_Caption       As String
    
  70.     V_Sizeable      As Ubyte
    
  71.     
    
  72.     T_DrawMem       As Any Ptr
    
  73.     T_Redraw        As Ubyte
    
  74.     
    
  75.     V_ControlD      As Form_Control_Type Ptr
    
  76.     V_ControlC      As Uinteger
    
  77. End Type
    
  78. '--------------------------------------------------------------------------------------------------------------
    
  79. Dim Shared G_FormD()        As Form_Type
    
  80. Dim Shared G_FormZ()        As Uinteger
    
  81. Dim Shared G_FormC          As Uinteger
    
  82. Dim Shared G_FormIDC        As Uinteger
    
  83. '--------------------------------------------------------------------------------------------------------------
    
  84. Dim Shared G_FormMutex      As Any Ptr
    
  85. 
    
  86. 
    
  87. 
    
  88. '--------------------------------------------------------------------------------------------------------------
    
  89. Dim Shared G_FormDefauld_Color  As Form_Color_Type
    
  90. Dim Shared G_Form_Bar_Size      As Uinteger: G_Form_Bar_Size = 14
    
  91. Dim Shared G_Form_Border_Size   As Uinteger: G_Form_Border_Size = 1
    
  92. 
    
  93. 
    
  94. 
    
  95. '--------------------------------------------------------------------------------------------------------------
    
  96. Dim Shared G_Form_DebugSystem       As Ubyte: G_Form_DebugSystem = 1
    
  97. Dim Shared G_Form_Debug_Time        As Double
    
  98. Dim Shared G_Form_Debug_Data        As Debug_Type
    
  99. Dim Shared G_Form_Debug_Last        As Debug_Type
    
  100. Dim Shared G_Form_Debug_Clear       As Debug_Type
    
  101. 
    
  102. 
    
  103. 
    
  104. '--------------------------------------------------------------------------------------------------------------
    
  105. Dim Shared G_Form_Mouse_AK      As Form_Mouse_Type
    
  106. Dim Shared G_Form_Mouse_Last    As Form_Mouse_Type
    
  107. Dim Shared G_Form_Mouse_Drag    As Vektor_2D_Type
    
  108. Dim Shared G_Form_Mouse_Size    As Vektor_2D_Type
    
  109. Dim Shared G_Form_Mouse_Pos     As Vektor_2D_Type
    
  110. Dim Shared G_Form_MoveID        As Uinteger
    
  111. Dim Shared G_Form_DragID        As Uinteger
    
  112. 
    
  113. 
    
  114. 
    
  115. 
    
  116. '##############################################################################################################
    
  117. Declare Function    MKVektor2D                  (V_X As Integer, V_Y As Integer) As Vektor_2D_Type
    
  118. '--------------------------------------------------------------------------------------------------------------
    
  119. Declare Function    F_Form_Add                  (V_Position As Vektor_2D_Type, V_Dimension As Vektor_2D_Type, V_Caption As String, V_Visible As Ubyte = 1, V_Enable As Ubyte = 1, V_ShowBar As Ubyte = 1, V_Sizeable As Ubyte = 1, V_Border As Ubyte = 1, V_ButtonExit As Ubyte = 1, V_ButtonMax As Ubyte = 1, V_ButtonMin As Ubyte = 1) As Integer
    
  120. '--------------------------------------------------------------------------------------------------------------
    
  121. Declare Function    F_Form_SetFocus             (V_FID As Uinteger) As Integer
    
  122. Declare Function    F_Form_Move                 (V_FID As Uinteger, V_X As Integer, V_Y As Integer, V_MoveLock As Ubyte = 0) As Integer
    
  123. Declare Function    F_Form_Resize               (V_FID As Uinteger, V_Width As Integer, V_Height As Integer) As Integer
    
  124. '--------------------------------------------------------------------------------------------------------------
    
  125. Declare Function    F_Form_Redraw               (V_FID As Uinteger) As Integer
    
  126. Declare Function    F_Form_Refresh              () As Uinteger
    
  127. '--------------------------------------------------------------------------------------------------------------
    
  128. Declare Function    F_Form_CheckInput           () As Integer
    
  129. Declare Function    F_Form_GetFID_OnMouse       (V_X As Integer, V_Y As Integer) As Uinteger
    
  130. Declare Function    F_Form_CheckBorderDrag      (V_FID As Uinteger, V_X As Integer, V_Y As Integer) As Uinteger
    
  131. 
    
  132. 
    
  133. 
    
  134. 
    
  135. '##############################################################################################################
    
  136. Function MKVektor2D(V_X As Integer, V_Y As Integer) As Vektor_2D_Type
    
  137. Dim T As Vektor_2D_Type
    
  138. T.X = V_X
    
  139. T.Y = V_Y
    
  140. Return T
    
  141. End Function
    
  142. 
    
  143. 
    
  144. 
    
  145. 
    
  146. 
    
  147. '##############################################################################################################
    
  148. Function F_Form_Add(V_Position As Vektor_2D_Type, V_Dimension As Vektor_2D_Type, V_Caption As String, V_Visible As Ubyte = 1, V_Enable As Ubyte = 1, V_ShowBar As Ubyte = 1, V_Sizeable As Ubyte = 1, V_Border As Ubyte = 1, V_ButtonExit As Ubyte = 1, V_ButtonMax As Ubyte = 1, V_ButtonMin As Ubyte = 1) As Integer
    
  149. If V_Dimension.X < G_Form_Bar_Size Or V_Dimension.Y < G_Form_Bar_Size Then Return 0
    
  150. Dim FID As Uinteger
    
  151. Mutexlock(G_FormMutex)
    
  152. For X As Uinteger = 1 To G_FormC
    
  153.     If G_FormD(X).V_InUse = 0 Then FID = X: Exit For
    
  154. Next
    
  155. If FID = 0 Then
    
  156.     G_FormC += 1
    
  157.     FID = G_FormC
    
  158.     Redim Preserve G_FormD(G_FormC) As Form_Type
    
  159.     Redim Preserve G_FormZ(G_FormC) As Uinteger
    
  160. End If
    
  161. Dim FOK As Ubyte
    
  162. Do
    
  163.     FOK = 1
    
  164.     G_FormIDC += 1
    
  165.     If G_FormIDC = 0 Then G_FormIDC = 1
    
  166.     For X As Uinteger = 1 To G_FormC
    
  167.         If G_FormD(X).V_InUse = 1 And G_FormD(X).V_FID = G_FormIDC Then FOK = 0: Exit For
    
  168.     Next
    
  169.     If FOK = 1 Then Exit Do
    
  170. Loop
    
  171. Dim XFIDC As Uinteger = G_FormIDC
    
  172. With G_FormD(FID)
    
  173.     .V_InUse        = 1
    
  174.     .V_FID          = XFIDC
    
  175.     .V_Enable       = V_Enable
    
  176.     .V_Visible      = V_Visible
    
  177.     .V_Pos          = V_Position
    
  178.     .V_Dimension    = V_Dimension
    
  179.     .V_Caption      = V_Caption
    
  180.     .T_Redraw       = 1
    
  181.     .V_Color        = G_FormDefauld_Color
    
  182.     .V_Sizeable     = V_Sizeable
    
  183.     With .V_Style
    
  184.         .V_Bar          = V_ShowBar
    
  185.         .V_Border       = V_Border
    
  186.         .V_ButtonMax    = V_ButtonMax
    
  187.         .V_ButtonMin    = V_ButtonMin
    
  188.         .V_ButtonExit   = V_ButtonExit
    
  189.     End With
    
  190.     If .T_DrawMem <> 0 Then Imagedestroy(.T_DrawMem)
    
  191.     .T_DrawMem      = Imagecreate(.V_Dimension.X, .V_Dimension.Y, 24)
    
  192. End With
    
  193. Mutexunlock(G_FormMutex)
    
  194. F_Form_SetFocus(XFIDC)
    
  195. Return XFIDC
    
  196. End Function
    
  197. 
    
  198. 
    
  199. '--------------------------------------------------------------------------------------------------------------
    
  200. Function F_Form_Del(V_FID As Uinteger) As Integer
    
  201. Mutexlock(G_FormMutex)
    
  202. For X As Uinteger = 1 To G_FormC
    
  203.     If G_FormD(X).V_FID = V_FID Then
    
  204.         If G_FormD(X).V_InUse = 1 Then
    
  205.             With G_FormD(X)
    
  206.                 .V_InUse = 0
    
  207.                 If .V_ControlC > 0 Then
    
  208.                     If .V_ControlD <> 0 Then Deallocate(.V_ControlD)
    
  209.                     .V_ControlD = 0
    
  210.                     .V_ControlC = 0
    
  211.                 End If
    
  212.                 If .T_DrawMem <> 0 Then Imagedestroy(.T_DrawMem)
    
  213.             End With
    
  214.         End If
    
  215.         Mutexunlock(G_FormMutex)
    
  216.         Return V_FID
    
  217.     End If
    
  218. Next
    
  219. Mutexunlock(G_FormMutex)
    
  220. Return 0
    
  221. End Function
    
  222. 
    
  223. 
    
  224. '--------------------------------------------------------------------------------------------------------------
    
  225. Sub F_Form_Clear()
    
  226. Mutexlock(G_FormMutex)
    
  227. For X As Uinteger = 1 To G_FormC
    
  228.     If G_FormD(X).V_InUse = 1 Then
    
  229.         With G_FormD(X)
    
  230.             .V_InUse = 0
    
  231.             If .V_ControlC > 0 Then
    
  232.                 If .V_ControlD <> 0 Then Deallocate(.V_ControlD)
    
  233.                 .V_ControlD = 0
    
  234.                 .V_ControlC = 0
    
  235.             End If
    
  236.             If .T_DrawMem <> 0 Then Imagedestroy(.T_DrawMem)
    
  237.         End With
    
  238.     End If
    
  239. Next
    
  240. Mutexunlock(G_FormMutex)
    
  241. End Sub
    
  242. 
    
  243. 
    
  244. 
    
  245. 
    
  246. 
    
  247. '##############################################################################################################
    
  248. Function F_Form_SetFocus(V_FID As Uinteger) As Integer
    
  249. Mutexlock(G_FormMutex)
    
  250. Dim XSID As Uinteger = 0
    
  251. Dim XFID As Uinteger = 0
    
  252. For X As Uinteger = 1 To G_FormC
    
  253.     If G_FormZ(X) > 0 Then
    
  254.         If G_FormD(G_FormZ(X)).V_FID = V_FID Then XFID = X: Exit For
    
  255.     Else: If XSID = 0 Then XSID = X
    
  256.     End If
    
  257. Next
    
  258. If XFID = 0 Then XFID = XSID
    
  259. If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
    
  260. If XFID = 1 And G_FormC > 1 Then Mutexunlock(G_FormMutex): Return V_FID
    
  261. For X As Uinteger = XFID - 1 To 1 Step -1
    
  262.     G_FormZ(X + 1) = G_FormZ(X)
    
  263. Next
    
  264. G_FormZ(1) = V_FID
    
  265. Mutexunlock(G_FormMutex)
    
  266. F_Form_Redraw(V_FID)
    
  267. Return V_FID
    
  268. End Function
    
  269. 
    
  270. 
    
  271. '--------------------------------------------------------------------------------------------------------------
    
  272. Function F_Form_Move(V_FID As Uinteger, V_X As Integer, V_Y As Integer, V_MoveLock As Ubyte = 0) As Integer
    
  273. Mutexlock(G_FormMutex)
    
  274. Dim XFID As Uinteger = 0
    
  275. For X As Uinteger = 1 To G_FormC
    
  276.     If G_FormD(X).V_FID = V_FID Then XFID = X: Exit For
    
  277. Next
    
  278. If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
    
  279. With G_FormD(XFID)
    
  280.     If V_MoveLock <> 1 Then .V_Pos.X = V_X
    
  281.     If V_MoveLock <> 2 Then .V_Pos.Y = V_Y
    
  282. End With
    
  283. G_Screen_ReDraw = 1
    
  284. Mutexunlock(G_FormMutex)
    
  285. Return V_FID
    
  286. End Function
    
  287. 
    
  288. 
    
  289. '--------------------------------------------------------------------------------------------------------------
    
  290. Function F_Form_Resize(V_FID As Uinteger, V_Width As Integer, V_Height As Integer) As Integer
    
  291. Mutexlock(G_FormMutex)
    
  292. Dim XFID As Uinteger = 0
    
  293. For X As Uinteger = 1 To G_FormC
    
  294.     If G_FormD(X).V_FID = V_FID Then XFID = X: Exit For
    
  295. Next
    
  296. If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
    
  297. With G_FormD(XFID)
    
  298.     If V_Width > 0 Then .V_Dimension.X = V_Width
    
  299.     If V_Height > 0 Then .V_Dimension.Y = V_Height
    
  300.     If .T_DrawMem <> 0 Then Imagedestroy(.T_DrawMem)
    
  301.     .T_DrawMem = Imagecreate(.V_Dimension.X, .V_Dimension.Y, 24)
    
  302.     .T_Redraw = 1
    
  303. End With
    
  304. G_Screen_ReDraw = 1
    
  305. Mutexunlock(G_FormMutex)
    
  306. Return V_FID
    
  307. End Function
    
  308. 
    
  309. 
    
  310. 
    
  311. 
    
  312. 
    
  313. '##############################################################################################################
    
  314. Function F_Form_Control_Add(V_FID As Uinteger, V_Type As Uinteger, V_Position As Vektor_2D_Type, V_Dimension As Vektor_2D_Type, V_Visible As Ubyte = 1, V_Enable As Ubyte = 1) As Integer
    
  315. If V_Dimension.X < 1 Or V_Dimension.Y < 1 Then Return 0
    
  316. Mutexlock(G_FormMutex)
    
  317. Dim XFID As Uinteger = 0
    
  318. For X As Uinteger = 1 To G_FormC
    
  319.     If G_FormD(X).V_FID = V_FID Then XFID = X: Exit For
    
  320. Next
    
  321. If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
    
  322. Dim XCID As Uinteger
    
  323. With G_FormD(XFID)
    
  324.     For X As Uinteger = 1 To .V_ControlC
    
  325.         If .V_ControlD[X].V_InUse = 0 Then XCID = X: Exit For
    
  326.     Next
    
  327.     Dim XTCD As Form_Control_Type
    
  328.     If XCID = 0 Then
    
  329.         If .V_ControlC = 0 Then .V_ControlD = Allocate(Sizeof(Form_Control_Type) + 1)
    
  330.         .V_ControlC += 1
    
  331.         XCID = .V_ControlC
    
  332.         .V_ControlD = Reallocate(.V_ControlD, Sizeof(Form_Control_Type) + 1)
    
  333.     End If
    
  334.     Dim FOK As Ubyte
    
  335.     With XTCD
    
  336.         .V_InUse        = 1
    
  337.         .V_Enable       = V_Enable
    
  338.         .V_Visible      = V_Visible
    
  339.         .V_Pos          = V_Position
    
  340.         .V_Dimension    = V_Dimension
    
  341.         .T_Redraw       = 1
    
  342.         If .T_DrawMem <> 0 Then Imagedestroy(.T_DrawMem)
    
  343.         .T_DrawMem      = Imagecreate(.V_Dimension.X, .V_Dimension.Y, 24)
    
  344.     End With
    
  345.     .V_ControlD[XCID] = XTCD
    
  346.     .T_Redraw = 1
    
  347. End With
    
  348. Mutexunlock(G_FormMutex)
    
  349. G_Screen_ReDraw = 1
    
  350. Return XCID
    
  351. End Function
    
  352. 
    
  353. 
    
  354. 
    
  355. 
    
  356. 
    
  357. '##############################################################################################################
    
  358. Function F_Form_Redraw(V_FID As Uinteger) As Integer
    
  359. Mutexlock(G_FormMutex)
    
  360. Dim XFID As Uinteger = 0
    
  361. For X As Uinteger = 1 To G_FormC
    
  362.     If G_FormD(X).V_FID = V_FID Then XFID = X: Exit For
    
  363. Next
    
  364. If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
    
  365. If G_FormD(XFID).V_InUse = 0 Or G_FormD(XFID).T_Redraw = 0 Then Mutexunlock(G_FormMutex): Return 0
    
  366. With G_FormD(XFID)
    
  367.     If .V_InUse = 1 And .T_Redraw = 1 Then
    
  368.         For X As Uinteger = 1 To .V_ControlC
    
  369.             If .V_ControlD[X].V_InUse = 1 And .V_ControlD[X].V_Visible = 1 Then
    
  370.                 If .V_ControlD[X].T_Redraw = 1 Then
    
  371.                     
    
  372.                 End If
    
  373.                 With .V_ControlD[X]
    
  374.                     Put G_FormD(XFID).T_DrawMem, (.V_Pos.X, .V_Pos.Y), .T_DrawMem, (0, 0)-(.V_Dimension.X, .V_Dimension.Y), Pset
    
  375.                 End With
    
  376.             End If
    
  377.         Next
    
  378.         Line .T_DrawMem, (0, 0)-(.V_Dimension.X - 1, .V_Dimension.Y - 1), .V_Color.V_Back, BF
    
  379.         If .V_Style.V_Bar = 1 Then
    
  380.             Line .T_DrawMem, (0, 0)-(.V_Dimension.X - 1, G_Form_Bar_Size + G_Form_Border_Size * 2), .V_Color.V_BarBack, BF
    
  381.             If .V_Style.V_ButtonExit = 1 Then
    
  382.                 Draw String .T_DrawMem, (G_Form_Bar_Size * 2 + 4 + G_Form_Border_Size + 4, G_Form_Border_Size + 5), .V_Caption, .V_Color.V_BarText
    
  383.             Else: Draw String .T_DrawMem, (G_Form_Border_Size + 4, G_Form_Border_Size + 5), .V_Caption, .V_Color.V_BarText
    
  384.             End If
    
  385.         End If
    
  386.         If .V_Style.V_Border = 1 Then
    
  387.             Line .T_DrawMem, (0, 0)-(.V_Dimension.X - 1, .V_Dimension.Y - 1), .V_Color.V_Border, B
    
  388.             For X As Uinteger = 1 To G_Form_Border_Size
    
  389.                 Line .T_DrawMem, (X, X)-(.V_Dimension.X - X - 1, .V_Dimension.Y - X - 1), .V_Color.V_BorderFill, B
    
  390.             Next
    
  391.             If .V_Style.V_Bar = 1 Then
    
  392.                 Line .T_DrawMem, (G_Form_Border_Size + 1, G_Form_Bar_Size + G_Form_Border_Size + 3)-(.V_Dimension.X - G_Form_Border_Size - 2, G_Form_Bar_Size + (G_Form_Border_Size * 2) + 2), .V_Color.V_BorderFill, BF
    
  393.                 Line .T_DrawMem, (G_Form_Border_Size + 1, G_Form_Border_Size + 1)-(.V_Dimension.X - G_Form_Border_Size - 2, G_Form_Bar_Size + G_Form_Border_Size + 2), .V_Color.V_Border, B
    
  394.                 Line .T_DrawMem, (G_Form_Border_Size + 1, G_Form_Bar_Size + (G_Form_Border_Size * 2) + 3)-(.V_Dimension.X - G_Form_Border_Size - 2, .V_Dimension.Y - G_Form_Border_Size - 2), .V_Color.V_Border, B
    
  395.                 If .V_Style.V_ButtonMax = 1 Then
    
  396.                     Line .T_DrawMem, (.V_Dimension.X - (G_Form_Border_Size + 2), G_Form_Border_Size + 2)-(.V_Dimension.X - (G_Form_Border_Size + G_Form_Bar_Size * 2 + 1), G_Form_Border_Size + G_Form_Bar_Size + 1), .V_Color.V_BorderFill, BF
    
  397.                     Line .T_DrawMem, (.V_Dimension.X - (G_Form_Border_Size + 2), G_Form_Border_Size + 2)-(.V_Dimension.X - (G_Form_Border_Size + G_Form_Bar_Size * 2  + 1), G_Form_Border_Size + G_Form_Bar_Size + 1), .V_Color.V_Border, B
    
  398.                 End If
    
  399.                 If .V_Style.V_ButtonExit = 1 Then
    
  400.                     Line .T_DrawMem, (G_Form_Border_Size + 2, G_Form_Border_Size + 2)-(G_Form_Border_Size + G_Form_Bar_Size * 2  + 1, G_Form_Border_Size + G_Form_Bar_Size + 1), .V_Color.V_BorderFill, BF
    
  401.                     Line .T_DrawMem, (G_Form_Border_Size + 2, G_Form_Border_Size + 2)-(G_Form_Border_Size + G_Form_Bar_Size * 2  + 1, G_Form_Border_Size + G_Form_Bar_Size + 1), .V_Color.V_Border, B
    
  402.                     Draw String .T_DrawMem, (G_Form_Bar_Size - (G_Form_Bar_Size / 2) + 2 + G_Form_Border_Size + 4, G_Form_Border_Size + 5), "X", .V_Color.V_BarText
    
  403.                 End If
    
  404.             Else: Line .T_DrawMem, (G_Form_Border_Size + 1, G_Form_Border_Size + 1)-(.V_Dimension.X - G_Form_Border_Size - 2, .V_Dimension.Y - G_Form_Border_Size - 2), .V_Color.V_Border, B
    
  405.             End If
    
  406.         End If
    
  407.         .T_Redraw = 0
    
  408.     End If
    
  409. End With
    
  410. Mutexunlock(G_FormMutex)
    
  411. G_Screen_ReDraw = 1
    
  412. Return V_FID
    
  413. End Function
    
  414. 
    
  415. 
    
  416. '--------------------------------------------------------------------------------------------------------------
    
  417. Function F_Form_Control_Redraw(V_FID As Uinteger) As Integer
    
  418. Mutexlock(G_FormMutex)
    
  419. Mutexunlock(G_FormMutex)
    
  420. Return V_FID
    
  421. End Function
    
  422. 
    
  423. 
    
  424. 
    
  425. 
    
  426. 
    
  427. '##############################################################################################################
    
  428. Function F_Form_Refresh() As Uinteger
    
  429. If G_Screen_ReDraw = 0 Then Return 0
    
  430. Dim FCR As Uinteger
    
  431. Dim XFID As Uinteger
    
  432. Mutexlock(G_FormMutex)
    
  433. For X As Uinteger = 1 To G_FormC
    
  434.     If G_FormZ(X) > 0 Then
    
  435.         With G_FormD(G_FormZ(X))
    
  436.             If .V_InUse = 1 And .T_Redraw = 1 Then
    
  437.                 XFID = G_FormZ(X)
    
  438.                 Mutexunlock(G_FormMutex)
    
  439.                 F_Form_Redraw(XFID)
    
  440.                 Mutexlock(G_FormMutex)
    
  441.                 FCR += 1
    
  442.             End If
    
  443.         End With
    
  444.     End If
    
  445. Next
    
  446. Screenlock
    
  447. Line (0, 0)-(1024, 768), 0, BF
    
  448. For X As Uinteger = G_FormC To 1 Step -1
    
  449.     If G_FormZ(X) > 0 Then
    
  450.         With G_FormD(G_FormZ(X))
    
  451.             Put (.V_Pos.X, .V_Pos.Y), .T_DrawMem, (0, 0)-(.V_Dimension.X, .V_Dimension.Y), Pset
    
  452.         End With
    
  453.     End If
    
  454. Next
    
  455. 
    
  456. If G_Form_DebugSystem = 1 Then
    
  457.     With G_Form_Mouse_AK
    
  458.         Locate 1, 1
    
  459.         Print "FPS_Calc: " & G_Form_Debug_Data.V_FPS_Calc
    
  460.         Print "FPS_Draw: " & G_Form_Debug_Data.V_FPS_Draw
    
  461.         Print ""
    
  462.         Print "Maus_X:" & .V_X
    
  463.         Print "Maus_Y:" & .V_Y
    
  464.         Print "Maus_Z:" & .V_Z
    
  465.         Print "Maus_B:" & .V_Button
    
  466.         Print ""
    
  467.         Print "FormC: " & G_FormC
    
  468.         Print "FormZ: ";
    
  469.         For X As Uinteger = 1 To G_FormC
    
  470.             Print G_FormZ(X) & " ";
    
  471.         Next
    
  472.         Print ""
    
  473.         Print "FID_Move: " & G_Form_MoveID
    
  474.         Print "FID_Drag: " & G_Form_DragID
    
  475.     End With
    
  476. End If
    
  477. 
    
  478. Screenunlock
    
  479. If G_Form_DebugSystem = 1 Then G_Form_Debug_Last.V_FPS_Draw += 1
    
  480. Mutexunlock(G_FormMutex)
    
  481. Return FCR
    
  482. End Function
    
  483. 
    
  484. 
    
  485. 
    
  486. 
    
  487. 
    
  488. '##############################################################################################################
    
  489. Function F_Form_CheckInput() As Integer
    
  490. If G_Form_DebugSystem = 1 Then
    
  491.     If G_Form_Debug_Time <= Timer Then
    
  492.         G_Form_Debug_Data = G_Form_Debug_Last
    
  493.         G_Form_Debug_Last = G_Form_Debug_Clear
    
  494.         G_Form_Debug_Time = Timer + 1
    
  495.     End If
    
  496. End If
    
  497. Dim MX As Integer
    
  498. Dim MY As Integer
    
  499. Dim MZ As Integer
    
  500. Dim MB As Integer
    
  501. Dim BV As Integer
    
  502. If G_Form_DebugSystem = 1 Then G_Form_Mouse_Last = G_Form_Mouse_AK
    
  503. With G_Form_Mouse_AK
    
  504.     .V_BV = Getmouse(.V_X, .V_Y, .V_Z, .V_Button)
    
  505.     If .V_BV <> 0 Then
    
  506.         If G_Form_DebugSystem = 1 Then F_Form_Refresh()
    
  507.         Return -1 'unbekannter Fehler
    
  508.     End If
    
  509.     If .V_Button = -1 Then
    
  510.         If G_Form_DebugSystem = 1 Then F_Form_Refresh()
    
  511.         Return -2 'Keine Maus gefunden
    
  512.     End If
    
  513.     If .V_X = G_Form_Mouse_Last.V_X And G_Form_Mouse_Last.V_Y = .V_Y And G_Form_Mouse_Last.V_Z = .V_Z And G_Form_Mouse_Last.V_Button = .V_Button Then F_Form_Refresh(): Return 0
    
  514.     G_Form_Debug_Last.V_FPS_Calc += 1
    
  515.     Dim XFID As Uinteger
    
  516.     If .V_Button = 1 Then
    
  517.         If G_Form_MoveID = 0 Then
    
  518.             XFID = F_Form_GetFID_OnMouse(.V_X, .V_Y)
    
  519.             If XFID > 0 Then
    
  520.                 G_Form_DragID = F_Form_CheckBorderDrag(XFID, .V_X, .V_Y)
    
  521.                 If G_Form_Mouse_Last.V_Button = 0 Then
    
  522.                     G_Form_MoveID = XFID
    
  523.                     Mutexlock(G_FormMutex)
    
  524.                     If G_Form_DragID > 0 Then
    
  525.                         G_Form_Mouse_Drag.X = .V_X
    
  526.                         G_Form_Mouse_Drag.Y = .V_Y
    
  527.                         G_Form_Mouse_Size = G_FormD(XFID).V_Dimension
    
  528.                     End If
    
  529.                     G_Form_Mouse_Pos.X = G_FormD(XFID).V_Pos.X - .V_X
    
  530.                     G_Form_Mouse_Pos.Y = G_FormD(XFID).V_Pos.Y - .V_Y
    
  531.                     Mutexunlock(G_FormMutex)
    
  532.                     F_Form_SetFocus(XFID)
    
  533.                 End If
    
  534.             Else: G_Form_DragID = 0
    
  535.             End If
    
  536.         Else
    
  537.             If G_Form_MoveID > 0 Then
    
  538.                 Select Case G_Form_DragID
    
  539.                     Case 0: If F_Form_Move(G_Form_MoveID, G_Form_Mouse_Pos.X + .V_X, G_Form_Mouse_Pos.Y + .V_Y) = 0 Then G_Form_MoveID = 0
    
  540.                     Case 1
    
  541.                         If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X - .V_X + G_Form_Mouse_Drag.X, 0) = 0 Then G_Form_MoveID = 0
    
  542.                         If F_Form_Move(G_Form_MoveID, G_Form_Mouse_Drag.X + .V_X - G_Form_Mouse_Drag.X + G_Form_Mouse_Pos.X, 0, 2) = 0 Then G_Form_MoveID = 0
    
  543.                     Case 2: If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X + .V_X - G_Form_Mouse_Drag.X, 0) = 0 Then G_Form_MoveID = 0
    
  544.                     Case 4
    
  545.                         If F_Form_Resize(G_Form_MoveID, 0, G_Form_Mouse_Size.Y - .V_Y + G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0
    
  546.                         If F_Form_Move(G_Form_MoveID, 0, G_Form_Mouse_Drag.Y + .V_Y - G_Form_Mouse_Drag.Y + G_Form_Mouse_Pos.Y, 1) = 0 Then G_Form_MoveID = 0
    
  547.                     Case 8: If F_Form_Resize(G_Form_MoveID, 0, G_Form_Mouse_Size.Y + .V_Y - G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0
    
  548.                     Case 5
    
  549.                         If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X - .V_X + G_Form_Mouse_Drag.X, G_Form_Mouse_Size.Y - .V_Y + G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0                      
    
  550.                         If F_Form_Move(G_Form_MoveID, G_Form_Mouse_Drag.X + .V_X - G_Form_Mouse_Drag.X + G_Form_Mouse_Pos.X, G_Form_Mouse_Drag.Y + .V_Y - G_Form_Mouse_Drag.Y + G_Form_Mouse_Pos.Y, 0) = 0 Then G_Form_MoveID = 0
    
  551.                     Case 6
    
  552.                         If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X + .V_X - G_Form_Mouse_Drag.X, G_Form_Mouse_Size.Y - .V_Y + G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0
    
  553.                         If F_Form_Move(G_Form_MoveID, 0, G_Form_Mouse_Drag.Y + .V_Y - G_Form_Mouse_Drag.Y + G_Form_Mouse_Pos.Y, 1) = 0 Then G_Form_MoveID = 0
    
  554.                     Case 9
    
  555.                         If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X - .V_X + G_Form_Mouse_Drag.X, G_Form_Mouse_Size.Y + .V_Y - G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0
    
  556.                         If F_Form_Move(G_Form_MoveID, G_Form_Mouse_Drag.X + .V_X - G_Form_Mouse_Drag.X + G_Form_Mouse_Pos.X, 0, 2) = 0 Then G_Form_MoveID = 0
    
  557.                     Case 10: If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X + .V_X - G_Form_Mouse_Drag.X, G_Form_Mouse_Size.Y + .V_Y - G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0
    
  558.                 End Select
    
  559.             End If
    
  560.         End If
    
  561.     Else
    
  562.         G_Form_MoveID = 0
    
  563.         G_Form_DragID = 0
    
  564.     End If
    
  565.     F_Form_Refresh()
    
  566. End With
    
  567. Return XFID
    
  568. End Function
    
  569. 
    
  570. 
    
  571. '--------------------------------------------------------------------------------------------------------------
    
  572. Function F_Form_GetFID_OnMouse(V_X As Integer, V_Y As Integer) As Uinteger
    
  573. Mutexlock(G_FormMutex)
    
  574. For X As Uinteger = 1 To G_FormC
    
  575.     With G_FormD(G_FormZ(X))
    
  576.         If .V_InUse = 1 And .V_Visible = 1 Then
    
  577.             If V_X >= .V_Pos.X And V_X <= .V_Pos.X + .V_Dimension.X And V_Y >= .V_Pos.Y And V_Y <= .V_Pos.Y + .V_Dimension.Y Then
    
  578.                 Dim XFID As Uinteger = G_FormD(G_FormZ(X)).V_FID
    
  579.                 Mutexunlock(G_FormMutex)
    
  580.                 Return XFID
    
  581.             End If
    
  582.         End If
    
  583.     End With
    
  584. Next
    
  585. Mutexunlock(G_FormMutex)
    
  586. Return 0
    
  587. End Function
    
  588. 
    
  589. 
    
  590. '--------------------------------------------------------------------------------------------------------------
    
  591. Function F_Form_CheckBorderDrag(V_FID As Uinteger, V_X As Integer, V_Y As Integer) As Uinteger
    
  592. Mutexlock(G_FormMutex)
    
  593. Dim XFID As Uinteger = 0
    
  594. For X As Uinteger = 1 To G_FormC
    
  595.     If G_FormD(X).V_FID = V_FID Then XFID = X: Exit For
    
  596. Next
    
  597. If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
    
  598. If G_FormD(XFID).V_InUse = 0 Then Mutexunlock(G_FormMutex): Return 0
    
  599. Dim XDID As Uinteger
    
  600. With G_FormD(XFID)
    
  601.     If V_X >= .V_Pos.X And V_X <= .V_Pos.X + G_Form_Border_Size + 2 Then XDID = XDID Or 1
    
  602.     If V_X <= .V_Pos.X + .V_Dimension.X And V_X >= .V_Pos.X + .V_Dimension.X - G_Form_Border_Size - 2 Then XDID = XDID Or 2
    
  603.     If V_Y >= .V_Pos.Y And V_Y <= .V_Pos.Y + G_Form_Border_Size + 2 Then XDID = XDID Or 4
    
  604.     If V_Y <= .V_Pos.Y + .V_Dimension.Y And V_Y >= .V_Pos.Y + .V_Dimension.Y - G_Form_Border_Size - 2 Then XDID = XDID Or 8
    
  605. End With
    
  606. Mutexunlock(G_FormMutex)
    
  607. Return XDID
    
  608. End Function
    
  609. 
    
  610. 
    
  611.