⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 w_edit.srw

📁 一个powerbuilder做的俄罗斯方块
💻 SRW
📖 第 1 页 / 共 2 页
字号:
$PBExportHeader$w_edit.srw
forward
global type w_edit from window
end type
type cb_7 from commandbutton within w_edit
end type
type cb_6 from commandbutton within w_edit
end type
type cb_reset from commandbutton within w_edit
end type
type st_2 from statictext within w_edit
end type
type st_1 from statictext within w_edit
end type
type cb_4 from commandbutton within w_edit
end type
type cb_3 from commandbutton within w_edit
end type
type rb_8 from radiobutton within w_edit
end type
type rb_7 from radiobutton within w_edit
end type
type rb_6 from radiobutton within w_edit
end type
type rb_5 from radiobutton within w_edit
end type
type rb_4 from radiobutton within w_edit
end type
type rb_3 from radiobutton within w_edit
end type
type rb_2 from radiobutton within w_edit
end type
type rb_1 from radiobutton within w_edit
end type
type cb_2 from commandbutton within w_edit
end type
type cb_1 from commandbutton within w_edit
end type
type dw_8 from datawindow within w_edit
end type
type dw_7 from datawindow within w_edit
end type
type dw_6 from datawindow within w_edit
end type
type dw_5 from datawindow within w_edit
end type
type dw_4 from datawindow within w_edit
end type
type dw_3 from datawindow within w_edit
end type
type dw_2 from datawindow within w_edit
end type
type dw_1 from datawindow within w_edit
end type
type gb_1 from groupbox within w_edit
end type
type gb_2 from groupbox within w_edit
end type
end forward

global type w_edit from window
integer width = 2043
integer height = 1588
boolean titlebar = true
string title = "自定义方块"
boolean controlmenu = true
windowtype windowtype = response!
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cb_7 cb_7
cb_6 cb_6
cb_reset cb_reset
st_2 st_2
st_1 st_1
cb_4 cb_4
cb_3 cb_3
rb_8 rb_8
rb_7 rb_7
rb_6 rb_6
rb_5 rb_5
rb_4 rb_4
rb_3 rb_3
rb_2 rb_2
rb_1 rb_1
cb_2 cb_2
cb_1 cb_1
dw_8 dw_8
dw_7 dw_7
dw_6 dw_6
dw_5 dw_5
dw_4 dw_4
dw_3 dw_3
dw_2 dw_2
dw_1 dw_1
gb_1 gb_1
gb_2 gb_2
end type
global w_edit w_edit

type variables
Long	ila_c[8]
Long	il_color = 1

str_fk  istr_fk[4]


end variables

forward prototypes
public subroutine wf_change_color ()
public subroutine wf_xz (datawindow adw_dw)
public subroutine wf_xun (datawindow adw_1, datawindow adw_2)
public function boolean wf_getfk (long al_fkid, long al_fkh)
public subroutine wf_c ()
public subroutine wf_save ()
end prototypes

public subroutine wf_change_color ();integer	li_r,li_c
dw_5.AcceptText()
dw_6.AcceptText()
dw_7.AcceptText()
dw_8.AcceptText()
For li_r = 1 to 4
	For li_c = 1 to 4
		If IsNull(dw_5.object.data[li_r,li_c]) = False Then
			dw_5.object.data[li_r,li_c] = ila_c[il_color]
		End If
		If IsNull(dw_6.object.data[li_r,li_c]) = False Then
			dw_6.object.data[li_r,li_c] = ila_c[il_color]
		End If
		If IsNull(dw_7.object.data[li_r,li_c]) = False Then
			dw_7.object.data[li_r,li_c] = ila_c[il_color]
		End If
		If IsNull(dw_8.object.data[li_r,li_c]) = False Then
			dw_8.object.data[li_r,li_c] = ila_c[il_color]
		End If
	End For
End for
this.setRedraw(True)
Return

end subroutine

public subroutine wf_xz (datawindow adw_dw);// 修改所给数据窗口内的数据
Integer li_c = 1,li_r,li_l
Long	ll_l
setNull(ll_l)
Boolean	lb_null
li_l = 1
do while li_l <= 4
	lb_null = True
	For li_r = 1 To 4
		If IsNull(adw_dw.Object.data[li_r,1]) = False Then
			lb_Null = False
			Exit
		End If
	End For
	If lb_Null Then
		For li_r = 1 To 4
			For li_c = 1 To 3
				adw_dw.Object.data[li_r,li_c] = adw_dw.Object.data[li_r,li_c + 1]
			End For
			adw_dw.Object.data[li_r,4] = ll_l
		End For
		li_l ++
	Else
		Exit
	End If
