コード例 #1
0
ファイル: textin.c プロジェクト: AlleyCat1976/Meridian59_103
/*
 * TextInputCreate:  Create the text input box.
 */
void TextInputCreate(HWND hParent)
{
   HWND hwndEdit;

   CalculateWindowHeight();
   hwndInput = CreateWindow("combobox", NULL, 
			    WS_CHILD | WS_BORDER | WS_VISIBLE |
			    CBS_AUTOHSCROLL | CBS_DROPDOWN | WS_VSCROLL,
			    0, 0, 0, GetTextInputHeight(), 
			    hParent, (HMENU) IDC_TEXTINPUT, hInst, NULL);

   SetWindowFont(hwndInput, GetFont(FONT_INPUT), TRUE);
   CalculateWindowHeight();
   ComboBox_LimitText(hwndInput, MAXSAY);

   // The editbox is the first child of the combobox.
   // Subclass the editbox for key events.
   //
   hwndEdit = GetWindow(hwndInput, GW_CHILD);
   lpfnDefInputProc = SubclassWindow(hwndEdit, TextInputProc);
}
コード例 #2
0
ファイル: dlg_find.c プロジェクト: now/slackedit
static BOOL Find_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
    HWND hwndFindCombo  = GetDlgItem(hwnd, IDC_COMBO_FIND);
    LPEDITINTERFACE lpInterface = PCP_Edit_GetInterface(MDI_MyGetActive(TRUE));

    ComboBox_LimitText(hwndFindCombo, MAX_PATH);

    MRU_SetComboBox(hwndFindCombo, _T("Find MRU"), g_MRUSettings.nFindMax);

    if (PCP_Edit_IsSelection(lpInterface))
    {
        POINT ptSelStart, ptSelEnd;
        LPTSTR pszSelection = NULL;

        PCP_Edit_GetSelection(lpew, &ptSelStart, &ptSelEnd);

        if (ptSelStart.y == ptSelEnd.y)
            PCP_Edit_GetText(lpInterface, ptSelStart, ptSelEnd, &pszSelection);
        else
            pszSelection = String_Duplicate(PCP_Edit_GetLineChars(lpInterface, ptSelStart.y));

        if (String_IsSpace(pszSelection))
            ComboBox_SetCurSel(hwndFindCombo, 0);
        else
            SetWindowText(hwndFindCombo, pszSelection);

        Mem_Free(pszSelection);
    }
    else
    {
        ComboBox_SetCurSel(hwndFindCombo, 0);
    }

    if (s_bReplaceMode)
    {
        HWND hwndReplaceCombo = GetDlgItem(hwnd, IDC_COMBO_REPLACE);

        if (PCP_Edit_IsSelection(lpInterface))
        {
            UINT uDirection;

            s_ptSaveCursorPos = PCP_Edit_GetCursorPos(lpInterface);
            PCP_Edit_GetSelection(lpInterface, &s_ptSaveSelStart, &s_ptSaveSelEnd);
            s_bSelectionPushed = TRUE;

            uDirection = ((s_ptSaveSelStart.y == s_ptSaveSelEnd.y) ? IDC_RADIO_DIRECTION_DOWN : IDC_RADIO_DIRECTION_UP);

            CheckRadioButton(hwnd, IDC_RADIO_DIRECTION_UP, IDC_RADIO_DIRECTION_DOWN, uDirection);
            Window_Command(hwnd, uDirection, 1, NULL);

            s_ptBlockBegin  = s_ptSaveSelStart;
            s_ptBlockEnd    = s_ptSaveSelEnd;
        }
        else
        {
            CheckRadioButton(hwnd, IDC_RADIO_DIRECTION_UP, IDC_RADIO_DIRECTION_DOWN, IDC_RADIO_DIRECTION_DOWN);
            Window_EnableDlgItem(hwnd, IDC_RADIO_DIRECTION_UP, FALSE);

            s_ptCurrentPos = PCP_Edit_GetCursorPos(lpInterface);
        }

        ComboBox_LimitText(hwndReplaceCombo, MAX_PATH);
        MRU_SetComboBox(hwndReplaceCombo, _T("Replace MRU"), g_MRUSettings.nReplaceMax);
        ComboBox_SetCurSel(hwndReplaceCombo, 0);

        Window_SetBothIcons(hwnd, ImageList_ExtractIcon(NULL, Menu_GetImageList(TRUE), IDP_REPLACE));
    }
    else
    {
        Window_SetBothIcons(hwnd, ImageList_ExtractIcon(NULL, Menu_GetImageList(TRUE), IDP_FIND));

        CheckRadioButton(hwnd, IDC_RADIO_DIRECTION_UP, IDC_RADIO_DIRECTION_DOWN, g_FindSettings.nDirection);
    }

    Find_ChangeMode(hwnd, s_bReplaceMode);

    if (GetWindowTextLength(hwndFindCombo))
        Window_EnableDlgItem(hwnd, IDOK, TRUE);

    CheckDlgButton(hwnd, IDC_CHECK_MATCHCASE, g_FindSettings.bCase);
    CheckDlgButton(hwnd, IDC_CHECK_REGEXP, g_FindSettings.bRegExp);
    CheckDlgButton(hwnd, IDC_CHECK_WRAPSEARCH, g_FindSettings.bWrapSearch);
    
    if (g_FindSettings.bRegExp)
    {
        Window_EnableDlgItem(hwnd, IDC_CHECK_WHOLEWORD, FALSE);
        g_FindSettings.bWholeWords = FALSE;
    }
    else
    {
        CheckDlgButton(hwnd, IDC_CHECK_WHOLEWORD, g_FindSettings.bWholeWords);
    }

    return (TRUE);
}
コード例 #3
0
BOOL plResponderProc::DlgProc(TimeValue t, IParamMap2 *pm, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    static UINT dragListMsg = 0;

    if (dragListMsg != 0 && msg == dragListMsg)
        if (DragListProc(hWnd, (DRAGLISTINFO*)lParam))
            return TRUE;

    switch (msg)
    {
    case WM_INITDIALOG:
        {
            if (!fhMenu)
                ICreateMenu();

            fhDlg = hWnd;
            fhList = GetDlgItem(fhDlg, IDC_CMD_LIST);
            fCurState = 0;
            fCmdIdx = -1;
            
            fPB = pm->GetParamBlock();
            fComp = (plResponderComponent*)fPB->GetOwner();

            fComp->IFixOldPB();

            LoadState();
            
            // Make it so the user can drag commands to different positions
            dragListMsg = RegisterWindowMessage(DRAGLISTMSGSTRING);
            MakeDragList(GetDlgItem(hWnd, IDC_CMD_LIST));

            // Setup the State Name combo
            HWND hStateName = GetDlgItem(hWnd, IDC_STATE_COMBO);
            ComboBox_LimitText(hStateName, 256);

// I give up, Windows doesn't want to tell me the real font size
#if 0//def CUSTOM_DRAW
            // TEMP
            HDC hDC = GetDC(hStateName);
            HFONT sysFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            HFONT oldFont = SelectFont(hDC, sysFont);

            TEXTMETRIC tm;
            GetTextMetrics(hDC, &tm);
            ComboBox_SetItemHeight(hStateName, 0, tm.tmHeight+2);

            DeleteFont(SelectFont(hDC, oldFont));
            ReleaseDC(hStateName, hDC);
#endif

            // Add the commands
            int idx = ComboBox_AddString(hStateName, "Add State");
            ComboBox_SetItemData(hStateName, idx, kStateAdd);
            idx = ComboBox_AddString(hStateName, "Remove Current State");
            ComboBox_SetItemData(hStateName, idx, kStateRemove);
            idx = ComboBox_AddString(hStateName, "Set Current as Default");
            ComboBox_SetItemData(hStateName, idx, kStateDefault);
            idx = ComboBox_AddString(hStateName, "Copy Current State");
            ComboBox_SetItemData(hStateName, idx, kStateCopy);

            HWND hSwitchCombo = GetDlgItem(hWnd, IDC_SWITCH_COMBO);

            int numStates = fPB->Count(kResponderStateName);
            for (int i = 0; i < numStates; i++)
            {
                const char *stateName = fPB->GetStr(kResponderStateName, 0, i);
                char buf[128];
                if (!stateName || *stateName == '\0')
                {
                    sprintf(buf, "State %d", i+1);
                    stateName = buf;
                }
                ComboBox_InsertString(hStateName, i, stateName);
                ComboBox_AddString(hSwitchCombo, stateName);
            }

            ComboBox_SetCurSel(hStateName, fCurState);

            ComboBox_SetCurSel(hSwitchCombo, fStatePB->GetInt(kStateCmdSwitch));
        }
        return TRUE;

#ifdef CUSTOM_DRAW
    case WM_DRAWITEM:
        if (wParam == IDC_STATE_COMBO)
        {
            IDrawComboItem((DRAWITEMSTRUCT*)lParam);
            return TRUE;
        }
        break;
#endif

    case WM_SETCURSOR:
        {
            if (HIWORD(lParam) == WM_RBUTTONDOWN && HWND(wParam) == GetDlgItem(hWnd, IDC_CMD_LIST))
            {
                ICmdRightClick(HWND(wParam));
                return TRUE;
            }
        }
        break;
    
    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED)
        {
            if (LOWORD(wParam) == IDC_ADD_ACTIVATOR)
            {
                // Adding an activator.  Set it and refresh the UI to show it in our list.
                plPick::Activator(fPB, kResponderActivators, false);
                pm->Invalidate(kResponderActivators);
                return TRUE;
            }
            else if (LOWORD(wParam) == IDC_ADD_CMD)
            {
                AddCommand();
                return TRUE;
            }
            // Remove the currently selected condition
            else if (LOWORD(wParam) == IDC_REMOVE_CMD)
            {
                RemoveCurCommand();
                return TRUE;
            }
        }
        else if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_CMD_LIST)
        {
            ICreateCmdRollups();
            return TRUE;
        }
        else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_SWITCH_COMBO)
        {
            int sel = ComboBox_GetCurSel((HWND)lParam);
            if (sel != CB_ERR)
                fStatePB->SetValue(kStateCmdSwitch, 0, sel);
        }
        else if (LOWORD(wParam) == IDC_STATE_COMBO)
        {
            HWND hCombo = (HWND)lParam;
            int code = HIWORD(wParam);

            // Disable accelerators when the combo has focus, so that new names can be typed in
            if (code == CBN_SETFOCUS)
            {
                plMaxAccelerators::Disable();
                return TRUE;
            }
            else if (code == CBN_KILLFOCUS)
            {
                plMaxAccelerators::Enable();
                return TRUE;
            }
            // State name changed, save it in the PB
            else if (code == CBN_EDITCHANGE)
            {
                char buf[256];
                ComboBox_GetText(hCombo, buf, sizeof(buf));
                const char *curName = fPB->GetStr(kResponderStateName, 0, fCurState);
                if (!curName || strcmp(buf, curName))
                {
                    HWND hSwitch = GetDlgItem(hWnd, IDC_SWITCH_COMBO);
                    int sel = ComboBox_GetCurSel(hSwitch);
                    ComboBox_DeleteString(hSwitch, fCurState);
                    ComboBox_InsertString(hSwitch, fCurState, buf);
                    ComboBox_SetCurSel(hSwitch, sel);
                    
                    fPB->SetValue(kResponderStateName, 0, buf, fCurState);
                    ComboBox_DeleteString(hCombo, fCurState);
                    ComboBox_InsertString(hCombo, fCurState, buf);
//                  ComboBox_SetCurSel(hCombo, fCurState);
                }

                return TRUE;
            }
            else if (code == CBN_SELCHANGE)
            {
                int sel = ComboBox_GetCurSel(hCombo);
                int type = ComboBox_GetItemData(hCombo, sel);

                if (type == kStateAdd)
                {
                    IParamBlock2 *pb = CreateParameterBlock2(&gStateBlock, nil);
                    fCurState = AddState(pb);
                    fCmdIdx = -1;
                }
                else if (type == kStateRemove)
                {
                    int count = fPB->Count(kResponderState);
                    // Don't let the user remove the last state
                    if (count == 1)
                    {
                        hsMessageBox("You must have at least one state.", "Error", hsMessageBoxNormal);
                        ComboBox_SetCurSel(hCombo, fCurState);
                        return TRUE;
                    }
                    // Verify that the user really wants to delete the state
                    else
                    {
                        int ret = hsMessageBox("Are you sure you want to remove this state?", "Verify Remove", hsMessageBoxYesNo);
                        if (ret == hsMBoxNo)
                        {
                            ComboBox_SetCurSel(hCombo, fCurState);
                            return TRUE;
                        }
                    }

                    fPB->Delete(kResponderState, fCurState, 1);
                    fPB->Delete(kResponderStateName, fCurState, 1);

                    ComboBox_DeleteString(hCombo, fCurState);
                    ComboBox_SetCurSel(hCombo, 0);

                    HWND hSwitch = GetDlgItem(hWnd, IDC_SWITCH_COMBO);
                    ComboBox_DeleteString(hSwitch, fCurState);

                    // If the deleted state was the default, set the default to the first
                    int defState = fPB->GetInt(kResponderStateDef);
                    if (fCurState == defState)
                        fPB->SetValue(kResponderStateDef, 0, 0);
                    else if (fCurState < defState)
                        fPB->SetValue(kResponderStateDef, 0, defState-1);

                    // Patch up the switch commands
                    for (int i = fCurState; i < fPB->Count(kResponderState); i++)
                    {
                        IParamBlock2 *pb = (IParamBlock2*)fPB->GetReferenceTarget(kResponderState, 0, i);

                        int switchState = pb->GetInt(kStateCmdSwitch);
                        // TODO: might want to warn about this
                        if (switchState == fCurState)
                            pb->SetValue(kStateCmdSwitch, 0, 0);
                        else if (switchState > fCurState)
                            pb->SetValue(kStateCmdSwitch, 0, switchState-1);
                    }

                    fCurState = 0;
                    fCmdIdx = -1;
                }
                else if (type == kStateDefault)
                {
                    // Set the current state as the default
                    fPB->SetValue(kResponderStateDef, 0, fCurState);
                    ComboBox_SetCurSel(hCombo, fCurState);
                }
                else if (type == kStateCopy)
                {
                    // Clone the state PB
                    IParamBlock2 *origPB = (IParamBlock2*)fPB->GetReferenceTarget(kResponderState, 0, fCurState);
                    IParamBlock2 *copyPB = (IParamBlock2*)origPB->Clone(gMyRemapDir);
                    fCurState = AddState(copyPB);
                    fCmdIdx = -1;
                }
                else
                {
                    fCurState = sel;
                    fCmdIdx = -1;
                }

                LoadState();

                return TRUE;
            }
        }
    }

    return FALSE;
}