예제 #1
0
/**
 * Copy a piece of map and instantly paste at given location.
 *
 * @param tile Tile where to paste (northern).
 * @param flags Command flags.
 * @param p1 Various bits:
 *    \li bits  0..27 [28] - northern tile of the source area
 *    \li bits 28..31  [4] - rail type (RailType) to convert to, ignored if CPM_CONVERT_RAILTYPE mode is off
 * @param p2 Various bits:
 *    \li bits  0..5   [6] - source area width
 *    \li bits  6..11  [6] - source area height
 *    \li bits 12..15  [4] - additional amount of tile heights to add to each tile (-8..7)
 *    \li bits 16..18  [3] - transformation to perform (DirTransformation)
 *    \li bits 19..27  [9] - mode (CopyPasteMode)
 *    \li bits 28..31  [4] - [ unused ]
 * @param text Unused.
 * @return The cost of this operation or an error.
 */
CommandCost CmdInstantCopyPaste(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
	CopyPasteParams copy_paste;

	/* extract and validate source area */
	copy_paste.src_area.tile = GenericTileIndex(TileIndex(GB(p1, 0, 28)));
	copy_paste.src_area.w = GB(p2, 0, 6);
	copy_paste.src_area.h = GB(p2, 6, 6);
	CommandCost ret = ValParamCopyPasteArea(copy_paste.src_area);
	if (ret.Failed()) return ret;

	/* calculate and validate destination area */
	copy_paste.dst_area = TransformTileArea(copy_paste.src_area, GenericTileIndex(tile), copy_paste.transformation);
	ret = ValParamCopyPasteArea(copy_paste.dst_area);
	if (ret.Failed()) return ret;

	/* extract and validate copy/paste mode */
	copy_paste.mode = (CopyPasteMode)GB(p2, 19, 9);
	if (!ValParamCopyPasteMode(copy_paste.mode)) return CMD_ERROR;

	/* extract and validate rail type */
	copy_paste.railtype = (RailType)GB(p1, 28,  4);
	if (!ValParamRailtype(copy_paste.railtype)) return CMD_ERROR;

	/* extract transformation */
	copy_paste.transformation = (DirTransformation)GB(p2, 16,  3);

	/* extract the additional number of height units */
	int additional_height_delta = GB(p2, 12, 4); // this is a 4-bit SIGNED integer (-8..7)
	additional_height_delta |= -(additional_height_delta & (1 << 3)); // propagate the sign bit

	/* calculate the height */
	copy_paste.height_delta = CalcCopyPasteHeightDelta(copy_paste.src_area, copy_paste.dst_area, copy_paste.transformation, additional_height_delta);

	/* when copy and paste areas are too close each other, firstly
	 * copy to the clipboard and then from the clipboard to the map */
	if (CopyPasteAreasMayColide(copy_paste)) {
		Map *clipboard = GetClipboardBuffer(INSTANT_COPY_PASTE_BUFFER);
		/* Copy to a buffer, but only in the first stage of the command.
		 * In a single player game and also while we are a server, the first one is non-DC_EXEC
		 * stage (which is fallowed then by a DC_EXEC stage). When we are a client, there is only
		 * one stage which is either a single non-DC_EXEC stage (shift pressed), or a single DC_EXEC
		 * stage (command comming from the network). */
		if ((_networking && !_network_server) || !(flags & DC_EXEC)) {
			CopyToClipboard(clipboard, copy_paste.src_area);
		}
		/* paste from the clipboard */
		ret = PasteFromClipboard(clipboard, tile, flags, copy_paste.mode, copy_paste.transformation, copy_paste.railtype, additional_height_delta);
	} else {
		/* copy/paste directly */
		InitializePasting(flags, copy_paste);
		DoCopyPaste(copy_paste);
		ret = FinalizePasting();
	}
	return ret;
}
예제 #2
0
/**
 * Paste clipboard contents onto the map.
 *
 * @param tile Tile where to paste (northern).
 * @param flags Command flags.
 * @param p1 Various bits:
 *    \li bits  0..1   [2] - clipboard buffer index
 *    \li bits  2..27 [26] - [ unused ]
 *    \li bits 28..31  [4] - rail type (RailType) to convert to, ignored if CPM_CONVERT_RAILTYPE mode is off
 * @param p2 Various bits:
 *    \li bits  0..11 [12] - [ unused ]
 *    \li bits 12..15  [4] - additional amount of tile heights to add to each tile (-8..7)
 *    \li bits 16..18  [3] - transformation to perform (DirTransformation)
 *    \li bits 19..27  [9] - mode (CopyPasteMode)
 *    \li bits 28..31  [4] - [ unused ]
 * @param text Unused.
 * @return The cost of this operation or an error.
 */