Loop

li_l = 1
do while li_l <= 4
	lb_null = True
	For li_c = 1 To 4
		If IsNull(adw_dw.Object.data[4,li_c]) = False Then
			lb_Null = False
			Exit
		End If
	End For
	If lb_Null Then
		For li_c = 1 To 4
			For li_r = 4 To 2 step -1
				adw_dw.Object.data[li_r,li_c] = adw_dw.Object.data[li_r - 1,li_c]
			End For
			adw_dw.Object.data[1,li_c] = ll_l
		End For
		li_l ++
	Else
		Exit
	End If
Loop
return

end subroutine

public subroutine wf_xun (datawindow adw_1, datawindow adw_2);// 将数据窗口一旋转90度放入数据窗口二
integer	li_r,li_c,li
For li_r = 1 to 4
	For li_c = 1 to 4
		adw_2.Object.data[li_r,li_c] = adw_1.object.data[5 - li_c,li_r]
	End For
End For
Return

end subroutine

public function boolean wf_getfk (long al_fkid, long al_fkh);// 取方块到结构中
boolean	lb_result = false
Long	ll_find
ll_find = w_main.dw_fklx.find('id = ' + string(al_fkid),1,w_main.dw_fklx.RowCount())
If ll_find <= 0 Then
	Return false
End If
string	ls_fk
Long	ll_color
ll_color = w_main.dw_fklx.object.fkcolor[ll_find]
Choose case al_fkh
	Case 1
		ls_fk = w_main.dw_fklx.object.fk1[ll_find]
	case 2
		ls_fk = w_main.dw_fklx.object.fk2[ll_find]
	Case 3
		ls_fk = w_main.dw_fklx.object.fk3[ll_find]
	Case 4
		ls_fk = w_main.dw_fklx.object.fk4[ll_find]
End choose
integer li_r,li_c
long	ll_l
For li_r = 1 to 4
	For li_c = 1 to 4
		If left(ls_fk,1) = '0' Then
			ll_l = rgb(0,0,0)
		Else
			ll_l = ll_color
		End If
		Choose case li_c
			Case 1
				istr_fk[li_r].long1 = ll_l
			Case 2
				istr_fk[li_r].long2 = ll_l
			Case 3
				istr_fk[li_r].long3 = ll_l
			Case 4
				istr_fk[li_r].long4 = ll_l
		End Choose
		ls_fk = mid(ls_fk,2)
	End For
	ls_fk = mid(ls_fk,2)
End for
lb_result = true
Return lb_Result


end function

public subroutine wf_c ();dw_1.Reset()
dw_1.insertRow(0)
dw_1.insertrow(0)
dw_1.insertrow(0)
dw_1.insertRow(0)

dw_2.Reset()
dw_3.reset()
dw_4.reset()

dw_1.Rowscopy(1,4,primary!,dw_2,1,primary!)
dw_1.Rowscopy(1,4,primary!,dw_3,1,primary!)
dw_1.Rowscopy(1,4,primary!,dw_4,1,primary!)

end subroutine

public subroutine wf_save ();Integer	li_r,li_c

// 判断是否有方块
boolean	lb_go
lb_go = False
For li_r = 1 to 4
	For li_c = 1 to 4
		If IsNull(dw_5.Object.data[li_r,li_c]) = False Then
			lb_go = True
			exit
		End If
	End For
	If lb_go Then
		exit
	End If
End For
If lb_go = False then
	MessageBox('保存方块阵列','空方块阵列不能保存。')
	REturn
End If

lb_go = False
For li_r = 1 to 4
	For li_c = 1 to 4
		If IsNull(dw_6.Object.data[li_r,li_c]) = False Then
			lb_go = True
			exit
		End If
	End For
	If lb_go Then
		exit
	End If
End For
If lb_go = False then
	MessageBox('保存方块阵列','请先做“生成”工作。')
	REturn
End If

