zoukankan      html  css  js  c++  java
  • TD button Group的实现

    1,用bool_button控件

    layout.ini

    main_win = {
        type = "window"
        x = 0
        y = 0
        w = 1024
        h = 600
        style = "main_win"
      flags={
        window_splash
      }
    
    
      audioBtn = {
        type = "bool_button"
        x = 10
        y = 10
        w = 172
        h = 70
        style = "audiobtn_style"
      }
    
      videoBtn = {
        type = "bool_button"
        x = 10
        y = 90
        w = 172
        h = 70
        style = "videobtn_style"
      }
    
      picBtn = {
        type = "bool_button"
        x = 10
        y = 170
        w = 172
        h = 70
        style = "picturebtn_style"
      }
    }
     

    2,style.rc

    bool_button.audiobtn_style {
    [nad]
    bg="./images/list_btn_music_n.png",stretch_normal
    [s]
    bg="./images/list_btn_music_p.png",stretch_normal
    }
    bool_button.videobtn_style {
    [nad]
    bg="./images/list_btn_video_n.png",stretch_normal
    [s]
    bg="./images/list_btn_video_p.png",stretch_normal
    }
    bool_button.picturebtn_style {
    [nad]
    bg="./images/list_btn_image_n.png",stretch_normal
    [s]
    bg="./images/list_btn_image_p.png",stretch_normal
    }

    2,用twRadioGroupAdd将控件加到一个组里面

    int main(int argc, const char *argv[])
    { TWidget *root;
        root = TwAppInit();
        signal(SIGTERM, &signal_handler);
         
        /*读取配置文件config.ini*/
        TwConfigParseFile(TGetExecutePath("../etc/config.ini"));
        TWidget *audioBtn = (TWidget*)TObjectGetFromName("audioBtn");
        TWidget *videoBtn = (TWidget*)TObjectGetFromName("videoBtn");
        TWidget *picBtn = (TWidget*)TObjectGetFromName("picBtn");
        TWidget *meidiaTypeGroup[3];
        meidiaTypeGroup[0] = audioBtn;
        meidiaTypeGroup[1] = videoBtn;
        meidiaTypeGroup[2] = picBtn;
        twRadioGroupAdd(meidiaTypeGroup, meidiaTypeGroup[0], "meidiatypegroup");
        twRadioGroupAdd(meidiaTypeGroup, meidiaTypeGroup[1], "meidiatypegroup");
        twRadioGroupAdd(meidiaTypeGroup, meidiaTypeGroup[2], "meidiatypegroup");
    
        TObjectAddEventHandler(audioBtn, CLICKED, click3func, (void *)"audioBtn");
        TObjectAddEventHandler(videoBtn, CLICKED, click3func, (void *)"videoBtn");
        TObjectAddEventHandler(picBtn, CLICKED, click3func, (void *)"picBtn");
        TwSetValue(picBtn, 1);
    TwMainLoop(); return 0; }

    3,通过TwSetValue设置控件的选中和非选中状态。

    static void click3func(void *obj, T_ID event, TTable *in, void *arg, TExist *exist)
    {
        const char *pbtn = (const char*)arg;
        TWidget *audioBtn = (TWidget*)TObjectGetFromName("audioBtn");
        TWidget *videoBtn = (TWidget*)TObjectGetFromName("videoBtn");
        TWidget *picBtn = (TWidget*)TObjectGetFromName("picBtn");
        printf("click3func---pbtn:%s
    ", pbtn);
        if(!strcmp(pbtn, "audioBtn"))
        {
            TwSetValue(audioBtn, 1);
            TwSetValue(videoBtn, 0);
            TwSetValue(picBtn, 0);
        }
        else if(!strcmp(pbtn, "videoBtn"))
        {
            TwSetValue(audioBtn, 0);
            TwSetValue(videoBtn, 1);
            TwSetValue(picBtn, 0);
        }
        else if(!strcmp(pbtn, "picBtn"))
        {
            TwSetValue(audioBtn, 0);
            TwSetValue(videoBtn, 0);
            TwSetValue(picBtn, 1);
        }
    }
  • 相关阅读:
    appium 方法整理
    appium_获取元素状态
    Locust性能测试_参数关联
    Locust性能测试-参数化批量注册
    pytest_命令行传参
    pytest_函数传参和firture传参数request
    pytest_用例a失败,跳过测试用例b和c并标记失败xfail
    pytest_skip跳过用例
    pytest_使用自定义标记mark
    算法:迷宫问题
  • 原文地址:https://www.cnblogs.com/senior-engineer/p/14099241.html
Copyright © 2011-2022 走看看