Пример #1
0
LRESULT CEmoticonRichEditCtrl::OnSetText(WPARAM wParam, LPARAM lParam)
{
	LRESULT res = Default();
	
	FormatAll();
	return res;	
}
Пример #2
0
void CEmoticonRichEditCtrl::OnChange() 
{
	if (m_bInForcedChange)
		return;

	CHARRANGE crCurSel; 
	GetSel(crCurSel);
	
	if (m_changeType == ctMove && crCurSel.cpMin == crCurSel.cpMax) {
		// cut was canceled, so this is paste operation
		m_changeType = ctPaste;
	}

	switch(m_changeType) {
	case ctReplSel:// old=(x,y) -> cur=(x+len,x+len)
	case ctPaste:  // old=(x,y) -> cur=(x+len,x+len)
		FormatTextLines(m_crOldSel.cpMin, crCurSel.cpMax);
		break;
	case ctDelete: // old=(x,y) -> cur=(x,x)
	case ctBack:   // old=(x,y) -> cur=(x,x), newline del => old=(x,x+1) -> cur=(x-1,x-1)
	case ctCut:    // old=(x,y) -> cur=(x,x)
		FormatTextLines(crCurSel.cpMin, crCurSel.cpMax);
		break;
	case ctUndo:   // old=(?,?) -> cur=(x,y)
		FormatTextLines(crCurSel.cpMin, crCurSel.cpMax);
		break;
	case ctMove:   // old=(x,x+len) -> cur=(y-len,y) | cur=(y,y+len)
		FormatTextLines(crCurSel.cpMin, crCurSel.cpMax);
		if (crCurSel.cpMin > m_crOldSel.cpMin) // move after
			FormatTextLines(m_crOldSel.cpMin, m_crOldSel.cpMin);
		else // move before
			FormatTextLines(m_crOldSel.cpMax, m_crOldSel.cpMax);
		break;
	//case ctPaste:  //kojh
	//	FormatAll();
	default:
		FormatAll();
		break;
	}

	//undo action does not call OnProtected, so make it default
	m_changeType = ctUndo;	
}
Пример #3
0
LRESULT CTWScriptEdit::OnSetText(WPARAM wParam, LPARAM lParam)
{
	LRESULT res = Default();
	FormatAll();
	return res;	
}
Пример #4
0
/*  PasteSign = 0:Paste to Page,  1: Paste to Text Box */
int ClipBoardGetBox(int PasteSign)
{
    ClipBoards ClipBoardDataInformation;
    HBOX InsertHBox;
//  Boxs TmpBox,*Box;
#define TmpBox        TmpBuf
    Boxs *Box;
    TextBoxs *TextBox;
    PictureBoxs *PictureBox;

    ClipBoardGetDataInfomation(&ClipBoardDataInformation);
    if( ClipBoardDataInformation.ClipBoardDataLength==0
            || ClipBoardDataInformation.ClipBoardDataType!=BOXDATA )
        return(0);

    Box=&TmpBox;
    ClipBoardGet(Box,&ClipBoardDataInformation.ClipBoardDataLength,
                 &ClipBoardDataInformation.ClipBoardDataType);
    InsertHBox=BoxInsert(Box,GlobalCurrentPage);
    if (!InsertHBox)
        return(OUTOFMEMORY);
    if (TextBoxGetBoxType((TextBoxs *)Box)==POLYGONPICTUREBOX)
    {
        int *PolygonEdges,PolygonLeft,PolygonTop,PolygonRight,PolygonBottom,i;
        ORDINATETYPE PolygonEdgeData[2*MAXPOLYGONNUMBER+1];

        ClipBoardGetDataInfomation(&ClipBoardDataInformation);
        if ((ClipBoardDataInformation.ClipBoardDataLength==0)||
                (ClipBoardDataInformation.ClipBoardDataType!=POLYGONDATA))
            return(OUTOFMEMORY);
        ClipBoardGet(PolygonEdgeData,&ClipBoardDataInformation.ClipBoardDataLength,
                     &ClipBoardDataInformation.ClipBoardDataType);
        PictureBox=HandleLock(ItemGetHandle(InsertHBox));
        if (PictureBox==NULL)
            return(OUTOFMEMORY);
        PictureBoxSetBorderPolygon(PictureBox,HandleAlloc(
                                       sizeof(int)+2*sizeof(ORDINATETYPE)*MAXPOLYGONNUMBER,0));
        if (!PictureBoxGetBorderPolygon(PictureBox))
        {
            HandleUnlock(ItemGetHandle(InsertHBox));
            return(OUTOFMEMORY);
        }
        PolygonEdges=HandleLock(PictureBoxGetBorderPolygon(PictureBox));
        if (PolygonEdges==NULL)
        {
            HandleUnlock(ItemGetHandle(InsertHBox));
            return(OUTOFMEMORY);
        }
        memcpy(PolygonEdges,PolygonEdgeData,
               ClipBoardDataInformation.ClipBoardDataLength);
        if (PasteSign==GETTOTEXTBOX)
        {
            PictureBoxSetBoxLeft(PictureBox,0);
            PictureBoxSetBoxTop(PictureBox,0);
            PolygonGetMinRectangle(*PolygonEdges,&(PolygonEdges[1]),
                                   &PolygonLeft,&PolygonTop,&PolygonRight,&PolygonBottom);
            for (i=0; i<*PolygonEdges; i++)
            {
                PolygonEdges[i*2+1]-=PolygonLeft;
                PolygonEdges[i*2+2]-=PolygonTop;
            }
        }
        HandleUnlock(PictureBoxGetBorderPolygon(PictureBox));
        HandleUnlock(ItemGetHandle(InsertHBox));
    }
    else if (TextBoxGetBoxType((TextBoxs *)Box)==TEXTBOX)
    {
        TextBox=HandleLock(ItemGetHandle(InsertHBox));
        if (TextBox==NULL)
            return(OUTOFMEMORY);

        TextBoxInitialLineTable(TextBox);
        TextBoxSetInvalidPolygons(TextBox,0);

        if ((TextBoxGetTextLength((TextBoxs *)Box)>0)&&
                !TextBoxGetPrevLinkBox((TextBoxs *)Box))
        {
            Wchar *TextBlock;

            ClipBoardGetDataInfomation(&ClipBoardDataInformation);
            if ((ClipBoardDataInformation.ClipBoardDataLength==0)||
                    (ClipBoardDataInformation.ClipBoardDataType!=TEXTDATA))
            {
                TextBoxSetTextHandle(TextBox,0);
                TextBoxSetTextLength(TextBox,0);
                TextBoxSetBlockLength(TextBox,0);
                HandleUnlock(ItemGetHandle(InsertHBox));
                return(OUTOFMEMORY);
            }
            TextBoxSetTextHandle(TextBox,HandleAlloc(TextBoxGetBlockLength(TextBox)
                                 *sizeof(Wchar),0));
            if (!TextBoxGetTextHandle(TextBox))
            {
                TextBoxSetTextLength(TextBox,0);
                TextBoxSetBlockLength(TextBox,0);
                HandleUnlock(ItemGetHandle(InsertHBox));
                return(OUTOFMEMORY);
            }
            TextBlock=HandleLock(TextBoxGetTextHandle(TextBox));
            ClipBoardGet(TextBlock,&ClipBoardDataInformation.ClipBoardDataLength,
                         &ClipBoardDataInformation.ClipBoardDataType);
            TextBlock[TextBoxGetTextLength(TextBox)]=0;
            HandleUnlock(TextBoxGetTextHandle(TextBox));
        }
        else
        {
            TextBoxSetTextHandle(TextBox,0);
            TextBoxSetTextLength(TextBox,0);
            TextBoxSetBlockLength(TextBox,0);
        }
        TextBoxSetPrevLinkBox(TextBox,0);
        TextBoxSetNextLinkBox(TextBox,0);
        InitRL(TextBox);
        FormatAll(InsertHBox);
        HandleUnlock(ItemGetHandle(InsertHBox));
    }
    else if ((TextBoxGetBoxType((TextBoxs *)Box)>=RECTANGLEPICTUREBOX)
             &&(TextBoxGetBoxType((TextBoxs *)Box)<=POLYGONPICTUREBOX))
    {
        PictureBox=HandleLock(ItemGetHandle(InsertHBox));
        if (PictureBox==NULL)
            return(OUTOFMEMORY);
        if (PictureBoxGetPictureFileName(PictureBox)[0])
        {
            ImageDescribes *TiffPresent;

            TiffPresent=&(PictureBoxGetPicturePresent(PictureBox));
            TiffPresent->ImageHandle=TiffPresent->ImageNewHandle=0;
            PictureBoxImportTiff(PictureBoxGetPictureFileName(PictureBox),
                                 InsertHBox);
        }
        HandleUnlock(ItemGetHandle(InsertHBox));
    }

    if (PasteSign==GETTOTEXTBOX)
    {
        ItemSetNext(ItemGetPrev(InsertHBox),0);
        ItemSetPrev(InsertHBox,0);
        ItemSetNext(InsertHBox,0);
        ItemSetFather(InsertHBox,0);

        TextBox=HandleLock(ItemGetHandle(InsertHBox));
        if (TextBox==NULL)
            return(OUTOFMEMORY);
        TextBoxSetEmbodyBox(TextBox);
        HandleUnlock(ItemGetHandle(InsertHBox));
    }
    return(InsertHBox);
}