diff options
Diffstat (limited to 'ldmicro/lib/linuxUI')
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.h | 33 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 116 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 64 |
3 files changed, 183 insertions, 30 deletions
diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h index 6f1e4f0..5f8e0e7 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -4,6 +4,7 @@ #include "linuxUI.h" #include <ctype.h> #include <vector> +#include <math.h> #include <algorithm> #include <sys/mman.h> @@ -21,6 +22,9 @@ #define IMAGE_ICON 1 #define LDMICRO_ICON "../ldmicro.ico" +/// Macro functions +#define max(_A, _B) std::max(_A, _B) + /// Typedefs //typedef int64_t __int64; typedef bool BOOL; @@ -54,14 +58,14 @@ typedef CHAR *LPSTR; typedef void *PVOID; typedef void *LPVOID; -typedef PVOID HFONT; typedef PVOID HMODULE; typedef PVOID HHOOK; -typedef PVOID HFONT; typedef PVOID HANDLE; typedef HANDLE HINSTANCE; -typedef HANDLE HDC; +typedef HANDLE HGDIOBJ; + +typedef cairo_t *HCRDC; typedef GtkWidget *HWID; typedef GtkWidget *HMENU; typedef GtkWindow *HWND; @@ -106,6 +110,14 @@ typedef class tagColorReferance: public GdkRGBA{ this->alpha = 1.0; } + // tagColorReferance(tagColorReferance &refCpy) + // { + // this->red = refCpy.red; + // this->green = refCpy.green; + // this->blue = refCpy.blue; + // this->alpha = refCpy.alpha; + // } + GdkRGBA* getThis() { return this; @@ -143,6 +155,21 @@ typedef struct tagNMHDR { UINT code; } NMHDR; +typedef struct FontTag { + int nHeight; + int nWidth; + int nOrientation; + int fnWeight; + DWORD fdwItalic; + LPCTSTR lpszFace; +} *HFONT, FONT; + +typedef struct tagLOGBRUSH { + UINT lbStyle; + COLORREF lbColor; +// ULONG_PTR lbHatch; +} LOGBRUSH, *PLOGBRUSH; + /// Variables extern std::vector<HEAPRECORD> HeapRecord; 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); +} + diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index 85b5fa8..552a6af 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -39,9 +39,15 @@ #define OFN_OVERWRITEPROMPT 0x00000400L /// window brushes -#define BLACK_BRUSH 0x00000002L -#define WHITE_BRUSH 0x00000004L -#define GREY_BRUSH 0x00000008L +#define BS_SOLID 0x00000001L +#define BS_HOLLOW 0x00000002L +#define BLACK_BRUSH 0x00000004L +#define WHITE_BRUSH 0x00000008L +#define GREY_BRUSH 0x00000010L + +/// Font flags +#define FW_REGULAR 0x00000001L +#define FW_BOLD 0x00000002L /// EnableMenuItem variables extern const UINT MF_ENABLED; @@ -66,12 +72,52 @@ typedef struct OpenFileInfoData { } OPENFILENAME; /// functions -BOOL isFocus(HWID); -COLORREF RGB(int, int, int); -int MessageBox(HWID, char*, char*, UINT); -BOOL GetSaveFileName(OPENFILENAME* ); -void EnableMenuItem(HMENU, HMENU, UINT); -void CheckMenuItem(HMENU, HMENU, UINT); +BOOL isFocus(HWID window); + +COLORREF RGB(int red, + int green, + int blue); + +int MessageBox(HWID pWindow, + char* message, + char* title, + UINT mFlags); + +BOOL GetSaveFileName(OPENFILENAME *ofn); + +void EnableMenuItem(HMENU MenuName, + HMENU MenuItem, + UINT CheckEnabledItem); + +void CheckMenuItem(HMENU MenuName, + HMENU MenuItem, + UINT Check); + HANDLE GetStockObject(int fnObject); +void SelectObject(HCRDC hcr, + HFONT hfont); + +HBRUSH CreateBrushIndirect(PLOGBRUSH plb); + +HFONT CreateFont(int nHeight, + int nWidth, + int nOrientation, + int fnWeight, + DWORD fdwItalic, + LPCTSTR lpszFace); + +void SetBkColor(HWID widget, + HCRDC hcr, + COLORREF bkCol); + +void SetTextColor(HCRDC hcr, + COLORREF color); + +void TextOut(HCRDC hcr, + int nXStart, + int nYStart, + LPCTSTR lpString, + int cchString); + #endif
\ No newline at end of file |