summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldmicro/draw_outputdev.cpp37
-rw-r--r--ldmicro/ldmicro.cpp65
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.cpp4
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.cpp93
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h52
-rw-r--r--ldmicro/maincontrols.cpp23
6 files changed, 168 insertions, 106 deletions
diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp
index d0b39bb..edde2e8 100644
--- a/ldmicro/draw_outputdev.cpp
+++ b/ldmicro/draw_outputdev.cpp
@@ -131,10 +131,10 @@ static void DrawCharsToScreen(int cx, int cy, const char *str)
if(inBrace == 1) {
prev = GetTextColor(Hdc);
SetTextColor(Hdc, HighlightColours.punct);
- TextOut(Hdc, x, y, str, 1);
+ TextOut(DrawWindow, Hdc, x, y, str, 1);
SetTextColor(Hdc, prev);
} else {
- TextOut(Hdc, x, y, str, 1);
+ TextOut(DrawWindow, Hdc, x, y, str, 1);
}
if(*str == ']' || *str == '}') inBrace--;
} else if((
@@ -144,7 +144,7 @@ static void DrawCharsToScreen(int cx, int cy, const char *str)
{
prev = GetTextColor(Hdc);
SetTextColor(Hdc, HighlightColours.lit);
- TextOut(Hdc, x, y, str, 1);
+ TextOut(DrawWindow, Hdc, x, y, str, 1);
SetTextColor(Hdc, prev);
inNumber = TRUE;
} else if(*str == '\x01') {
@@ -170,14 +170,14 @@ static void DrawCharsToScreen(int cx, int cy, const char *str)
if(isdigit(*str) || *str == '.') {
prev = GetTextColor(Hdc);
SetTextColor(Hdc, HighlightColours.lit);
- TextOut(Hdc, x, y, str, 1);
+ TextOut(DrawWindow, Hdc, x, y, str, 1);
SetTextColor(Hdc, prev);
} else {
- TextOut(Hdc, x, y, str, 1);
+ TextOut(DrawWindow, Hdc, x, y, str, 1);
inNumber = FALSE;
}
} else {
- TextOut(Hdc, x, y, str, 1);
+ TextOut(DrawWindow, Hdc, x, y, str, 1);
}
firstTime = FALSE;
@@ -220,21 +220,6 @@ int ScreenRowsAvailable(void)
//-----------------------------------------------------------------------------
void PaintWindow()
{
- /*
- cairo_set_source_rgb(cr, Cairo_R, Cairo_G, Cairo_G);
-
- cairo_select_font_face(cr, "Purisa",
- CAIRO_FONT_SLANT_NORMAL,
- CAIRO_FONT_WEIGHT_BOLD);
-
- cairo_set_font_size(cr, 20);
-
- cairo_move_to(cr, 20, height / 2.0);
- cairo_show_text(cr, "-----------THIS IS A TEST DRAW----------");
-
- cairo_fill (cr);
- */
-
// SetBkColor(DrawWindow, hcr, InSimulationMode ? HighlightColours.simBg :
// HighlightColours.bg);
@@ -243,7 +228,7 @@ void PaintWindow()
// SelectObject(hcr, FixedWidthFont);
- // TextOut(hcr, 5, 100, "-------] [-------------------------------------------------------------------------------------------------------------------------------------------------{RES}-------", 14);
+ // TextOut(DrawWindow, hcr, 5, 100, "-------] [-------------------------------------------------------------------------------------------------------------------------------------------------{RES}-------", 14);
// static HBITMAP BackBitmap;
// static HDC BackDc;
@@ -313,10 +298,10 @@ void PaintWindow()
if(rung < 10) {
char r[1] = { rung + '0' };
- TextOut(Hdc, 8 + FONT_WIDTH, yp, r, 1);
+ TextOut(DrawWindow, Hdc, 8 + FONT_WIDTH, yp, r, 1);
} else {
char r[2] = { (rung / 10) + '0', (rung % 10) + '0' };
- TextOut(Hdc, 8, yp, r, 2);
+ TextOut(DrawWindow, Hdc, 8, yp, r, 2);
}
int cx = 0;
@@ -354,9 +339,13 @@ void PaintWindow()
r.top = 0;
r.right = r.left + 4;
r.bottom = IoListTop;
+ g_print("IoList = %i\n", IoListTop);
FillRect(Hdc, &r, InSimulationMode ? BusLeftBrush : BusBrush);
+ g_print("ColsAvailable = %i\n", ColsAvailable);
r.left += POS_WIDTH*FONT_WIDTH*ColsAvailable + 2;
r.right += POS_WIDTH*FONT_WIDTH*ColsAvailable + 2;
+ g_print("right = %i\n", r.right);
+ g_print("left = %i\n", r.left);
FillRect(Hdc, &r, InSimulationMode ? BusRightBus : BusBrush);
CursorDrawn = FALSE;
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index e878eae..49371d4 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -1058,10 +1058,14 @@ gboolean LD_WM_Paint_call(HWID widget, HCRDC cr, gpointer data)
// GtkStyleContext *context;
// context = gtk_widget_get_style_context (widget);
-
+
// 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);
+ // SetBkColor(widget, cr, HighlightColours.bg);
+
// gtk_render_background (context, cr, 0, 0, width, height);
// cairo_arc (cr,
@@ -1069,32 +1073,25 @@ gboolean LD_WM_Paint_call(HWID widget, HCRDC cr, gpointer data)
// MIN (width, height) / 3.0,
// 0, 2 * G_PI);
+ // cairo_rectangle(cr, 0, 0, width, height);
+ // cairo_stroke_preserve(cr);
+
// gtk_style_context_get_color (context,
// gtk_style_context_get_state (context),
// &color);
// gdk_cairo_set_source_rgba (cr, &color);
// cairo_fill (cr);
- // static double Cairo_R = 0.0, Cairo_G = 0.0, Cairo_B = 0.0;
- // cairo_set_source_rgb(cr, Cairo_R, Cairo_G, Cairo_G);
- // Cairo_R = (Cairo_R+0.2 > 0.4) ? 0 : Cairo_R+0.2;
- // Cairo_G = (Cairo_G+0.4 > 1.0) ? 0.4 : Cairo_G+0.4;
- // Cairo_B = (Cairo_B+0.1 > 0.5) ? 0 : Cairo_B+0.1;
- // cairo_select_font_face(cr, "Purisa",
- // CAIRO_FONT_SLANT_NORMAL,
- // CAIRO_FONT_WEIGHT_BOLD);
-
- // cairo_set_font_size(cr, 20);
-
- // cairo_move_to(cr, 20, height / 2.0);
- // cairo_show_text(cr, "-----------THIS IS A TEST DRAW----------");
-
- // cairo_fill (cr);
+ // SetTextColor(cr, HighlightColours.rungNum);
+ // SelectObject(cr, FixedWidthFont);
+ // for(int i = 10; i<500; i+=20)
+ // {
+ // TextOut(DrawWindow, cr, 20, i, "-------] [-------------------------------------------------------------------------------------------------------------------------------------------------{RES}-------", 14);
+ // }
- // PAINTSTRUCT ps;
- Hdc = cr;//BeginPaint(hwnd, &ps);
+ Hdc = cr;
/// This draws the schematic.
PaintWindow();
@@ -1107,32 +1104,6 @@ gboolean LD_WM_Paint_call(HWID widget, HCRDC cr, gpointer data)
// cairo_stroke_preserve(cr);
// cairo_fill(cr);
- RECT r;
- // Fill around the scroll bars
- // if(NeedHoriz) {
- ScrollHeight = 10;
- r.top = IoListTop - ScrollHeight - 2;
- r.bottom = IoListTop - 2;
- r.right = 5;
- FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
- // }
- GetClientRect(DrawWindow, &r);
- ScrollWidth = 10;
- r.left = r.right - ScrollWidth - 2;
- FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
- // Draw the splitter thing to grab to resize the I/O listview.
- GetClientRect(DrawWindow, &r);
- r.top = IoListTop - 2;
- r.bottom = IoListTop;
- FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
- r.top = IoListTop - 2;
- r.bottom = IoListTop - 1;
- FillRect(Hdc, &r, (HBRUSH)GetStockObject(WHITE_BRUSH));
- r.top = IoListTop;
- r.bottom = IoListTop + 1;
- FillRect(Hdc, &r, (HBRUSH)GetStockObject(DKGRAY_BRUSH));
- // EndPaint(hwnd, &ps);
-
return FALSE;
}
@@ -1156,8 +1127,7 @@ gboolean LD_WM_Size_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
* WM_SIZE
*/
- // MainWindowResized();
- // break;
+ MainWindowResized();
return FALSE;
}
@@ -1168,8 +1138,7 @@ gboolean LD_WM_SetFocus_call(GtkWidget *widget, GdkEvent *event, gpointer user_d
* WM_SETFOCUS
*/
- // InvalidateRect(MainWindow, NULL, FALSE);
- // break;
+ InvalidateRect(DrawWindow, NULL, FALSE);
return FALSE;
}
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
diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp
index a08696f..9ed011a 100644
--- a/ldmicro/maincontrols.cpp
+++ b/ldmicro/maincontrols.cpp
@@ -885,10 +885,33 @@ void GenerateIoListDontLoseSelection(void)
//-----------------------------------------------------------------------------
void MainWindowResized(void)
{
+ RECT main;
+ GetClientRect(DrawWindow, &main);
+
+ RECT status;
+ GetWindowRect(StatusBar, &status);
+ int statusHeight = status.bottom - status.top;
+
+ // MoveWindow(StatusBar, 0, main.bottom - statusHeight, main.right,
+ // statusHeight, TRUE);
+
// Make sure that the I/O list can't disappear entirely.
if(IoListHeight < 30) {
IoListHeight = 30;
}
+ IoListTop = main.bottom ;//- IoListHeight - statusHeight;
+
+ // Make sure that we can't drag the top of the I/O list above the
+ // bottom of the menu bar, because it then becomes inaccessible.
+ if(IoListTop < 5) {
+ IoListHeight = main.bottom - statusHeight - 5;
+ IoListTop = main.bottom - IoListHeight - statusHeight;
+ }
+ // MoveWindow(IoList, 0, IoListTop, main.right, IoListHeight, TRUE);
+
+ RefreshScrollbars();
+
+ InvalidateRect(DrawWindow, NULL, FALSE);
}
//-----------------------------------------------------------------------------