首页 > 其他分享 >PB DW内容自适应

PB DW内容自适应

时间:2023-04-03 10:03:54浏览次数:20  
标签:适应 ll list PB ldw ls dw DW type

演示GIF

20230403_090052.gif

思路

1、记录上一次DW大小、名称等信息。 2、根据DW最新大小除以上一次记录的DW大小,计算出缩放比列。 3、循环出DW中字段、控件等、根据类型分别计算出长宽高、X、Y坐标等。

源码

1、创建Custom Class对象、命名为uo_dwresize 2、使用

uo_dwresize dwresize
//open事件中
//实例化
dwresize = create uo_dwresize
//记录初始DW大小
dwresize.of_add_dwsize(dw_1)

//根据特定需求增加自适应方法
//根据DW大小,内容自适应
dwresize.of_draw_dwsize()

3、源码

forward
global type uo_dwresize from nonvisualobject
end type
type str_dwsize from structure within uo_dwresize
end type
end forward

global type str_dwsize from structure
	string	ls_classname
	long		ll_width
	long		ll_height
	datawindow		ldw_datawindow
end type

global type uo_dwresize from nonvisualobject
end type
global uo_dwresize uo_dwresize

type variables

any iany_arr[]
end variables

forward prototypes
public function any of_split (string as_bj, string as_input)
public subroutine of_add_dwsize (datawindow adw_dw)
public subroutine of_draw_dwsize ()
end prototypes

public function any of_split (string as_bj, string as_input);//================================================
//按符号分割字符串
//_of_split(as_bj,as_input)
//as_bj:符号
//as_input:字符串
//===============================================
string ls_list[] //接收返回的字符串列表
string ls_temp
integer i = 1
long  ll_pos
integer li_len

li_len = len(as_bj)  //分割符的长度
ll_pos = pos(as_input,as_bj)

do
	if ll_pos = 0 then
		ls_list[i] = as_input
	else  
		ls_list[i] = left(as_input,ll_pos - 1) 
		i++  
		as_input = mid(as_input,ll_pos + li_len)
		ll_pos = pos(as_input,as_bj)
		if ll_pos = 0 then ls_list[i] = as_input
	end if
loop while ll_pos <> 0

return ls_list
end function

public subroutine of_add_dwsize (datawindow adw_dw);long ll_for,ll_find = 0
str_dwsize str_size

for ll_for = 1 to upperbound(iany_arr)
	str_size = iany_arr[1]
	if str_size.ls_classname = adw_dw.classname() then exit
next

str_size.ls_classname = adw_dw.classname()
str_size.ll_width = adw_dw.width
str_size.ll_height = adw_dw.height
str_size.ldw_datawindow = adw_dw

if ll_find = 0 then iany_arr[upperbound(iany_arr) + 1] = str_size


end subroutine

public subroutine of_draw_dwsize ();long ll_widthOld = 0,ll_heightOld = 0
string ls_input='',ls_list[],ls_type = '',ls_band=''
dec ldc_RadioW = 0,ldc_RadioH = 0	
int ll_DWX,ll_DWY,ll_DWX2,ll_DWY2,ll_ApartW,ll_Processing
int ll_i,ll_ContentW,ll_ContentH,ll_DWHeaderH,ll_DWDetailH
long ll_textsize,ll_KJheight,ll_row
str_dwsize str_size
datawindow ldw_dw 

