static void uiFormMinimumSize(uiWindowsControl *c, int *width, int *height) { uiForm *f = uiForm(c); int xpadding, ypadding; int nStretchy; // these two contain the largest minimum width and height of all stretchy controls in the form // all stretchy controls will use this value to determine the final minimum size int maxLabelWidth, maxControlWidth; int maxStretchyHeight; int labelwid; int i; int minimumWidth, minimumHeight; int nVisible; uiWindowsSizing sizing; *width = 0; *height = 0; if (f->controls->size() == 0) return; // 0) get this Form's padding formPadding(f, &xpadding, &ypadding); // 1) determine the longest width of all controls and labels; add in the height of non-stretchy controls and get (but not add in) the largest heights of stretchy controls // we still add in like direction of stretchy controls nStretchy = 0; maxLabelWidth = 0; maxControlWidth = 0; maxStretchyHeight = 0; nVisible = 0; for (const struct formChild &fc : *(f->controls)) { if (!uiControlVisible(fc.c)) continue; nVisible++; labelwid = uiWindowsWindowTextWidth(fc.label); if (maxLabelWidth < labelwid) maxLabelWidth = labelwid; uiWindowsControlMinimumSize(uiWindowsControl(fc.c), &minimumWidth, &minimumHeight); if (fc.stretchy) { nStretchy++; if (maxStretchyHeight < minimumHeight) maxStretchyHeight = minimumHeight; } if (maxControlWidth < minimumWidth) maxControlWidth = minimumWidth; if (!fc.stretchy) *height += minimumHeight; } if (nVisible == 0) // nothing to show; return 0x0 return; *width += maxLabelWidth + maxControlWidth; // 2) outset the desired rect with the needed padding *width += xpadding; *height += (nVisible - 1) * ypadding; // 3) and now we can add in stretchy controls *height += nStretchy * maxStretchyHeight; }
static void uiFormSyncEnableState(uiWindowsControl *c, int enabled) { uiForm *f = uiForm(c); if (uiWindowsShouldStopSyncEnableState(uiWindowsControl(f), enabled)) return; for (const struct formChild &fc : *(f->controls)) uiWindowsControlSyncEnableState(uiWindowsControl(fc.c), enabled); }
static void uiFormMinimumSizeChanged(uiWindowsControl *c) { uiForm *f = uiForm(c); if (uiWindowsControlTooSmall(uiWindowsControl(f))) { uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl(f)); return; } formRelayout(f); }
static void uiFormDestroy(uiControl *c) { uiForm *f = uiForm(c); for (const struct formChild &fc : *(f->controls)) { uiControlSetParent(fc.c, NULL); uiControlDestroy(fc.c); uiWindowsEnsureDestroyWindow(fc.label); } delete f->controls; uiWindowsEnsureDestroyWindow(f->hwnd); uiFreeControl(uiControl(f)); }
void QgsEditFormConfig::writeXml( QDomNode& node ) const { QDomDocument doc( node.ownerDocument() ); QDomElement efField = doc.createElement( "editform" ); QDomText efText = doc.createTextNode( QgsProject::instance()->writePath( uiForm() ) ); efField.appendChild( efText ); node.appendChild( efField ); QDomElement efiField = doc.createElement( "editforminit" ); if ( !initFunction().isEmpty() ) efiField.appendChild( doc.createTextNode( initFunction() ) ); node.appendChild( efiField ); QDomElement eficsField = doc.createElement( "editforminitcodesource" ); eficsField.appendChild( doc.createTextNode( QString::number( initCodeSource() ) ) ); node.appendChild( eficsField ); QDomElement efifpField = doc.createElement( "editforminitfilepath" ); efifpField.appendChild( doc.createTextNode( QgsProject::instance()->writePath( initFilePath() ) ) ); node.appendChild( efifpField ); QDomElement eficField = doc.createElement( "editforminitcode" ); eficField.appendChild( doc.createCDATASection( initCode() ) ); node.appendChild( eficField ); QDomElement fFSuppElem = doc.createElement( "featformsuppress" ); QDomText fFSuppText = doc.createTextNode( QString::number( suppress() ) ); fFSuppElem.appendChild( fFSuppText ); node.appendChild( fFSuppElem ); // tab display QDomElement editorLayoutElem = doc.createElement( "editorlayout" ); switch ( layout() ) { case QgsEditFormConfig::UiFileLayout: editorLayoutElem.appendChild( doc.createTextNode( "uifilelayout" ) ); break; case QgsEditFormConfig::TabLayout: editorLayoutElem.appendChild( doc.createTextNode( "tablayout" ) ); break; case QgsEditFormConfig::GeneratedLayout: default: editorLayoutElem.appendChild( doc.createTextNode( "generatedlayout" ) ); break; } node.appendChild( editorLayoutElem ); // tabs and groups of edit form if ( tabs().size() > 0 ) { QDomElement tabsElem = doc.createElement( "attributeEditorForm" ); for ( QList< QgsAttributeEditorElement* >::const_iterator it = mAttributeEditorElements.constBegin(); it != mAttributeEditorElements.constEnd(); ++it ) { QDomElement attributeEditorWidgetElem = ( *it )->toDomElement( doc ); tabsElem.appendChild( attributeEditorWidgetElem ); } node.appendChild( tabsElem ); } //// TODO: MAKE THIS MORE GENERIC, SO INDIVIDUALL WIDGETS CAN NOT ONLY SAVE STRINGS /// SEE QgsEditorWidgetFactory::writeConfig QDomElement widgetsElem = doc.createElement( "widgets" ); QMap<QString, QgsEditorWidgetConfig >::ConstIterator configIt( mWidgetConfigs.constBegin() ); while ( configIt != mWidgetConfigs.constEnd() ) { if ( mFields.indexFromName( configIt.key() ) == -1 ) { QDomElement widgetElem = doc.createElement( "widget" ); widgetElem.setAttribute( "name", configIt.key() ); QDomElement configElem = doc.createElement( "config" ); widgetElem.appendChild( configElem ); QgsEditorWidgetConfig::ConstIterator cfgIt( configIt.value().constBegin() ); while ( cfgIt != configIt.value().constEnd() ) { QDomElement optionElem = doc.createElement( "option" ); optionElem.setAttribute( "key", cfgIt.key() ); optionElem.setAttribute( "value", cfgIt.value().toString() ); configElem.appendChild( optionElem ); ++cfgIt; } widgetsElem.appendChild( widgetElem ); } ++configIt; } node.appendChild( widgetsElem ); //// END TODO }
static void onResize(uiWindowsControl *c) { formRelayout(uiForm(c)); }
static void deleteFirst(uiButton *b, void *data) { uiForm *f = uiForm(data); uiFormDelete(f, 0); }