$PBExportHeader$nvo_dw_ext.sru
forward
global type nvo_dw_ext
end type
end forward
global type nvo_dw_ext
end type
type variables
//freedom排序用
integer ii_colnum =1 //目标列个数
integer ii_x = 14 //起始点x
integer ii_y = 100 //起始点y
integer ii_each_x_col = 56 //text距column的列间距
integer ii_each_x_text = 20 //column距text的列间距
integer ii_each_y = 20//行间距
end variables
forward prototypes
public function datastore uf_getdwcontent (datawindow dw, string pos)
public function integer uf_dwsort (datawindow adw_dw, integer ai_colnum, integer ai_x, integer ai_y, integer ai_each_x_col, integer ai_each_x_text, integer ai_each_y)
public function integer uf_dwsort (datawindow adw_dw)
public function integer uf_dwchangestyle (datawindow adw_source, datawindow adw_target, integer ai_col_border, integer ai_col_height, integer ai_col_width, integer ai_text_height, integer ai_text_width, integer ai_header_height, integer ai_detail_height)
public function integer uf_dwchangestyle (datawindow adw_source, datawindow adw_target)
public function integer uf_dwautonewline (datawindow adw_dw, string as_pos)
end prototypes
public function datastore uf_getdwcontent (datawindow dw, string pos);//====================================================================
// Function: uf_getdwcontent
//--------------------------------------------------------------------
// Description: 用来获得datawindow中不同位置的text、column和compute信息的集合
// 创建一个包括name、位置、type、x坐标、y坐标、height、width、tabsequence的datastore,保存数据
// 并返回
//--------------------------------------------------------------------
// Arguments:
// datawindow 数据窗体dw
// string 要获得数据的位置pos:header、detail、summary或footer
//--------------------------------------------------------------------
// Returns: datastore
//--------------------------------------------------------------------
String ls_objects,ls_obj,ls_sql,ls_err,ls_text,la_columns[]
Long li_pos
datastore lds_sort //返回的datastore
String ls_pbver //pb 版本信息
environment env //环境变量
GetEnvironment(env)
ls_pbver = String(env.PBMajorRevision)
lds_sort = Create datastore //创建排序列 datastore
ls_sql = 'column=(type=char(100) name = zname dbname="zname" )' + '~r~n' + &
'column=(type=char(7) name = zpos dbname="zpos" )' + '~r~n' + &
'column=(type=char(7) name = ztype dbname="ztype" )' + '~r~n' + &
'column=(type=long name = ztabsequence dbname="ztabsequence" )' + '~r~n' + &
'column=(type=long name = zx dbname="zx" )' + '~r~n' + &
'column=(type=long name = zy dbname="zy" )' + '~r~n' + &
'column=(type=long name = zheight dbname="zheight" )' + '~r~n' + &
'column=(type=long name = zwidth dbname="zwidth" )' + '~r~n'
ls_sql = 'release ' + ls_pbver + ';~r~ntable(' + ls_sql + ')'
lds_sort.Create(ls_sql, ls_err)
Integer i,ii
ls_objects = dw.Describe("datawindow.objects")
DO While (Pos(ls_objects,"~t") > 0)
li_pos = Pos(ls_objects,"~t")
ls_obj = Left(ls_objects,li_pos - 1)
ls_objects = Right(ls_objects,Len(ls_objects) - li_pos)
If (dw.Describe(ls_obj+".band") = Pos ) And &
(dw.Describe(ls_obj+".visible") = "1" ) THEN
lds_sort.InsertRow(0)
lds_sort.SetItem(lds_sort.RowCount(), 'zname', ls_obj)
lds_sort.SetItem(lds_sort.RowCount(), 'zpos', Pos)
lds_sort.SetItem(lds_sort.RowCount(), 'ztype', dw.Describe(ls_obj + '.type'))
lds_sort.SetItem(lds_sort.RowCount(), 'ztabsequence', Long(dw.Describe(ls_obj + '.tabsequence')))
lds_sort.SetItem(lds_sort.RowCount(), 'zx', Long(dw.Describe(ls_obj + '.x')))
lds_sort.SetItem(lds_sort.RowCount(), 'zy', Long(dw.Describe(ls_obj + '.y')))
lds_sort.SetItem(lds_sort.RowCount(), 'zheight', Long(dw.Describe(ls_obj + '.height')) + ii - 1)
lds_sort.SetItem(lds_sort.RowCount(), 'zwidth', Long(dw.Describe(ls_obj + '.width')))
END IF
LOOP
ls_obj = ls_objects
If (dw.Describe(ls_obj+".band") = Pos ) And &
(dw.Describe(ls_obj+".visible") = "1" ) THEN
lds_sort.InsertRow(0)
lds_sort.SetItem(lds_sort.RowCount(), 'zname', ls_obj)
lds_sort.SetItem(lds_sort.RowCount(), 'zpos', Pos)
lds_sort.SetItem(lds_sort.RowCount(), 'ztype', dw.Describe(ls_obj + '.type'))
lds_sort.SetItem(lds_sort.RowCount(), 'ztabsequence', Long(dw.Describe(ls_obj + '.tabsequence')))
lds_sort.SetItem(lds_sort.RowCount(), 'zx', Long(dw.Describe(ls_obj + '.x')))
lds_sort.SetItem(lds_sort.RowCount(), 'zy', Long(dw.Describe(ls_obj + '.y')))
lds_sort.SetItem(lds_sort.RowCount(), 'zheight', Long(dw.Describe(ls_obj + '.height')) + ii - 1)
lds_sort.SetItem(lds_sort.RowCount(), 'zwidth', Long(dw.Describe(ls_obj + '.width')))
END IF
//返回结果
RETURN lds_sort
end function
public function integer uf_dwsort (datawindow adw_dw, integer ai_colnum, integer ai_x, integer ai_y, integer ai_each_x_col, integer ai_each_x_text, integer ai_each_y);//==============================================================================
// Function: uf_dwsort()
//------------------------------------------------------------------------------
// Description: 数据窗体排序
//------------------------------------------------------------------------------
// Arguments:
// value datawindow adw_dw 目标数据窗体(freedom)
// value integer ai_colnum 目标列个数
// value integer ai_x 起始点x
// value integer ai_y 起始点y
// value integer ai_each_x_col text距column的列间距
// value integer ai_each_x_text column距text的列间距
// value integer ai_each_y 行间距
//------------------------------------------------------------------------------
// Returns: integer,成功返回1,失败返回0
//------------------------------------------------------------------------------
// Author: mojf@neusoft.com Date: 2006-3-16
//------------------------------------------------------------------------------
// Modify History:
// mojf@neusoft.com 2006-4-27 增加自适应大小功能
// 调整分割线位置
//------------------------------------------------------------------------------
// CopyRight By Neusoft Co.,Ltd
//==============================================================================
datastore lds_sort
integer li_width_max,li_height_max,i,j
integer li_x,li_y,li_each_x_col,li_each_x_text,li_each_y
//--------------------------------------------------------
//为自适应定义
integer li_dw_width//数据窗体宽度
integer li_std_width//标准宽度li_std_width=li_dw_width/ai_colnum
integer li_x_text//记录text的x位
integer li_width_text//记录text的宽度
//------------------------------------------------
string ls_name
integer li_num,li_rownum
//0、错误判断
if isnull(adw_dw) then return 0
if adw_dw.Describe("datawindow.objects")="" then return 0
if Integer(adw_dw.object.DataWindow.Column.Count)<=0 then return 0
if ai_colnum<=0 then return 0
if ai_colnum>Integer(adw_dw.object.DataWindow.Column.Count) then return 0
if adw_dw.Object.DataWindow.Processing<>'0' then
return 0
end if
//1、获得数据窗体objects的datastore
lds_sort=create datastore
lds_sort=uf_getdwcontent(adw_dw,'detail')
if isnull(lds_sort) or lds_sort.rowcount()<=0 then return 0
//2、计算总个数、行数
lds_sort.setfilter("ztype='column' or ztype='compute'")
lds_sort.filter()
li_num=lds_sort.rowcount()
li_rownum=Ceiling(li_num/ai_colnum)
//3、布局左对齐
lds_sort.setsort("ztabsequence a")
lds_sort.sort()
//3.1设置起始位置x、y,行间距、列间距(包括column距text的距离和text距column的距离)
//li_x=14
//li_y=100
//li_each_x_col=400 - 14 - 330//text距column的距离
//li_each_x_text=20//column距text的距离
//li_each_y=100 - 80
li_x=ai_x
li_y=ai_y
li_each_x_col=ai_each_x_col//text距column的距离
li_each_x_text=ai_each_x_text//column距text的距离
li_each_y=ai_each_y
//设置平均每列宽度
li_dw_width=adw_dw.width
li_std_width=li_dw_width/ai_colnum
//3.2列
for i=1 to ai_colnum
if i=ai_colnum then i=0
li_width_max=0
//设置x
for j=1 to lds_sort.rowcount()
if mod(j,ai_colnum)=i then
//text
ls_name=lds_sort.object.zname[j]
adw_dw.modify(ls_name+"_t.x="+string(li_x))
if integer(adw_dw.describe(ls_name+"_t.width"))>li_width_max then li_width_max=integer(adw_dw.describe(ls_name+"_t.width"))
end if
next
//设置width
li_width_max= li_width_max+55//调节量
for j=1 to lds_sort.rowcount()
if mod(j,ai_colnum)=i then
//text
ls_name=lds_sort.object.zname[j]
adw_dw.modify(ls_name+"_t.width="+string(li_width_max))
end if
next
li_x_text=li_x//记录每一列的text位,为自适应用
li_width_text=li_width_max//记录每一列的text宽度,为自适应用
li_x=li_x+li_width_max+li_each_x_text
li_width_max=0
//设置x
for j=1 to lds_sort.rowcount()
if mod(j,ai_colnum)=i then
//column
ls_name=lds_sort.object.zname[j]
adw_dw.modify(ls_name+".x="+string(li_x))
if integer(adw_dw.describe(ls_name+".width"))>li_width_max then li_width_max=integer(adw_dw.describe(ls_name+".width"))
end if
next
//--------------------------------------------------------
//为自适应修改
if (li_width_text + li_each_x_text + li_width_max + li_each_x_col)>li_std_width then
//如果text的宽度+col对text的距离+col的宽度+text对col的距离
li_x=li_x+li_width_max+li_each_x_col
else
li_x=li_x_text+li_std_width
//设置width
li_width_max = li_width_max + li_std_width - (li_width_text + li_each_x_text + li_width_max + li_each_x_col)
for j=1 to lds_sort.rowcount()
if mod(j,ai_colnum)=i then
//text
ls_name=lds_sort.object.zname[j]
adw_dw.modify(ls_name+".width="+string(li_width_max))
end if
next
end if
//----------------------
if i=0 then i=ai_colnum
next
//3.3行
for i=1 to li_rownum
li_height_max=0
for j=1 to lds_sort.rowcount()
if j<=i * ai_colnum and j> (i - 1) * ai_colnum then
//text
ls_name=lds_sort.object.zname[j]
adw_dw.modify(ls_name+"_t.y="+string(li_y))
if integer(adw_dw.describe(ls_name+"_t.height"))>li_height_max then li_height_max=integer(adw_dw.describe(ls_name+"_t.height"))
//column
adw_dw.modify(ls_name+".y="+string(li_y))
if integer(adw_dw.describe(ls_name+".height"))>li_height_max then li_height_max=integer(adw_dw.describe(ls_name+".height"))
end if
next
li_y=li_y+li_height_max+li_each_y
next
adw_dw.Modify("DataWindow.detail.Height="+string(li_y))
//调整分割线位置
li_y = li_y - li_each_y/2
adw_dw.Modify("l_freedom.y1="+string(li_y))
adw_dw.Modify("l_freedom.y2="+string(li_y))
return 1
end function
public function integer uf_dwsort (datawindow adw_dw);//==============================================================================
// Function: uf_dwsort()
//------------------------------------------------------------------------------
// Description: 数据窗体排序
//------------------------------------------------------------------------------
// Arguments:
// value datawindow adw_dw 目标数据窗体(freedom)
//------------------------------------------------------------------------------
// Returns: integer,成功返回1,失败返回0
//------------------------------------------------------------------------------
// Author: mojf@neusoft.com Date: 2006-3-16
//------------------------------------------------------------------------------
// Modify History:
//
//------------------------------------------------------------------------------
// CopyRight By Neusoft Co.,Ltd
//==============================================================================
return uf_dwsort(adw_dw,ii_colnum,ii_x,ii_y,ii_each_x_col,ii_each_x_text,ii_each_y)
end function
public function integer uf_dwchangestyle (datawindow adw_source, datawindow adw_target, integer ai_col_border, integer ai_col_height, integer ai_col_width, integer ai_text_height, integer ai_text_width, integer ai_header_height, integer ai_detail_height);//==============================================================================
// Function: uf_dwchangestyle()
//------------------------------------------------------------------------------
// Description: 改变数据窗体风格(freedom与grid互换)
//------------------------------------------------------------------------------
// Arguments:
// value datawindow adw_source 源数据窗体
// value datawindow adw_target 目标数据窗体
// value integer ai_col_border column对象border值
// value integer ai_col_height column对象height值
// value integer ai_col_width column对象width值
// value integer ai_text_height text对象height值
// value integer ai_text_width text对象width值
// value integer ai_header_height header区域height值
// value integer ai_detail_height detail区域height值
//------------------------------------------------------------------------------
// Returns: integer,成功返回1,失败返回0
//------------------------------------------------------------------------------
// Author: mojf@neusoft.com Date: 2006-4-12
//------------------------------------------------------------------------------
// Modify History:
//
//------------------------------------------------------------------------------
// CopyRight By Neusoft Co.,Ltd
//==============================================================================
string ls_freedom,ls_grid,ls_syntax,ls_error,ls_band_header,ls_band_detail
string ls_texts[],ls_temp
integer li_pos,i
datastore lds_sort
//0、错误判断
if isnull(adw_source) or isnull(adw_target) then return 0
if adw_source.Describe("datawindow.objects")="" or adw_target.Describe("datawindow.objects")="" then return 0
if Integer(adw_source.object.DataWindow.Column.Count)<=0 or Integer(adw_target.object.DataWindow.Column.Count)<=0 then return 0
//1、获得数据窗体objects的datastore
lds_sort=create datastore
lds_sort=uf_getdwcontent(adw_source,'detail')
if isnull(lds_sort) or lds_sort.rowcount()<=0 then return 0
lds_sort.setfilter("ztype='column' or ztype='compute'")
lds_sort.filter()
//2、变换风格
ls_freedom="processing=0"
ls_grid="processing=1"
ls_band_header="band=header"
ls_band_detail="band=detail"
ls_syntax=adw_source.describe('datawindow.syntax')
if integer( adw_source.describe("DataWindow.Processing"))=0 then//freedom变成grid
ls_syntax= Replace(ls_syntax, pos(ls_syntax,ls_freedom), len(ls_freedom), ls_grid)
adw_target.create(ls_syntax,ls_error)
if ls_error <> '' then
messagebox('Create Error',ls_error)
return 0
end if
adw_target.Modify("DataWindow.header.Height=92")
adw_target.Modify("DataWindow.detail.Height=104")
adw_target.Modify("DataWindow.header.color='"+adw_target.describe("DataWindow.detail.color")+"'")
for i=1 to lds_sort.rowcount()
adw_target.modify(lds_sort.object.zname[i]+".border='0'")
adw_target.modify(lds_sort.object.zname[i]+".height='60'")
adw_target.modify(lds_sort.object.zname[i]+"_t.height='60'")
adw_target.modify(lds_sort.object.zname[i]+"_t.width='500'")
adw_target.modify(lds_sort.object.zname[i]+".width='500'")
adw_target.modify(lds_sort.object.zname[i]+"_t.y=0")
adw_target.modify(lds_sort.object.zname[i]+".y=0")
adw_target.modify(lds_sort.object.zname[i]+".x="+string(500*(i - 1)))
adw_target.modify(lds_sort.object.zname[i]+"_t.x="+string(500*(i - 1)))
next
for i=1 to lds_sort.rowcount()
adw_target.modify(lds_sort.object.zname[i]+"_t.x="+adw_target.describe(lds_sort.object.zname[i]+".x"))
next
ls_temp=adw_target.describe('datawindow.syntax')
do while len(ls_temp)>0
i=UpperBound(ls_texts) + 1
ls_texts[i]=left(ls_temp,pos(ls_temp,'~r~n'))
if pos(ls_texts[i],"text(")>0 then
ls_texts[i]= Replace(ls_texts[i], pos(ls_texts[i],ls_band_detail), len(ls_band_detail), ls_band_header)
end if
ls_texts[i]=left(ls_texts[i],len(ls_texts[i]) -1)
ls_temp=Mid (ls_temp, pos(ls_temp,'~r~n') +2, Len (ls_temp))
loop
for i=1 to UpperBound(ls_texts)
ls_temp+=ls_texts[i]
ls_temp+='~r~n'
next
adw_target.create(ls_temp,ls_error)
if ls_error <> '' then
messagebox('Create Error',ls_error)
return 0
end if
elseif integer( adw_source.describe("DataWindow.Processing"))=1 then//grid变成freedom
ls_syntax= Replace(ls_syntax, pos(ls_syntax,ls_grid), len(ls_grid), ls_freedom)
do while pos(ls_syntax,ls_band_header)>0
ls_syntax= Replace(ls_syntax, pos(ls_syntax,ls_band_header), len(ls_band_header), ls_band_detail)
loop
adw_target.create(ls_syntax,ls_error)
if ls_error <> '' then
messagebox('Create Error',ls_error)
return 0
end if
for i=1 to lds_sort.rowcount()
adw_target.modify(lds_sort.object.zname[i]+".border='5'")
adw_target.modify(lds_sort.object.zname[i]+".height='80'")
adw_target.modify(lds_sort.object.zname[i]+"_t.height='80'")
adw_target.modify(lds_sort.object.zname[i]+"_t.width='329'")
adw_target.modify(lds_sort.object.zname[i]+".width='498'")
adw_target.modify(lds_sort.object.zname[i]+"_t.y=0")
adw_target.modify(lds_sort.object.zname[i]+".y="+string(integer(adw_target.describe(lds_sort.object.zname[i]+'_t.height'))+20))
next
adw_target.Modify("DataWindow.header.Height=0")
adw_target.Modify("DataWindow.detail.Height=2520")
end if
return 1
end function
public function integer uf_dwchangestyle (datawindow adw_source, datawindow adw_target);//==============================================================================
// Function: uf_dwchangestyle()
//------------------------------------------------------------------------------
// Description: 改变数据窗体风格(freedom与grid互换)
//------------------------------------------------------------------------------
// Arguments:
// value datawindow adw_source 源数据窗体
// value datawindow adw_target 目标数据窗体
//------------------------------------------------------------------------------
// Returns: integer,成功返回1,失败返回0
//------------------------------------------------------------------------------
// Author: mojf@neusoft.com Date: 2006-4-12
//------------------------------------------------------------------------------
// Modify History:
// mojf@neusoft.com 加入分割线 修改freedom情况下text的border
// 加入修改text的background是553648127transparent
//------------------------------------------------------------------------------
// CopyRight By Neusoft Co.,Ltd
//==============================================================================
string ls_freedom,ls_grid,ls_syntax,ls_error,ls_band_header,ls_band_detail
string ls_texts[],ls_temp
string ls_line//加入分割线用
integer li_detail_height,li_dw_width//加入分割线用
integer li_pos,i
datastore lds_sort
//0、错误判断
if isnull(adw_source) then return 0
if adw_source.Describe("datawindow.objects")="" then return 0
if Integer(adw_source.object.DataWindow.Column.Count)<=0 then return 0
//1、获得数据窗体objects的datastore
lds_sort=create datastore
lds_sort=uf_getdwcontent(adw_source,'detail')
if isnull(lds_sort) or lds_sort.rowcount()<=0 then return 0
lds_sort.setfilter("ztype='column' or ztype='compute'")
lds_sort.filter()
//2、变换风格
ls_freedom="processing=0"
ls_grid="processing=1"
ls_band_header="band=header"
ls_band_detail="band=detail"
ls_syntax=adw_source.describe('datawindow.syntax')
if integer( adw_source.describe("DataWindow.Processing"))=0 then//freedom变成grid
ls_syntax= Replace(ls_syntax, pos(ls_syntax,ls_freedom), len(ls_freedom), ls_grid)
adw_target.create(ls_syntax,ls_error)
if ls_error <> '' then
return 0
end if
adw_target.Modify("DataWindow.header.Height=92")
adw_target.Modify("DataWindow.detail.Height=104")
adw_target.Modify("DataWindow.header.color='"+adw_target.describe("DataWindow.detail.color")+"'")
adw_target.Modify("destroy l_freedom")
for i=1 to lds_sort.rowcount()
adw_target.modify(lds_sort.object.zname[i]+".border='0'")
adw_target.modify(lds_sort.object.zname[i]+"_t.border='6'")
adw_target.modify(lds_sort.object.zname[i]+"_t.background.color='553648127'")
adw_target.modify(lds_sort.object.zname[i]+".height='60'")
adw_target.modify(lds_sort.object.zname[i]+"_t.height='60'")
adw_target.modify(lds_sort.object.zname[i]+"_t.width='500'")
adw_target.modify(lds_sort.object.zname[i]+".width='500'")
adw_target.modify(lds_sort.object.zname[i]+"_t.y=0")
adw_target.modify(lds_sort.object.zname[i]+".y=0")
adw_target.modify(lds_sort.object.zname[i]+".x="+string(500*(i - 1)))
adw_target.modify(lds_sort.object.zname[i]+"_t.x="+string(500*(i - 1)))
next
for i=1 to lds_sort.rowcount()
adw_target.modify(lds_sort.object.zname[i]+"_t.x="+adw_target.describe(lds_sort.object.zname[i]+".x"))
next
ls_temp=adw_target.describe('datawindow.syntax')
do while len(ls_temp)>0
i=UpperBound(ls_texts) + 1
ls_texts[i]=left(ls_temp,pos(ls_temp,'~r~n'))
if pos(ls_texts[i],"text(")>0 then
ls_texts[i]= Replace(ls_texts[i], pos(ls_texts[i],ls_band_detail), len(ls_band_detail), ls_band_header)
end if
ls_texts[i]=left(ls_texts[i],len(ls_texts[i]) -1)
ls_temp=Mid (ls_temp, pos(ls_temp,'~r~n') +2, Len (ls_temp))
loop
for i=1 to UpperBound(ls_texts)
ls_temp+=ls_texts[i]
ls_temp+='~r~n'
next
adw_target.create(ls_temp,ls_error)
if ls_error <> '' then
return 0
end if
elseif integer( adw_source.describe("DataWindow.Processing"))=1 then//grid变成freedom
ls_syntax= Replace(ls_syntax, pos(ls_syntax,ls_grid), len(ls_grid), ls_freedom)
do while pos(ls_syntax,ls_band_header)>0
ls_syntax= Replace(ls_syntax, pos(ls_syntax,ls_band_header), len(ls_band_header), ls_band_detail)
loop
adw_target.create(ls_syntax,ls_error)
if ls_error <> '' then
return 0
end if
for i=1 to lds_sort.rowcount()
adw_target.modify(lds_sort.object.zname[i]+".border='5'")
adw_target.modify(lds_sort.object.zname[i]+"_t.border='0'")
adw_target.modify(lds_sort.object.zname[i]+"_t.background.color='553648127'")
adw_target.modify(lds_sort.object.zname[i]+".height='80'")
adw_target.modify(lds_sort.object.zname[i]+"_t.height='80'")
adw_target.modify(lds_sort.object.zname[i]+"_t.width='329'")
adw_target.modify(lds_sort.object.zname[i]+".width='498'")
adw_target.modify(lds_sort.object.zname[i]+"_t.y=0")
adw_target.modify(lds_sort.object.zname[i]+".y="+string(integer(adw_target.describe(lds_sort.object.zname[i]+'_t.height'))+20))
next
adw_target.Modify("DataWindow.header.Height=0")
adw_target.Modify("DataWindow.detail.Height="+string(lds_sort.rowcount()*(100 + 80)))
//加入分割线
adw_target.Modify("destroy l_freedom")
li_detail_height=integer(adw_target.describe("DataWindow.detail.Height"))
li_dw_width=adw_target.width
ls_line = "create line(band=detail x1='0' y1='"+string(li_detail_height)+"' x2='"+string(li_dw_width)+"' y2='"+string(li_detail_height)+"' name=l_freedom visible='1' pen.style='0' pen.width='5' pen.color='33554432' background.mode='1' background.color='553648127' ) "
// ls_line = "create text(band=detail alignment='0' text='' border='5' color='33554432' x='0' y='"+string(li_detail_height)+"' height='4' width='"+string(li_dw_width)+"' html.valueishtml='0' name=l_freedom visible='1' font.face='Arial' font.height='-12' font.weight='400' font.family='2' font.pitch='2' font.charset='0' background.mode='1' background.color='553648127' )"
adw_target.Modify(ls_line)
end if
return 1
end function
public function integer uf_dwautonewline (datawindow adw_dw, string as_pos);//==============================================================================
// Function: uf_dwautonewline()
//------------------------------------------------------------------------------
// Description: 数据窗体自动折行
// 令数据窗体对象文本部分自动换行,适应地修改高度
//------------------------------------------------------------------------------
// Arguments:
// value datawindow as_dw 目标数据窗体
// value string as_pos 目标位置:detail、summary、footer、header
// value string as_type 目标对象类型:text
//------------------------------------------------------------------------------
// Returns: integer,成功返回1,失败返回0
//------------------------------------------------------------------------------
// Author: mojf@neusoft.com Date: 2006-3-17
//------------------------------------------------------------------------------
// Modify History:
//
//------------------------------------------------------------------------------
// CopyRight By Neusoft Co.,Ltd
//==============================================================================
datastore lds_sort
integer i,li_len,li_width,li_height,li_height_old,li_height_change
integer li_base_len,li_base_width,li_base_rate,li_base_height
string ls_name,ls_text
//1、错误判断
if isnull(adw_dw) then return 0
if adw_dw.Describe("datawindow.objects")="" then return 0
//2、获得数据窗体objects的datastore
lds_sort=create datastore
lds_sort=uf_getdwcontent(adw_dw,as_pos)
if isnull(lds_sort) or lds_sort.rowcount()<=0 then return 0
//3、获得as_type类型的对象
lds_sort.setfilter("ztype='text'")
lds_sort.filter()
//4、判断如果对象text的宽度小于len*li_base_rate,并且高度小于len*li_base_rate整除宽度再乘以li_base_height的结果
// 那么就把对象的高度加高li_base_height
for i=1 to lds_sort.rowcount()
ls_name=lds_sort.object.zname[i]
ls_text=adw_dw.describe(ls_name+".text")
li_len=len(ls_text)
li_width=integer(adw_dw.describe(ls_name+".width"))
li_height=integer(adw_dw.describe(ls_name+".height"))
li_height_old=li_height
//根据字体和实际情况设定标准值,计算text的width对len的比率
if adw_dw.describe(ls_name+".font.face")="Arial" &
and adw_dw.describe(ls_name+".font.height")="-9" then
//字体"Arial",9号 font.face="Arial" font.height="-9"
li_base_len=12
li_base_width=329
li_base_height=60
//elseif 其它字体
else//不变
li_base_len=li_len
li_base_width=li_width
li_base_height=li_height
end if
li_base_rate=li_base_width/li_base_len
if li_len<=li_base_len and li_width>=li_base_width then continue
if li_width<li_len*li_base_rate then
do while li_height<Ceiling((li_len*li_base_rate)/li_width)*li_base_height
li_height=Ceiling((li_len*li_base_rate)/li_width)*li_base_height
adw_dw.modify(ls_name+".height="+string(li_height))
loop
end if
if li_height_change<li_height - li_height_old then
li_height_change=li_height - li_height_old
end if
next
adw_dw.modify("datawindow."+as_pos+".height="+string(integer(adw_dw.describe("datawindow."+as_pos+".height"))+li_height_change))
return 1
end function