for ll_row = 1 to upperbound(iany_arr)
	str_size = iany_arr[ll_row]
	ldw_dw = str_size.ldw_datawindow
	
	ll_widthOld = str_size.ll_width
	ll_heightOld = str_size.ll_height
	
	str_size.ll_width = ldw_dw.width
	str_size.ll_height = ldw_dw.height
	iany_arr[ll_row] = str_size

	ldc_RadioW = ldw_dw.width / ll_widthOld
	ldc_RadioH = ldw_dw.height / ll_heightOld

	ldw_dw.setredraw(false)
	
	ls_input = ldw_dw.Describe("DataWindow.Objects")
	ls_list = of_split('	',ls_input)
	
	ll_DWHeaderH = long(ldw_dw.describe("datawindow.header.height"))
	ll_DWDetailH = long(ldw_dw.describe("datawindow.detail.height"))
	ll_DWHeaderH = ll_DWHeaderH * ldc_RadioH
	ll_DWDetailH = ll_DWDetailH * ldc_RadioH
	ldw_dw.Modify("datawindow.header.height = '"+string(ll_DWHeaderH)+"'")
	ldw_dw.Modify("datawindow.detail.height = '"+string(ll_DWDetailH)+"'")
	
	for ll_i = 1 to upperbound(ls_list)
		ls_band = ldw_dw.describe(ls_list[ll_i] + ".band")
		ls_type = ldw_dw.describe(ls_list[ll_i] + ".type")

		if ls_band <> '!'  then
			if ls_type = 'text' or ls_type = 'column'   or ls_type = 'compute' then
				if long(ldw_dw.describe(ls_list[ll_i] + ".visible")) = 0 then continue;
				ll_ContentW = long(ldw_dw.describe(ls_list[ll_i] + ".width"))
				ll_ContentH = long(ldw_dw.describe(ls_list[ll_i] + ".height"))
				ll_DWX = long(ldw_dw.describe(ls_list[ll_i] + ".x"))
				ll_DWY = long(ldw_dw.describe(ls_list[ll_i] + ".y"))
				ll_Processing = long(ldw_dw.Object.DataWindow.Processing)
				
				//Grid 只改变宽度;不改变X,Y
				if ll_Processing = 1 then
				else
					ldw_dw.Modify(ls_list[ll_i]+".x = '"+string(ll_DWX * ldc_RadioW)+"'")
					ldw_dw.Modify(ls_list[ll_i]+".y = '"+string(ll_DWY * ldc_RadioH)+"'")
				end if
				ldw_dw.Modify(ls_list[ll_i]+".width = '"+string(ll_ContentW * ldc_RadioW)+"'")
				ldw_dw.Modify(ls_list[ll_i]+".height = '"+string(ll_ContentH * ldc_RadioH)+"'")
			elseif ls_type = 'line'  then
				ll_DWX = long(ldw_dw.describe(ls_list[ll_i] + ".x1"))
				ll_DWY = long(ldw_dw.describe(ls_list[ll_i] + ".y1"))
				ll_DWX2 = long(ldw_dw.describe(ls_list[ll_i] + ".x2"))
				ll_DWY2 = long(ldw_dw.describe(ls_list[ll_i] + ".y2"))
		
				ldw_dw.Modify(ls_list[ll_i]+".x1 = '"+string(ll_DWX * ldc_RadioW)+"'")
				ldw_dw.Modify(ls_list[ll_i]+".y1 = '"+string(ll_DWY * ldc_RadioH)+"'")
				ldw_dw.Modify(ls_list[ll_i]+".x2 = '"+string(ll_DWX2 * ldc_RadioW)+"'")
				ldw_dw.Modify(ls_list[ll_i]+".y2 = '"+string(ll_DWY2 * ldc_RadioH)+"'")
			elseif ls_type = 'rectangle' or ls_type = 'button' or ls_type = 'roundrectangle' or ls_type = 'ellipse' or ls_type = 'report' or ls_type = 'bitmap' or ls_type = 'graph' then 
				ll_ContentW = long(ldw_dw.describe(ls_list[ll_i] + ".width"))
				ll_ContentH = long(ldw_dw.describe(ls_list[ll_i] + ".height"))
				ll_DWX = long(ldw_dw.describe(ls_list[ll_i] + ".x"))
				ll_DWY = long(ldw_dw.describe(ls_list[ll_i] + ".y"))
				
				ldw_dw.Modify(ls_list[ll_i]+".x = '"+string(ll_DWX * ldc_RadioW)+"'")
				ldw_dw.Modify(ls_list[ll_i]+".y = '"+string(ll_DWY * ldc_RadioH)+"'")
				ldw_dw.Modify(ls_list[ll_i]+".width = '"+string(ll_ContentW * ldc_RadioW)+"'")
				ldw_dw.Modify(ls_list[ll_i]+".height = '"+string(ll_ContentH * ldc_RadioH)+"'")
			end if
		end if
	next
	
	ldw_dw.setredraw(true)
next

end subroutine

on uo_dwresize.create
call super::create
TriggerEvent( this, "constructor" )
end on

on uo_dwresize.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

标签:适应,ll,list,PB,ldw,ls,dw,DW,type
From: https://blog.51cto.com/u_12956873/6165559

