コード例 #1
0
void zerokernel::VariableListEntry::setVariable(settings::IVariable *variable)
{
    switch (variable->getType())
    {
    case settings::VariableType::BOOL:
        control = std::move(createCheckbox(variable));
        break;
    case settings::VariableType::INT:
    case settings::VariableType::FLOAT:
        control = std::move(createSpinner(variable));
        break;
    case settings::VariableType::STRING:
        control = std::move(createTextInput(variable));
        break;
    case settings::VariableType::COLOR:
        control = std::move(createColorPicker(variable));
        break;
    case settings::VariableType::KEY:
        control = std::move(createKeyInput(variable));
        break;
    }
    if (control)
    {
        control->setParent(this);
        control->bb.setMargin(0, 0, 0, 4);
    }
}
コード例 #2
0
ファイル: main.cpp プロジェクト: TUM-FAF/FAF-141-Maxian-Nicu
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
    RECT window;

    GetWindowRect(hwnd,&window);
    container.left = (window.right - window.left)/2 - 200;
    container.right = (window.right - window.left)/2 + 200;
    container.top = (window.bottom-window.top)/2 - 60;
    container.bottom = (window.bottom-window.top)/2 + 60;

    switch (message) {
        /*case WM_SYSCOMMAND:
            if ((wParam & 0xFFF0) == SC_MINIMIZE){
                ExitProcess(0);
                return 0;
            }
            break;*/
        case WM_CREATE:
            createButtons(hwnd);
            createText(hwnd);
            createTextInput(hwnd);
            break;
        case WM_COMMAND:
            if (wParam == buttonA->getId()) {
                labelA->setText(textA->getText());
                RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE);
            }
            if (wParam == buttonB->getId()) {
                labelB->setText(textB->getText());
                RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE);
            }
            if (wParam == superButton->getId()){
                RECT rect;
                GetWindowRect(hwnd, &rect);
                int x = rect.left;
                int y = rect.top;
                if (rect.left == 0){
                    x = 100-rand()%200;
                    y = 100-rand()%200;
                    switch(rand()%3) {
                        case 0 :
                            superButton->setText("Are you tired ? :D");
                            break;
                        case 1 :
                            superButton->setText("Maybe you want to try another trick ?");
                            break;
                        case 2 :
                            superButton->setText("Not funny ?! Click again ! :D");
                            x = 30;
                            y = 40;
                            break;
                    }
                }
                rect.left = 0;
                rect.right -= x;
                rect.bottom -= y;
                rect.top = 0;
                SetWindowPos(hwnd, HWND_TOP, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
                             SWP_FRAMECHANGED);
                break;
            }
            break;
        case WM_PAINT:
            draw(hwnd);
            break;
        case WM_SIZE:
            draw(hwnd);
            if (wParam == SIZE_MINIMIZED){
                ExitProcess(0);
            }
            if (wParam == SIZE_MAXIMIZED){
                MessageBox(hwnd,"This features is not available in demo.","Sorry",MB_OK|MB_ICONASTERISK);
                return 0;
            }
            break;
        case WM_MOVE:{
            int x = rand()%20 + 230;
            HBRUSH brush = CreateSolidBrush(RGB(x,x,x));
            SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND, (LONG)brush);
            RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE);
            break;}
        case WM_CLOSE:
            MessageBox(hwnd,"NOOOOO ! YOU CANNOT EXIT !!!!","UTM",MB_OK|MB_ICONSTOP);
            return 0;
        case WM_DESTROY:
            PostQuitMessage(0);       /* send a WM_QUIT to the message queue */
            break;
        case WM_GETMINMAXINFO:{
            MINMAXINFO *mmi = (MINMAXINFO *) lParam;
            mmi->ptMinTrackSize.x = 420;
            mmi->ptMinTrackSize.y = 140;
            return 0;
        }
        case WM_CTLCOLORBTN: {
            HDC hdc = (HDC) wParam;
            if ((GetDlgItem(hwnd, textB->getId()) == (HWND) lParam)) {
                SetTextColor(hdc, (COLORREF)whiteColor);

                SetBkColor(hdc,(COLORREF)primaryColor);
                return (LRESULT)CreateSolidBrush((COLORREF)primaryColor);
            }
        }
        case WM_CTLCOLOREDIT: {
            HDC hdc = (HDC) wParam;
            if ((GetDlgItem(hwnd, textB->getId()) == (HWND) lParam)) {
                SetTextColor(hdc, (COLORREF)whiteColor);

                SetBkColor(hdc,(COLORREF)primaryColor);
                return (LRESULT)CreateSolidBrush((COLORREF)primaryColor);
            }
        } default:                      /* for messages that we don't deal with */
            return DefWindowProc(hwnd, message, wParam, lParam);
    }

    return 0;
}