2019-12-12 09:24:58 -07:00
|
|
|
# UPIWIN - Micro Pi Windowing Framework Kernel
|
|
|
|
# Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
# Test of line clipping
|
2019-12-10 13:04:24 -07:00
|
|
|
import upiwin
|
|
|
|
|
|
|
|
hdc = upiwin.DevCtxt(type='screen')
|
|
|
|
hdc.text_color = 0xFFFFFF # white
|
2019-12-10 15:00:51 -07:00
|
|
|
hdc.rectangle(99, 99, 200, 200)
|
2019-12-10 13:04:24 -07:00
|
|
|
|
2019-12-10 13:25:36 -07:00
|
|
|
clip = hdc.get_clip_rect()
|
|
|
|
hdc.set_clip_rect(100, 100, 200, 200)
|
2019-12-10 13:04:24 -07:00
|
|
|
|
2019-12-10 13:25:36 -07:00
|
|
|
hdc.text_color = 0x0000FF # red
|
2019-12-10 15:00:51 -07:00
|
|
|
hdc.move_to(50, 200)
|
|
|
|
hdc.line_to(200, 50)
|
2019-12-10 13:04:24 -07:00
|
|
|
|
2019-12-10 13:25:36 -07:00
|
|
|
hdc.text_color = 0x00FF00 # green
|
2019-12-10 15:00:51 -07:00
|
|
|
hdc.move_to(250, 200)
|
2019-12-10 13:25:36 -07:00
|
|
|
hdc.line_to(100, 50)
|
|
|
|
|
2019-12-10 15:00:51 -07:00
|
|
|
hdc.text_color = 0xFF0000 # blue
|
|
|
|
hdc.move_to(50, 100)
|
|
|
|
hdc.line_to(200, 250)
|
|
|
|
|
|
|
|
hdc.text_color = 0x00FFFF # yellow
|
|
|
|
hdc.move_to(250, 100)
|
|
|
|
hdc.line_to(100, 250)
|
|
|
|
|
2019-12-10 13:25:36 -07:00
|
|
|
hdc.set_clip_rect(clip[0], clip[1], clip[2], clip[3])
|
2019-12-10 13:04:24 -07:00
|
|
|
|
|
|
|
msg = {}
|
|
|
|
while upiwin.get_message(msg):
|
|
|
|
if msg['message'] == upiwin.WM_HWBUTTONUP:
|
|
|
|
bn = msg['attrs'][0]
|
|
|
|
if bn == 4:
|
|
|
|
print("Quitting the application.")
|
|
|
|
upiwin.post_quit_message(0)
|