From 6fe9770bf83c6af777af028d46ab07d4b555b497 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Tue, 14 Oct 2025 06:56:03 +0000 Subject: [PATCH] new function git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@317 b9cfdab3-6d41-4d17-bbe4-086880011989 --- include/Mw/LowLevel.h | 1 + src/backend/gdi.c | 10 ++++++++++ src/backend/x11.c | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index a20f67c..36be614 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -82,6 +82,7 @@ MWDECL MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height); MWDECL void MwLLDestroy(MwLL handle); MWDECL void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color); +MWDECL void MwLLLine(MwLL handle, MwPoint* points, MwLLColor color); MWDECL MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b); MWDECL void MwLLFreeColor(MwLLColor color); diff --git a/src/backend/gdi.c b/src/backend/gdi.c index 84d0dc6..e18f8b5 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -239,6 +239,16 @@ void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color free(p); } +void MwLLLine(MwLL handle, MwPoint* points, MwLLColor color) { + HPEN pen = CreatePen(PS_SOLID, 1, RGB(color->red, color->green, color->blue)); + + SelectObject(handle->hDC, pen); + MoveToEx(handle->hDC, points[0].x, points[0].y, NULL); + LineTo(handle->hDC, points[1].x, points[1].y); + + DeleteObject(pen); +} + MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) { MwLLColor c = malloc(sizeof(*c)); HDC dc = GetDC(handle->hWnd); diff --git a/src/backend/x11.c b/src/backend/x11.c index c66bdfc..8fbbcb3 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -123,6 +123,12 @@ void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color free(p); } +void MwLLLine(MwLL handle, MwPoint* points, MwLLColor color) { + XSetForeground(handle->display, handle->gc, color->pixel); + + XDrawLine(handle->display, handle->pixmap, handle->gc, points[0].x, points[0].y, points[1].x, points[1].y); +} + MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) { MwLLColor c = malloc(sizeof(*c)); XColor xc;