diff options
Diffstat (limited to 'ldmicro')
-rw-r--r-- | ldmicro/includes/linuxUI/linuxLD.h | 58 | ||||
-rw-r--r-- | ldmicro/includes/linuxUI/linuxUI.h | 67 | ||||
-rw-r--r-- | ldmicro/linuxUI.cpp | 53 |
3 files changed, 59 insertions, 119 deletions
diff --git a/ldmicro/includes/linuxUI/linuxLD.h b/ldmicro/includes/linuxUI/linuxLD.h new file mode 100644 index 0000000..77352e4 --- /dev/null +++ b/ldmicro/includes/linuxUI/linuxLD.h @@ -0,0 +1,58 @@ +#ifndef __LINUX_LD__ +#define __LINUX_LD__ + +#include "linuxUI/linuxUI.h" + +/// common windows referances for linux + +/// definitions +#define MAX_PATH PATH_MAX +/// CALLBACK or __stdcall os defined empty +#define CALLBACK + +/// typedefs +//typedef int64_t __int64; +typedef bool BOOL; +typedef unsigned char BYTE; +typedef unsigned int DWORD; + +/// all handles will hold a GtkWindow* type +typedef void* PVOID; +typedef GtkWidget* HANDLE; +typedef HANDLE HINSTANCE; +typedef HANDLE HWND; +typedef HANDLE HDC; +typedef HANDLE HMENU; + +typedef GtkApplication* HAPP; + +/// Check if system is x64 or x86 +#if defined(__UNIX64) +typedef uint64_t UINT_PTR; +#else +typedef unsigned int UINT_PTR; +#endif + +typedef UINT_PTR WPARAM; +typedef unsigned int UINT; + +/// custom classes +class COLORREF : public GdkRGBA{ + public: + COLORREF() + { + this->red = 0.0; + this->green = 0.0; + this->blue = 0.0; + this->alpha = 1.0; + } + COLORREF(int r, int g, int b) + { + this->red = r/255.0; + this->green = g/255.0; + this->blue = b/255.0; + this->alpha = 1.0; + } +}; + +#endif diff --git a/ldmicro/includes/linuxUI/linuxUI.h b/ldmicro/includes/linuxUI/linuxUI.h index 803f915..01b7af2 100644 --- a/ldmicro/includes/linuxUI/linuxUI.h +++ b/ldmicro/includes/linuxUI/linuxUI.h @@ -6,77 +6,12 @@ #include <linux/limits.h> #include <stdio.h> #include <inttypes.h> +#include "linuxUI/linuxLD.h" /// version control #define LDMicro_VERSION_MAJOR 1 #define LDMicro_VERSION_MINOR 0 -/// common windows referances for linux -/// definitions -#define MAX_PATH PATH_MAX -/// CALLBACK or __stdcall os defined empty -#define CALLBACK - -/// typedefs -//typedef int64_t __int64; -typedef bool BOOL; -typedef unsigned char BYTE; -typedef unsigned int DWORD; - -/// all handles will hold a GtkWindow* type -typedef void* PVOID; -typedef GtkWidget* HANDLE; -typedef HANDLE HINSTANCE; -typedef HANDLE HWND; -typedef HANDLE HDC; -typedef HANDLE HMENU; - -typedef GtkApplication* HAPP; - -/* -/// Check if system is x64 or x86 using GCC -#if __GNUC__ -#if __x86_64__ || __ppc64__ -/// system is x64 -typedef unsigned __int64 UINT_PTR; -#else -/// system is x86 -typedef unsigned int UINT_PTR; -#endif -#endif -*/ - -/// Check if system is x64 or x86 -#if defined(__UNIX64) -typedef uint64_t UINT_PTR; -#else -typedef unsigned int UINT_PTR; -#endif - -typedef UINT_PTR WPARAM; -typedef unsigned int UINT; - -/// custom classes -class COLORREF : public GdkRGBA{ - public: - COLORREF() - { - this->red = 0.0; - this->green = 0.0; - this->blue = 0.0; - this->alpha = 1.0; - } - COLORREF(int r, int g, int b) - { - this->red = r/255.0; - this->green = g/255.0; - this->blue = b/255.0; - this->alpha = 1.0; - } -}; - -/// common windows referances for linux - end - /// functions BOOL isFocus(HWND); COLORREF RGB(int, int, int); diff --git a/ldmicro/linuxUI.cpp b/ldmicro/linuxUI.cpp index 8b65426..85c605e 100644 --- a/ldmicro/linuxUI.cpp +++ b/ldmicro/linuxUI.cpp @@ -15,57 +15,4 @@ COLORREF RGB(int red, int green, int blue) col.alpha = 1.0; return col; -} - -gboolean draw_callback (GtkWidget *widget, cairo_t *cr, gpointer data) -{ - guint width, height; - COLORREF color = RGB (255, 0, 0); - - width = gtk_widget_get_allocated_width (widget); - height = gtk_widget_get_allocated_height (widget); - cairo_arc (cr, - width / 2.0, height / 2.0, - MIN (width, height) / 2.0, - 0, 2 * G_PI); - - gtk_style_context_get_color (gtk_widget_get_style_context (widget), - GTK_STATE_FLAG_NORMAL, - &color); - - gdk_cairo_set_source_rgba (cr, &color); - - cairo_fill (cr); - - return FALSE; -} - -static void load (GtkApplication* app, gpointer user_data) -{ - /// Make window - HWND window = gtk_application_window_new(app); - gtk_window_set_title(GTK_WINDOW(window), "Window"); - gtk_window_set_default_size(GTK_WINDOW(window), 200, 200); - - HWND drawing_area = gtk_drawing_area_new (); - gtk_widget_set_size_request (drawing_area, 100, 100); - g_signal_connect (G_OBJECT (drawing_area), "draw", G_CALLBACK (draw_callback), NULL); - - gtk_container_add(GTK_CONTAINER(window), drawing_area); - - gtk_widget_show_all (window); -} - -int main (int argc, char** argv) -{ - /// Make app - HAPP app; - int status; - - app = gtk_application_new ("org.git.ldmicro", G_APPLICATION_FLAGS_NONE); - g_signal_connect (app, "activate", G_CALLBACK (load), NULL); - status = g_application_run (G_APPLICATION (app), argc, argv); - g_object_unref (app); - - return status; }
\ No newline at end of file |