Long	ll_Rows,ll_id
String ls_fk1,ls_fk2,ls_fk3,ls_fk4
// 生成四种方块阵列
ls_fk1 = ''
For li_r = 1 to 4
	For li_c = 1 to 4
		If IsNull(dw_5.Object.data[li_r,li_c]) Then
			ls_fk1 = ls_fk1 + '0'
		Else
			ls_fk1 = ls_fk1 + '1'
		End If
	End For
	ls_fk1 = ls_fk1 + ';'
End For

ls_fk2 = ''
For li_r = 1 to 4
	For li_c = 1 to 4
		If IsNull(dw_6.Object.data[li_r,li_c]) Then
			ls_fk2 = ls_fk2 + '0'
		Else
			ls_fk2 = ls_fk2 + '1'
		End If
	End For
	ls_fk2 = ls_fk2 + ';'
End For

ls_fk3 = ''
For li_r = 1 to 4
	For li_c = 1 to 4
		If IsNull(dw_7.Object.data[li_r,li_c]) Then
			ls_fk3 = ls_fk3 + '0'
		Else
			ls_fk3 = ls_fk3 + '1'
		End If
	End For
	ls_fk3 = ls_fk3 + ';'
End For

ls_fk4 = ''
For li_r = 1 to 4
	For li_c = 1 to 4
		If IsNull(dw_8.Object.data[li_r,li_c]) Then
			ls_fk4 = ls_fk4 + '0'
		Else
			ls_fk4 = ls_fk4 + '1'
		End If
	End For
	ls_fk4 = ls_fk4 + ';'
End For

//  取方块编号
ll_Rows = w_main.dw_fklx.Rowcount()
If ll_Rows = 0 Then
	ll_id = 1
Else
	ll_id = w_main.dw_fklx.Object.id[ll_Rows] + 1
End If

ll_Rows ++
w_main.dw_fklx.InsertRow(ll_Rows)
w_main.dw_fklx.object.id[ll_Rows] = ll_id
w_main.dw_fklx.object.fkcolor[ll_Rows] = ila_c[il_color]
w_main.dw_fklx.object.fk1[ll_Rows] = ls_fk1
w_main.dw_fklx.object.fk2[ll_Rows] = ls_fk2
w_main.dw_fklx.object.fk3[ll_Rows] = ls_fk3
w_main.dw_fklx.object.fk4[ll_Rows] = ls_fk4

w_main.dw_fklx.ScrolltoRow(ll_rows)
w_main.dw_fklx.SetRow(ll_rows)

w_main.dw_fklx.Saveas('fklx.dbf',dBASE3!,true)
wf_c()
boolean lb_b
lb_b = wf_getfk(ll_id,1)
If lb_b Then
	w_main.wf_writefk(dw_1,istr_fk,1,1,false)
End If
lb_b = wf_getfk(ll_id,2)
If lb_b Then
	w_main.wf_writefk(dw_2,istr_fk,1,1,false)
End If
lb_b = wf_getfk(ll_id,3)
If lb_b Then
	w_main.wf_writefk(dw_3,istr_fk,1,1,false)
End If
lb_b = wf_getfk(ll_id,4)
If lb_b Then
	w_main.wf_writefk(dw_4,istr_fk,1,1,false)
End If
dw_1.SetRedraw(True)
dw_2.SetRedraw(True)
dw_3.SetRedraw(True)
dw_4.SetRedraw(True)

cb_reset.post event clicked()
Return

end subroutine

on w_edit.create
this.cb_7=create cb_7
this.cb_6=create cb_6
this.cb_reset=create cb_reset
this.st_2=create st_2
this.st_1=create st_1
this.cb_4=create cb_4
this.cb_3=create cb_3
this.rb_8=create rb_8
this.rb_7=create rb_7
this.rb_6=create rb_6
this.rb_5=create rb_5
this.rb_4=create rb_4
this.rb_3=create rb_3
this.rb_2=create rb_2
this.rb_1=create rb_1
this.cb_2=create cb_2
this.cb_1=create cb_1
this.dw_8=create dw_8
this.dw_7=create dw_7
this.dw_6=create dw_6
this.dw_5=create dw_5
this.dw_4=create dw_4
this.dw_3=create dw_3
this.dw_2=create dw_2
this.dw_1=create dw_1
this.gb_1=create gb_1
this.gb_2=create gb_2
this.Control[]={this.cb_7,&
this.cb_6,&
this.cb_reset,&
this.st_2,&
this.st_1,&
this.cb_4,&
this.cb_3,&
this.rb_8,&
this.rb_7,&
this.rb_6,&
this.rb_5,&
this.rb_4,&
this.rb_3,&
this.rb_2,&
this.rb_1,&
this.cb_2,&
this.cb_1,&
this.dw_8,&
this.dw_7,&
this.dw_6,&
this.dw_5,&
this.dw_4,&
this.dw_3,&
this.dw_2,&
this.dw_1,&
this.gb_1,&
this.gb_2}
end on

