diff options
Diffstat (limited to 'ldmicro/lib/linuxUI/linuxUI.cpp')
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 116 |
1 files changed, 98 insertions, 18 deletions
diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index f0c9124..23ac060 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -27,24 +27,6 @@ COLORREF RGB(int red, int green, int blue) return col; } -HANDLE GetStockObject(int fnObject) -{ - switch(fnObject) - { - case BLACK_BRUSH: - return new COLORREF(0, 0, 0); - break; - case WHITE_BRUSH: - return new COLORREF(255, 255, 255); - break; - case GREY_BRUSH: - return new COLORREF(128, 128, 128); - break; - default: - return new COLORREF(255, 255, 255); - } -} - int MessageBox(HWID pWindow, char* message, char* title, UINT mFlags) { GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT; @@ -96,6 +78,7 @@ int MessageBox(HWID pWindow, char* message, char* title, UINT mFlags) return result; } + BOOL GetSaveFileName(OPENFILENAME *ofn) { GtkWidget *dialog; @@ -193,3 +176,100 @@ void CheckMenuItem(HMENU MenuName, HMENU MenuItem, UINT Check) break; } } + +HANDLE GetStockObject(int fnObject) +{ + switch(fnObject) + { + case BLACK_BRUSH: + return new COLORREF(0, 0, 0); + break; + case WHITE_BRUSH: + return new COLORREF(255, 255, 255); + break; + case GREY_BRUSH: + return new COLORREF(128, 128, 128); + break; + default: + return new COLORREF(255, 255, 255); + } +} + +void SelectObject(HCRDC hcr, HFONT hfont) +{ + cairo_select_font_face(hcr, hfont->lpszFace, + hfont->fdwItalic ? CAIRO_FONT_SLANT_ITALIC : CAIRO_FONT_SLANT_NORMAL, + 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_matrix_t matrix; + cairo_matrix_init_scale (&matrix, + (double)hfont->nWidth / extents.width, + (double)hfont->nHeight / extents.width); + + 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, 20); +} + +HBRUSH CreateBrushIndirect(PLOGBRUSH plb) +{ + COLORREF brush(plb->lbColor); + brush.alpha = (plb->lbStyle == BS_SOLID) ? 1 : 0.2; + + return &brush; +} + +HFONT CreateFont(int nHeight, int nWidth, int nOrientation, int fnWeight, + DWORD fdwItalic, LPCTSTR lpszFace) +{ + HFONT font = new FONT; + font->nHeight = nHeight; + font->nWidth = nWidth; + font->nOrientation = nOrientation; + font->fnWeight = fnWeight; + font->fdwItalic = fdwItalic; + font->lpszFace = lpszFace; + + return font; +} + +void SetBkColor(HWID widget, HCRDC hcr, COLORREF bkCol) +{ + gtk_widget_override_background_color(GTK_WIDGET(widget), + GTK_STATE_FLAG_NORMAL, &bkCol); + + GtkStyleContext *context; + COLORREF col; + + context = gtk_widget_get_style_context (widget); + gint width = gtk_widget_get_allocated_width (widget); + gint height = gtk_widget_get_allocated_height (widget); + + gtk_style_context_get_color (context, + gtk_style_context_get_state (context), + &col); + + gdk_cairo_set_source_rgba (hcr, &col); + + gtk_render_background (context, hcr, 0, 0, width, height); +} + +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) +{ + cairo_move_to(hcr, nXStart, nYStart); + cairo_show_text(hcr, lpString); + + cairo_fill (hcr); +} + |