Restored from previous forum. Originally posted by BigSnake.
It would be nice if you could set a Viewport and all drawing commands will work only within the borders of this viewport.
I´ve the problem, that i must cut a text at the edge of a box,
Viewport
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
Here is something that might be useful until PB gets its own command for clipping graphic areas.
PS, this is not perfect. For example, it does not check to see if PB has already installed a clipping area before freeing it (ideally it would go back to the one PB installs). However, I couldn't figure out how to do it.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)
Here is something that might be useful until PB gets its own command for clipping graphic areas.
Code: Select all
If OpenWindow(0, 0, 0, 400, 300, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_TitleBar, "foo")
Repeat
ev.l = WaitWindowEvent()
Select ev
Case #PB_Event_Repaint
hdc.l = StartDrawing(WindowOutput())
rgn.l = CreateRectRgn_(50, 50, 101, 101) ; Try to create cliiping rectangle
If rgn ; Make sure it was successful
SelectClipRgn_(hdc, rgn) ; Install it into the device context
Box(0, 0, 200, 200, RGB(255, 0, 0)) ; Draw something to prove it clips
SelectClipRgn_(hdc, 0) ; Remove clipping
DeleteObject_(rgn) ; And free the region we created
EndIf
StopDrawing()
EndSelect
Until ev=#PB_Event_CloseWindow
EndIf
End
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)