diff options
Diffstat (limited to 'ldmicro/lib')
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.h | 5 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 136 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 101 |
3 files changed, 103 insertions, 139 deletions
diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h index 470c7cc..edaead8 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -74,14 +74,15 @@ typedef GtkApplication* HAPP; typedef GtkTreeViewColumn* HTVC; typedef GdkRectangle* GDRECT; typedef QTreeWidget* HLIST; -typedef GtkTreeIter ITLIST; +typedef QList<QTreeWidgetItem *> ITLIST; typedef GDRECT* PGDRECT; typedef QMenu* HMENU; -typedef ITLIST* HITLIST; +typedef ITLIST HITLIST; typedef QPainter* HCRDC; typedef QWidget* HWID; typedef QWidget* HWND; typedef GdkPixbuf* HICON; +typedef QScrollArea* WM_SCROLL; /// Check if system is x64 or x86 diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index 3f8896c..b17edf7 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -49,56 +49,10 @@ COLORREF RGB(int red, int green, int blue) return col; } -int MessageBox(HWID pWindow, char* message, char* title, UINT mFlags) +int MessageBox(HWID pWindow, char* message, char* title, UINT mFlags, UINT iFlags) { -/* GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT; - GtkMessageType mType; - - if ((mFlags & MB_ICONERROR) == MB_ICONERROR) - mType = GTK_MESSAGE_ERROR; - else if ((mFlags & MB_ICONQUESTION) == MB_ICONQUESTION) - mType = GTK_MESSAGE_QUESTION; - else if ((mFlags & MB_ICONWARNING) == MB_ICONWARNING) - mType = GTK_MESSAGE_WARNING; - else if ((mFlags & MB_ICONINFORMATION) == MB_ICONINFORMATION) - mType = GTK_MESSAGE_INFO; - else - mType = GTK_MESSAGE_OTHER; - - mType = GTK_MESSAGE_ERROR; - HWID dialog = gtk_message_dialog_new (GTK_WINDOW(pWindow), - flags, - mType, - GTK_BUTTONS_NONE, - message); - - if ((mFlags & MB_OKCANCEL) == MB_OKCANCEL) - { - gtk_dialog_add_button(GTK_DIALOG(dialog), "_OK", IDOK); - gtk_dialog_add_button(GTK_DIALOG(dialog), "_CANCEL", IDCANCEL); - } - else if ((mFlags & MB_YESNO) == MB_YESNO) - { - gtk_dialog_add_button(GTK_DIALOG(dialog), "_YES", IDYES); - gtk_dialog_add_button(GTK_DIALOG(dialog), "_NO", IDNO); - } - else if ((mFlags & MB_YESNOCANCEL) == MB_YESNOCANCEL) - { - gtk_dialog_add_button(GTK_DIALOG(dialog), "_YES", IDYES); - gtk_dialog_add_button(GTK_DIALOG(dialog), "_NO", IDNO); - gtk_dialog_add_button(GTK_DIALOG(dialog), "_CANCEL", IDCANCEL); - } - else - gtk_dialog_add_button(GTK_DIALOG(dialog), "OK", IDOK); - - gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG(dialog), - title); - gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog), message); - int result = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -*/ - // return result; - return TRUE; + QMessageBox msg((QMessageBox::Icon)iFlags, title, message, (QMessageBox::StandardButton)mFlags, pWindow); + return msg.exec(); } @@ -175,63 +129,39 @@ BOOL GetSaveFileName(OPENFILENAME *ofn) BOOL GetOpenFileName(OPENFILENAME *ofn) { -/* GtkWidget *dialog; - GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; - - dialog = gtk_file_chooser_dialog_new (ofn->lpstrTitle, - GTK_WINDOW(ofn->parentWindow), - action, - "_Cancel", - GTK_RESPONSE_CANCEL, - "_Open", - GTK_RESPONSE_ACCEPT, - NULL); - - GtkFileFilter *filter = gtk_file_filter_new (); - char* strFilter = new char[strlen(ofn->lpstrFilter)]; + std::string strFilter; DWORD strFilterLen = 0; BOOL filterResetFlag = FALSE; - - for (int i = 0; !(ofn->lpstrFilter[i] == '\0' && ofn->lpstrFilter[i-1] == '\0'); ++i) + while(!((ofn->lpstrFilter[strFilterLen] == '\0') && + (ofn->lpstrFilter[strFilterLen + 1] == '\0'))) { - memcpy (strFilter + strFilterLen, &ofn->lpstrFilter[i], 1 ); - ++strFilterLen; - if (ofn->lpstrFilter[i] == '\0') - if (filterResetFlag) - { - gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter), strFilter); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(dialog), filter); - filter = gtk_file_filter_new (); - strFilterLen = 0; - filterResetFlag = FALSE; - } - else - { - gtk_file_filter_set_name (GTK_FILE_FILTER(filter), strFilter); - strFilterLen = 0; - filterResetFlag = TRUE; - } + if(filterResetFlag) + { + strFilter = strFilter + "("; + strFilter.append(&ofn->lpstrFilter[strFilterLen]); + strFilter = strFilter + ");;"; + filterResetFlag = FALSE; + } + else + { + strFilter.append(&ofn->lpstrFilter[strFilterLen]); + filterResetFlag = TRUE; + } + strFilterLen = strFilterLen + strlen(&ofn->lpstrFilter[strFilterLen]) +1; } - - sprintf(strFilter, "*.%s", ofn->lpstrDefExt); - gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter), strFilter); - //gtk_file_filter_set_name (filter, "int files"); - gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(dialog), filter); - - delete strFilter; - - BOOL exitStatus = gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT; - if (exitStatus) + // printf("patterns:%s\n",strFilter.c_str() ); + QString filename = QFileDialog::getOpenFileName(ofn->parentWindow, ofn->lpstrTitle, + QStandardPaths::locate(QStandardPaths::HomeLocation,".", + QStandardPaths::LocateDirectory), + strFilter.c_str()); + if(filename == NULL) { - char* str; - str = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(dialog)); - strcpy(ofn->lpstrFile, str); - g_free(str); + return FALSE; } - gtk_widget_destroy (dialog); + strcpy(ofn->lpstrFile,filename.toStdString().c_str()); + // printf("FileName:%s",ofn->lpstrFile); - return exitStatus;*/ return TRUE; } @@ -538,7 +468,7 @@ UINT SetTimer(HWID hWid, UINT nIDEvent, UINT uElapse, UINT TimerID) pal.setColor(QPalette::Background, Qt::white); CursorObject->setAutoFillBackground(true); CursorObject->setPalette(pal); - // CursorObject->setGeometry(100,100,2,20); + CursorObject->setGeometry(0,0,2,20); } // if(hWid!=NULL) // CursorObject->setVisible(TRUE); @@ -560,14 +490,18 @@ UINT SetTimer(HWID hWid, UINT nIDEvent, UINT uElapse, UINT TimerID) BOOL KillTimer(HWID hWid, UINT uIDEvent) { - auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&uIDEvent](TimerRecord &Record) { return Record.ufID == uIDEvent; }); + /*auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&uIDEvent](TimerRecord &Record) { return Record.ufID == uIDEvent; }); if (record_it == timerRecords.end()) return FALSE; record_it->pfun(TRUE); g_source_remove (record_it->utID); - timerRecords.erase(record_it); + timerRecords.erase(record_it);*/ + if(uIDEvent == TIMER_BLINK_CURSOR) + { + hWid->killTimer(CursorTimer); + } return TRUE; } diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index 7054b61..ed2a961 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -11,6 +11,14 @@ #include <QLabel> #include <QPainter> #include <QGroupBox> +#include <QSignalMapper> +#include <QKeyEvent> +#include <QScrollArea> +#include <QScrollBar> +#include <QMessageBox> +#include <QFileDialog> +#include <QStandardPaths> +#include <QPlainTextEdit> // #include <QtGui> // #include <QSize> // #include "freezeLD.h" @@ -34,20 +42,20 @@ /// Flags /// message box -#define MB_OK 0x00000001L -#define MB_OKCANCEL 0x00000002L -#define MB_YESNO 0x00000004L -#define MB_YESNOCANCEL 0x00000008L +#define MB_OK QMessageBox::Ok +#define MB_OKCANCEL QMessageBox::Ok | QMessageBox::Cancel +#define MB_YESNO QMessageBox::Yes | QMessageBox::No +#define MB_YESNOCANCEL QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel -#define IDOK 1 -#define IDCANCEL 2 -#define IDYES 3 -#define IDNO 4 +#define IDOK QMessageBox::Ok +#define IDCANCEL QMessageBox::Cancel +#define IDYES QMessageBox::Yes +#define IDNO QMessageBox::No -#define MB_ICONERROR 0x00000010L -#define MB_ICONQUESTION 0x00000020L -#define MB_ICONWARNING 0x00000040L -#define MB_ICONINFORMATION 0x00000080L +#define MB_ICONERROR QMessageBox::Critical +#define MB_ICONQUESTION QMessageBox::Question +#define MB_ICONWARNING QMessageBox::Warning +#define MB_ICONINFORMATION QMessageBox::Information /// Scroll #define SB_LINEUP 0x00000001 @@ -77,34 +85,34 @@ #define PATINVERT 0x00000100L /// Key masks -#define VK_TAB GDK_KEY_Tab +#define VK_TAB Qt::Key_Tab -#define VK_DOWN 65364 -#define VK_UP 65362 -#define VK_LEFT 65361 -#define VK_RIGHT 65363 +#define VK_DOWN Qt::Key_Down +#define VK_UP Qt::Key_Up +#define VK_LEFT Qt::Key_Left +#define VK_RIGHT Qt::Key_Right -#define VK_NP_DOWN 65433 -#define VK_NP_UP 65431 -#define VK_NP_LEFT 65430 -#define VK_NP_RIGHT 65432 +#define VK_NP_DOWN Qt::Key_Down +#define VK_NP_UP Qt::Key_Up +#define VK_NP_LEFT Qt::Key_Left +#define VK_NP_RIGHT Qt::Key_Right -#define VK_RETURN GDK_KEY_Return -#define VK_ESCAPE GDK_KEY_Escape -#define VK_F5 GDK_KEY_F5 -#define VK_F1 GDK_KEY_F1 +#define VK_RETURN Qt::Key_Return +#define VK_ESCAPE Qt::Key_Escape +#define VK_F5 Qt::Key_F5 +#define VK_F1 Qt::Key_F1 -#define VK_OEM_PLUS GDK_KEY_plus -#define VK_OEM_MINUS GDK_KEY_minus -#define VK_OEM_PERIOD GDK_KEY_period -#define VK_OEM_COMMA GDK_KEY_comma +#define VK_OEM_PLUS Qt::Key_Plus +#define VK_OEM_MINUS Qt::Key_Minus +#define VK_OEM_PERIOD Qt::Key_Period +#define VK_OEM_COMMA Qt::Key_Comma -#define VK_DELETE GDK_KEY_Delete -#define VK_NP_DELETE GDK_KEY_KP_Delete +#define VK_DELETE Qt::Key_Delete +#define VK_NP_DELETE Qt::Key_Delete -// #define VK_OEM_1 GDK_KEY_colon // GDK_KEY_semicolon -// #define VK_OEM_2 GDK_KEY_question // GDK_KEY_slash -// #define VK_OEM_5 GDK_KEY_backslash // GDK_KEY_bar +#define VK_OEM_1 Qt::Key_Colon // GDK_KEY_semicolon +#define VK_OEM_2 Qt::Key_Question // GDK_KEY_slash +#define VK_OEM_5 Qt::Key_Backslash // GDK_KEY_bar /// Window brushes #define BS_SOLID 0x00000001L @@ -140,10 +148,14 @@ extern QGroupBox* CursorObject; extern HWID view; extern HTVC column; +// Timer IDs associated with the main window. +extern int CursorTimer; +extern int SimulateTimer; + /// Structures typedef struct OpenFileInfoData { DWORD lStructSize; - HWID *parentWindow; + HWID parentWindow; LPTSTR lpstrFile; LPCTSTR lpstrFilter; DWORD nMaxFile; @@ -158,11 +170,25 @@ typedef struct TimerRecordTag { UINT utID; } TimerRecord; +/****************************************************************** +Class to create slots for signals + +*******************************************************************/ +class ProgramSlots : public QObject +{ + Q_OBJECT + public: + signals: + public slots: + void LD_WM_Command_call(int CommandCode); +}; + /// Variables extern COLORREF HdcCurrentTextColor; extern std::vector<TimerRecord> timerRecords; extern int GLOBAL_mouse_last_clicked_x; extern int GLOBAL_mouse_last_clicked_y; +extern ProgramSlots MenuHandle; /// functions BOOL GetFocus(HWID window); @@ -175,7 +201,8 @@ int MessageBox( HWID pWindow, char* message, char* title, - UINT mFlags); + UINT mFlags, + UINT iFlags); BOOL GetSaveFileName(OPENFILENAME *ofn); @@ -283,6 +310,8 @@ class PaintWidget : public QWidget Q_OBJECT public: // MyWidget(); + // PaintWidget(QWidget* parent): QWidget(parent) + // {} protected: void paintEvent(QPaintEvent *event); |