INT_PTR IE_EffectEditDialog::CreateDialogBox(HINSTANCE hInst, HWND hwndParent, ImgFile_Ptr file, IEffect* effect) { ClearDialog(); m_pEditFile = file; m_pEditEffect = effect; int ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_EFFECT_EDIT), hwndParent, IE_EffectEditDialog::DialogProc, (LPARAM)this); if(ret == -1){ char str[256]; wsprintf(str, "IEffectEditDialog::CreateDialogBox() error code %d", GetLastError()); OutputError::Alert(str); } return ret; }
/******************************************************************************* * Slot function. Translates command object recevied from the parser thread * to appropriate function call. * ****************************************************************************/ void DialogBox::ExecuteCommand(DialogCommand command) { QWidget* widget=NULL; if(empty) { ClearDialog(); empty=false; } switch(command.command & DialogCommand::command_mask) { case DialogCommand::add: if(command.command & DialogCommand::option_space & DialogCommand::option_mask) { // Seems sscanf %d in some versions of standard C library has a bug // returning 32k on sero-size strings if(command.GetText()[0]) { int size; sscanf(command.GetText(), "%d", &size); AddSpace(size); } else AddSpace(); break; } if(command.command & DialogCommand::option_stretch & DialogCommand::option_mask) { AddStretch(); break; } switch(command.control & ~DialogCommand::property_mask) { case DialogCommand::label: AddLabel(command.GetTitle(), command.GetName(), command.control & DialogCommand::property_picture & DialogCommand::property_mask ? DialogBox::pixmap : command.control & DialogCommand::property_animation & DialogCommand::property_mask ? DialogBox::movie : DialogBox::text); break; case DialogCommand::groupbox: AddGroupbox(command.GetTitle(), command.GetName(), command.control & DialogCommand::property_vertical & DialogCommand::property_mask, command.control & DialogCommand::property_checkable & DialogCommand::property_mask, command.control & DialogCommand::property_checked & DialogCommand::property_mask); break; case DialogCommand::frame: AddFrame(command.GetTitle(), command.control & DialogCommand::property_vertical & DialogCommand::property_mask, command.control); break; case DialogCommand::pushbutton: AddPushbutton(command.GetTitle(), command.GetName(), command.control & DialogCommand::property_apply & DialogCommand::property_mask, command.control & DialogCommand::property_exit & DialogCommand::property_mask, command.control & DialogCommand::property_default & DialogCommand::property_mask); break; case DialogCommand::checkbox: AddCheckbox(command.GetTitle(), command.GetName(), command.control & DialogCommand::property_checked & DialogCommand::property_mask); break; case DialogCommand::radiobutton: AddRadiobutton(command.GetTitle(), command.GetName(), command.control & DialogCommand::property_checked & DialogCommand::property_mask); break; case DialogCommand::textbox: AddTextbox(command.GetTitle(), command.GetName(), command.GetText(), command.GetAuxText(), command.control & DialogCommand::property_password & DialogCommand::property_mask); break; case DialogCommand::listbox: AddListbox(command.GetTitle(), command.GetName(), command.control & DialogCommand::property_activation & DialogCommand::property_mask, command.control & DialogCommand::property_selection & DialogCommand::property_mask); break; case DialogCommand::combobox: AddCombobox(command.GetTitle(), command.GetName(), command.control & DialogCommand::property_editable & DialogCommand::property_mask, command.control & DialogCommand::property_selection & DialogCommand::property_mask); break; case DialogCommand::item: AddItem(command.GetTitle(), command.GetName(), command.control & DialogCommand::property_current & DialogCommand::property_mask); break; case DialogCommand::separator: AddSeparator(command.GetTitle(), command.control & DialogCommand::property_vertical & DialogCommand::property_mask, command.control); break; case DialogCommand::progressbar: AddProgressbar(command.GetTitle(), command.control & DialogCommand::property_vertical & DialogCommand::property_mask, command.control & DialogCommand::property_busy & DialogCommand::property_mask); break; case DialogCommand::slider: { int min(0), max(100); if(command.GetName()[0]) sscanf(command.GetName(), "%d", &min); if(command.GetText()[0]) sscanf(command.GetText(), "%d", &max); AddSlider(command.GetTitle(), command.control & DialogCommand::property_vertical & DialogCommand::property_mask, min, max); } break; case DialogCommand::textview: AddTextview(command.GetTitle(), command.GetName()); break; case DialogCommand::tabs: AddTabs(command.GetTitle(), command.control); break; case DialogCommand::page: AddPage(command.GetTitle(), command.GetName(), command.GetText(), command.control & DialogCommand::property_current & DialogCommand::property_mask); break; } break; case DialogCommand::clear: Clear(command.GetName()); break; case DialogCommand::end: switch(command.control & ~DialogCommand::property_mask) { case DialogCommand::groupbox: case DialogCommand::frame: EndGroup(); break; case DialogCommand::listbox: case DialogCommand::combobox: EndList(); break; case DialogCommand::tabs: EndTabs(); break; case DialogCommand::page: EndPage(); break; case DialogCommand::widget_mask: // none type mentioned if(current_view) EndList(); else if(group_layout) EndGroup(); else if(current_tab_widget) { if(current_tab_widget->indexOf(current_layout->parentWidget())==-1) EndTabs(); else EndPage(); } break; } break; case DialogCommand::step: if(command.command & DialogCommand::option_vertical & DialogCommand::option_mask) StepVertical(); else StepHorizontal(); break; case DialogCommand::set: if(command.GetName()[0]) { if(!(widget=FindWidget(command.GetName()))) break; } else widget=this; if(command.command & DialogCommand::option_enabled & DialogCommand::option_mask) SetEnabled(widget, true); if(command.command & DialogCommand::option_focus & DialogCommand::option_mask) { QTimer::singleShot(0, widget, SLOT(setFocus())); // select text for QLineEdit objects // selectedText property is not writable and this must be done in the class specific way if(QWidget* proxywidget=widget->focusProxy()) { switch(WidgetType(proxywidget)) { case DialogCommand::combobox: proxywidget=((QComboBox*)proxywidget)->lineEdit(); break; case DialogCommand::textbox: break; default: proxywidget=NULL; break; } if(proxywidget) ((QLineEdit*)proxywidget)->selectAll(); } } // see http://doc.qt.io/qt-4.8/stylesheet.html for reference if(command.command & DialogCommand::option_stylesheet & DialogCommand::option_mask) { widget->setStyleSheet(command.GetText()); if(QWidget* proxywidget=widget->focusProxy()) proxywidget->setStyleSheet(command.GetText()); } if(command.command & DialogCommand::option_visible & DialogCommand::option_mask) { widget->show(); if(QWidget* proxywidget=widget->focusProxy()) proxywidget->show(); } if(command.control) SetOptions(widget, command.control, command.control, command.GetText()); // setting of some properties (calls like show and hide) generates events which are optimised next // or sets widget attributes which might impact next calls // to avoid races and to ensure the command is executed as expected we process all events that // have been generated: QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers); break; case DialogCommand::unset: if(command.GetName()[0]) { if(!(widget=FindWidget(command.GetName()))) break; } else widget=this; if(command.command & DialogCommand::option_enabled & DialogCommand::option_mask) SetEnabled(widget, false); // see http://doc.qt.io/qt-4.8/stylesheet.html for reference if(command.command & DialogCommand::option_stylesheet & DialogCommand::option_mask) { // rarely it was seen this fails (unset stylesheet or set it to empty string) // hopefully this was caused by the race which is now fixed // (queued signaling between threads and optimisation of queued GUI events) widget->setStyleSheet(QString()); if(QWidget* proxywidget=widget->focusProxy()) proxywidget->setStyleSheet(QString()); } if(command.command & DialogCommand::option_visible & DialogCommand::option_mask) { widget->hide(); if(QWidget* proxywidget=widget->focusProxy()) proxywidget->hide(); } if(command.control) SetOptions(widget, 0, command.control, NULL); // setting of some properties (calls like show and hide) generates events which are optimised next // or sets widget attributes which might impact next calls // to avoid races and to ensure the command is executed as expected we process all events that // have been generated: QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers); break; case DialogCommand::remove: RemoveWidget(command.GetName()); break; case DialogCommand::position: Position(command.GetText(), command.command & DialogCommand::option_behind & DialogCommand::option_mask, command.command & DialogCommand::option_onto & DialogCommand::option_mask); break; case DialogCommand::query: Report(); break; case DialogCommand::noop: default: ; } // clean up after possible FindWidget call chosen_view=NULL; chosen_row_flag=false; }
IE_EffectEditDialog::~IE_EffectEditDialog() { ClearDialog(); }