用st控件来做spliter分割条,应该怎么做?
要对那几个事件编写代码,比如在一个窗口水平方向上有两个数据窗口dw_1,dw_2,在它们中间加一个spliter。 问题点数:30、回复次数:7Top
1 楼Flying_Hawk(飞鹰)回复于 2002-04-16 10:57:32 得分 20
发个例子给你。你的mail??Top
2 楼zhanwei(@_@,初学.Net)回复于 2002-04-16 11:00:31 得分 0
$PBExportHeader$u_st_splitbar.sru
$PBExportComments$PFC SplitBar class. This object needs to be removed if application is migrated to PFC 6.0
forward
global type u_st_splitbar from statictext
end type
end forward
global type u_st_splitbar from statictext
int Width=535
int Height=21
boolean FocusRectangle=false
long BackColor=8421504
event mousemove pbm_mousemove
event lbuttonup pbm_lbuttonup
end type
global u_st_splitbar u_st_splitbar
type variables
Public:
//-- Define the "style" of split bar. --
constant integer VERTICAL = 1
constant integer HORIZONTAL = 2
//-- Define the "Register" type. --
constant integer LEFT=1
constant integer RIGHT=2
constant integer ABOVE=3
constant integer BELOW=4
Protected:
//-- Define the "Extreme points" constants. --
constant integer LEFTMOST=1
constant integer RIGHTMOST=2
constant integer TOPMOST=3
constant integer BOTTOMMOST=4
//-- Define default icons. --
string is_verticalpointer ='SizeWE!'
string is_horizontalpointer ='SizeNS!'
// -- Registered information. --
integer ii_lefttopbound
dragobject idrg_lefttop[]
real ir_lefttopx[]
real ir_lefttopy[]
real ir_lefttopwidth[]
real ir_lefttopheight[]
integer ii_rightbottombound
dragobject idrg_rightbottom[]
real ir_rightbottomx[]
real ir_rightbottomy[]
real ir_rightbottomwidth[]
real ir_rightbottomheight[]
// --Other. --
integer ii_style = -1 // Default to negative value.
Integer ii_barwidth = -1 // Default to negative value.
long il_barcolor=78682240
long il_barmovecolor=8421504
integer ii_minobjectsize = 20
boolean ib_performredraw=True
//-- Internal attributes. --
integer ii_prevpositionx = -1
integer ii_prevpositiony = -1
window iw_parent
userobject iuo_parent
tab itab_parent
Integer ii_rounding=5
end variables
forward prototypes
public function integer of_setbarcolor (long al_color)
public function integer of_setbarmovecolor (long al_color)
protected function integer of_lbuttonup (unsignedlong aul_flags, integer ai_xpos, integer ai_ypos)
protected function integer of_mousemove (unsignedlong aul_flags, integer ai_xpos, integer ai_ypos)
public function integer of_register (dragobject adrg_object, integer ai_position)
protected function integer of_updateobjectdata ()
protected function integer of_redraw (integer ai_prevx, integer ai_prevwidth, integer ai_prevy, integer ai_prevheight)
public function integer of_getextremepoint (integer ai_extremetype)
public function integer of_SetMinObjectSize (integer ai_minsize)
public function integer of_getminobjectsize ()
public function integer of_getbarcolor ()
public function string of_GetHorizontalPointer ()
public function string of_GetVerticalPointer ()
public function integer of_sethorizontalpointer (string as_icon)
public function integer of_setverticalpointer (string as_icon)
public function integer of_GetBarMoveColor ()
public function integer of_getinfo (ref n_cst_infoattrib anv_infoattrib)
end prototypes
event mousemove;call super::mousemove;
//////////////////////////////////////////////////////////////////////////////
//
// Event: mousemove
//
// Arguments:
// flags
// xpos
// ypos
//
// Returns: None.
//
// Description: Perform the Mouse Move processing.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 6.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright ?1996 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
If Not KeyDown(keyLeftButton!) Then
Return
End If
of_MouseMove(flags, xpos, ypos)
end event
event lbuttonup;call super::lbuttonup;
//////////////////////////////////////////////////////////////////////////////
//
// Event: lbuttonup
//
// Arguments:
// flags
// xpos
// ypos
//
// Returns: None.
//
// Description: Perform the Left Button Up processing.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 6.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright ?1996 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
of_lbuttonup(flags, xpos, ypos)
end event
public function integer of_setbarcolor (long al_color);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_SetBarColor
//
// Access: Public
//
// Arguments:
// al_color The desired color.
//
// Returns: Integer
// Returns 1 if it succeeds and?1 if an error occurs.
//
// Description: Set the Non-Moving Split Bar Color.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 6.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright ?1996 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
// Validate the argument.
If IsNull(al_color) Or al_color<0 Then
Return -1
End If
// Set the color.
il_barcolor = al_color
// Start using the requested color.
this.BackColor = il_barcolor
Return 1
end function
Top
3 楼zhanwei(@_@,初学.Net)回复于 2002-04-16 11:06:00 得分 10
public function integer of_setbarmovecolor (long al_color);
// Validate the argument.
If IsNull(al_color) Or al_color<0 Then
Return -1
End If
il_barmovecolor = al_color
Return 1
end function
protected function integer of_lbuttonup (unsignedlong aul_flags, integer ai_xpos, integer ai_ypos);
Integer li_cnt
Integer li_deltax, li_deltay
Integer li_pointerx, li_pointery
Integer li_minx, li_maxx, li_miny, li_maxy
Integer li_x, li_y, li_width, li_height
// Validate required values.
If ii_style <0 or ii_barwidth <0 Then
Return -1
End If
// Validate that objects were registered.
If UpperBound(idrg_lefttop) =0 Or UpperBound(idrg_rightbottom) =0 Then
Return -1
End If
this.SetPosition(ToTop!)
// Change to the base color.
this.BackColor = il_barcolor
// Validate that the bar has been moved.
If ii_prevpositionx < 0 Or ii_prevpositiony < 0 Then
Return 0
End If
// Get the new position.
If IsValid(iuo_parent) Then
li_pointerx = iuo_parent.PointerX()
li_pointery = iuo_parent.PointerY()
ElseIf IsValid(itab_parent) Then
li_pointerx = itab_parent.PointerX()
li_pointery = itab_parent.PointerY()
ElseIf IsValid(iw_parent) Then
li_pointerx = iw_parent.PointerX()
li_pointery = iw_parent.PointerY()
Else
// Reset the Previous position variables to 'no position'.
ii_prevpositionx = -1
ii_prevpositiony = -1
Return -1
End If
// Calculate the Extreme points the split bars can be moved.
If ii_style = HORIZONTAL Then
li_miny = of_GetExtremePoint(TOPMOST)
li_maxy = of_GetExtremePoint(BOTTOMMOST)
If li_pointery < li_miny Then
li_pointery = li_miny
ElseIf li_pointery > li_maxy Then
li_pointery = li_maxy
End If
ElseIf ii_style = VERTICAL Then
li_minx = of_GetExtremePoint(LEFTMOST)
li_maxx = of_GetExtremePoint(RIGHTMOST)
If li_pointerx < li_minx Then
li_pointerx = li_minx
ElseIf li_pointerx > li_maxx Then
li_pointerx = li_maxx
End If
End If
// Calculate delta values.
li_deltax = li_pointerx - ii_prevpositionx
li_deltay = li_pointery - ii_prevpositiony
// Minimize size rounding problems.
of_UpdateObjectData()
If ii_style = HORIZONTAL Then
// Position bar on its new location.
this.Y = li_pointery
// Refresh the Width of the bar.
this.Height = ii_barwidth
// Resize the objects above the horizontal split bar.
For li_cnt = 1 to UpperBound(idrg_lefttop)
If IsValid(idrg_lefttop[li_cnt]) Then
ir_lefttopheight[li_cnt] += li_deltay
idrg_lefttop[li_cnt].Resize(ir_lefttopwidth[li_cnt], ir_lefttopheight[li_cnt])
End If
Next
// Resize the objects below the horizontal split bar.
For li_cnt = 1 to UpperBound(idrg_rightbottom)
If IsValid(idrg_rightbottom[li_cnt]) Then
ir_rightbottomy[li_cnt] += li_deltay
ir_rightbottomheight[li_cnt] -= li_deltay
idrg_rightbottom[li_cnt].Move (ir_rightbottomx[li_cnt], ir_rightbottomy[li_cnt])
idrg_rightbottom[li_cnt].Resize (ir_rightbottomwidth[li_cnt], ir_rightbottomheight[li_cnt])
End If
Next
ElseIf ii_style = VERTICAL Then
// Position bar on its new location.
this.X = li_pointerx
// Refresh the Width of the bar.
this.Width = ii_barwidth
// Resize the objects left of the verticalbar.
For li_cnt = 1 to UpperBound(idrg_lefttop)
If IsValid(idrg_lefttop[li_cnt]) Then
ir_lefttopwidth[li_cnt] += li_deltax
idrg_lefttop[li_cnt].Resize(ir_lefttopwidth[li_cnt], ir_lefttopheight[li_cnt])
End If
Next
// Resize the objects right of the verticalbar.
For li_cnt = 1 to UpperBound(idrg_rightbottom)
If IsValid(idrg_rightbottom[li_cnt]) Then
ir_rightbottomx[li_cnt] += li_deltax
ir_rightbottomWidth[li_cnt] -= li_deltax
idrg_rightbottom[li_cnt].Move (ir_rightbottomx[li_cnt], ir_rightbottomy[li_cnt])
idrg_rightbottom[li_cnt].Resize(ir_rightbottomWidth[li_cnt], ir_rightbottomHeight[li_cnt])
End If
Next
End If
// Reset the Previous position variables to 'no position'.
ii_prevpositionx = -1
ii_prevpositiony = -1
Return 1
end function
protected function integer of_mousemove (unsignedlong aul_flags, integer ai_xpos, integer ai_ypos);
Integer li_cnt
Integer li_pointerx, li_pointery
Integer li_minx, li_maxx, li_miny, li_maxy
Integer li_prevx
Integer li_prevwidth
Integer li_prevheight
Integer li_prevy
Integer li_upperbound
Integer li_parentx, li_parenty
string ls_redraw
Integer li_x, li_y, li_width, li_height
// Validate required values.
If ii_style < 0 Then
Return -1
End If
// Validate that objects were registered.
If UpperBound(idrg_lefttop) =0 Or UpperBound(idrg_rightbottom) =0 Then
Return -1
End If
// Always keep the Split Bar on top of other objects.
this.SetPosition(ToTop!)
// Store the Begin Movement information.
If ii_prevpositionx < 0 or ii_prevpositiony < 0 Then
ii_prevpositionx = This.X
ii_prevpositiony = This.Y
End If
// Store the previous placement information.
li_prevx = this.X
li_prevwidth = this.Width
li_prevy = this.Y
li_prevheight = this.Height
// Get the new position.
If IsValid(iuo_parent) Then
li_pointerx = iuo_parent.PointerX()
li_pointery = iuo_parent.PointerY()
ElseIf IsValid(itab_parent) Then
li_pointerx = itab_parent.PointerX()
li_pointery = itab_parent.PointerY()
ElseIf IsValid(iw_parent) Then
li_pointerx = iw_parent.PointerX()
li_pointery = iw_parent.PointerY()
Else
Return -1
End If
// Calculate the Extreme points the split bars can be moved.
If ii_style = HORIZONTAL Then
li_miny = of_GetExtremePoint(TOPMOST)
li_maxy = of_GetExtremePoint(BOTTOMMOST)
If li_pointery < li_miny Then
li_pointery = li_miny
ElseIf li_pointery > li_maxy Then
li_pointery = li_maxy
End If
ElseIf ii_style = VERTICAL Then
li_minx = of_GetExtremePoint(LEFTMOST)
li_maxx = of_GetExtremePoint(RIGHTMOST)
If li_pointerx < li_minx Then
li_pointerx = li_minx
ElseIf li_pointerx > li_maxx Then
li_pointerx = li_maxx
End If
End If
// Change to the "Moving" color.
this.BackColor = il_barmovecolor
If ii_style = HORIZONTAL Then
// Position bar on its new location.
this.Y = li_pointery
// Refresh the Width of the bar.
this.Height = ii_barwidth
// Perform redraws when appropriate.
If ib_performredraw Then
If (li_prevy <> this.Y) Then
of_Redraw(li_prevx, li_prevwidth, li_prevy, li_prevheight)
End If
End If
ElseIf ii_style = VERTICAL Then
// Position bar on its new location.
this.X = li_pointerx
// Refresh the Width of the bar.
this.Width = ii_barwidth
// Perform redraws when appropriate.
If ib_performredraw Then
If (li_prevx <> this.X) Then
of_Redraw(li_prevx, li_prevwidth, li_prevy, li_prevheight)
End If
End If
End If
Return 1
end function
Top
4 楼zhanwei(@_@,初学.Net)回复于 2002-04-16 11:07:47 得分 0
public function integer of_register (dragobject adrg_object, integer ai_position);
Integer li_rc
Integer li_upperbound
Integer li_obj
// Validate required values.
If ii_style <0 or ii_barwidth <0 Then
Return -1
End If
// Validate the dragobject.
If IsNull(adrg_object) Or Not IsValid(adrg_object) Then
Return -1
End If
// Validate the position parameter.
If IsNull(ai_position) Or ai_position < 0 Or ai_position > 4 Then
Return -1
Else
If (ii_style = HORIZONTAL) And &
(ai_position = LEFT Or ai_position = RIGHT) Then
Return -1
ElseIf (ii_style = VERTICAL) And &
(ai_position = ABOVE Or ai_position = BELOW) Then
Return -1
End If
End If
// Make sure this object is not already registered on the left/top array.
li_upperbound = UpperBound (idrg_lefttop)
For li_obj = 1 to li_upperbound
If IsValid(idrg_lefttop[li_obj]) Then
If adrg_object = idrg_lefttop[li_obj] Then
Return -1
End If
End If
Next
// Make sure this object is not already registered on the right/bottom array.
li_upperbound = UpperBound (idrg_rightbottom)
For li_obj = 1 to li_upperbound
If IsValid(idrg_rightbottom[li_obj]) Then
If adrg_object = idrg_rightbottom[li_obj] Then
Return -1
End If
End If
Next
// Register the new object.
If ai_position = LEFT Or ai_position = ABOVE Then
ii_lefttopbound = UpperBound (idrg_lefttop) + 1
idrg_lefttop[ii_lefttopbound] = adrg_object
ir_lefttopx[ii_lefttopbound] = adrg_object.X
ir_lefttopy[ii_lefttopbound] = adrg_object.Y
ir_lefttopwidth[ii_lefttopbound] = adrg_object.Width
ir_lefttopheight[ii_lefttopbound] = adrg_object.Height
Else
ii_rightbottombound = UpperBound (idrg_rightbottom) + 1
idrg_rightbottom[ii_rightbottombound] = adrg_object
ir_rightbottomx[ii_rightbottombound] = adrg_object.X
ir_rightbottomy[ii_rightbottombound] = adrg_object.Y
ir_rightbottomwidth[ii_rightbottombound] = adrg_object.Width
ir_rightbottomheight[ii_rightbottombound] = adrg_object.Height
End If
Return 1
end function
protected function integer of_updateobjectdata ();
Integer li_cnt
Integer li_upperbound
li_upperbound = Upperbound (idrg_lefttop)
For li_cnt = 1 to li_upperbound
If IsValid(idrg_lefttop[li_cnt]) Then
If abs(ir_lefttopx[li_cnt] - idrg_lefttop[li_cnt].X) > ii_rounding Then
ir_lefttopx[li_cnt] = idrg_lefttop[li_cnt].X
End If
If abs(ir_lefttopy[li_cnt] - idrg_lefttop[li_cnt].Y) > ii_rounding Then
ir_lefttopy[li_cnt] = idrg_lefttop[li_cnt].Y
End If
If abs(ir_lefttopwidth[li_cnt] - idrg_lefttop[li_cnt].Width) > ii_rounding Then
ir_lefttopwidth[li_cnt] = idrg_lefttop[li_cnt].Width
End If
If abs(ir_lefttopheight[li_cnt] - idrg_lefttop[li_cnt].Height) > ii_rounding Then
ir_lefttopheight[li_cnt] = idrg_lefttop[li_cnt].Height
End If
End If
Next
li_upperbound = Upperbound (idrg_rightbottom)
For li_cnt = 1 to li_upperbound
If IsValid(idrg_rightbottom[li_cnt]) Then
If abs(ir_rightbottomx[li_cnt] - idrg_rightbottom[li_cnt].X) > ii_rounding Then
ir_rightbottomx[li_cnt] = idrg_rightbottom[li_cnt].X
End If
If abs(ir_rightbottomy[li_cnt] - idrg_rightbottom[li_cnt].Y) > ii_rounding Then
ir_rightbottomy[li_cnt] = idrg_rightbottom[li_cnt].Y
End If
If abs(ir_rightbottomwidth[li_cnt] - idrg_rightbottom[li_cnt].Width) > ii_rounding Then
ir_rightbottomwidth[li_cnt] = idrg_rightbottom[li_cnt].Width
End If
If abs(ir_rightbottomheight[li_cnt] - idrg_rightbottom[li_cnt].Height) > ii_rounding Then
ir_rightbottomheight[li_cnt] = idrg_rightbottom[li_cnt].Height
End If
End If
Next
Return 1
end function
protected function integer of_redraw (integer ai_prevx, integer ai_prevwidth, integer ai_prevy, integer ai_prevheight);
Integer li_cnt
// Validate required values.
If ii_style <0 or ii_barwidth <0 Then
Return -1
End If
If ii_style = HORIZONTAL Then
// Redraw the objects above the Horizontal Split Bar.
For li_cnt = 1 to ii_lefttopbound
If IsValid(idrg_lefttop[li_cnt]) Then
If (ai_prevy >= idrg_lefttop[li_cnt].Y Or &
ai_prevy + ai_prevheight >= idrg_lefttop[li_cnt].Y) And &
ai_prevy < idrg_lefttop[li_cnt].Y + idrg_lefttop[li_cnt].Height Then
idrg_lefttop[li_cnt].SetRedraw(True)
End If
End If
Next
// Redraw the objects below the Horizontal Split Bar.
For li_cnt = 1 to ii_rightbottombound
If IsValid(idrg_rightbottom[li_cnt]) Then
If (ai_prevy >= idrg_rightbottom[li_cnt].Y Or &
ai_prevy + ai_prevheight >= idrg_rightbottom[li_cnt].Y ) And &
ai_prevy < idrg_rightbottom[li_cnt].Y + idrg_rightbottom[li_cnt].Height Then
idrg_rightbottom[li_cnt].SetRedraw(True)
End If
End If
Next
ElseIf ii_style = VERTICAL Then
// Redraw the objects left of the Vertical Split Bar.
For li_cnt = 1 to ii_lefttopbound
If IsValid(idrg_lefttop[li_cnt]) Then
If (ai_prevx >= idrg_lefttop[li_cnt].X Or &
ai_prevx + ai_prevwidth >= idrg_lefttop[li_cnt].X) And &
ai_prevx < idrg_lefttop[li_cnt].X + idrg_lefttop[li_cnt].Width Then
idrg_lefttop[li_cnt].SetRedraw(True)
End If
End If
NextTop
5 楼uml()回复于 2002-04-16 11:25:03 得分 0
不用怎么复杂吧,我的email:hjw75@163.netTop
6 楼Flying_Hawk(飞鹰)回复于 2002-04-16 11:34:29 得分 0
楼上的是这个用户对象的导出文件。邮件已发出,请查收。Top
7 楼uml()回复于 2002-04-18 20:42:49 得分 0
对st空间的鼠标按下、移动和释放三事件处理,我已实现Top




