diff options
author | Rr42 | 2018-06-18 13:41:24 +0530 |
---|---|---|
committer | Rr42 | 2018-06-18 13:41:24 +0530 |
commit | 28777b68e7479e6515231fc849c61b3748da8712 (patch) | |
tree | c7c22de2c9c954bf158d40600175a0da5606184e /ldmicro/lib | |
parent | 9570fa4d9fc0083df2e50c0ca6330847555eee2b (diff) | |
download | LDMicroGtk-28777b68e7479e6515231fc849c61b3748da8712.tar.gz LDMicroGtk-28777b68e7479e6515231fc849c61b3748da8712.tar.bz2 LDMicroGtk-28777b68e7479e6515231fc849c61b3748da8712.zip |
Fixed bug in FillRect
Diffstat (limited to 'ldmicro/lib')
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.cpp | 4 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 93 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 52 |
3 files changed, 115 insertions, 34 deletions
diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp index 95f1221..966c5b3 100644 --- a/ldmicro/lib/linuxUI/linuxLD.cpp +++ b/ldmicro/lib/linuxUI/linuxLD.cpp @@ -116,8 +116,8 @@ HICON LoadImage(HINSTANCE hinst, LPCTSTR lpszName, UINT uType, int cxDesired, void RECT_to_GDRECT(const RECT *rc, GDRECT *gdrc) { - gdrc->x = rc->top; - gdrc->y = rc->left; + gdrc->x = rc->left; + gdrc->y = rc->top; gdrc->width = rc->right - rc->left; gdrc->height = rc->bottom - rc->top; } 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 diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index e7b1d90..e921777 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -85,51 +85,61 @@ extern COLORREF HdcCurrentTextColor; /// functions BOOL isFocus(HWID window); -COLORREF RGB(int red, - int green, - int blue); +COLORREF RGB( + int red, + int green, + int blue); -int MessageBox(HWID pWindow, +int MessageBox( + HWID pWindow, char* message, char* title, UINT mFlags); BOOL GetSaveFileName(OPENFILENAME *ofn); -void EnableMenuItem(HMENU MenuName, +void EnableMenuItem( + HMENU MenuName, HMENU MenuItem, UINT CheckEnabledItem); -void CheckMenuItem(HMENU MenuName, +void CheckMenuItem( + HMENU MenuName, HMENU MenuItem, UINT Check); HANDLE GetStockObject(int fnObject); -void SelectObject(HCRDC hcr, +void SelectObject( + HCRDC hcr, HFONT hfont); HBRUSH CreateBrushIndirect(PLOGBRUSH plb); -HFONT CreateFont(int nHeight, +HFONT CreateFont( + int nHeight, int nWidth, int nOrientation, int fnWeight, DWORD fdwItalic, LPCTSTR lpszFace); -void SetBkColor(HWID widget, +void SetBkColor( + HWID widget, HCRDC hcr, COLORREF bkCol); -void SetTextColor(HCRDC hcr, +void SetTextColor( + HCRDC hcr, COLORREF 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); COLORREF GetTextColor(HCRDC Hdc); @@ -147,4 +157,16 @@ BOOL GetClientRect( HWID hWid, PRECT lpRect); +BOOL MoveWindow( + HWID hWid, + int X, + int Y, + int nWidth, + int nHeight, + BOOL bRepaint); + +BOOL GetWindowRect( + HWID hWid, + PRECT pRect); + #endif
\ No newline at end of file |