on w_edit.destroy
destroy(this.cb_7)
destroy(this.cb_6)
destroy(this.cb_reset)
destroy(this.st_2)
destroy(this.st_1)
destroy(this.cb_4)
destroy(this.cb_3)
destroy(this.rb_8)
destroy(this.rb_7)
destroy(this.rb_6)
destroy(this.rb_5)
destroy(this.rb_4)
destroy(this.rb_3)
destroy(this.rb_2)
destroy(this.rb_1)
destroy(this.cb_2)
destroy(this.cb_1)
destroy(this.dw_8)
destroy(this.dw_7)
destroy(this.dw_6)
destroy(this.dw_5)
destroy(this.dw_4)
destroy(this.dw_3)
destroy(this.dw_2)
destroy(this.dw_1)
destroy(this.gb_1)
destroy(this.gb_2)
end on

event open;ila_c[1] = Rgb(255,0,0)
ila_c[2] = Rgb(255,128,064)
ila_c[3] = Rgb(0,0,255)
ila_c[4] = Rgb(0,255,255)
ila_c[5] = Rgb(0,255,0)
ila_c[6] = Rgb(192,192,192)
ila_c[7] = Rgb(255,0,255)
ila_c[8] = rgb(255,255,255)

rb_1.textcolor = ila_c[1]
rb_2.textcolor = ila_c[2]
rb_3.textcolor = ila_c[3]
rb_4.textcolor = ila_c[4]
rb_5.textcolor = ila_c[5]
rb_6.textcolor = ila_c[6]
rb_7.textcolor = ila_c[7]
rb_8.textcolor = ila_c[8]

dw_1.object.col5.x = 400
dw_2.object.col5.x = 400
dw_3.object.col5.x = 400
dw_4.object.col5.x = 400
dw_5.object.col5.x = 400
dw_6.object.col5.x = 400
dw_7.object.col5.x = 400
dw_8.object.col5.x = 400

dw_1.Object.datawindow.readonly = true
dw_2.Object.datawindow.readonly = true
dw_3.Object.datawindow.readonly = true
dw_4.Object.datawindow.readonly = true
dw_5.Object.datawindow.readonly = true
dw_6.Object.datawindow.readonly = true
dw_7.Object.datawindow.readonly = true
dw_8.Object.datawindow.readonly = true

w_main.dw_fklx.SetSort('id a')
w_main.dw_fklx.sort()

wf_c()

boolean lb_b
Long	ll_id,ll_r
ll_r = w_main.dw_fklx.getrow()
If ll_r <= 0 Then
	Return
End If
ll_id = w_main.dw_fklx.object.id[ll_r]
lb_b = wf_getfk(ll_id,1)
If lb_b Then
	w_main.wf_writefk(dw_1,istr_fk,1,1,false)
End If
lb_b = wf_getfk(ll_id,2)
If lb_b Then
	w_main.wf_writefk(dw_2,istr_fk,1,1,false)
End If
lb_b = wf_getfk(ll_id,3)
If lb_b Then
	w_main.wf_writefk(dw_3,istr_fk,1,1,false)
End If
lb_b = wf_getfk(ll_id,4)
If lb_b Then
	w_main.wf_writefk(dw_4,istr_fk,1,1,false)
End If
dw_1.SetRedraw(True)
dw_2.SetRedraw(True)
dw_3.SetRedraw(True)
dw_4.SetRedraw(True)

cb_Reset.Post event clicked()
Return


end event
type cb_7 from commandbutton within w_edit
integer x = 1490
integer y = 1244
integer width = 302
integer height = 92
integer taborder = 80
integer textsize = -10
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "退出"
end type

type cb_6 from commandbutton within w_edit
integer x = 1490
integer y = 688
integer width = 302
integer height = 92
integer taborder = 60
integer textsize = -10

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -