summaryrefslogtreecommitdiff
path: root/ldmicro/lib/linuxUI/linuxUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ldmicro/lib/linuxUI/linuxUI.cpp')
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.cpp93
1 files changed, 76 insertions, 17 deletions
diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp
index d5a9ad6..f21094e 100644
--- a/ldmicro/lib/linuxUI/linuxUI.cpp
+++ b/ldmicro/lib/linuxUI/linuxUI.cpp
@@ -218,19 +218,18 @@ void SelectObject(HCRDC hcr, HFONT hfont)
hfont->fnWeight == FW_BOLD ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL);
cairo_rotate(hcr, hfont->nOrientation);
-
- cairo_text_extents_t extents;
- cairo_text_extents (hcr, "H", &extents);
+ // cairo_text_extents_t extents;
+ // cairo_text_extents (hcr, "Z", &extents);
+ // cairo_matrix_t matrix;
+ // cairo_matrix_init_scale (&matrix,
+ // (double)hfont->nWidth,
+ // (double)hfont->nHeight);
- cairo_matrix_t matrix;
- cairo_matrix_init_scale (&matrix,
- (double)hfont->nWidth * 1.6,
- (double)hfont->nHeight * 1.4);
-
- cairo_set_font_matrix (hcr, &matrix);
+ // cairo_set_font_matrix (hcr, &matrix);
+
// g_print("wR = %f\nhR = %f\n", (double)hfont->nWidth / extents.width, (double)hfont->nHeight / extents.height);
- // g_print("tW = %f\ntH = %f\n", extents.width, extents.width);
- // cairo_set_font_size(hcr, 15);
+ // g_print("tW = %f tH = %f\n", extents.width, extents.width);
+ cairo_set_font_size(hcr, 10);
}
HBRUSH CreateBrushIndirect(PLOGBRUSH plb)
@@ -285,8 +284,29 @@ void SetTextColor(HCRDC hcr, COLORREF color)
gdk_cairo_set_source_rgba (hcr, &color);
}
-void TextOut(HCRDC hcr, int nXStart, int nYStart, LPCTSTR lpString, int cchString)
+void TextOut(HWID hWid, HCRDC hcr, int nXStart, int nYStart, LPCTSTR lpString, int cchString)
{
+ cairo_text_extents_t extents;
+ cairo_text_extents (hcr, lpString, &extents);
+ int width = gtk_widget_get_allocated_width (hWid);
+ int height= gtk_widget_get_allocated_height (hWid);
+ BOOL resize_flag = FALSE;
+ // g_print("w = %f h = %f")
+ if(nYStart+(extents.height/2.0) >= height)
+ {
+ height += extents.height;
+ resize_flag = TRUE;
+ }
+
+ if (nXStart+(extents.width/2.0) >= width)
+ {
+ width += extents.width;
+ resize_flag = TRUE;
+ }
+
+ if (resize_flag)
+ gtk_widget_set_size_request(hWid, width, height);
+
cairo_move_to(hcr, nXStart, nYStart);
cairo_show_text(hcr, lpString);
@@ -305,10 +325,21 @@ COLORREF GetTextColor(HCRDC Hdc)
BOOL InvalidateRect(HWID hWid, const RECT *lpRect, BOOL bErase)
{
+ if(!GDK_IS_WINDOW(hWid))
+ return FALSE;
+
+ if (lpRect == NULL)
+ {
+ gdk_window_invalidate_rect (gtk_widget_get_window (hWid), NULL, FALSE);
+ return TRUE;
+ }
+
GDRECT Gdrect;
RECT_to_GDRECT(lpRect, &Gdrect);
// gtk_widget_queue_draw(hWid);
- gdk_window_invalidate_rect (gtk_widget_get_window (hWid), &Gdrect, bErase);
+ gdk_window_invalidate_rect (gtk_widget_get_window (hWid), &Gdrect, FALSE);
+
+ return TRUE;
}
int FillRect(HCRDC hDC, const RECT *lprc, HBRUSH hbr)
@@ -325,11 +356,39 @@ int FillRect(HCRDC hDC, const RECT *lprc, HBRUSH hbr)
}
BOOL GetClientRect(HWID hWid, PRECT pRect)
+{
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (hWid, &allocation);
+
+ pRect->top = allocation.x;
+ pRect->left = allocation.y;
+ pRect->right = allocation.width;
+ pRect->bottom = allocation.height;
+
+ return TRUE;
+}
+
+BOOL MoveWindow(HWID hWid, int X, int Y, int nWidth, int nHeight, BOOL bRepaint)
{
- pRect->top = 0;
- pRect->left = 0;
- pRect->right = gtk_widget_get_allocated_width (hWid);
- pRect->bottom = gtk_widget_get_allocated_height (hWid);
+ gtk_window_move(GTK_WINDOW(hWid), X, Y);
+ gtk_window_resize(GTK_WINDOW(hWid), nWidth, nHeight);
+ if (bRepaint)
+ gdk_window_invalidate_rect (gtk_widget_get_window (hWid), NULL, FALSE);
+
return TRUE;
}
+
+
+BOOL GetWindowRect(HWID hWid, PRECT pRect)
+{
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (hWid, &allocation);
+
+ pRect->top = allocation.x;
+ pRect->left = allocation.y;
+ pRect->right = allocation.width;
+ pRect->bottom = allocation.height;
+
+ return TRUE;
+} \ No newline at end of file