CommandCost CmdPasteFromClipboard(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
	/* extract and validate clipboard buffer index */
	uint index = GB(p1, 0, 2);
	if (index >= NUM_CLIPBOARD_BUFFERS || index == INSTANT_COPY_PASTE_BUFFER) return CMD_ERROR;

	/* clipboard is available only in a sigle player game and only to the local company */
	if (_networking || !IsLocalCompany() || IsClipboardBufferEmpty(GetClipboardBuffer(index))) return CMD_ERROR;

	/* extract and validate copy/paste mode */
	CopyPasteMode mode = (CopyPasteMode)GB(p2, 19, 9);
	if (!ValParamCopyPasteMode(mode)) return CMD_ERROR;

	/* extract and validate rail type */
	RailType railtype = (RailType)GB(p1, 28,  4);
	if (!ValParamRailtype(railtype)) return CMD_ERROR;

	/* extract transformation and additional height delta */
	DirTransformation transformation = (DirTransformation)GB(p2, 16,  3);
	int additional_height_delta = GB(p2, 12, 4);
	additional_height_delta |= -(additional_height_delta & (1 << 3)); // propagate sign bit

	return PasteFromClipboard(GetClipboardBuffer(index), tile, flags, mode, transformation, railtype, additional_height_delta);
}
예제 #3
0
void MyLineEdit::slotPasteVector()
{
	PasteFromClipboard();
}
예제 #4
0
BOOL CALLBACK KG_DlgKeyGenerate(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg)
    {
    case WM_INITDIALOG:
    {
        SetLevelList(hwndDlg);
        SetDlgItemTextA(hwndDlg, IDC_EDT_HWID, "0000-0000");
        bool en = false;
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER1), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER2), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER3), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER4), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_KEYSTRING), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_PVT), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_Y), en);
        ShowWindow(GetDlgItem(hwndDlg, IDC_CHK_BABOON), 0);
        keygenerate_level = -1;
        SYSTEMTIME systime = {0};
        GetSystemTime(&systime);
        char temp[20] = "";
        sprintf(temp, "%d", MakeDate(systime.wYear, systime.wMonth, systime.wDay));
        SetDlgItemTextA(hwndDlg, IDC_EDT_DATE, temp);
        sprintf(temp, "%.4d-%.2d-%.2d", systime.wYear, systime.wMonth, systime.wDay);
        SetDlgItemTextA(hwndDlg, IDC_EDT_DATEYMD, temp);
        SendDlgItemMessageA(hwndDlg, IDC_EDT_KEYSTRING, EM_SETLIMITTEXT, 255, 0);
    }
    return TRUE;

    case WM_CONTEXTMENU:
    {
        if(GetDlgCtrlID((HWND)wParam) == IDC_EDT_SERIAL)
        {
            char serial[2048] = "";
            int len = GetDlgItemTextA(hwndDlg, IDC_EDT_SERIAL, serial, 2048);
            if(!len)
                return TRUE;
            HMENU myMenu = 0;
            myMenu = CreatePopupMenu();
            AppendMenu(myMenu, MF_STRING, 1, "Copy Serial");
            POINT cursorPos;
            GetCursorPos(&cursorPos);
            SetForegroundWindow(hwndDlg);
            UINT MenuItemClicked = TrackPopupMenu(myMenu, TPM_RETURNCMD | TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0);
            SendMessage(hwndDlg, WM_NULL, 0, 0);
            if(MenuItemClicked == 1)
            {
                CopyToClipboard(serial);
                MessageBeep(MB_ICONINFORMATION);
            }
        }
    }
    return TRUE;

    case WM_HELP:
    {
        char id[10] = "";
        sprintf(id, "%d", IDS_HELPKEYGEN);
        SetEnvironmentVariableA("HELPID", id);
        SetEnvironmentVariableA("HELPTITLE", "KeyGen Help");
        DialogBox(hInst, MAKEINTRESOURCE(DLG_HELP), hwndDlg, DlgHelp);
    }
    return TRUE;

    case WM_COMMAND:
    {
        switch(LOWORD(wParam))
        {
        case IDC_BTN_GENERATE:
        {
            NoFocus();
            char name[512] = "";
            char keystring[512] = "";
            char pvt[512] = "";
            char y[512] = "";
            char hwid[10] = "";
            char sym[10] = "";
            char templ[512] = "";
            unsigned int sy = 0, hw = 0;

            GetDlgItemTextA(hwndDlg, IDC_EDT_NAME, name, 512);
            GetDlgItemTextA(hwndDlg, IDC_EDT_KEYSTRING, keystring, 256);
            GetDlgItemTextA(hwndDlg, IDC_EDT_HWID, hwid, 10);
            GetDlgItemTextA(hwndDlg, IDC_EDT_SYM, sym, 10);
            FormatHex(hwid);
            FormatHex(sym);

            sscanf(hwid, "%X", &hw);
            sscanf(sym, "%X", &sy);
            sprintf(sym, "%.8X", sy);
            SetDlgItemTextA(hwndDlg, IDC_EDT_SYM, sym);

            GetDlgItemTextA(hwndDlg, IDC_EDT_PVT, pvt, 512);
            int len = GetDlgItemTextA(hwndDlg, IDC_EDT_Y, y, 512);
            int comma_count = 0;
            for(int i = 0; i < len; i++)
                if(y[i] == ',')
                    comma_count++;
            bool baboon = !!IsDlgButtonChecked(hwndDlg, IDC_CHK_BABOON);
            if(keygenerate_level == 29 and comma_count != 2 and !baboon)
            {
                AddLogMessage(GetDlgItem(hwndDlg, IDC_EDT_ADVLOG), "Invalid ECDSA Public format...\nUse: ", true);
                return TRUE;
            }
            if(((!*pvt) or (!*y)) and keygenerate_level != -1 and !baboon)
            {
                if(GetDlgItemTextA(hwndDlg, IDC_EDT_TEMPLATE, templ, 512))
                {
                    KG_GeneratePvtY(keygenerate_level, templ, pvt, y);
                    SetDlgItemTextA(hwndDlg, IDC_EDT_PVT, pvt);
                    SetDlgItemTextA(hwndDlg, IDC_EDT_Y, y);
                }
                else
                {
                    AddLogMessage(GetDlgItem(hwndDlg, IDC_EDT_ADVLOG), "You should enter the values for the key signing...", true);
                    return TRUE;
                }
            }

            int date = GetDlgItemInt(hwndDlg, IDC_EDT_DATE, 0, 0);
            int other0 = GetDlgItemInt(hwndDlg, IDC_EDT_OTHER0, 0, 0) & 65535;
            int other1 = GetDlgItemInt(hwndDlg, IDC_EDT_OTHER1, 0, 0) & 65535;
            int other2 = GetDlgItemInt(hwndDlg, IDC_EDT_OTHER2, 0, 0) & 65535;
            int other3 = GetDlgItemInt(hwndDlg, IDC_EDT_OTHER3, 0, 0) & 65535;
            int other4 = GetDlgItemInt(hwndDlg, IDC_EDT_OTHER4, 0, 0) & 65535;

            SetDlgItemInt(hwndDlg, IDC_EDT_DATE, date, 1);
            if(IsDlgButtonChecked(hwndDlg, IDC_CHK_MODKEY))
                date = 65344;
            SetDlgItemInt(hwndDlg, IDC_EDT_OTHER0, other0, 0);
            if(keygenerate_level != -1)
            {
                SetDlgItemInt(hwndDlg, IDC_EDT_OTHER1, other1, 0);
                SetDlgItemInt(hwndDlg, IDC_EDT_OTHER2, other2, 0);
                SetDlgItemInt(hwndDlg, IDC_EDT_OTHER3, other3, 0);
                SetDlgItemInt(hwndDlg, IDC_EDT_OTHER4, other4, 0);
            }
            SetDlgItemTextA(hwndDlg, IDC_EDT_SERIAL, CreateSignedKey(keygenerate_level, sy, keygenerate_sym_xorval, pvt, y, keystring, date, name, hw, other0, other1, other2, other3, other4, baboon, GetDlgItem(hwndDlg, IDC_EDT_ADVLOG)));
            SendMessageA(GetDlgItem(hwndDlg, IDC_EDT_ADVLOG), WM_VSCROLL, SB_BOTTOM, 0);
        }
        return TRUE;

        case IDC_BTN_MAKEDATE:
        {
            NoFocus();
            char date_text[20] = "";
            char new_date[20] = "";
            int len = GetDlgItemTextA(hwndDlg, IDC_EDT_DATEYMD, date_text, 20);
            for(int i = 0, j = 0; i < len; i++)
                if(date_text[i] != '-')
                    j += sprintf(new_date + j, "%c", date_text[i]);
            len = strlen(new_date);
            UINT dest_id;

            HMENU myMenu = 0;
            myMenu = CreatePopupMenu();

            if(len != 8)
                AppendMenuA(myMenu, MF_STRING | MF_GRAYED, 3, "Error!");
            else
            {
                AppendMenu(myMenu, MF_STRING, 1, "Date");
                AppendMenu(myMenu, MF_STRING, 2, "oth0");
            }
            POINT cursorPos;
            GetCursorPos(&cursorPos);
            SetForegroundWindow(hwndDlg);
            UINT MenuItemClicked = TrackPopupMenu(myMenu, TPM_RETURNCMD | TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0);
            SendMessage(hwndDlg, WM_NULL, 0, 0);
            switch(MenuItemClicked)
            {
            case 1:
                dest_id = IDC_EDT_DATE;
                break;
            case 2:
                dest_id = IDC_EDT_OTHER0;
                break;
            case 3:
                return TRUE;
                break;
            }

            char y[5] = "", m[3] = "", d[3] = "";
            int y_ = 0, m_ = 0, d_ = 0;
            strncpy(y, new_date, 4);
            strncpy(m, new_date + 4, 2);
            strncpy(d, new_date + 6, 2);
            sscanf(y, "%d", &y_);
            sscanf(m, "%d", &m_);
            sscanf(d, "%d", &d_);
            sprintf(date_text, "%d", MakeDate(y_, m_, d_));
            SetDlgItemTextA(hwndDlg, dest_id, date_text);
        }
        return TRUE;

        case IDC_CHK_BABOON:
        {
            NoFocus();
            bool baboon = true;
            if(IsDlgButtonChecked(hwndDlg, IDC_CHK_BABOON))
                baboon = false;
            EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_PVT), baboon);
            EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_Y), baboon);
        }
        return TRUE;

        case IDC_BTN_CALC:
        {
            NoFocus();
            char temp[1024] = "";
            char temp2[256] = "";
            UINT MenuItemClicked = 1;
            HMENU myMenu = 0;
            char clipboard[256] = "";
            char pvt[1024] = "";
            char y[1024] = "";

            if(!GetDlgItemTextA(hwndDlg, IDC_EDT_TEMPLATE, temp, 1024))
                return TRUE;

            KG_GeneratePvtY(keygenerate_level, temp, pvt, y);
            sprintf(temp, "%.8X", KG_GenerateSymmetric(keygenerate_level, temp));

            if(keygenerate_level >= 0)
            {
                myMenu = CreatePopupMenu();
                AppendMenuA(myMenu, MF_STRING, 4, "Sym Only");
                if(keygenerate_level == 29)
                    AppendMenu(myMenu, MF_STRING, 1, "Pvt, ECDSA, Sym");
                else
                    AppendMenu(myMenu, MF_STRING, 1, "Pvt, Y, Sym");
                if(keygenerate_level == 29)
                    AppendMenu(myMenu, MF_STRING, 2, "Pvt, ECDSA");
                else
                    AppendMenu(myMenu, MF_STRING, 2, "Pvt, Y");
                PasteFromClipboard(clipboard, 256);
                FormatHex(clipboard);
                int len = strlen(clipboard);
                if(len and len < 9)
                {
                    unsigned int clipboard_sym = 0;
                    sscanf(clipboard, "%X", &clipboard_sym);
                    if(keygenerate_level == 29)
                        sprintf(temp2, "Pvt, ECDSA, Sym: %.8X", clipboard_sym);
                    else
                        sprintf(temp2, "Pvt, Y, Sym: %.8X", clipboard_sym);
                    AppendMenu(myMenu, MF_STRING, 3, temp2);
                }
                POINT cursorPos;
                GetCursorPos(&cursorPos);
                SetForegroundWindow(hwndDlg);
                MenuItemClicked = TrackPopupMenu(myMenu, TPM_RETURNCMD | TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0);
                SendMessage(hwndDlg, WM_NULL, 0, 0);
            }
            switch(MenuItemClicked)
            {
            case 1:
            {
                SetDlgItemTextA(hwndDlg, IDC_EDT_Y, y);
                SetDlgItemTextA(hwndDlg, IDC_EDT_PVT, pvt);
                SetDlgItemTextA(hwndDlg, IDC_EDT_SYM, temp);
            }
            break;

            case 2:
            {
                SetDlgItemTextA(hwndDlg, IDC_EDT_Y, y);
                SetDlgItemTextA(hwndDlg, IDC_EDT_PVT, pvt);
            }
            break;

            case 3:
            {
                SetDlgItemTextA(hwndDlg, IDC_EDT_Y, y);
                SetDlgItemTextA(hwndDlg, IDC_EDT_PVT, pvt);
                SetDlgItemTextA(hwndDlg, IDC_EDT_SYM, clipboard);
            }
            break;

            case 4:
            {
                SetDlgItemTextA(hwndDlg, IDC_EDT_SYM, temp);
            }
            break;
            }
            if(keygenerate_level >= 0)
                DestroyMenu(myMenu);
        }
        return TRUE;

        case IDC_CHK_DIGITALRIVER: ///Digital River checkbox.
        {
            NoFocus();
            if(IsDlgButtonChecked(hwndDlg, LOWORD(wParam)))
            {
                CheckDlgButton(hwndDlg, IDC_CHK_ESELLERATE, 0);
                keygenerate_sym_xorval = 0x91827364; ///Official XOR value of DigitalRiver tagged keys...
            }
            else
                keygenerate_sym_xorval = 0;
        }
        return TRUE;

        case IDC_CHK_ESELLERATE: ///eSellerate checkbox.
        {
            NoFocus();
            if(IsDlgButtonChecked(hwndDlg, LOWORD(wParam)))
            {
                CheckDlgButton(hwndDlg, IDC_CHK_DIGITALRIVER, 0);
                keygenerate_sym_xorval = 0x19283746; ///Official XOR value of eSellerate tagged keys...
            }
            else
                keygenerate_sym_xorval = 0;
        }
        return TRUE;

        case IDC_CHK_MODKEY:
        {
            NoFocus();
        }
        return TRUE;

        case IDC_COMBO_LEVEL:
        {
            switch(HIWORD(wParam))
            {
            case CBN_SELCHANGE:
            {
                bool isNoSeperator = true;
                keygenerate_level = SendDlgItemMessageA(hwndDlg, LOWORD(wParam), CB_GETCURSEL, 0, 0);
                if(keygenerate_level == 1 or keygenerate_level == 6 or keygenerate_level == 16)
                    isNoSeperator = false;

                if(!keygenerate_level)
                    keygenerate_level--;
                else if(keygenerate_level > 1 and keygenerate_level < 6) //signed v2
                    keygenerate_level -= 2;
                else if(keygenerate_level > 6 and keygenerate_level < 16) //signed v3
                    keygenerate_level += 3;
                else if(keygenerate_level > 16) //short v3
                    keygenerate_level += 3;
                bool en = isNoSeperator;
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_NAME), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_HWID), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_TEMPLATE), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_CALC), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DIGITALRIVER), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ESELLERATE), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_SYM), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_DATEYMD), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_DATE), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_MAKEDATE), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER0), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_GENERATE), en);

                if(keygenerate_level == -1)
                    en = false;
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER1), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER2), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER3), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER4), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_PVT), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_Y), en);
                en = false;
                if(keygenerate_level > 18 and isNoSeperator)
                    en = true;
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_KEYSTRING), en);

                /*char temp[10]="";
                sprintf(temp, "%d", keygenerate_level);*/
                if(isNoSeperator)
                {
                    SetDlgItemTextA(hwndDlg, IDC_EDT_PVT, "");
                    SetDlgItemTextA(hwndDlg, IDC_EDT_Y, "");
                }
                bool baboon = false;
                if(keygenerate_level == 29)
                {
                    SetDlgItemTextA(hwndDlg, IDC_STC_YPUB, "ECDSA Public:");
                    baboon = true;
                }
                else
                {
                    SetDlgItemTextA(hwndDlg, IDC_STC_YPUB, "Y:");
                    CheckDlgButton(hwndDlg, IDC_CHK_BABOON, 0);
                }
                ShowWindow(GetDlgItem(hwndDlg, IDC_CHK_BABOON), baboon);
            }
            return TRUE;
            }
        }
        return TRUE;
        }
    }
    return TRUE;
    }
    return FALSE;
}
예제 #5
0
bool CUIEditBox::MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    if(!m_bEnabled || !m_bVisible)
        return false;

    switch(uMsg)
    {
    // Make sure that while editing, the keyup and keydown messages associated with
    // WM_CHAR messages don't go to any non-focused controls or cameras
    case WM_KEYUP:
    case WM_KEYDOWN:
        return true;

    case WM_CHAR:
    {
        switch((WCHAR)wParam)
        {
        // Backspace
        case VK_BACK:
        {
            if (m_bEditEnabled)
            {
                // If there's a selection, treat this
                // like a delete key.
                if(m_nCaret != m_nSelStart)
                {
                    DeleteSelectionText();
                    sendEvent(EVENT_EDITBOX_CHANGE);
                }
                else if(m_nCaret > 0)
                {
                    // Move the caret, then delete the char.
                    PlaceCaret(m_nCaret - 1);
                    m_nSelStart = m_nCaret;
                    if (m_bPassword)
                    {
                        m_wstrPassword.erase(m_nCaret,1);
                    }
                    m_Buffer.RemoveChar(m_nCaret);
                    sendEvent(EVENT_EDITBOX_CHANGE);
                }
                ResetCaretBlink();
            }
            break;
        }

        case 24:        // Ctrl-X Cut
        case VK_CANCEL: // Ctrl-C Copy
        {
            CopyToClipboard();
            if (m_bEditEnabled)
            {
                // If the key is Ctrl-X, delete the selection too.
                if((WCHAR)wParam == 24)
                {
                    DeleteSelectionText();
                    sendEvent(EVENT_EDITBOX_CHANGE);
                }
            }
            break;
        }

        // Ctrl-V Paste
        case 22:
        {
            if (m_bEditEnabled)
            {
                PasteFromClipboard();
                sendEvent(EVENT_EDITBOX_CHANGE);
            }
            break;
        }

        // Ctrl-A Select All
        case 1:
            if(m_nSelStart == m_nCaret)
            {
                m_nSelStart = 0;
                PlaceCaret(m_Buffer.GetTextSize());
            }
            break;

        case VK_RETURN:
            // Invoke the callback when the user presses Enter.
            sendEvent(EVENT_EDITBOX_STRING);
            break;

        // Junk characters we don't want in the string
        case 26:  // Ctrl Z
        case 2:   // Ctrl B
        case 14:  // Ctrl N
        case 19:  // Ctrl S
        case 4:   // Ctrl D
        case 6:   // Ctrl F
        case 7:   // Ctrl G
        case 10:  // Ctrl J
        case 11:  // Ctrl K
        case 12:  // Ctrl L
        case 17:  // Ctrl Q
        case 23:  // Ctrl W
        case 5:   // Ctrl E
        case 18:  // Ctrl R
        case 20:  // Ctrl T
        case 25:  // Ctrl Y
        case 21:  // Ctrl U
        case 9:   // Ctrl I
        case 15:  // Ctrl O
        case 16:  // Ctrl P
        case 27:  // Ctrl [
        case 29:  // Ctrl ]
        case 28:  // Ctrl \ 
            break;

        default:
            if (m_bEditEnabled)
            {
                // If there's a selection and the user
                // starts to type, the selection should
                // be deleted.
                if(m_nCaret != m_nSelStart)
                    DeleteSelectionText();

                // If we are in overwrite mode and there is already
                // a char at the caret's position, simply replace it.
                // Otherwise, we insert the char as normal.
                if(!m_bInsertMode && m_nCaret < m_Buffer.GetTextSize())
                {
                    m_Buffer[m_nCaret] = (WCHAR)wParam;
                    PlaceCaret(m_nCaret + 1);
                    m_nSelStart = m_nCaret;
                }
                else
                {
                    // Insert the char
                    if (m_bPassword)
                    {
                        m_wstrPassword.insert(m_wstrPassword.begin()+m_nCaret,(WCHAR)wParam);
                        if(m_Buffer.InsertChar(m_nCaret, L'*'))
                        {
                            PlaceCaret(m_nCaret + 1);
                            m_nSelStart = m_nCaret;
                        }
                    }
                    else
                    {
                        if(m_Buffer.InsertChar(m_nCaret, (WCHAR)wParam))
                        {
                            PlaceCaret(m_nCaret + 1);
                            m_nSelStart = m_nCaret;
                        }
                    }
                }
                ResetCaretBlink();
                sendEvent(EVENT_EDITBOX_CHANGE);
            }
        }
        return true;
    }
    }
    return false;
}
예제 #6
0
bool CUIEditBox::HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    if(!m_bEnabled || !m_bVisible)
        return false;

    bool bHandled = false;

    switch(uMsg)
    {
    case WM_KEYDOWN:
    {
        switch(wParam)
        {
        case VK_TAB:
            // We don't process Tab in case keyboard input is enabled and the user
            // wishes to Tab to other controls.
            break;

        case VK_HOME:
            PlaceCaret(0);
            if(GetKeyState(VK_SHIFT) >= 0)
                // Shift is not down. Update selection
                // start along with the caret.
                m_nSelStart = m_nCaret;
            ResetCaretBlink();
            bHandled = true;
            break;

        case VK_END:
            PlaceCaret(m_Buffer.GetTextSize());
            if(GetKeyState(VK_SHIFT) >= 0)
                // Shift is not down. Update selection
                // start along with the caret.
                m_nSelStart = m_nCaret;
            ResetCaretBlink();
            bHandled = true;
            break;

        case VK_INSERT:
            if(GetKeyState(VK_CONTROL) < 0)
            {
                // Control Insert. Copy to clipboard
                CopyToClipboard();
            } else if(GetKeyState(VK_SHIFT) < 0)
            {
                // Shift Insert. Paste from clipboard
                PasteFromClipboard();
            } else
            {
                // Toggle caret insert mode
                m_bInsertMode = !m_bInsertMode;
            }
            break;

        case VK_DELETE:
            if (m_bEditEnabled)
            {
                // Check if there is a text selection.
                if(m_nCaret != m_nSelStart)
                {
                    DeleteSelectionText();
                    sendEvent(EVENT_EDITBOX_CHANGE);
                }
                else
                {
                    // Deleting one character
                    if (m_bPassword)
                    {
                        m_wstrPassword.erase(m_nCaret,1);
                    }
                    if(m_Buffer.RemoveChar(m_nCaret))
                        sendEvent(EVENT_EDITBOX_CHANGE);
                }
                ResetCaretBlink();
                bHandled = true;
            }
            break;

        case VK_LEFT:
            if(GetKeyState(VK_CONTROL) < 0)
            {
                // Control is down. Move the caret to a new item
                // instead of a character.
                m_Buffer.GetPriorItemPos(m_nCaret, &m_nCaret);
                PlaceCaret(m_nCaret);
            }
            else if(m_nCaret > 0)
                PlaceCaret(m_nCaret - 1);
            if(GetKeyState(VK_SHIFT) >= 0)
                // Shift is not down. Update selection
                // start along with the caret.
                m_nSelStart = m_nCaret;
            ResetCaretBlink();
            bHandled = true;
            break;

        case VK_RIGHT:
            if(GetKeyState(VK_CONTROL) < 0)
            {
                // Control is down. Move the caret to a new item
                // instead of a character.
                m_Buffer.GetNextItemPos(m_nCaret, &m_nCaret);
                PlaceCaret(m_nCaret);
            }
            else if(m_nCaret < m_Buffer.GetTextSize())
                PlaceCaret(m_nCaret + 1);
            if(GetKeyState(VK_SHIFT) >= 0)
                // Shift is not down. Update selection
                // start along with the caret.
                m_nSelStart = m_nCaret;
            ResetCaretBlink();
            bHandled = true;
            break;

        case VK_UP:
        case VK_DOWN:
            // Trap up and down arrows so that the dialog
            // does not switch focus to another control.
            bHandled = true;
            break;

        default:
            bHandled = wParam != VK_ESCAPE;  // Let the application handle Esc.
        }
    }
    }
    return bHandled;
}
예제 #7
0
// ----------------------------------------------------------------------------
void MMSapEvents::OnMiddleMouseDown(wxMouseEvent& event, cbStyledTextCtrl* ed)
// ----------------------------------------------------------------------------
{
    // If selected text, paste selected text at current cursor position
    // If selected text, and user middle-clicks inside selection, copy to clipboard
    // If no selected text, paste clipboard data at cursor position

    int pos = ed->PositionFromPoint(wxPoint(event.GetX(), event.GetY()));

    if(pos == wxSCI_INVALID_POSITION)
        return;

    int start = ed->GetSelectionStart();
    int end = ed->GetSelectionEnd();

    const wxString selectedText = ed->GetSelectedText();

    // If no current selection, or shift key is down, use paste from the clipboard
    bool shiftKeyState = ::wxGetKeyState(WXK_SHIFT);

    if (  shiftKeyState || selectedText.IsEmpty() )
    {
        PasteFromClipboard( event, ed, shiftKeyState );
        return;
    }

    //if user middle-clicked inside the selection, copy to clipboard
    if ( (pos >= start) && (pos <= end) )
    {
        #if defined(__WXGTK__)
            gtk_clipboard_set_text(
                gtk_clipboard_get(GDK_SELECTION_PRIMARY),
                selectedText.mb_str(wxConvUTF8),
                selectedText.Length() );
        #else //__WXMSW__
                if (wxTheClipboard->Open())
                {
                    wxTheClipboard->AddData(new wxTextDataObject(selectedText));
                    wxTheClipboard->Close();
                }
        #endif
        return;
    }//if

    if(pos < ed->GetCurrentPos())
    {
        start += selectedText.length();
        end += selectedText.length();
    }

    #if defined(LOGGING)
    //LOGIT( _T("pos,start,end[%d][%d][%d]"), pos, start, end);
    #endif

    // paste selected text at current cursor position
    ed->InsertText(pos, selectedText);
    //-SetSelection(start, end);
    ed->GotoPos(pos);
    ed->SetSelectionVoid(pos, pos+selectedText.length());
    #if defined(LOGGING)
    LOGIT( _T("OnMiddleMouseDown[%s]"), selectedText.c_str());
    #endif

} // end of OnGPM
예제 #8
0
long DoCommand( HWND hWindow, WPARAM wParam, LPARAM lParam )
/***********************************************************************/
{
FNAME szFileName;
LPFRAME lpFrame;
LPOBJECT lpObject, lpBase;
RECT rect, rMask, rTemp, rAll;
HWND hWnd;
STRING szString;
int i, idFileType, x, y, dx, dy;
BOOL fDoZoom, bPrint, fHasZoom;
LPSTR lpszCmdLine;
HGLOBAL hMem;
ITEMID idDataType;
DWORD dwReturn;
int NewShape;
UINT wID;

SoundStartID( wParam, NO/*bLoop*/, NULL/*hInstance*/ );
/*
	WIN16:	ID          = wParam
			ctrl handle = LOWORD(lParam)
			notify code = HIWORD(lParam)

	WIN32:	ID          = LOWORD(wParam)
			ctrl handle = lParam
			notify code = HIWORD(wParam)
*/

#ifdef WIN32
	wID = LOWORD(wParam);
#else
	wID = wParam;
#endif

switch (wID)
	{
	case IDM_EXIT:
	DeactivateTool();
	PostMessage( hWndAstral, WM_CLOSE, 0, 0L);
    Delay (750);
	break;

	case IDM_CLOSE:
	DeactivateTool();
	/* Check to see if the image needs to be saved */
	if ( !ConfirmClose(NO,NO) )
		break;
	CloseImage( NO, lpImage ); // Close the active image
	break;

	case IDM_ABOUT:
	/* Bring up the modal 'About' dialog box */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_ABOUT, DlgAboutProc);
	break;

	case IDM_NEXTPAGE:
	if ( !lpImage )
		break;
	DeactivateTool();
	SendMessage( lpImage->hWnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0L );
	break;

	case IDM_NEW:
	DeactivateTool();
	SoundStartResource( "magic01", NO, NULL );
	AstralCursor( IDC_WAIT );
	New( Control.NewWidth, Control.NewHeight, Control.NewResolution,
		Control.NewDepth );
	AstralCursor( NULL );
	break;

	case IDM_OPEN:
	DeactivateTool();
	/* Bring up the modal 'File Open' box */
	if ( !(dwReturn = DoOpenDlg( hWindow, IDD_OPEN,
		Save.FileType, szFileName, NO )) )
		break;
	idFileType = LOWORD( dwReturn );
	Save.FileType = idFileType;
	PutDefaultInt( "FileType", idFileType - IDN_TIFF );
	AstralImageLoad( idFileType, szFileName, MAYBE, YES );
	break;

	case IDM_ALTOPEN:
	DeactivateTool();
	// Command line sent from a second instance prior to it closing
	/* If the caller passed in a file name, try to load it or print it */
	if ( !(lpszCmdLine = (LPSTR)lParam) )
		break;
	HandleCommandLine( hWindow, lpszCmdLine, &bPrint );
	break;

	case IDM_SAVE:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEAS:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVESPECIAL:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEWALLPAPER:
	DeactivateTool();
	SaveWallpaper( "CRAYOLA", NO/*fTiled*/ );
	break;

	case IDM_REVERT:
	if ( !lpImage )
		break;
	DeactivateTool();
	if ( lpImage->fUntitled ) // If the picture doesn't have a name, get out
		break;
	if ( ImgChanged(lpImage) )
		{
		/* Check to see if its OK to trash changes */
		if ( AstralOKCancel(IDS_OKTOREVERT,
				(LPSTR)lpImage->CurFile) == IDCANCEL )
			break;
		}
	lstrcpy( szFileName, lpImage->CurFile );
	idFileType = lpImage->FileType;
	fDoZoom = IsZoomed(lpImage->hWnd);
	fHasZoom = Window.fHasZoom;
	CloseImage( NO, lpImage ); // Close the active image
	if ( !AstralImageLoad( idFileType, szFileName, fDoZoom, YES ) )
		break;
	break;

	case IDM_RECALLIMAGE0:
	case IDM_RECALLIMAGE1:
	case IDM_RECALLIMAGE2:
	case IDM_RECALLIMAGE3:
	case IDM_RECALLIMAGE4:
	case IDM_RECALLIMAGE5:
	case IDM_RECALLIMAGE6:
	case IDM_RECALLIMAGE7:
	case IDM_RECALLIMAGE8:
	case IDM_RECALLIMAGE9:
	DeactivateTool();
	GetMenuString( GetMenu(hWindow), wID,
		szFileName, sizeof(szFileName), MF_BYCOMMAND );
	i = 0;
	while ( szFileName[i] && szFileName[i] != ' ' )
		i++; // Skip over the numeric id in the string (3. junk.tif)
	lstrcpy(szString, &szFileName[i+1]);
	GetRecallFileName(szString);
	AstralImageLoad( NULL, szString, MAYBE, YES );
	break;

	case IDM_PRINT:
	if ( !lpImage )
		break;
	DeactivateTool();
	AstralCursor( IDC_WAIT );
	DoPrintSizeInits();
	SoundStartResource( "print", YES, NULL );
	PrintFile( hWindow, filename(lpImage->CurFile), YES, lpImage, NULL );
	SoundStop();
	AstralCursor( NULL );
	break;

	case IDM_PRINTSETUP:
	/* Bring up the setup dialog box for the active printer */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PRINTSETUP,
		DlgPrintSetupProc);
	break;

	case IDC_SOUND:
	SoundToggle();
	break;

	case IDM_UNDO:
	if ( !lpImage )
		break;
	DeactivateTool();
	ImgEditUndo(lpImage, YES, NO);
	break;

	case IDM_CUT:
	case IDM_COPY:
	if ( !lpImage )
		break;
	DeactivateTool();

	// Create the clipboard files from the image
	ProgressBegin(1, IDS_PROGCOPY);
	if ( !ImgWriteClipOut( lpImage, NULL, NULL, &rMask, lpImage->DataType ) )
		{
		ProgressEnd();
		Message(IDS_EMEMALLOC);
		break;
		}
	ProgressEnd();

	OpenClipboard(hWindow);
	EmptyClipboard();

	// Passing a NULL data handle in SetClipboardData() means that
	// the data will be requested in a WM_RENDERFORMAT message
	hMem = ConstructObject( lpImage,
		IsRectEmpty(&rMask)? (LPRECT)NULL : (LPRECT)&rMask );
	if ( pOLE )
		{ // Any data put on before Native will become staticly copied
		SetClipboardData( pOLE->cfNative, NULL );
		SetClipboardData( pOLE->cfOwnerLink, hMem );
		}
	SetClipboardData( CF_DIB, NULL );
	if ( Control.DoPicture )
		SetClipboardData( CF_METAFILEPICT, NULL );
	if ( Control.DoBitmap )
		SetClipboardData( CF_BITMAP, NULL );
	SetClipboardData( CF_PALETTE, NULL );
	SetClipboardData( Control.cfImage, NULL );
	if ( pOLE && wID == IDM_COPY && !lpImage->fUntitled )
		{ // ObjectLink is retrieved during a Paste Link...
		SetClipboardData( pOLE->cfObjectLink, hMem );
		}
	CloseClipboard();
	if ( wID == IDM_COPY )
		break;

	// else fall through to IDM_DELETE

	case IDM_DELETE:
	if ( !lpImage )
		break;
	{
	COLORINFO ColorInfo;

	DeactivateTool();
	ColorInfo.gray   = 255;
	SetColorInfo( &ColorInfo, &ColorInfo, CS_GRAY );
	TintFill( lpImage, &ColorInfo, 255, MM_NORMAL,
		wID == IDM_CUT ? IDS_UNDOCUT : IDS_UNDODELETE );
	}
	break;

	case IDM_PASTE:
	if ( !lpImage )
		break;

	case IDM_PASTEASNEW:
	if ( !OpenClipboard(hWndAstral) )
		{
		Message( IDS_ECLIPOPEN );
		break;
		}
	if ( !IsClipboardFormatAvailable(CF_DIB) &&
	     !IsClipboardFormatAvailable(CF_BITMAP) &&
	     !IsClipboardFormatAvailable(Control.cfImage) )
		{
		Message( IDS_ECLIPOPEN );
		CloseClipboard();
		break;
		}
	CloseClipboard();

	DeactivateTool();
	// First put clipboard contents into a file(s)
	AstralCursor(IDC_WAIT);
	if ( !PasteFromClipboard( hWindow, (wID == IDM_PASTE) /*fNeedMask*/ ) )
		{
		AstralCursor(NULL);
		Message(IDS_EMEMALLOC);
		break;
		}
	if ( wID == IDM_PASTE )
		{
		ProgressBegin(1, IDS_PROGPASTECLIP);
		TransformObjectsStart( YES/*fNewObject*/ );
        if ( ImgCreateClipInObject( lpImage, NO ) )
			;
		ProgressEnd();
		}
	else
	if ( wID == IDM_PASTEASNEW )
		{
		if ( lpFrame = AstralFrameLoad( Names.PasteImageFile, -1,
			 &idDataType, &idFileType) )
			{
			if ( NewImageWindow(
				NULL,			// lpOldFrame
				NULL,			// Name
				lpFrame, 		// lpNewFrame
				idFileType,		// lpImage->FileType
				idDataType,		// lpImage->DataType
				FALSE,			// New view?
				IMG_DOCUMENT,	// lpImage->DocumentType
				NULL,			// lpImage->ImageName
				MAYBE
				) )
					lpImage->fChanged = YES;
			}
		}
	break;

	case IDM_ESCAPE:
	if (!lpImage)
		break;
	if (lpImage->hWnd == hZoomWindow)
		break;
	if ( Tool.bActive && Tool.lpToolProc )
		DestroyProc( lpImage->hWnd, 1L );
	break;

	case IDM_SIZEUP:
	case IDM_SIZEDOWN:
	if (!Retouch.hBrush)
		break;				 
	SetFocus( hWindow ); // Take focus away from any controls
	if ( Retouch.BrushShape == IDC_BRUSHCUSTOM )
		break;
	if ( wID == IDM_SIZEUP )
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 ))
    		Retouch.BrushSize += 2;
        else        
    		Retouch.BrushSize++;
    }
	else	
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 )) 
    		Retouch.BrushSize -= 2;
        else        
    		Retouch.BrushSize--;
    }
	if ( Retouch.BrushSize < 1 || Retouch.BrushSize > MAX_BRUSH_SIZE )
		{
		Retouch.BrushSize = bound( Retouch.BrushSize, 1,MAX_BRUSH_SIZE);
		MessageBeep(0);
		break;
		}
	if (lpImage)
		DisplayBrush(0, 0, 0, OFF);
	SetMgxBrushSize(Retouch.hBrush, Retouch.BrushSize);
	if (lpImage && Window.hCursor == Window.hNullCursor)
		DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		SetSlide( Tool.hRibbon, IDC_BRUSHSIZE, Retouch.BrushSize );
	break;

	case IDM_SHAPEUP:
	case IDM_SHAPEDOWN:
	if (!Retouch.hBrush)
		break;
	SetFocus( hWindow ); // Take focus away from any controls
	NewShape = Retouch.BrushShape;
	if ( wID == IDM_SHAPEUP )
		NewShape++;
	else	NewShape--;
	if ( NewShape > IDC_BRUSHCUSTOM )
		NewShape = IDC_BRUSHCIRCLE;
	if ( NewShape < IDC_BRUSHCIRCLE )
		NewShape = IDC_BRUSHCUSTOM;
	if (lpImage)
	 	DisplayBrush(0, 0, 0, OFF);
	if (!SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush))
		{
		NewShape = IDC_BRUSHCIRCLE;
		SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush);
		}
	Retouch.BrushShape = NewShape;
	if (lpImage && Window.hCursor == Window.hNullCursor)
	 	DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		{
		CheckComboItem( Tool.hRibbon, IDC_BRUSHSHAPE, IDC_BRUSHCIRCLE,
			IDC_BRUSHCUSTOMNEW, Retouch.BrushShape );
		SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L );
		}
	break;

	case IDM_MOVEUP:
	case IDM_MOVEDOWN:
	case IDM_MOVELEFT:
	case IDM_MOVERIGHT:
	if (!lpImage)
		break;
	lpBase = ImgGetBase(lpImage);
	if (ImgGetSelObject(lpImage, NULL) == lpBase)
		break;
	dx = dy = 0;
	if (wID == IDM_MOVEUP)
		--dy;
	if (wID == IDM_MOVEDOWN)
		++dy;
	if (wID == IDM_MOVELEFT)
		--dx;
	if (wID == IDM_MOVERIGHT)
		++dx;
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&rect, dx, dy);
		if (!AstralIntersectRect(&rTemp, &lpBase->rObject, &rect))
			break;
		}
	if (lpObject)
		break;
	AstralSetRectEmpty(&rAll);
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&lpObject->rObject, dx, dy);
		AstralUnionRect(&rAll, &rAll, &lpObject->rObject);
		if (!lpObject->Pixmap.fNewFrame &&
				EqualRect(&rect, &lpObject->rUndoObject))
			lpObject->rUndoObject = lpObject->rObject;
		UpdateImage(&rect, TRUE);
		UpdateImage(&lpObject->rObject, TRUE);
		}
	if (wID == IDM_MOVEUP)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.top;
		}
	else
	if (wID == IDM_MOVEDOWN)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.bottom;
		}
	else
	if (wID == IDM_MOVELEFT)
		{
		x = rAll.left;
		y = (rAll.top + rAll.bottom)/2;
		}
	else
	if (wID == IDM_MOVERIGHT)
		{
		x = rAll.right;
		y = (rAll.top + rAll.bottom)/2;
		}
	File2Display(&x, &y);
	AutoScroll(lpImage->hWnd, x, y);
	AstralUpdateWindow(lpImage->hWnd);
	DisplayInfo(-1, &rAll);
	break;

	case IDM_LASTTOOL:
	DeactivateTool();
	if ( Tool.idLast && (hWnd = AstralDlgGet(IDD_MAIN)) )
		SendMessage( hWnd, WM_COMMAND, Tool.idLast, 2L);
	break;

	case IDM_PREF:
	// prevent problems if running animations and they change
	// the wave mix dll setting in preferences
	StopAnimation();
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PREF, DlgPrefProc );
	break;

	case IDC_VIEWLAST: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	RevertLastView();
	break;

//	case IDC_VIEWFULL: // duplicate of function in the view ribbon
//	if ( !lpImage )
//		break;
//	AstralDlg( NO, hInstAstral, hWindow, IDD_VIEWFULL, DlgFullScreenViewProc );
//	break;

	case IDC_VIEWALL: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	ViewAll();
	break;

	case IDC_ZOOMIN: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, +100, YES, ( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDC_ZOOMOUT: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, -100, YES,( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDM_HELP:
	Control.Hints = !Control.Hints;
	PutDefInt (Control.Hints,Control.Hints);
	break;

	default:
	return( FALSE );
	}

return( TRUE );
}
예제 #9
0
/*---------------------------------------------------------------------------
                                  CmdPaste
---------------------------------------------------------------------------*/
void CmdPaste( WNDATTR *wndattr )
{
   PasteFromClipboard( wndattr->hab, wndattr->Client );

   return;
}