相关文章

  • 提升集群吞吐量与稳定性的秘诀: Dubbo 自适应负载均衡与限流策略实现解析
    作者:刘泉禄整体介绍本文所说的“柔性服务”主要是指consumer端的负载均衡和provider端的限流两个功能。在之前的Dubbo版本中,负载均衡部分更多的考虑的是公平性原则,即consumer端尽可能平等的从provider中作出选择,在某些情况下表现并不够理想。而限流部分只提供了静态的限......
  • 提升集群吞吐量与稳定性的秘诀: Dubbo 自适应负载均衡与限流策略实现解析
    作者:刘泉禄整体介绍本文所说的“柔性服务”主要是指consumer端的负载均衡和provider端的限流两个功能。在之前的Dubbo版本中,负载均衡部分更多的考虑的是公平性原则,即consumer端尽可能平等的从provider中作出选择,在某些情况下表现并不够理想。而限流部分只提供了静态......
  • AMBA总线(2)—— APB代码设计
    1前言本文所用EDA虚拟机来自博主【芯王国】的分享,版本是EDA_lite,对于没精力折腾环境的小白来说非常友好,强烈推荐!出处:https://blog.csdn.net/weixin_40377195/article/details/124899571本文的例程改编于知乎博主【四人独行】的博客《soc设计入门7-APBmaster设计》。......
  • STM32F103的PB3、PB4引脚
    做了一个使用STM32F103RBT6的PCB,将PB3~9分配给了三位一体八段数码管,发现PB3、PB4对应的这两段映硬是不亮,检查寄存器是有值的,由于芯片是从另一块板子上面拆下来的,所以首先怀疑芯片故障,结果换了新的MCU还是同样的效果,于是上网搜索,原来PB3和PB4在系统复位时分别默认为JTag接口的SYS_J......
  • AMBA总线(1)—— APB手册翻译
    APB是最简单的AMBA总线了,它多用于低速外围设备。相比AHB和AXI,有两个很不一样的点:不能outstanding传输,数据有效时,其地址必然是当前数据的对应地址。不能流水线式传输,必须至少2个周期传输一个数据,PSEL起来然后PENABLE起来。1前言1.2APB版本1998年发布的APBSpecification......
  • TOF方案在DW1000上的实现(四):DS-TWR方案
    说明在由DW1000芯片的制造原厂提供的示例代码中,同样提供了DS-TWR方案的实现示例:Example5a:double-sidedtwo-wayranging(DSTWR)initiatorExample5b:double-sidedtwo-wayrangingrespond该示例以C代码形式,演示了一个简单的双边双向测距的实现过程,本质上双边双向测距......
  • Dreamweaver 2021 for Mac(dw 2021) v21.0中文版
    Dreamweaver 2021mac中文版是一款为编码设计师提供了更快,更简单的方法来设计的软件,编写和发布在任何尺寸的屏幕上看起来很棒的网站和网络应用程序,新版本的dw2021下载比以往任何版本都更专注、更高效和快速,具备全新代码编辑器、更直观的用户界面和多种增强功能。强大的功能可以帮......
  • How to find the "usbmodem" of Raspberry Pi Pico on macOS All In One
    Howtofindthe"usbmodem"ofRaspberryPiPicoonmacOSAllInOneerrors/dev/tty.usbmodem0000000000001notexistbug❌#0000000000001❌$minicom-b115200-o-D/dev/tty.usbmodem0000000000001官方SDK文档❌bughttps://datasheets.raspberr......
  • 对于11g新特性自适应游标共享
    绑定变量优缺点、使用、绑定变量窥探、Oracle自适应共享游标_ITPUB博客自适应游标共享虽然解决了一些由于10g中绑定变量窥探只进行首次硬解析才窥探生成执行计划,由于数据倾斜造成执行计划不准确问题,但是不是每次执行sql都进行窥探,游标共享是“自适应”的,也会出现执行计划不准确......
  • 要么忙着生,要么忙着死。Dropbox怎么选择?
    Dropbox是当今硅谷最热门的创业公司,但这种热度并不意味着Dropbox的未来一片坦途。两年前,Dropbox的创始人DrewHouston与乔布斯之间有过一段有趣的对话。当时乔布斯微笑着说,苹果准备接管Dropbox的市场。他有一句话让Houston记忆犹新:Dropbox是一项功能,而不是一个产品。乔......