fb:porticula NoPaste
wxDC
Uploader: | MOD |
Datum/Zeit: | 28.04.2014 21:20:26 |
' clientdc01_wx-c.bas
#Include Once "wx-c/wx.bi"
Dim Shared As wxPanel Ptr Panel
Dim Shared As wxApp Ptr App
Dim Shared As wxColour Ptr c
Sub wxDCSetPenColor(dc As wxDC Ptr,r As wxChar, g As wxChar, b As wxChar, a As wxChar=&HFF)
Dim As wxColour Ptr colour = wxColour_ctorByPartsWithAlpha(r,g,b,a)
Dim As wxPen Ptr pen = wxDC_GetPen(dc)
wxPen_SetColour(pen,colour)
wxDC_SetPen(dc,pen)
wxColour_dtor(colour)
End Sub
Sub EventListener WXCALL(event As wxEvent Ptr,iListener As wxInt)
' allocate a client DC
Dim As wxDC Ptr dc = CPtr(_wxDC Ptr,wxClientDC_ctor2(Panel))
' use it
wxDC_Clear(dc)
For i As Integer = 1 To 3
wxDCSetPenColor(dc,Rnd*255,Rnd*255,Rnd*255)
wxDC_DrawCircle(dc, Rnd*640, Rnd*480, 1+Rnd*240)
Next
For i As Integer = 1 To 30
wxDCSetPenColor(dc,Rnd*255,Rnd*255,Rnd*255)
wxDC_DrawLine (dc, Rnd*640, Rnd*480, Rnd*640, Rnd*480)
Next
For i As Integer = 1 To 10
wxColour_Set(c,Rnd*255,Rnd*255,Rnd*255,Rnd*255)
wxDC_SetTextForeground(dc,c)
wxDC_DrawRotatedText(dc, wxString_ctorUTF8("Hello world!"), Rnd*640, Rnd*480, Rnd*360)
Next
' release it
wxDC_dtor(dc)
End Sub
Function OnInit WXCALL As wxBool
Dim As wxFrame Ptr Frame=wxFrame_ctor()
wxFrame_Create(Frame,WX_NULL,-1,wxString_ctorUTF8("test for wxClientDC()"), _
-1,-1, 640,480, _
wxFRAME_DEFAULT_STYLE Or wxCLOSE_BOX _
Xor wxMAXIMIZE_BOX Xor wxRESIZE_BORDER)
Panel = wxPanel_ctor2(Frame)
Dim As wxButton Ptr Button = wxButton_ctor()
wxButton_Create(Button,Panel,,wxString_ctorUTF8("click me"), 70, 270, 250, 60)
wxEvtHandler_proxy(Button, @EventListener)
wxEvtHandler_Connect(Button, wxEvent_EVT_COMMAND_BUTTON_CLICKED())
wxWindow_Show(Frame)
c=wxColour_ctor()
Return wxApp_OnInit(App)
End Function
Function OnExit WXCALL As wxInt
Return wxApp_OnExit(App)
End Function
' main
App = wxAPP_ctor()
wxApp_RegisterVirtual(App,@OnInit,@OnExit)
wxApp_Run()