diff options
Diffstat (limited to 'ldmicro/lib/linuxUI/linuxUI.cpp')
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 161 |
1 files changed, 101 insertions, 60 deletions
diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index e8a8ab5..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) @@ -288,22 +300,13 @@ void SelectObject(HCRDC hcr, HFONT hfont) { if (hcr ==NULL) return; - - 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, "Z", &extents); - // cairo_matrix_t matrix; - // cairo_matrix_init_scale (&matrix, - // (double)hfont->nWidth, - // (double)hfont->nHeight); - - // cairo_set_font_matrix (hcr, &matrix); - - cairo_set_font_size(hcr, 10); + 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(qtfont); } HBRUSH CreateBrushIndirect(PLOGBRUSH plb) @@ -334,41 +337,54 @@ HFONT CreateFont(int nHeight, int nWidth, int nOrientation, int fnWeight, void SetBkColor(HWID widget, HCRDC hcr, COLORREF bkCol) { -/* if (hcr == NULL) - return; - - gtk_widget_override_background_color(GTK_WIDGET(widget), - GTK_STATE_FLAG_NORMAL, &bkCol); - - 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); - - // gtk_style_context_get_color (context, - // gtk_style_context_get_state (context), - // &col); - gdk_cairo_set_source_rgba (hcr, &bkCol); - // cairo_rectangle(hcr, 0, 0, width, height); - // cairo_stroke_preserve(hcr); - - cairo_fill (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; @@ -431,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); @@ -450,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; @@ -503,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); - if (record_it != timerRecords.end()) - return 0; + return TimerID; + // auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&nIDEvent](TimerRecord &Record) { return Record.ufID == nIDEvent; }); - TimerRecord tr; - tr.pfun = lpTimerFunc; - tr.ufID = nIDEvent; - tr.utID = g_timeout_add(uElapse, (GSourceFunc)lpTimerFunc, FALSE); + // if (record_it != timerRecords.end()) + // return 0; - timerRecords.push_back(tr); - return tr.utID; + // TimerRecord tr; + // tr.pfun = lpTimerFunc; + // tr.ufID = nIDEvent; + // tr.utID = g_timeout_add(uElapse, (GSourceFunc)lpTimerFunc, FALSE); + + // timerRecords.push_back(tr); + // return tr.utID; } BOOL KillTimer(HWID hWid, UINT uIDEvent) @@ -540,3 +579,5 @@ void DestroyWindow (HWID widget) gtk_widget_destroy (widget); }*/ } + + |