diff options
author | akshay-c | 2019-04-12 16:52:28 +0530 |
---|---|---|
committer | akshay-c | 2019-04-12 16:52:28 +0530 |
commit | 3b94e473db82f28fb022c1f5f9aa74a2e48fdaf3 (patch) | |
tree | 2d082c364682d8ff0e3457de6d2d0e1cdf968113 | |
parent | b0c1405589824fc9f9f464683286cdac7ad139d0 (diff) | |
download | LDmicroQt-3b94e473db82f28fb022c1f5f9aa74a2e48fdaf3.tar.gz LDmicroQt-3b94e473db82f28fb022c1f5f9aa74a2e48fdaf3.tar.bz2 LDmicroQt-3b94e473db82f28fb022c1f5f9aa74a2e48fdaf3.zip |
Simulation Code Uncommented; simpledialog addition in progress
-rw-r--r-- | ldmicro/CMakeLists.txt | 4 | ||||
-rw-r--r-- | ldmicro/coildialog.cpp | 93 | ||||
-rw-r--r-- | ldmicro/includes/ldmicro.h | 2 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 13 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 3 | ||||
-rw-r--r-- | ldmicro/maincontrols.cpp | 2 | ||||
-rw-r--r-- | ldmicro/miscutil.cpp | 13 | ||||
-rw-r--r-- | ldmicro/schematic.cpp | 12 | ||||
-rw-r--r-- | ldmicro/simpledialog.cpp | 14 | ||||
-rw-r--r-- | ldmicro/simulate.cpp | 6 |
10 files changed, 92 insertions, 70 deletions
diff --git a/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt index 2b4d332..ff67a60 100644 --- a/ldmicro/CMakeLists.txt +++ b/ldmicro/CMakeLists.txt @@ -144,8 +144,8 @@ endif() #confdialog.cpp #lutdialog.cpp #resetdialog.cpp - #simpledialog.cpp - #coildialog.cpp + # simpledialog.cpp + coildialog.cpp #contactsdialog.cpp #commentdialog.cpp simulate.cpp diff --git a/ldmicro/coildialog.cpp b/ldmicro/coildialog.cpp index 48630d4..f4888b9 100644 --- a/ldmicro/coildialog.cpp +++ b/ldmicro/coildialog.cpp @@ -29,19 +29,19 @@ static HWID CoilDialog; -static HWID SourceInternalRelayRadio; -static HWID SourceMcuPinRadio; -static HWID NegatedRadio; -static HWID NormalRadio; -static HWID SetOnlyRadio; -static HWID ResetOnlyRadio; -static HWID NameTextbox; +static QRadioButton* SourceInternalRelayRadio; +static QRadioButton* SourceMcuPinRadio; +static QRadioButton* NegatedRadio; +static QRadioButton* NormalRadio; +static QRadioButton* SetOnlyRadio; +static QRadioButton* ResetOnlyRadio; +static QLineEdit* NameTextbox; static HWID OkButton; static HWID CancelButton; static LONG_PTR PrevNameProc; -static HWID CoilGrid; +static QGridLayout* CoilGrid; static HWID CoilPackingBox; static bool* tmpnegated; static bool* tmpsetOnly ; @@ -51,7 +51,7 @@ static bool* tmpresetOnly; // Don't allow any characters other than A-Za-z0-9_ in the name. //----------------------------------------------------------------------------- -void CoilDialogMyNameProc (GtkEditable *editable, gchar *NewText, gint length, +/*void CoilDialogMyNameProc (GtkEditable *editable, gchar *NewText, gint length, gint *position, gpointer data){ for (int i = 0; i < length; i++){ if (!(isalpha (NewText[i]) || NewText[i] == '_' || isdigit (NewText[i]) @@ -61,21 +61,47 @@ void CoilDialogMyNameProc (GtkEditable *editable, gchar *NewText, gint length, } } } - +*/ static void MakeControls(void) { - NormalRadio = gtk_radio_button_new_with_label (NULL, "( ) Normal"); - NegatedRadio = gtk_radio_button_new_with_label_from_widget - (GTK_RADIO_BUTTON (NormalRadio), "(/) Negated"); - SetOnlyRadio = gtk_radio_button_new_with_label_from_widget - (GTK_RADIO_BUTTON (NormalRadio), "(S) Set-Only"); - ResetOnlyRadio = gtk_radio_button_new_with_label_from_widget - (GTK_RADIO_BUTTON (NormalRadio), "(R) Reset-Only"); + QGroupBox* grouper = new QGroupBox(_("Type")); + QGroupBox* grouper2 = new QGroupBox(_("Source")); + QGridLayout *TypeGrid = new QGridLayout(); + QGridLayout *SourceGrid = new QGridLayout(); + QGridLayout *NameGrid = new QGridLayout(); + NormalRadio = new QRadioButton(_("( ) Normal"), CoilDialog); + NegatedRadio = new QRadioButton(_("(/) Negated"), CoilDialog); + SetOnlyRadio = new QRadioButton(_("(S) Set-Only"), CoilDialog); + ResetOnlyRadio = new QRadioButton(_("(R) Reset-Only"), CoilDialog); + /*NormalRadio->setAutoExclusive(FALSE); + NegatedRadio->setAutoExclusive(FALSE);*/ + TypeGrid->addWidget(NormalRadio,0,0); + TypeGrid->addWidget(NegatedRadio,1,0); + TypeGrid->addWidget(SetOnlyRadio,2,0); + TypeGrid->addWidget(ResetOnlyRadio,3,0); + SourceInternalRelayRadio = new QRadioButton(_("Internal Relay"), CoilDialog); + SourceMcuPinRadio = new QRadioButton(_("Pin on MCU"), CoilDialog); + SourceGrid->addWidget(SourceInternalRelayRadio,0,0); + SourceGrid->addWidget(SourceMcuPinRadio,1,0); + QLabel* textLabel = new QLabel(_("Name:")); + NameTextbox = new QLineEdit(); + NameTextbox->setFixedWidth(155); + NameGrid->addWidget(textLabel,0,0); + NameGrid->addWidget(NameTextbox,0,1); + SourceGrid->addLayout(NameGrid,2,0); + grouper->setLayout(TypeGrid); + grouper2->setLayout(SourceGrid); + CoilGrid->addWidget(grouper,0,0); + CoilGrid->addWidget(grouper2,0,1); + // CoilGrid->addWidget(NormalRadio,0,0); + // CoilGrid->addWidget(NegatedRadio,1,0); + // CoilGrid->addWidget(SetOnlyRadio,2,0); + // CoilGrid->addWidget(ResetOnlyRadio,3,0); + /* SourceInternalRelayRadio = gtk_radio_button_new_with_label (NULL, "Internal Relay"); SourceMcuPinRadio = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (SourceInternalRelayRadio), "Pin on MCU"); - HWID textLabel = gtk_label_new ("Name:"); NameTextbox = gtk_entry_new(); @@ -99,9 +125,9 @@ static void MakeControls(void) gtk_box_pack_start(GTK_BOX(CoilPackingBox), CoilGrid, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (NameTextbox), "insert-text", - G_CALLBACK (CoilDialogMyNameProc), NULL); + G_CALLBACK (CoilDialogMyNameProc), NULL);*/ } - +/* void CoilDialogGetData (char* name){ bool* negated = tmpnegated; @@ -170,24 +196,25 @@ void CoilCallDestroyWindow (HWID widget, gpointer data){ DestroyWindow (CoilDialog); ProgramChanged(); gtk_widget_set_sensitive (MainWindow, TRUE); -} +}*/ void ShowCoilDialog(BOOL *negated, BOOL *setOnly, BOOL *resetOnly, char *name) { - CoilGrid = gtk_grid_new(); - CoilPackingBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - - CoilDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(CoilDialog), "Coil"); - gtk_window_set_default_size(GTK_WINDOW(CoilDialog), 100, 50); - gtk_window_set_resizable (GTK_WINDOW (CoilDialog), FALSE); - gtk_container_add(GTK_CONTAINER(CoilDialog), CoilPackingBox); - gtk_widget_add_events (CoilDialog, GDK_KEY_PRESS_MASK); - gtk_widget_add_events (CoilDialog, GDK_BUTTON_PRESS_MASK); + // CoilPackingBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + CoilDialog = CreateWindowClient(_("Coil"), + 100, 100, 359, 115, MainWindow); + CoilGrid = new QGridLayout(CoilDialog); + CoilDialog->setWindowTitle("Coil"); + // CoilDialog->resize(100, 50); + // CoilDialog->setFixedSize(359,115); + CoilDialog->show(); + // gtk_container_add(GTK_CONTAINER(CoilDialog), CoilPackingBox); + // gtk_widget_add_events (CoilDialog, GDK_KEY_PRESS_MASK); + // gtk_widget_add_events (CoilDialog, GDK_BUTTON_PRESS_MASK); MakeControls(); - if(name[0] == 'R') { + /*if(name[0] == 'R') { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (SourceInternalRelayRadio), TRUE); } else { @@ -221,6 +248,6 @@ void ShowCoilDialog(BOOL *negated, BOOL *setOnly, BOOL *resetOnly, char *name) G_CALLBACK(CoilDialogMouseClick), (gpointer)name); g_signal_connect (G_OBJECT (CancelButton), "clicked", G_CALLBACK(CoilCallDestroyWindow), NULL); - +*/ return; } diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h index f9710a0..5f56788 100644 --- a/ldmicro/includes/ldmicro.h +++ b/ldmicro/includes/ldmicro.h @@ -794,7 +794,7 @@ void WriteIhex(FILE *f, BYTE b); void FinishIhex(FILE *f); char *IoTypeToString(int ioType); void PinNumberForIo(char *dest, PlcProgramSingleIo *io); -HWID CreateWindowClient(GtkWindowType wType, GdkWindowTypeHint wthint, char *windowName, +HWID CreateWindowClient(char *windowName, int x, int y, int width, int height, HWND parent); void MakeComponentListClass(void); diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index a8c4eb3..015cbb8 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -152,16 +152,13 @@ void EnableMenuItem(HMENU MenuName, QAction* MenuItem, UINT CheckEnabledItem) } } +// Special function designed for qt, since disabling top-level menu +// Does not disable its child menus. They can still be accessed via +// keyboard shortcuts void EnableMenuItem(HMENU MenuName, HMENU MenuItem, UINT CheckEnabledItem) { - /*Blocks only the top menu signals. Does not block submenu signals. - Signals still executed through keyboard shortcuts - Reqd: - QList<QAction *> actions() - action->blockSignals(bool)*/ QList<QAction *> MenuList = MenuItem->actions(); QList<QAction *>::iterator item = MenuList.begin(); - // printf("MenuListCount%d\n", MenuList.count()); switch (CheckEnabledItem){ case MF_ENABLED : while((item != MenuList.end()))/* || !(MenuList->isEmpty))*/ @@ -169,7 +166,6 @@ void EnableMenuItem(HMENU MenuName, HMENU MenuItem, UINT CheckEnabledItem) (*item)->setEnabled(true); (*item)->blockSignals(false); item++; - // printf("Indexof%d\n", MenuList.indexOf(*item, 0)); } MenuItem->setEnabled(true); MenuItem->blockSignals(false); @@ -179,10 +175,7 @@ void EnableMenuItem(HMENU MenuName, HMENU MenuItem, UINT CheckEnabledItem) { (*item)->setEnabled(false); (*item)->blockSignals(true); - /*if(*item == InsertContactsMenu) - printf("InsertContactsMenu\n");*/ item++; - // printf("Indexof%d\n", MenuList.indexOf(*item, 0)); } MenuItem->setEnabled(false); MenuItem->blockSignals(true); diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index ed2a961..0ba229b 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -19,6 +19,9 @@ #include <QFileDialog> #include <QStandardPaths> #include <QPlainTextEdit> +#include <QRadioButton> +#include <QButtonGroup> +#include <QLineEdit> // #include <QtGui> // #include <QSize> // #include "freezeLD.h" diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp index 51d7b54..6794fea 100644 --- a/ldmicro/maincontrols.cpp +++ b/ldmicro/maincontrols.cpp @@ -1035,7 +1035,7 @@ void RefreshControlsToSettings(void) items.append(new QTreeWidgetItem(QStringList(QString("Item2")))); items.append(new QTreeWidgetItem(QStringList(QString("Item3")))); IoList->insertTopLevelItems(0, items);*/ - DrawWindow->repaint(); + // DrawWindow->repaint(); QTreeWidgetItem iter; QTreeWidgetItem* selection; if(!IoListOutOfSync) { diff --git a/ldmicro/miscutil.cpp b/ldmicro/miscutil.cpp index 9493943..18e7f82 100644 --- a/ldmicro/miscutil.cpp +++ b/ldmicro/miscutil.cpp @@ -204,15 +204,12 @@ void FinishIhex(FILE *f) //----------------------------------------------------------------------------- // Create a window with a given client area. //----------------------------------------------------------------------------- -/*HWID CreateWindowClient(GtkWindowType wType, GdkWindowTypeHint wthint, char *windowName, +HWID CreateWindowClient(char *windowName, int x, int y, int width, int height, HWND parent) { - HWID h = gtk_window_new(wType); - gtk_window_set_title(GTK_WINDOW(h), windowName); - gtk_window_resize (GTK_WINDOW(h), width, height); - gtk_window_move(GTK_WINDOW(h), x, y); - gtk_window_set_type_hint (GTK_WINDOW(h), wthint); - + HWID h = new QDialog(parent); + h->resize(width,height); + h->setWindowTitle(windowName); // HWND h = CreateWindowEx(exStyle, className, windowName, style, x, y, // width, height, parent, menu, instance, param); @@ -224,7 +221,7 @@ void FinishIhex(FILE *f) // SetWindowPos(h, HWND_TOP, x, y, width, height, 0); return h; -}*/ +} //----------------------------------------------------------------------------- // Window proc for the dialog boxes. This Ok/Cancel stuff is common to a lot diff --git a/ldmicro/schematic.cpp b/ldmicro/schematic.cpp index a656183..1670475 100644 --- a/ldmicro/schematic.cpp +++ b/ldmicro/schematic.cpp @@ -402,22 +402,22 @@ void EditSelectedElement(void) { if(!Selected || Selected->selectedState == SELECTED_NONE) return; - /*switch(SelectedWhich) { - case ELEM_COMMENT: + switch(SelectedWhich) { + /*case ELEM_COMMENT: ShowCommentDialog(Selected->d.comment.str); break; case ELEM_CONTACTS: ShowContactsDialog(&(Selected->d.contacts.negated), Selected->d.contacts.name); - break; + break;*/ case ELEM_COIL: ShowCoilDialog(&(Selected->d.coil.negated), &(Selected->d.coil.setOnly), &(Selected->d.coil.resetOnly), Selected->d.coil.name); break; - +/* case ELEM_TON: case ELEM_TOF: case ELEM_RTO: @@ -492,8 +492,8 @@ void EditSelectedElement(void) case ELEM_LOOK_UP_TABLE: ShowLookUpTableDialog(Selected); - break; - }*/ + break;*/ + } } //----------------------------------------------------------------------------- diff --git a/ldmicro/simpledialog.cpp b/ldmicro/simpledialog.cpp index 3fe5e1f..6291e24 100644 --- a/ldmicro/simpledialog.cpp +++ b/ldmicro/simpledialog.cpp @@ -59,7 +59,7 @@ static SimpleDialogData SDdata; #define SD_SHIFT_REGISTER 0x0000009 #define SD_FORMATTED_STRING 0x0000010 #define SD_PERSIST 0x0000011 - +/* //----------------------------------------------------------------------------- // Don't allow any characters other than -A-Za-z0-9_ in the box. //----------------------------------------------------------------------------- @@ -328,7 +328,7 @@ static gboolean SimpleDialogKeyPressProc(HWID widget, GdkEventKey* event, gpoint } return FALSE; -} +}*/ void ShowSimpleDialog(char *title, int boxes, char **labels, DWORD numOnlyMask, DWORD alnumOnlyMask, DWORD fixedFontMask, char **dests) @@ -343,13 +343,14 @@ void ShowSimpleDialog(char *title, int boxes, char **labels, DWORD numOnlyMask, if(boxes > MAX_BOXES) oops(); SimpleDialog = CreateWindowClient(GTK_WINDOW_TOPLEVEL, GDK_WINDOW_TYPE_HINT_NORMAL, - title, 100, 100, 304, 15 + 30*(boxes < 2 ? 2 : boxes), GTK_WINDOW(MainWindow) ); + title, 100, 100, 304, 15 + 30*(boxes < 2 ? 2 : boxes), MainWindow); + SimpleDialog->show(); // CreateWindowClient(0, "LDmicroDialog", title, // WS_OVERLAPPED | WS_SYSMENU, // 100, 100, 304, 15 + 30*(boxes < 2 ? 2 : boxes), NULL, NULL, // Instance, NULL); - MakeControls(boxes, labels, fixedFontMask); +/* MakeControls(boxes, labels, fixedFontMask); int i; for(i = 0; i < boxes; i++) @@ -379,7 +380,7 @@ void ShowSimpleDialog(char *title, int boxes, char **labels, DWORD numOnlyMask, // EnableWindow(MainWindow, FALSE); // ShowWindow(SimpleDialog, TRUE); gtk_widget_show_all(SimpleDialog); - // SetFocus(Textboxes[0]); +*/ // SetFocus(Textboxes[0]); // SendMessage(Textboxes[0], EM_SETSEL, 0, -1); // MSG msg; @@ -413,7 +414,7 @@ void ShowSimpleDialog(char *title, int boxes, char **labels, DWORD numOnlyMask, // return !didCancel; } -void ShowTimerDialog(int which, int *delay, char *name) +/*void ShowTimerDialog(int which, int *delay, char *name) { char *s; switch(which) { @@ -698,3 +699,4 @@ void ShowPersistDialog(char *var) ShowSimpleDialog(_("Make Persistent"), 1, labels, 0, 1, 1, dests); } +*/
\ No newline at end of file diff --git a/ldmicro/simulate.cpp b/ldmicro/simulate.cpp index 4a3475a..2d9be0b 100644 --- a/ldmicro/simulate.cpp +++ b/ldmicro/simulate.cpp @@ -694,7 +694,7 @@ void SimulateOneCycle(BOOL forceRefresh) // event loop, and there is risk that we would go recursive. So let // us fix that. (Note that there are no concurrency issues; we really // would get called recursively, not just reentrantly.) -/* static BOOL Simulating = FALSE; + static BOOL Simulating = FALSE; if(Simulating) return; Simulating = TRUE; @@ -713,14 +713,14 @@ void SimulateOneCycle(BOOL forceRefresh) if(NeedRedraw || SimulateRedrawAfterNextCycle || forceRefresh) { InvalidateRect(DrawWindow, NULL, FALSE); RefreshControlsToSettings(); - gtk_widget_queue_draw(DrawWindow); + // gtk_widget_queue_draw(DrawWindow); // ListView_RedrawItems(IoList, 0, Prog.io.count - 1); } SimulateRedrawAfterNextCycle = FALSE; if(NeedRedraw) SimulateRedrawAfterNextCycle = TRUE; - Simulating = FALSE;*/ + Simulating = FALSE; } //----------------------------------------------------------------------------- |