diff options
Diffstat (limited to 'ldmicro')
-rw-r--r-- | ldmicro/draw_outputdev.cpp | 1 | ||||
-rw-r--r-- | ldmicro/includes/ldmicro.h | 4 | ||||
-rw-r--r-- | ldmicro/ldmicro.cpp | 43 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.h | 10 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 24 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 10 | ||||
-rw-r--r-- | ldmicro/maincontrols.cpp | 128 |
7 files changed, 132 insertions, 88 deletions
diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp index 9965483..2fdb98e 100644 --- a/ldmicro/draw_outputdev.cpp +++ b/ldmicro/draw_outputdev.cpp @@ -308,6 +308,7 @@ void PaintWindow() r.left += POS_WIDTH*FONT_WIDTH*ColsAvailable + 2; r.right += POS_WIDTH*FONT_WIDTH*ColsAvailable + 2; FillRect(Hdc, &r, InSimulationMode ? BusRightBus : BusBrush); + InvalidateRect(DrawWindow, NULL, FALSE); CursorDrawn = FALSE; diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h index e69adb4..c93db3e 100644 --- a/ldmicro/includes/ldmicro.h +++ b/ldmicro/includes/ldmicro.h @@ -532,8 +532,8 @@ void CheckHeap(char *file, int line); // maincontrols.cpp void MakeMainWindowControls(void); HMENU MakeMainWindowMenus(void); -void VscrollProc(WPARAM wParam); -void HscrollProc(WPARAM wParam); +void VscrollProc(int wParam); +void HscrollProc(int wParam); void GenerateIoListDontLoseSelection(void); void RefreshControlsToSettings(void); void MainWindowResized(void); diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp index 9a5c9a3..1fa8567 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -1000,23 +1000,31 @@ gboolean LD_GTK_mouse_scroll_hook(GtkWidget *widget, GdkEvent *event, gpointer u * WM_VSCROLL, WM_HSCROLL, WM_MOUSEWHEEL */ + MainWindowResized(); + PaintWindow(); + switch(event->scroll.direction) { case GDK_SCROLL_UP: + VscrollProc(SB_LINEUP); + break; case GDK_SCROLL_DOWN: - // VscrollProc(wParam); + VscrollProc(SB_LINEDOWN); break; case GDK_SCROLL_LEFT: + HscrollProc(SB_LINEUP); + break; case GDK_SCROLL_RIGHT: - // HscrollProc(wParam); + HscrollProc(SB_LINEDOWN); break; case GDK_SCROLL_SMOOTH: - // if((GET_WHEEL_DELTA_WPARAM(wParam)) > 0) { - // VscrollProc(SB_LINEUP); - // } else { - // VscrollProc(SB_LINEDOWN); - // } - // gdk_event_get_scroll_deltas (const GdkEvent *event, gdouble *delta_x, gdouble *delta_y); + double d_x, d_y; + gdk_event_get_scroll_deltas (event, &d_x, &d_y); + if(d_y > 0) { + VscrollProc(SB_LINEUP); + } else { + VscrollProc(SB_LINEDOWN); + } break; } @@ -1051,7 +1059,7 @@ gboolean LD_WM_Paint_call(HWID widget, HCRDC cr, gpointer data) * WM_PAINT */ - g_print("draw called\n"); + // g_print("draw called----------------------------------\n"); // guint width, height; // GdkRGBA color; @@ -1061,10 +1069,10 @@ gboolean LD_WM_Paint_call(HWID widget, HCRDC cr, gpointer data) // width = gtk_widget_get_allocated_width (widget); // height = gtk_widget_get_allocated_height (widget); - // // g_print("w = %i\n", width); - // // g_print("h = %i\n", height); + // g_print("w = %i\n", width); + // g_print("h = %i\n", height); - // // SetBkColor(widget, cr, HighlightColours.bg); + // SetBkColor(widget, cr, HighlightColours.bg); // gtk_render_background (context, cr, 0, 0, width, height); @@ -1083,8 +1091,17 @@ gboolean LD_WM_Paint_call(HWID widget, HCRDC cr, gpointer data) // cairo_fill (cr); - Hdc = cr; + // SetBkColor(DrawWindow, cr, InSimulationMode ? HighlightColours.simBg : + // HighlightColours.bg); + // SetTextColor(cr, InSimulationMode ? HighlightColours.simRungNum : + // HighlightColours.rungNum); + // SelectObject(cr, FixedWidthFont); + // for (int xp = 0; xp<= width; xp += 7) + // for (int yp = 0; yp <= height; yp += 7) + // TextOut(DrawWindow, cr, xp, yp, "H", 1); + Hdc = cr; + /// This draws the schematic. PaintWindow(); diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h index 8a3e3a2..80f4471 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -16,6 +16,7 @@ #define CALLBACK #define CONST const +/// Meamory flags #define HEAP_ZERO_MEMORY 0x00000008 /// Image loading flags @@ -24,7 +25,6 @@ /// Macro functions #define max(_A, _B) std::max(_A, _B) -// #define min(_A, _B) std::min(_A, _B) /// Typedefs //typedef int64_t __int64; @@ -114,6 +114,14 @@ typedef class tagColorReferance: public GdkRGBA{ this->alpha = 1.0; } + bool operator== (tagColorReferance& arg1) + { + if( ((int)arg1.red == (int)this->red) && ((int)arg1.green == (int)this->green) && ((int)arg1.blue == (int)this->blue) ) + return true; + else + return false; + } + GdkRGBA* getThis() { return this; diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index 5125ed9..3447c02 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -262,20 +262,21 @@ void SetBkColor(HWID widget, HCRDC hcr, COLORREF bkCol) gtk_widget_override_background_color(GTK_WIDGET(widget), GTK_STATE_FLAG_NORMAL, &bkCol); - GtkStyleContext *context; + gint width = gtk_widget_get_allocated_width (widget); + gint height = gtk_widget_get_allocated_height (widget); + COLORREF col; + GtkStyleContext *context; 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); + gtk_style_context_get_state (context), + &col); gdk_cairo_set_source_rgba (hcr, &col); - gtk_render_background (context, hcr, 0, 0, width, height); + cairo_fill (hcr); } void SetTextColor(HCRDC hcr, COLORREF color) @@ -286,7 +287,7 @@ void SetTextColor(HCRDC hcr, COLORREF color) void TextOut(HWID hWid, HCRDC hcr, int nXStart, int nYStart, LPCTSTR lpString, int cchString) { - nYStart += 20; + nYStart += 30; cairo_text_extents_t extents; cairo_text_extents (hcr, lpString, &extents); @@ -297,12 +298,14 @@ void TextOut(HWID hWid, HCRDC hcr, int nXStart, int nYStart, LPCTSTR lpString, i if(nYStart+(extents.height/2.0) >= height) { - height += extents.height; + // g_print("Y extend\n"); + height += extents.height += 50; resize_flag = TRUE; } if (nXStart+(extents.width/2.0) >= width) { + // g_print("X extend\n"); width += extents.width; resize_flag = TRUE; } @@ -316,6 +319,8 @@ void TextOut(HWID hWid, HCRDC hcr, int nXStart, int nYStart, LPCTSTR lpString, i cairo_move_to(hcr, nXStart, nYStart); cairo_show_text(hcr, text); + // g_print("%s", text); + cairo_fill (hcr); } @@ -332,7 +337,10 @@ COLORREF GetTextColor(HCRDC Hdc) BOOL InvalidateRect(HWID hWid, const RECT *lpRect, BOOL bErase) { if(!GDK_IS_WINDOW(hWid)) + { + // g_print("not window\n"); return FALSE; + } if (lpRect == NULL) { diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index e921777..8ac0c9b 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -33,6 +33,16 @@ #define MB_ICONWARNING 0x00000040L #define MB_ICONINFORMATION 0x00000080L +/// Scroll +#define SB_LINEUP 0x00000001 +#define SB_PAGEUP 0x00000002 +#define SB_LINEDOWN 0x00000004 +#define SB_PAGEDOWN 0x00000008 +#define SB_TOP 0x00000010 +#define SB_BOTTOM 0x00000020 +#define SB_THUMBTRACK 0x00000040 +#define SB_THUMBPOSITION 0x00000040 + /// open/save file #define OFN_PATHMUSTEXIST 0x00000100L #define OFN_HIDEREADONLY 0x00000200L diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp index 9ed011a..60760b7 100644 --- a/ldmicro/maincontrols.cpp +++ b/ldmicro/maincontrols.cpp @@ -538,37 +538,37 @@ void RefreshScrollbars(void) // Respond to a WM_VSCROLL sent to the main window, presumably by the one and // only vertical scrollbar that it has as a child. //----------------------------------------------------------------------------- -void VscrollProc(WPARAM wParam) +void VscrollProc(int wParam) { - // int prevY = ScrollYOffset; - // switch(LOWORD(wParam)) { - // case SB_LINEUP: - // case SB_PAGEUP: - // if(ScrollYOffset > 0) { - // ScrollYOffset--; - // } - // break; - - // case SB_LINEDOWN: - // case SB_PAGEDOWN: - // if(ScrollYOffset < ScrollYOffsetMax) { - // ScrollYOffset++; - // } - // break; - - // case SB_TOP: - // ScrollYOffset = 0; - // break; - - // case SB_BOTTOM: - // ScrollYOffset = ScrollYOffsetMax; - // break; - - // case SB_THUMBTRACK: - // case SB_THUMBPOSITION: - // ScrollYOffset = HIWORD(wParam); - // break; - // } + int prevY = ScrollYOffset; + switch(wParam) { + case SB_LINEUP: + case SB_PAGEUP: + if(ScrollYOffset > 0) { + ScrollYOffset--; + } + break; + + case SB_LINEDOWN: + case SB_PAGEDOWN: + if(ScrollYOffset < ScrollYOffsetMax) { + ScrollYOffset++; + } + break; + + case SB_TOP: + ScrollYOffset = 0; + break; + + case SB_BOTTOM: + ScrollYOffset = ScrollYOffsetMax; + break; + + // case SB_THUMBTRACK: + // case SB_THUMBPOSITION: + // ScrollYOffset = HIWORD(wParam); + // break; + } // if(prevY != ScrollYOffset) { // SCROLLINFO si; // si.cbSize = sizeof(si); @@ -584,42 +584,42 @@ void VscrollProc(WPARAM wParam) // Respond to a WM_HSCROLL sent to the main window, presumably by the one and // only horizontal scrollbar that it has as a child. //----------------------------------------------------------------------------- -void HscrollProc(WPARAM wParam) +void HscrollProc(int wParam) { - // int prevX = ScrollXOffset; - // switch(LOWORD(wParam)) { - // case SB_LINEUP: - // ScrollXOffset -= FONT_WIDTH; - // break; - - // case SB_PAGEUP: - // ScrollXOffset -= POS_WIDTH*FONT_WIDTH; - // break; - - // case SB_LINEDOWN: - // ScrollXOffset += FONT_WIDTH; - // break; - - // case SB_PAGEDOWN: - // ScrollXOffset += POS_WIDTH*FONT_WIDTH; - // break; - - // case SB_TOP: - // ScrollXOffset = 0; - // break; - - // case SB_BOTTOM: - // ScrollXOffset = ScrollXOffsetMax; - // break; - - // case SB_THUMBTRACK: - // case SB_THUMBPOSITION: - // ScrollXOffset = HIWORD(wParam); - // break; - // } + int prevX = ScrollXOffset; + switch(wParam) { + case SB_LINEUP: + ScrollXOffset -= FONT_WIDTH; + break; + + case SB_PAGEUP: + ScrollXOffset -= POS_WIDTH*FONT_WIDTH; + break; + + case SB_LINEDOWN: + ScrollXOffset += FONT_WIDTH; + break; + + case SB_PAGEDOWN: + ScrollXOffset += POS_WIDTH*FONT_WIDTH; + break; + + case SB_TOP: + ScrollXOffset = 0; + break; + + case SB_BOTTOM: + ScrollXOffset = ScrollXOffsetMax; + break; + + // case SB_THUMBTRACK: + // case SB_THUMBPOSITION: + // ScrollXOffset = HIWORD(wParam); + // break; + } - // if(ScrollXOffset > ScrollXOffsetMax) ScrollXOffset = ScrollXOffsetMax; - // if(ScrollXOffset < 0) ScrollXOffset = 0; + if(ScrollXOffset > ScrollXOffsetMax) ScrollXOffset = ScrollXOffsetMax; + if(ScrollXOffset < 0) ScrollXOffset = 0; // if(prevX != ScrollXOffset) { // SCROLLINFO si; |