Subversion Repositories tpanel

Rev

Rev 351 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 351 Rev 361
Line 943... Line 943...
943
    REG_CMD(getFON, "?FON");    // Get the current font index.
943
    REG_CMD(getFON, "?FON");    // Get the current font index.
944
//    REG_CMD(doGDI, "^GDI");     // Change the bargraph drag increment.
944
//    REG_CMD(doGDI, "^GDI");     // Change the bargraph drag increment.
945
//    REG_CMD(doGDV, "^GDV");     // Invert the joystick axis to move the origin to another corner.
945
//    REG_CMD(doGDV, "^GDV");     // Invert the joystick axis to move the origin to another corner.
946
    REG_CMD(doGLH, "^GLH");     // Change the bargraph upper limit.
946
    REG_CMD(doGLH, "^GLH");     // Change the bargraph upper limit.
947
    REG_CMD(doGLL, "^GLL");     // Change the bargraph lower limit.
947
    REG_CMD(doGLL, "^GLL");     // Change the bargraph lower limit.
-
 
948
    REG_CMD(doGSN, "^GSN");     // Set slider/cursor name.
948
    REG_CMD(doGSC, "^GSC");     // Change the bargraph slider color or joystick cursor color.
949
    REG_CMD(doGSC, "^GSC");     // Change the bargraph slider color or joystick cursor color.
949
    REG_CMD(doICO, "^ICO");     // Set the icon to a button.
950
    REG_CMD(doICO, "^ICO");     // Set the icon to a button.
950
    REG_CMD(getICO, "?ICO");    // Get the current icon index.
951
    REG_CMD(getICO, "?ICO");    // Get the current icon index.
951
    REG_CMD(doJSB, "^JSB");     // Set bitmap/picture alignment using a numeric keypad layout for those buttons with a defined address range.
952
    REG_CMD(doJSB, "^JSB");     // Set bitmap/picture alignment using a numeric keypad layout for those buttons with a defined address range.
952
    REG_CMD(getJSB, "?JSB");    // Get the current bitmap justification.
953
    REG_CMD(getJSB, "?JSB");    // Get the current bitmap justification.
Line 7438... Line 7439...
7438
                string content;
7439
                string content;
7439
 
7440
 
7440
                switch(cmd)
7441
                switch(cmd)
7441
                {
7442
                {
7442
                    case 'B':   // Border style
7443
                    case 'B':   // Border style
-
 
7444
                        if (iter->at(1) == ',')
-
 
7445
                            content = iter->substr(2);
-
 
7446
                        else
7443
                        content = iter->substr(1);
7447
                            content = iter->substr(1);
7444
 
7448
 
7445
                        if (!content.empty() && isdigit(content[0]))
7449
                        if (!content.empty() && isdigit(content[0]))
7446
                            bt->setBorderStyle(atoi(content.c_str()), btState);
7450
                            bt->setBorderStyle(atoi(content.c_str()), btState);
7447
                        else
7451
                        else
7448
                            bt->setBorderStyle(content, btState);
7452
                            bt->setBorderStyle(content, btState);
Line 7533... Line 7537...
7533
                            break;
7537
                            break;
7534
                        }
7538
                        }
7535
                    break;
7539
                    break;
7536
 
7540
 
7537
                    case 'F':   // Set font file name
7541
                    case 'F':   // Set font file name
-
 
7542
                        if (iter->at(1) == ',')
-
 
7543
                            content = iter->substr(2);
-
 
7544
                        else
7538
                        content = iter->substr(1);
7545
                            content = iter->substr(1);
7539
 
7546
 
7540
                        if (!isdigit(content[0]))
7547
                        if (!isdigit(content[0]))
7541
                            bt->setFontName(content, btState);
7548
                            bt->setFontName(content, btState);
7542
                        else
7549
                        else
7543
                            bt->setFontIndex(atoi(content.c_str()), btState);
7550
                            bt->setFontIndex(atoi(content.c_str()), btState);
Line 7576... Line 7583...
7576
                            case 'L':   // Lower limit
7583
                            case 'L':   // Lower limit
7577
                                bt->setBargraphLowerLimit(atoi(content.c_str()));
7584
                                bt->setBargraphLowerLimit(atoi(content.c_str()));
7578
                            break;
7585
                            break;
7579
 
7586
 
7580
                            case 'N':   // Slider name
7587
                            case 'N':   // Slider name
7581
                                // FIXME: Add function to set slider name
7588
                                bt->setBargraphSliderName(content);
