diff options
author | NatsuDrag9 | 2018-06-28 09:49:09 +0530 |
---|---|---|
committer | NatsuDrag9 | 2018-06-28 09:49:09 +0530 |
commit | 8b1f25cfb7b201c873b39ca0e4521b971a085d48 (patch) | |
tree | adf1f6d8b4a9509ee6ce2668e285a6abe2d796d3 /ldmicro | |
parent | daa2a7810dedccf79355ecfeb31ce115a6508824 (diff) | |
download | LDMicroGtk-8b1f25cfb7b201c873b39ca0e4521b971a085d48.tar.gz LDMicroGtk-8b1f25cfb7b201c873b39ca0e4521b971a085d48.tar.bz2 LDMicroGtk-8b1f25cfb7b201c873b39ca0e4521b971a085d48.zip |
Testing piecewise dialog
Diffstat (limited to 'ldmicro')
-rw-r--r-- | ldmicro/lutdialog.cpp | 188 |
1 files changed, 99 insertions, 89 deletions
diff --git a/ldmicro/lutdialog.cpp b/ldmicro/lutdialog.cpp index 919b9bd..c28f6d3 100644 --- a/ldmicro/lutdialog.cpp +++ b/ldmicro/lutdialog.cpp @@ -530,99 +530,109 @@ void ShowLookUpTableDialog(ElemLeaf *l) // GLOBAL_LUT_DIALOG_TIMER = g_timeout_add(100, (GSourceFunc)LutRefreshDialog, (gpointer)l); } +gboolean PiecewiseDialogKeyPress (HWID widget, + GdkEventKey* event, gpointer data){ + if (event->keyval = GDK_KEY_Return){ + PiecewiseDialogGetData(); + } + else if (event->keyval = GDK_KEY_Return){ + + } +} + //----------------------------------------------------------------------------- // Show the piecewise linear table dialog. This one can only be edited in // only a single format, which makes things easier than before. // //----------------------------------------------------------------------------- -// void ShowPiecewiseLinearDialog(ElemLeaf *l) -// { -// ElemPiecewiseLinear *t = &(l->d.piecewiseLinear); - -// // First copy over all the stuff from the leaf structure; in particular, -// // we need our own local copy of the table entries, because it would be -// // bad to update those in the leaf before the user clicks okay (as he -// // might cancel). -// int count = t->count; -// memset(ValuesCache, 0, sizeof(ValuesCache)); -// int i; -// for(i = 0; i < count*2; i++) { -// ValuesCache[i] = t->vals[i]; -// } - -// // Now create the dialog's fixed controls, plus the changing (depending -// // on show style/entry count) controls for the initial configuration. - -// LutDialog = gtk_dialog_new_with_buttons ("Piecewise Linear Table", GTK_WINDOW (MainWindow), -// GTK_DIALOG_MODAL, "Ok", GTK_RESPONSE_ACCEPT, -// "Cancel", GTK_RESPONSE_REJECT, NULL); -// gtk_widget_add_events (LutDialog, GDK_KEY_PRESS_MASK); -// gtk_widget_add_events (LutDialog, GDK_BUTTON_PRESS_MASK); -// MakeFixedControls(TRUE); -// MakeLutControls(FALSE, count*2, TRUE); +void ShowPiecewiseLinearDialog(ElemLeaf *l) +{ + ElemPiecewiseLinear *t = &(l->d.piecewiseLinear); + + // First copy over all the stuff from the leaf structure; in particular, + // we need our own local copy of the table entries, because it would be + // bad to update those in the leaf before the user clicks okay (as he + // might cancel). + int count = t->count; + memset(ValuesCache, 0, sizeof(ValuesCache)); + int i; + for(i = 0; i < count*2; i++) { + ValuesCache[i] = t->vals[i]; + } + + // Now create the dialog's fixed controls, plus the changing (depending + // on show style/entry count) controls for the initial configuration. + + LutDialog = gtk_dialog_new_with_buttons ("Piecewise Linear Table", GTK_WINDOW (MainWindow), + GTK_DIALOG_MODAL, "Ok", GTK_RESPONSE_ACCEPT, + "Cancel", GTK_RESPONSE_REJECT, NULL); + gtk_widget_add_events (LutDialog, GDK_KEY_PRESS_MASK); + gtk_widget_add_events (LutDialog, GDK_BUTTON_PRESS_MASK); + MakeFixedControls(TRUE); + MakeLutControls(FALSE, count*2, TRUE); -// // Set up the controls to reflect the initial configuration. -// gtk_entry_set_text (GTK_ENTRY (DestTextbox), t->dest); -// gtk_entry_set_text (GTK_ENTRY (IndexTextbox), t->index); -// char buf[30]; -// sprintf(buf, "%d", t->count); -// gtk_entry_set_text (GTK_ENTRY (CountTextbox), buf); - -// // And show the window -// gtk_widget_set_sensitive (MainWindow, FALSE); -// gtk_widget_show_all (LutDialog); -// gtk_widget_grab_focus (DestTextbox); -// // SendMessage(DestTextbox, EM_SETSEL, 0, -1); - -// // MSG msg; -// // DWORD ret; -// // DialogDone = FALSE; -// // DialogCancel = FALSE; -// // while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { -// // if(msg.message == WM_KEYDOWN) { -// // if(msg.wParam == VK_RETURN) { -// // DialogDone = TRUE; -// // break; -// // } else if(msg.wParam == VK_ESCAPE) { -// // DialogDone = TRUE; -// // DialogCancel = TRUE; -// // break; -// // } -// // } - -// // if(!IsDialogMessage(LutDialog, &msg)) { -// // TranslateMessage(&msg); -// // DispatchMessage(&msg); -// // } - -// // Watch the (user-editable) count field, and use that to -// // determine how many textboxes to show. -// char* buf; -// buf = gtk_entry_get_text (GTK_ENTRY (CountTextbox)); -// // SendMessage(CountTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)buf); -// if(atoi(buf) != count) { -// count = atoi(buf); -// if(count < 0 || count > 10) { -// count = 0; -// gtk_entry_set_text (GTK_ENTRY (CountTextbox), ""); + // Set up the controls to reflect the initial configuration. + gtk_entry_set_text (GTK_ENTRY (DestTextbox), t->dest); + gtk_entry_set_text (GTK_ENTRY (IndexTextbox), t->index); + char buf[30]; + sprintf(buf, "%d", t->count); + gtk_entry_set_text (GTK_ENTRY (CountTextbox), buf); + + // And show the window + gtk_widget_set_sensitive (MainWindow, FALSE); + gtk_widget_show_all (LutDialog); + gtk_widget_grab_focus (DestTextbox); +// SendMessage(DestTextbox, EM_SETSEL, 0, -1); + +// MSG msg; +// DWORD ret; +// DialogDone = FALSE; +// DialogCancel = FALSE; + // while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { +// if(msg.message == WM_KEYDOWN) { +// if(msg.wParam == VK_RETURN) { +// DialogDone = TRUE; +// break; +// } else if(msg.wParam == VK_ESCAPE) { +// DialogDone = TRUE; +// DialogCancel = TRUE; +// break; // } -// DestroyLutControls(); -// MakeLutControls(FALSE, count*2, TRUE); // } -// } - -// // if(!DialogCancel) { -// // SendMessage(DestTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->dest)); -// // SendMessage(IndexTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->index)); -// // DestroyLutControls(); -// // // The call to DestroyLutControls updated ValuesCache, so just read -// // // them out of there. -// // int i; -// // for(i = 0; i < count*2; i++) { -// // t->vals[i] = ValuesCache[i]; -// // } -// // t->count = count; -// // } - -// // EnableWindow(MainWindow, TRUE); -// // DestroyWindow(LutDialog); -// } + +// if(!IsDialogMessage(LutDialog, &msg)) { +// TranslateMessage(&msg); +// DispatchMessage(&msg); + // } + + // Watch the (user-editable) count field, and use that to + // determine how many textboxes to show. + char* buf; + strcpy (buf, gtk_entry_get_text (GTK_ENTRY (CountTextbox))); + // SendMessage(CountTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)buf); + if(atoi(buf) != count) { + count = atoi(buf); + if(count < 0 || count > 10) { + count = 0; + gtk_entry_set_text (GTK_ENTRY (CountTextbox), ""); + } + // DestroyLutControls(); + MakeLutControls(FALSE, count*2, TRUE); + } + } + + if(!DialogCancel) { + SendMessage(DestTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->dest)); + SendMessage(IndexTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->index)); + DestroyLutControls(); + // The call to DestroyLutControls updated ValuesCache, so just read + // them out of there. + int i; + for(i = 0; i < count*2; i++) { + t->vals[i] = ValuesCache[i]; + } + t->count = count; + } + + EnableWindow(MainWindow, TRUE); + DestroyWindow(LutDialog); +} |