如何在 dm-script 中创建旋转框?
How to create a spin box in dm-script?
我想在 dm-script 的 modal/modeless 对话框中创建一个旋转框,它使用户能够通过单击向上或向下箭头按钮(即,旋转按钮)。
有没有合适的方法来创建这样的旋转框?如果您分享一些智慧,我们将不胜感激。非常感谢您。
There exists no "spin control" for scripted dialogs.
但是,您可以根据 push-buttons 创建和排列来构建 proxy-spin 控件。它有点粗糙,但是下面的代码创建了它:
Class CMySpin : UIFrame
{
TagGroup CreateDLGTgs( object self )
{
TagGroup DLGtgs, DLGItems
DLGtgs = DLGCreateDialog( "Test", DLGItems )
TagGroup upButton = DLGCreatePushButton( "U", "OnPushUp" ).DLGExternalPadding(0,-5).DLGInternalPadding(-2,-3)
TagGroup downButton = DLGCreatePushButton( "D", "OnPushDown" ).DLGInternalPadding(-2,-3)
TagGroup field = DLGCreateIntegerField( 10, 10 ).DLGIdentifier( "field" )
TagGroup SpinGroup = DLGGroupItems( upButton, downButton ).DLGTableLayout(1,2,0)
TagGroup fieldWithSpin = DLGGroupItems( field, SpinGroup ).DLGTableLayout(2,1,0)
DLGItems.DLGAddElement( fieldWithSpin )
return DLGtgs
}
void OnPushUp( object self )
{
taggroup fieldTG = self.LookupElement( "field" )
number value = fieldTG.DLGGetValue()
value++
fieldTG.DLGValue( value )
}
void OnPushDown( object self )
{
taggroup fieldTG = self.LookupElement( "field" )
number value = fieldTG.DLGGetValue()
value--
fieldTG.DLGValue( value )
}
void CreateAndPose( object self )
{
self.Init( self.CreateDLGTgs() )
self.Pose()
}
}
Alloc(CMySpin).CreateAndPose()
然后您可以通过使用位图按钮而不是简单的按钮来稍微调整一下外观,并进行设置直到它们看起来更吸引人。
f.e。我创建了这个变体:
使用此代码:
Class CMySpin : UIFrame
{
TagGroup CreateDLGTgs( object self )
{
image arrowImg := [7,5]:
{ { 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 1, 0, 0, 0 },
{ 0, 0, 1, 1, 1, 0, 0 },
{ 0, 1, 1, 1, 1, 1, 0 },
{ 0, 0, 0, 0, 0, 0, 0 } }
number factor = 2
image upArrow := RealImage("",4,factor*7,factor*5)
upArrow=arrowImg.warp( icol / factor, irow / factor )
image downArrow = upArrow
downArrow.FlipVertical()
rgbImage upArrowUp = RGB( upArrow * 100, upArrow * 100, upArrow * 100 )
rgbImage upArrowDown = RGB( upArrow * 200, upArrow * 200, upArrow * 200 )
rgbImage downArrowUp = RGB( downArrow * 100, downArrow * 100, downArrow * 100 )
rgbImage downArrowDown = RGB( downArrow * 200, downArrow * 200, downArrow * 200 )
TagGroup DLGtgs, DLGItems
DLGtgs = DLGCreateDialog( "Test", DLGItems )
TagGroup upButton = DLGCreateBevelButton( upArrowUp, upArrowDown, "OnPushUp" ).DLGExternalPadding(0,-3).DLGInternalPadding(-2,-3)
TagGroup downButton = DLGCreateBevelButton( downArrowUp, downArrowDown, "OnPushDown" ).DLGExternalPadding(0,-3).DLGInternalPadding(-2,-3)
TagGroup field = DLGCreateIntegerField( 10, 10 ).DLGIdentifier( "field" )
TagGroup SpinGroup = DLGGroupItems( upButton, downButton ).DLGTableLayout(1,2,0)
TagGroup fieldWithSpin = DLGGroupItems( field, SpinGroup ).DLGTableLayout(2,1,0)
DLGItems.DLGAddElement( fieldWithSpin )
return DLGtgs
}
void OnPushUp( object self )
{
taggroup fieldTG = self.LookupElement( "field" )
number value = fieldTG.DLGGetValue()
value++
fieldTG.DLGValue( value )
}
void OnPushDown( object self )
{
taggroup fieldTG = self.LookupElement( "field" )
number value = fieldTG.DLGGetValue()
value--
fieldTG.DLGValue( value )
}
void CreateAndPose( object self )
{
self.Init( self.CreateDLGTgs() )
self.Pose()
}
}
Alloc(CMySpin).CreateAndPose()
我想在 dm-script 的 modal/modeless 对话框中创建一个旋转框,它使用户能够通过单击向上或向下箭头按钮(即,旋转按钮)。
有没有合适的方法来创建这样的旋转框?如果您分享一些智慧,我们将不胜感激。非常感谢您。
There exists no "spin control" for scripted dialogs.
但是,您可以根据 push-buttons 创建和排列来构建 proxy-spin 控件。它有点粗糙,但是下面的代码创建了它:
Class CMySpin : UIFrame
{
TagGroup CreateDLGTgs( object self )
{
TagGroup DLGtgs, DLGItems
DLGtgs = DLGCreateDialog( "Test", DLGItems )
TagGroup upButton = DLGCreatePushButton( "U", "OnPushUp" ).DLGExternalPadding(0,-5).DLGInternalPadding(-2,-3)
TagGroup downButton = DLGCreatePushButton( "D", "OnPushDown" ).DLGInternalPadding(-2,-3)
TagGroup field = DLGCreateIntegerField( 10, 10 ).DLGIdentifier( "field" )
TagGroup SpinGroup = DLGGroupItems( upButton, downButton ).DLGTableLayout(1,2,0)
TagGroup fieldWithSpin = DLGGroupItems( field, SpinGroup ).DLGTableLayout(2,1,0)
DLGItems.DLGAddElement( fieldWithSpin )
return DLGtgs
}
void OnPushUp( object self )
{
taggroup fieldTG = self.LookupElement( "field" )
number value = fieldTG.DLGGetValue()
value++
fieldTG.DLGValue( value )
}
void OnPushDown( object self )
{
taggroup fieldTG = self.LookupElement( "field" )
number value = fieldTG.DLGGetValue()
value--
fieldTG.DLGValue( value )
}
void CreateAndPose( object self )
{
self.Init( self.CreateDLGTgs() )
self.Pose()
}
}
Alloc(CMySpin).CreateAndPose()
然后您可以通过使用位图按钮而不是简单的按钮来稍微调整一下外观,并进行设置直到它们看起来更吸引人。
f.e。我创建了这个变体:
使用此代码:
Class CMySpin : UIFrame
{
TagGroup CreateDLGTgs( object self )
{
image arrowImg := [7,5]:
{ { 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 1, 0, 0, 0 },
{ 0, 0, 1, 1, 1, 0, 0 },
{ 0, 1, 1, 1, 1, 1, 0 },
{ 0, 0, 0, 0, 0, 0, 0 } }
number factor = 2
image upArrow := RealImage("",4,factor*7,factor*5)
upArrow=arrowImg.warp( icol / factor, irow / factor )
image downArrow = upArrow
downArrow.FlipVertical()
rgbImage upArrowUp = RGB( upArrow * 100, upArrow * 100, upArrow * 100 )
rgbImage upArrowDown = RGB( upArrow * 200, upArrow * 200, upArrow * 200 )
rgbImage downArrowUp = RGB( downArrow * 100, downArrow * 100, downArrow * 100 )
rgbImage downArrowDown = RGB( downArrow * 200, downArrow * 200, downArrow * 200 )
TagGroup DLGtgs, DLGItems
DLGtgs = DLGCreateDialog( "Test", DLGItems )
TagGroup upButton = DLGCreateBevelButton( upArrowUp, upArrowDown, "OnPushUp" ).DLGExternalPadding(0,-3).DLGInternalPadding(-2,-3)
TagGroup downButton = DLGCreateBevelButton( downArrowUp, downArrowDown, "OnPushDown" ).DLGExternalPadding(0,-3).DLGInternalPadding(-2,-3)
TagGroup field = DLGCreateIntegerField( 10, 10 ).DLGIdentifier( "field" )
TagGroup SpinGroup = DLGGroupItems( upButton, downButton ).DLGTableLayout(1,2,0)
TagGroup fieldWithSpin = DLGGroupItems( field, SpinGroup ).DLGTableLayout(2,1,0)
DLGItems.DLGAddElement( fieldWithSpin )
return DLGtgs
}
void OnPushUp( object self )
{
taggroup fieldTG = self.LookupElement( "field" )
number value = fieldTG.DLGGetValue()
value++
fieldTG.DLGValue( value )
}
void OnPushDown( object self )
{
taggroup fieldTG = self.LookupElement( "field" )
number value = fieldTG.DLGGetValue()
value--
fieldTG.DLGValue( value )
}
void CreateAndPose( object self )
{
self.Init( self.CreateDLGTgs() )
self.Pose()
}
}
Alloc(CMySpin).CreateAndPose()