7582
                            break;
7589
                            break;
7583
 
7590
 
7584
                            case 'R':   // Repeat interval
7591
                            case 'R':   // Repeat interval
7585
                                // FIXME: Add function to set repeat interval
7592
                                // FIXME: Add function to set repeat interval
7586
                            break;
7593
                            break;
Line 7605... Line 7612...
7605
                    break;
7612
                    break;
7606
 
7613
 
7607
                    case 'J':   // Set text justification
7614
                    case 'J':   // Set text justification
7608
                        cmd2 = iter->at(1);
7615
                        cmd2 = iter->at(1);
7609
 
7616
 
7610
                        if (cmd2 != 'T' && cmd2 != 'B' && cmd2 != 'I')
7617
                        if (cmd2 == ',')
7611
                        {
7618
                        {
7612
                            content = iter->substr(1);
7619
                            content = iter->substr(1);
7613
                            int just = atoi(content.c_str());
7620
                            int just = atoi(content.c_str());
7614
                            int x = 0, y = 0;
7621
                            int x = 0, y = 0;
7615
 
7622
 
Line 7632... Line 7639...
7632
                                string s = intToString(just) + "," + intToString(x) + "," + intToString(y);
7639
                                string s = intToString(just) + "," + intToString(x) + "," + intToString(y);
7633
                                _gTestMode->setResult(s);
7640
                                _gTestMode->setResult(s);
7634
                            }
7641
                            }
7635
#endif
7642
#endif
7636
                        }
7643
                        }
7637
                        else
7644
                        else if (cmd2 == 'T' || cmd2 == 'B' || cmd2 == 'I')
7638
                        {
7645
                        {
7639
                            content = iter->substr(2);
7646
                            content = iter->substr(2);
7640
                            int x = 0, y = 0;
7647
                            int x = 0, y = 0;
7641
                            int just = atoi(content.c_str());
7648
                            int just = atoi(content.c_str());
7642
 
7649
 
Line 9105... Line 9112...
9105
        vector<Button::TButton *>::iterator mapIter;
9112
        vector<Button::TButton *>::iterator mapIter;
9106
 
9113
 
9107
        for (mapIter = buttons.begin(); mapIter != buttons.end(); mapIter++)
9114
        for (mapIter = buttons.begin(); mapIter != buttons.end(); mapIter++)
9108
        {
9115
        {
9109
            Button::TButton *bt = *mapIter;
9116
            Button::TButton *bt = *mapIter;
9110
//            setButtonCallbacks(bt);
-
 
9111
            bt->setBargraphSliderColor(color);
9117
            bt->setBargraphSliderColor(color);
9112
        }
9118
        }
9113
    }
9119
    }
9114
}
9120
}
9115
 
9121
 
-
 
9122
/*
-
 
9123
 * Change the bargraph slider name or joystick cursor name.
-
 
9124
 */
-
 
9125
void TPageManager::doGSN(int port, vector<int>& channels, vector<string>& pars)
-
 
9126
{
-
 
9127
    DECL_TRACER("TPageManager::doGSN(int port, vector<int>& channels, vector<string>& pars)");
-
 
9128
 
-
 
9129
    if (pars.size() < 1)
-
 
9130
    {
-
 
9131
        MSG_ERROR("Expecting 1 parameter but got " << pars.size() << "! Ignoring command.");
-
 
9132
        return;
-
 
9133
    }
-
 
9134
 
-
 
9135
    TError::clear();
-
 
9136
    string name = pars[0];
-
 
9137
    vector<TMap::MAP_T> map = findButtons(port, channels);
-
 
9138
 
-
 
9139
    if (TError::isError() || map.empty())
-
 
9140
        return;
-
 
9141
 
-
 
9142
    vector<Button::TButton *> buttons = collectButtons(map);
-
 
9143
 
-
 
9144
    if (buttons.size() > 0)
-
 
9145
    {
-
 
9146
        vector<Button::TButton *>::iterator mapIter;
-
 
9147
 
-
 
9148
        for (mapIter = buttons.begin(); mapIter != buttons.end(); mapIter++)
-
 
9149
        {
-
 
9150
            Button::TButton *bt = *mapIter;
-
 
9151
            bt->setBargraphSliderName(name);
-
 
9152
        }
-
 
9153
    }
-
 
9154
}
-
 
9155
 
9116
/**
9156
/**
9117
 * Set the icon to a button.
9157
 * Set the icon to a button.
9118
 */
9158
 */
