diff options
author | akshay-c | 2019-03-18 12:52:03 +0530 |
---|---|---|
committer | akshay-c | 2019-03-18 12:52:03 +0530 |
commit | 08ca539a8d6624e979bf4e85a61ff00567575667 (patch) | |
tree | dbdce755481abdbe999fdd83be9408c002401a71 /ldmicro/lib/linuxUI | |
parent | 0dbffa99fda94203c74b955f6f9fe534f30c6421 (diff) | |
download | LDmicroQt-08ca539a8d6624e979bf4e85a61ff00567575667.tar.gz LDmicroQt-08ca539a8d6624e979bf4e85a61ff00567575667.tar.bz2 LDmicroQt-08ca539a8d6624e979bf4e85a61ff00567575667.zip |
Cursor updates
Diffstat (limited to 'ldmicro/lib/linuxUI')
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.h | 2 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 126 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 22 |
3 files changed, 116 insertions, 34 deletions
diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h index 29e6ebc..470c7cc 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -78,7 +78,7 @@ typedef GtkTreeIter ITLIST; typedef GDRECT* PGDRECT; typedef QMenu* HMENU; typedef ITLIST* HITLIST; -typedef QPalette* HCRDC; +typedef QPainter* HCRDC; typedef QWidget* HWID; typedef QWidget* HWND; typedef GdkPixbuf* HICON; diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index 727fea8..3f8896c 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -236,28 +236,40 @@ BOOL GetOpenFileName(OPENFILENAME *ofn) } +void EnableMenuItem(HMENU MenuName, QAction* MenuItem, UINT CheckEnabledItem) +{ + switch (CheckEnabledItem){ + case MF_ENABLED : + MenuItem->setEnabled(true); + break; + case MF_GRAYED : + MenuItem->setEnabled(false); + break; + } +} + void EnableMenuItem(HMENU MenuName, HMENU MenuItem, UINT CheckEnabledItem) { - /*switch (CheckEnabledItem){ + switch (CheckEnabledItem){ case MF_ENABLED : - gtk_widget_set_sensitive (MenuItem, true); + MenuItem->setEnabled(true); break; case MF_GRAYED : - gtk_widget_set_sensitive (MenuItem, false); + MenuItem->setEnabled(false); break; - }*/ + } } -void CheckMenuItem(HMENU MenuName, HMENU MenuItem, UINT Check) +void CheckMenuItem(HMENU MenuName, QAction* MenuItem, UINT Check) { - /*switch (Check){ + switch (Check){ case MF_CHECKED : - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(MenuItem), true); + MenuItem->setChecked(true); break; case MF_UNCHECKED : - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(MenuItem), false); + MenuItem->setChecked(false); break; - }*/ + } } HANDLE GetStockObject(int fnObject) @@ -284,15 +296,17 @@ HANDLE GetStockObject(int fnObject) } } -void SelectObject(QPainter* hcr, HFONT hfont) +void SelectObject(HCRDC hcr, HFONT hfont) { if (hcr ==NULL) return; - QFont qtfont(hfont->lpszFace); - qtfont.setPointSize(hfont->nHeight); + QFont qtfont = hcr->font(); + qtfont.setFamily(hfont->lpszFace); + qtfont.setPixelSize(hfont->nHeight - 3); + qtfont.setFixedPitch(TRUE); qtfont.setStyle(hfont->fdwItalic ? QFont::StyleItalic : QFont::StyleNormal); qtfont.setWeight(hfont->fnWeight == FW_BOLD ? QFont::Bold : QFont::Normal); - hcr->setFont(); + hcr->setFont(qtfont); } HBRUSH CreateBrushIndirect(PLOGBRUSH plb) @@ -323,21 +337,54 @@ HFONT CreateFont(int nHeight, int nWidth, int nOrientation, int fnWeight, void SetBkColor(HWID widget, HCRDC hcr, COLORREF bkCol) { - hcr->setColor(QPalette::Background, bkCol); - widget->setPalette(*hcr); + QPalette pal = widget->palette(); + pal.setColor(QPalette::Background, bkCol); + widget->setPalette(pal); } void SetTextColor(HCRDC hcr, COLORREF color) { if (hcr == NULL) return; - + QPen qtpen = hcr->pen(); + qtpen.setColor(color); + hcr->setPen(qtpen); HdcCurrentTextColor = color; // gdk_cairo_set_source_rgba (hcr, &color); } void TextOut(HWID hWid, HCRDC hcr, int nXStart, int nYStart, LPCTSTR lpString, int cchString) { + if (hcr == NULL) + return; + int width = hWid->width(); + int height = hWid->height(); + BOOL resize_flag = FALSE; + QFont newFont= hcr->font(); + // newFont + /*if(nYStart+(extents.height/2.0) >= height) + { + height += extents.height + 50; + resize_flag = TRUE; + } + + if (nXStart+(extents.width/2.0) >= width) + { + width += extents.width; + resize_flag = TRUE; + }*/ + char* text = (char*)malloc(cchString); + strncpy(text, lpString, cchString); + text[cchString] = '\0'; + + hcr->drawText(nXStart, nYStart, (QString)text); + // cairo_move_to(hcr, nXStart, nYStart); + // cairo_show_text(hcr, text); + + // cairo_fill (hcr); + + /*if (resize_flag) // To do later + hcr->setWindow();*/ /*if (hcr == NULL) return; @@ -400,13 +447,19 @@ BOOL InvalidateRect(HWID hWid, const RECT *lpRect, BOOL bErase) // gtk_widget_queue_draw(hWid); gdk_window_invalidate_rect (gtk_widget_get_window (hWid), &Gdrect, FALSE); */ + hWid->repaint(); return TRUE; } -int FillRect(HCRDC hDC, const RECT *lprc, HBRUSH hbr) +int FillRect(HCRDC hDC, const QRect *lprc, HBRUSH hbr) { if (hDC == NULL) return -1; + QBrush curbrush = hDC->brush(); + curbrush.setColor(*hbr); + curbrush.setStyle(Qt::SolidPattern); + hDC->setBrush(curbrush); + hDC->drawRect(*lprc); /* GDRECT gdrc; RECT_to_GDRECT(lprc, &gdrc); @@ -419,7 +472,7 @@ int FillRect(HCRDC hDC, const RECT *lprc, HBRUSH hbr) return 0; } -BOOL PatBlt(HCRDC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, DWORD dwRop, HBRUSH hbr) +BOOL PatBlt(HWID hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, DWORD dwRop, HBRUSH hbr) { if (hdc == NULL) return FALSE; @@ -472,20 +525,37 @@ BOOL GetWindowRect(HWID hWid, PRECT pRect) } -UINT SetTimer(HWID hWid, UINT nIDEvent, UINT uElapse, BOOL (*lpTimerFunc)(BOOL) ) +UINT SetTimer(HWID hWid, UINT nIDEvent, UINT uElapse, UINT TimerID) { - auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&nIDEvent](TimerRecord &Record) { return Record.ufID == nIDEvent; }); + if(TimerID != NULL) + return nIDEvent; + if(nIDEvent == TIMER_BLINK_CURSOR) + { + TimerID = hWid->startTimer(uElapse); + CursorObject = new QGroupBox(hWid); + + QPalette pal = CursorObject->palette(); + pal.setColor(QPalette::Background, Qt::white); + CursorObject->setAutoFillBackground(true); + CursorObject->setPalette(pal); + // CursorObject->setGeometry(100,100,2,20); + } + // if(hWid!=NULL) + // CursorObject->setVisible(TRUE); + + return TimerID; + // auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&nIDEvent](TimerRecord &Record) { return Record.ufID == nIDEvent; }); - if (record_it != timerRecords.end()) - return 0; + // if (record_it != timerRecords.end()) + // return 0; - TimerRecord tr; - tr.pfun = lpTimerFunc; - tr.ufID = nIDEvent; - tr.utID = g_timeout_add(uElapse, (GSourceFunc)lpTimerFunc, FALSE); + // TimerRecord tr; + // tr.pfun = lpTimerFunc; + // tr.ufID = nIDEvent; + // tr.utID = g_timeout_add(uElapse, (GSourceFunc)lpTimerFunc, FALSE); - timerRecords.push_back(tr); - return tr.utID; + // timerRecords.push_back(tr); + // return tr.utID; } BOOL KillTimer(HWID hWid, UINT uIDEvent) diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index 88a89c4..7054b61 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -10,6 +10,7 @@ #include <QVBoxLayout> #include <QLabel> #include <QPainter> +#include <QGroupBox> // #include <QtGui> // #include <QSize> // #include "freezeLD.h" @@ -27,6 +28,10 @@ #define LDMicro_VERSION_MAJOR 1 #define LDMicro_VERSION_MINOR 0 +// Timer IDs associated with the main window. +#define TIMER_BLINK_CURSOR 1 +#define TIMER_SIMULATE 2 + /// Flags /// message box #define MB_OK 0x00000001L @@ -129,6 +134,7 @@ extern const UINT MF_UNCHECKED; /// Accelerators (keyboard shortcuts) extern GtkAccelGroup* AccelGroup; extern GClosure* closure; +extern QGroupBox* CursorObject; /// ListStore extern HWID view; @@ -177,18 +183,23 @@ BOOL GetOpenFileName(OPENFILENAME *ofn); void EnableMenuItem( HMENU MenuName, + QAction* MenuItem, + UINT CheckEnabledItem); + +void EnableMenuItem( + HMENU MenuName, HMENU MenuItem, UINT CheckEnabledItem); void CheckMenuItem( HMENU MenuName, - HMENU MenuItem, + QAction* MenuItem, UINT Check); HANDLE GetStockObject(int fnObject); void SelectObject( - QPainter* hcr, + HCRDC hcr, HFONT hfont); HBRUSH CreateBrushIndirect(PLOGBRUSH plb); @@ -227,11 +238,11 @@ BOOL InvalidateRect( int FillRect( HCRDC hDC, - const RECT *lprc, + const QRect *lprc, HBRUSH hbr); BOOL PatBlt( - HCRDC hdc, + HWID hdc, int nXLeft, int nYLeft, int nWidth, @@ -259,7 +270,7 @@ UINT SetTimer( HWID hWid, UINT nIDEvent, UINT uElapse, - BOOL (*lpTimerFunc)(BOOL)); + UINT TimerID); BOOL KillTimer( HWID hWid, @@ -275,6 +286,7 @@ public: protected: void paintEvent(QPaintEvent *event); + void timerEvent(QTimerEvent *event); signals: public slots: |