$PBExportHeader$n_svc_dw_form.sru $PBExportComments$dw_form service forward global type n_svc_dw_form from n_svc_dw end type end forward global type n_svc_dw_form from n_svc_dw end type global n_svc_dw_form n_svc_dw_form type variables Protected: CONSTANT long REQUIRED_LABEL_COLOR = CColor.LINK CONSTANT long REQUIRED_COLUMN_COLOR = CColor.REQUIRED_BACKGROUND_COLOR CONSTANT long REQUIRED_FAILED_LABEL_COLOR = CColor.RED CONSTANT string ERROR_MESSAGE_TAG = "ERRMSG" CONSTANT long AUTOSIZE_PAD = 192 end variables forward prototypes public subroutine of_standarddddw (ref n_svc_mgr anv_svc, readonly u_dw_form adw) public subroutine of_initvalidatefields (u_dw_form adw, ref string as_columns[]) public function long of_validatefields (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_validatecolumns[], ref string as_errorcolumns[], ref long al_rows[], ref string as_messages[]) public subroutine of_autosizecolumns (ref n_svc_mgr anv_svc, u_dw adw) public function integer of_ignoredatetimeerror (readonly u_dw_form adw, readonly long al_row, readonly string as_colname) public subroutine of_recalcdddw (ref n_svc_mgr anv_svc, readonly u_dw_form adw) public subroutine of_editmode (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_taborders, readonly string as_validatecolumns[], readonly boolean ab_editmode, readonly boolean ab_standarddddw) public subroutine of_autosizecolumns (ref n_svc_mgr anv_svc, u_dw adw, readonly boolean ab_initcolsize) public subroutine of_autosizecolumns (ref n_svc_mgr anv_svc, u_dw adw, readonly boolean ab_initcolsize, readonly boolean ab_halfpad) public subroutine of_addtooltip (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_colname, readonly boolean ab_balloon, readonly icon ai_icon, readonly string as_title, readonly string as_tooltip) public subroutine of_resetvalidate (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_validatecolumns[]) end prototypes public subroutine of_standarddddw (ref n_svc_mgr anv_svc, readonly u_dw_form adw);long ll_count, n, ll_count2, m, ll_childtotwidth, ll_scrollwidth, ll_percent, ll_columnwidth string ls_cols[], ls_dropcols[] n_ds lds DatawindowChild dwc CONSTANT string DW = "standard_dropdowndatawindow" CONSTANT string HEADER = "dummy_t" CONSTANT string COL = "dummy" CONSTANT string PAD = " " string HEADER_COLOR, HEADER_TEXTCOLOR, HEADER_HEIGHT, HEADER_BORDER, HEADER_FONTFAMILY, HEADER_FONTCHARSET, HEADER_FONTFACE, HEADER_FONTHEIGHT, HEADER_FONTWEIGHT string COL_HEIGHT, COL_BORDER, COL_FONTFAMILY, COL_FONTCHARSET, COL_FONTFACE, COL_FONTHEIGHT, COL_FONTWEIGHT string ls_mod, ls_pmod n_svc_win32 lnv_win32 ll_count = this.of_GetVisibleColumns(anv_svc, adw, ls_cols) //load service anv_svc.of_loadsvc(lnv_win32, CSvc.WIN32) //get dropdown template lds = CREATE n_ds IF lds.of_SetDataobject(DW) = CRet.FAILURE THEN RETURN n_svc_theme lnv_t str_theme lstr anv_svc.of_LoadSvc(lnv_t, CSvc.THEME) lstr = lnv_t.of_GetTheme() //Header HEADER_COLOR = STRING(lstr.toolbargradientend) //lds.Describe("Datawindow.Header.Color") HEADER_HEIGHT = lds.Describe("Datawindow.Header.Height") HEADER_TEXTCOLOR = STRING(lstr.textcolor)//lds.Describe(HEADER + ".Color") HEADER_BORDER = lds.Describe(HEADER + ".Border") HEADER_FONTFAMILY = lds.Describe(HEADER + ".Font.Family") HEADER_FONTCHARSET = lds.Describe(HEADER + ".Font.CharSet") HEADER_FONTFACE = lds.Describe(HEADER + ".Font.Face") HEADER_FONTHEIGHT = lds.Describe(HEADER + ".Font.Height") HEADER_FONTWEIGHT = lds.Describe(HEADER + ".Font.Weight") //Column COL_HEIGHT = lds.Describe("Datawindow.Detail.Height") COL_BORDER = lds.Describe(COL + ".Border") COL_FONTFAMILY = lds.Describe(COL + ".Font.Family") COL_FONTCHARSET = lds.Describe(COL + ".Font.CharSet") COL_FONTFACE = lds.Describe(COL + ".Font.Face") COL_FONTHEIGHT = lds.Describe(COL + ".Font.Height") COL_FONTWEIGHT = lds.Describe(COL + ".Font.Weight") DESTROY lds //get system vscrollbar width ll_scrollwidth = PixelsToUnits(lnv_win32.GetSystemMetrics(CWin32.SM_CXVSCROLL) + 6, XPixelsToUnits!) FOR n = 1 to ll_count IF adw.Describe(ls_cols[n] + ".Edit.Style") = CDWedit.DDDW THEN adw.GetChild(ls_cols[n], dwc) IF NOT ISVALID(dwc) THEN CONTINUE //get columns including computed fields ll_count2 = of_GetVisibleColumns(anv_svc, dwc, ls_dropcols, TRUE, FALSE) //setup dropdowndatawindow //bands ls_mod = "Datawindow.Header.Height=" + HEADER_HEIGHT + PAD ls_mod += "Datawindow.Detail.Height=" + COL_HEIGHT + PAD ls_mod += 'Datawindow.Header.Color="' + HEADER_COLOR + '"' + PAD // dwc.Modify(ls_mod) // ls_mod = "" ll_childtotwidth = 0 FOR m = 1 to ll_count2 //total width ll_childtotwidth += LONG(dwc.Describe(ls_dropcols[m] + ".width")) //header ls_mod += ls_dropcols[m] + '_t.Color=' + HEADER_TEXTCOLOR + PAD ls_mod += ls_dropcols[m] + '_t.Border=' + HEADER_BORDER + PAD ls_mod += ls_dropcols[m] + '_t.Font.Family="' + HEADER_FONTFAMILY + '"' + PAD ls_mod += ls_dropcols[m] + '_t.Font.CharSet="' + HEADER_FONTCHARSET + '"' + PAD ls_mod += ls_dropcols[m] + '_t.Font.Face="' + HEADER_FONTFACE + '"' + PAD ls_mod += ls_dropcols[m] + '_t.Font.Height="' + HEADER_FONTHEIGHT + '"' + PAD ls_mod += ls_dropcols[m] + '_t.Font.Weight="' + HEADER_FONTWEIGHT + '"' + PAD ls_mod += ls_dropcols[m] + '_t.Background.Mode="1"' + PAD //column ls_mod += ls_dropcols[m] + '.Border=' + COL_BORDER + PAD ls_mod += ls_dropcols[m] + '.Font.Family="' + COL_FONTFAMILY + '"' + PAD ls_mod += ls_dropcols[m] + '.Font.CharSet="' + COL_FONTCHARSET + '"' + PAD ls_mod += ls_dropcols[m] + '.Font.Face="' + COL_FONTFACE + '"' + PAD ls_mod += ls_dropcols[m] + '.Font.Height="' + COL_FONTHEIGHT + '"' + PAD ls_mod += ls_dropcols[m] + '.Font.Weight="' + COL_FONTWEIGHT + '"' + PAD NEXT //setup column ll_columnwidth = LONG(adw.Describe(ls_cols[n] + ".width")) IF ll_columnwidth <> 0 THEN ll_percent = ((ll_childtotwidth + ll_scrollwidth) / ll_columnwidth) * 100 ls_pmod = ls_cols[n] + ".dddw.Percentwidth=" + STRING(ll_percent) + PAD ls_pmod += ls_cols[n] + '.dddw.VScrollBar="Yes"' + PAD ls_pmod += ls_cols[n] + '.dddw.HScrollBar="Yes"' + PAD adw.Modify(ls_pmod) END IF //one hit Modify adw.GetChild(ls_cols[n], dwc) //bugfix -> GetChild again dwc.Modify(ls_mod) END IF NEXT end subroutine public subroutine of_initvalidatefields (u_dw_form adw, ref string as_columns[]);long ll_count, n, m, c string ls_empty[], ls_col string ls_types[], ls_mod //init validation for following edit types ls_types = {CDWedit.EDIT, & CDWedit.EDITMASK, & CDWedit.DDLB, & CDWedit.DDDW, & CDWedit.CHKBOX, & CDWedit.COLUMN} ll_count = this.of_GetColumnCount(adw) FOR n = 1 to ll_count ls_col = '#' + STRING(n) FOR m = 1 to 6 IF adw.Describe(ls_col + "." + ls_types[m] + ".Required") = YES THEN c ++ as_columns[c] = adw.Describe(ls_col + ".Name") ls_mod += as_columns[c] + "." + ls_types[m] + ".Required=" + NO + CString.SPACE & + as_columns[c] + "_t.Color=" + STRING(REQUIRED_LABEL_COLOR) + CString.SPACE & + as_columns[c] + ".Background.Mode =0 " + CString.SPACE & + as_columns[c] + ".Background.Color=" + STRING(REQUIRED_COLUMN_COLOR) + CString.SPACE EXIT END IF NEXT NEXT //one-hit modify adw.Modify(ls_mod) end subroutine public function long of_validatefields (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_validatecolumns[], ref string as_errorcolumns[], ref long al_rows[], ref string as_messages[]);long ll_upper, n, ll_count, ll_rows, ll_ctr n_svc_isempty lnv_check any la_ret string ls_str adw.AcceptText() ll_upper = UPPERBOUND(as_validatecolumns) ll_count = adw.RowCount() IF ll_upper <= 0 THEN RETURN CRet.NO_ACTION anv_svc.of_loadsvc(lnv_check, CSvc.ISEMPTY) FOR ll_rows = 1 to ll_count FOR n = 1 to ll_upper la_ret = of_GetItemAny(adw, ll_rows, as_validatecolumns[n]) IF lnv_check.of_IsEmpty(la_ret) THEN //set the buddy label color to failed adw.Modify(as_validatecolumns[n] + "_t.Color=" + STRING(REQUIRED_FAILED_LABEL_COLOR)) // adw.Modify(as_validatecolumns[n] + "_t.Font.Weight=700") //increment counter ll_ctr ++ //check if there is an embedded error message ls_str = of_GetTagKeyword(anv_svc, adw, as_validatecolumns[n], ERROR_MESSAGE_TAG) IF lnv_check.of_isempty(ls_str) THEN //let's get the text of the //column's buddy label instead ls_str = TRIM(adw.Describe(as_validatecolumns[n] + "_t.Text")) IF lnv_check.of_IsEmpty(ls_str) THEN ls_str = as_validatecolumns[n] ELSE //remove any colons (":") IF RIGHT(ls_str, 1) = ":" THEN ls_str = MID(ls_str, 1, LEN(ls_str) - 1) END IF END IF END IF //store failed validation al_rows[ll_ctr] = ll_rows as_errorcolumns[ll_ctr] = as_validatecolumns[n] as_messages[ll_ctr] = ls_str ELSE //return buddy label color adw.Modify(as_validatecolumns[n] + "_t.Color=" + STRING(REQUIRED_LABEL_COLOR)) // adw.Modify(as_validatecolumns[n] + "_t.Font.Weight=400") END IF NEXT NEXT IF ll_count <= 0 THEN of_ResetValidate(anv_svc, adw, as_validatecolumns) END IF RETURN ll_ctr end function public subroutine of_autosizecolumns (ref n_svc_mgr anv_svc, u_dw adw);of_AutosizeColumns(anv_svc, adw, FALSE) end subroutine public function integer of_ignoredatetimeerror (readonly u_dw_form adw, readonly long al_row, readonly string as_colname);string lst, lsr long ll_ret TRY lsr = this.of_getcolumndatatype(adw, as_colname) CHOOSE CASE lsr CASE CDWDataType.DATE date ld SetNull(ld) adw.SetItem(al_row, as_colname, ld) ll_ret = 3 CASE CDWDataType.DATETIME datetime ldt SetNull(ldt) adw.SetItem(al_row, as_colname, ldt) ll_ret = 3 CASE CDWDataType.TIME time lt SetNull(lt) adw.SetItem(al_row, as_colname, lt) ll_ret = 3 CASE ELSE ll_ret = CRet.NO_ACTION END CHOOSE CATCH (RuntimeError ex) //swallow exception FINALLY RETURN ll_ret END TRY end function public subroutine of_recalcdddw (ref n_svc_mgr anv_svc, readonly u_dw_form adw);long ll_count, n, ll_count2, m, ll_childtotwidth, ll_scrollwidth, ll_percent, ll_columnwidth string ls_cols[], ls_dropcols[] DatawindowChild dwc string ls_pmod n_svc_win32 lnv_win32 CONSTANT string PAD = " " ll_count = this.of_GetVisibleColumns(anv_svc, adw, ls_cols) //get system vscrollbar width anv_svc.of_LoadSvc(lnv_win32, CSvc.WIN32) ll_scrollwidth = PixelsToUnits(lnv_win32.GetSystemMetrics(CWin32.SM_CXVSCROLL) + 6, XPixelsToUnits!) FOR n = 1 to ll_count IF adw.Describe(ls_cols[n] + ".Edit.Style") = CDWedit.DDDW THEN adw.GetChild(ls_cols[n], dwc) IF NOT ISVALID(dwc) THEN CONTINUE //get columns including computed fields ll_count2 = of_GetVisibleColumns(anv_svc, dwc, ls_dropcols, TRUE, FALSE) ll_childtotwidth = 0 FOR m = 1 to ll_count2 //total width ll_childtotwidth += LONG(dwc.Describe(ls_dropcols[m] + ".width")) NEXT //setup column ll_columnwidth = LONG(adw.Describe(ls_cols[n] + ".width")) IF ll_columnwidth <> 0 THEN ll_percent = ((ll_childtotwidth + ll_scrollwidth) / ll_columnwidth) * 100 ls_pmod = ls_cols[n] + ".dddw.Percentwidth=" + STRING(ll_percent) adw.Modify(ls_pmod) END IF END IF NEXT end subroutine public subroutine of_editmode (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_taborders, readonly string as_validatecolumns[], readonly boolean ab_editmode, readonly boolean ab_standarddddw);long ll_count, n, ll_labelcolor, ll_backcolor, ll_dwbackcolor string ls_mod, ls_backmode, ls_weight IF ab_editmode THEN of_SetTabSequence(anv_svc, adw, as_taborders) of_Removedropdownarrows(anv_svc, adw, FALSE) IF ab_standarddddw THEN of_Standarddddw(anv_svc, adw) ll_labelcolor = REQUIRED_LABEL_COLOR ll_backcolor = REQUIRED_COLUMN_COLOR ll_dwbackcolor = CColor.WINDOW_BACKGROUND ls_backmode = "0" ls_weight = "400" ELSE of_RemoveTabSequence(anv_svc, adw) of_Removedropdownarrows(anv_svc, adw, TRUE) ll_labelcolor = CColor.WINDOW_TEXT ll_backcolor = CColor.WINDOW_BACKGROUND ll_backcolor = CColor.WINDOW_BACKGROUND ll_dwbackcolor = CColor.BUTTON_FACE ls_backmode = "1" ls_weight = "400" END IF ll_count = UPPERBOUND(as_validatecolumns) FOR n = 1 to ll_count ls_mod += as_validatecolumns[n] + "_t.Color=" + STRING(ll_labelcolor) + CString.SPACE & + as_validatecolumns[n] + "_t.Font.Weight=" + ls_weight + CString.SPACE & + as_validatecolumns[n] + ".Background.Mode =" + ls_backmode + CString.SPACE & + as_validatecolumns[n] + ".Background.Color=" + STRING(ll_backcolor) + CString.SPACE NEXT ls_mod += "Datawindow.Color=" + STRING(ll_dwbackcolor) //one-hit modify adw.Modify(ls_mod) end subroutine public subroutine of_autosizecolumns (ref n_svc_mgr anv_svc, u_dw adw, readonly boolean ab_initcolsize);of_Autosizecolumns(anv_svc, adw, ab_initcolsize, FALSE) end subroutine public subroutine of_autosizecolumns (ref n_svc_mgr anv_svc, u_dw adw, readonly boolean ab_initcolsize, readonly boolean ab_halfpad);string ls_col[], ls long ll_count, n, llw, ll_pad string ls_mod ll_count = this.of_GetVisibleColumns(anv_svc, adw, ls_col, TRUE, FALSE) IF ab_halfpad THEN ll_pad = AUTOSIZE_PAD / 2 ELSE ll_pad = AUTOSIZE_PAD END IF FOR n = 1 TO ll_count ls = of_GetColumnEditStyle(adw, ls_col[n]) CHOOSE CASE ls CASE CDWEdit.CHKBOX, CDWEdit.RADIOBUTTON CONTINUE END CHOOSE of_SetTagKeyword(anv_svc, adw, ls_col[n], "ANCHOR", "1,1,1,0") //set the columns initial size IF ab_initcolsize THEN llw = adw.Width - LONG(adw.Describe(ls_col[n] + ".x")) IF llw > 0 THEN llw -= ll_pad ELSE llw += ll_pad END IF ls_mod += ls_col[n] + '.width="' + STRING(llw) + '" ' END IF NEXT IF ab_initcolsize THEN adw.Modify(ls_mod) end subroutine public subroutine of_addtooltip (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_colname, readonly boolean ab_balloon, readonly icon ai_icon, readonly string as_title, readonly string as_tooltip);n_svc_isempty lnv_check n_svc_tooltip lnv_tip IF ab_balloon THEN of_SetTagKeyword(anv_svc, adw, as_colname, CTooltip.KEY_BALLOON, "1") anv_svc.of_LoadSvc(lnv_check, CSvc.ISEMPTY) IF NOT lnv_check.of_IsEmpty(as_title) THEN of_SetTagKeyword(anv_svc, adw, as_colname, CTooltip.KEY_BALLOON_TITLE, as_title) END IF anv_svc.of_LoadSvc(lnv_tip, CSvc.TOOLTIP) of_SetTagKeyword(anv_svc, adw, as_colname, CTooltip.KEY_BALLOON_ICON, STRING(lnv_tip.of_geticontostring(ai_icon))) END IF of_SetTagKeyword(anv_svc, adw, as_colname, CTooltip.KEY_TOOLTIP, as_tooltip) end subroutine public subroutine of_resetvalidate (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_validatecolumns[]);long ll_upper, n string ls_str ll_upper = UPPERBOUND(as_validatecolumns) //reset all columns ls_str = CString.EMPTY FOR n = 1 to ll_upper ls_str += as_validatecolumns[n] + "_t.Color=" + STRING(REQUIRED_LABEL_COLOR) IF n < ll_upper THEN ls_str += " " NEXT adw.Modify(ls_str) end subroutine on n_svc_dw_form.create call super::create end on on n_svc_dw_form.destroy call super::destroy end on
- Sources
- Kodigo
- OpenExplorer
- n_svc_dw_form.sru
File: n_svc_dw_form.sru
Size: 15474
Date: Mon, 07 Apr 2008 21:31:45 +0200
Size: 15474
Date: Mon, 07 Apr 2008 21:31:45 +0200
- n_svc_dw n_svc_dw_form(sru)
- of_addtooltip (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_colname, readonly boolean ab_balloon, readonly icon ai_icon, readonly string as_title, readonly string as_tooltip)
- of_autosizecolumns (ref n_svc_mgr anv_svc, u_dw adw)
- of_autosizecolumns (ref n_svc_mgr anv_svc, u_dw adw, readonly boolean ab_initcolsize)
- of_autosizecolumns (ref n_svc_mgr anv_svc, u_dw adw, readonly boolean ab_initcolsize, readonly boolean ab_halfpad)
- of_editmode (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_taborders, readonly string as_validatecolumns[], readonly boolean ab_editmode, readonly boolean ab_standarddddw)
- of_ignoredatetimeerror (readonly u_dw_form adw, readonly long al_row, readonly string as_colname) returns integer
- of_initvalidatefields (u_dw_form adw, ref string as_columns[])
- of_recalcdddw (ref n_svc_mgr anv_svc, readonly u_dw_form adw)
- of_resetvalidate (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_validatecolumns[])
- of_standarddddw (ref n_svc_mgr anv_svc, readonly u_dw_form adw)
- of_validatefields (ref n_svc_mgr anv_svc, readonly u_dw_form adw, readonly string as_validatecolumns[], ref string as_errorcolumns[], ref long al_rows[], ref string as_messages[]) returns long