9119
void TPageManager::doICO(int port, vector<int>& channels, vector<string>& pars)
9159
void TPageManager::doICO(int port, vector<int>& channels, vector<string>& pars)
9120
{
9160
{
Line 9849... Line 9889...
9849
 
9889
 
9850
    TError::clear();
9890
    TError::clear();
9851
    int btState = atoi(pars[0].c_str()) - 1;
9891
    int btState = atoi(pars[0].c_str()) - 1;
9852
    string text;
9892
    string text;
9853
 
9893
 
9854
    // Because UTF8 is not supported out of the box from Windows and NetLinx
9894
    // Unicode is the stadard character set used by Windows internally. It
9855
    // Studio has no native support for it, any UTF8 text must be encoded in
9895
    // consists of 16 bit unsiged numbers. This can't be transported into a
9856
    // bytes. Because of this we must decode the bytes into real bytes here.
9896
    // standard character string because a NULL byte means end of string.
-
 
9897
    // Therefor we must convert it to UFT-8.
9857
    if (pars.size() > 1)
9898
    if (pars.size() > 1)
9858
    {
9899
    {
9859
        string byte;
9900
        string byte;
-
 
9901
        std::wstring uni;
9860
        size_t pos = 0;
9902
        size_t pos = 0;
9861
 
9903
 
9862
        while (pos < pars[1].length())
9904
        while (pos < pars[1].length())
9863
        {
9905
        {
9864
            byte = pars[1].substr(pos, 2);
9906
            byte = pars[1].substr(pos, 4);
9865
            char ch = (char)strtol(byte.c_str(), NULL, 16);
9907
            wchar_t ch = (char)strtol(byte.c_str(), NULL, 16);
9866
            text += ch;
9908
            uni += ch;
9867
            pos += 2;
9909
            pos += 4;
9868
        }
9910
        }
-
 
9911
 
-
 
9912
        text = UnicodeToUTF8(uni);
9869
    }
9913
    }
9870
 
9914
 
9871
    vector<TMap::MAP_T> map = findButtons(port, channels);
9915
    vector<TMap::MAP_T> map = findButtons(port, channels);
9872
 
9916
 
9873
    if (TError::isError() || map.empty())
9917
    if (TError::isError() || map.empty())
Line 9942... Line 9986...
9942
        vector<Button::TButton *>::iterator mapIter;
9986
        vector<Button::TButton *>::iterator mapIter;
9943
 
9987
 
9944
        for (mapIter = buttons.begin(); mapIter != buttons.end(); mapIter++)
9988
        for (mapIter = buttons.begin(); mapIter != buttons.end(); mapIter++)
9945
        {
9989
        {
9946
            Button::TButton *bt = *mapIter;
9990
            Button::TButton *bt = *mapIter;
9947
//            setButtonCallbacks(bt);
-
 
9948
 
9991
 
9949
            if (btState == 0)       // All instances?
9992
            if (btState == 0)       // All instances?
9950
            {
9993
            {
9951
                int bst = bt->getNumberInstances();
9994
                int bst = bt->getNumberInstances();
9952
                MSG_DEBUG("Setting TXT on all " << bst << " instances...");
-
 
9953
 
9995
 
9954
                for (int i = 0; i < bst; i++)
9996
                for (int i = 0; i < bst; i++)
9955
                    bt->setText(text, i);
9997
                    bt->setText(text, i);
9956
            }
9998
            }
9957
            else
9999
            else
9958
                bt->setText(text, btState - 1);
10000
                bt->setText(text, btState - 1);
9959
        }
10001
        }
9960
    }
10002
    }
9961
}
10003
}
9962
 
10004
 
-
 
10005
/**
-
 
10006
 * Simulates a touch/release/pulse at the given coordinate. If the push event
-
 
10007
 * is less then 0 or grater than 2 the command is ignored. It is also ignored
-
 
10008
 * if the x and y coordinate is out of range. The range must be between 0 and
-
 
10009
 * the maximum with and height.
-
 
10010
 */
9963
void TPageManager::doVTP (int, vector<int>&, vector<string>& pars)
10011
void TPageManager::doVTP (int, vector<int>&, vector<string>& pars)
9964
{
10012
{
9965
    DECL_TRACER("TPageManager::doVTP (int, vector<int>&, vector<string>& pars)");
10013
    DECL_TRACER("TPageManager::doVTP (int, vector<int>&, vector<string>& pars)");
9966
 
10014
 
9967
    if (pars.size() < 3)
10015
    if (pars.size() < 3)