如何在dm-script中创建旋转框? [英] How to create a spin box in dm-script?

查看:132
本文介绍了如何在dm-script中创建旋转框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在dm-script中的模态/非模态对话框上创建一个旋转框,该框使用户可以通过单击向上或向下箭头按钮(即旋转按钮)来增加或减少文本字段中的数字值.

I would like to create a spin box on a modal/modeless dialog in dm-script, which enables users to increase or decrease the number value in the text field by clicking up or down arrow buttons (i.e., spin buttons).

是否存在创建此类旋转框的适当方法?如果您分享一些智慧,将不胜感激.提前非常感谢您.

Is there an appropriate way to create such a spin box? It will be appreciated if you share some wisdom. Thank you very much in advance.

推荐答案

没有用于脚本对话框的旋转控件".

但是,您可以通过创建和安排相应的按钮来构建代理旋转控件.有点粗糙,但是下面的代码创建了这个代码:

However, you can build a proxy-spin control by creating and arranging according push-buttons. It is a bit crude, but the following code creates this:

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()

然后,您可以使用位图按钮而不是简单的按钮来设置外观,直到看起来更吸引人为止.

You can then play with looks a bit by using bitmap buttons instead of simple push buttons and setting things up until they look more appealing.

f.e.我创建了这个变体:

f.e. I created this variant:

使用以下代码:

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中创建旋转框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