示例#1
0
BOOL CxEdit::LineSwap(int line0, int line1, BOOL bScroll /*= TRUE*/, BOOL bCanUndo /*= FALSE*/)
{
   BOOL bOK = TRUE;
   if (line0 != line1)
   {
      const int linecount = GetLineCount();
      CString str[2];
      int line[2];
      line[0] = min(line0, line1);
      line[1] = max(line0, line1);

      bOK = (linecount > line[1]);
      if (bOK)
      {
         GetLine(line[0], &str[0]);
         GetLine(line[1], &str[1]);
         DeleteLine(line[1], FALSE);
         DeleteLine(line[0], FALSE);
//return bOK;
         CString temp = str[1] + _T("\r\n");
         InsertString(line[0], temp, FALSE, bCanUndo);

         temp = str[0] + ((line[1] == (linecount - 1)) ? &afxChNil : _T("\r\n"));
         InsertString(line[1], temp, bScroll, bCanUndo);
      }
   }
   return bOK;
}
示例#2
0
BOOL duTreeListCtrl::DeleteItemT(TreeListItem *pItem)
{
	if (pItem == NULL)
		return FALSE;

	TreeListItem *pChildItem = pItem->pFirstChild;
	while (pChildItem)
	{
		TreeListItem *pDelItem = pChildItem;
		pChildItem = pChildItem->pNextSibling;
		DeleteItemT(pDelItem);
	}

	if (pItem != &m_RootItem)
	{
		if (m_pSel == pItem->pPlugin)
			m_pSel = NULL;
	
		int nIndex = GetLinePluginIndex(pItem->pPlugin);
		if (nIndex == -1)
		{
			Plugin_Delete(pItem->pPlugin);
		}

		DeleteLine(nIndex, FALSE);
		delete pItem;
	}

	return TRUE;
}
示例#3
0
boolean TextManip::HandleKey (Event& e) {
    World* world = GetViewer()->GetWorld();
    char c = e.keystring[0];
    boolean manipulating = true;

    switch (c) {
        case '\007':  world->RingBell(1); break;
        case '\001':  BeginningOfLine(); break;
        case '\005':  EndOfLine(); break;
        case '\006':  ForwardCharacter(1); break;
        case '\002':  BackwardCharacter(1); break;
        case '\016':  ForwardLine(1); break;
        case '\020':  BackwardLine(1); break;
        case '\013':  DeleteLine(); break;
        case '\004':  DeleteCharacter(1); break;
        case '\010':  DeleteCharacter(-1); break;
        case '\177':  DeleteCharacter(-1); break;
        case '\011':  InsertCharacter('\t'); break;
        case '\015':  if (_multiline) InsertCharacter('\n'); break;
        case '\033':  manipulating = false; break;
        default:
            if (!iscntrl(c & 0x7f)) {
                InsertCharacter(c);
            }
            break;
    }
    return manipulating;
}
//
// Called when the user clicks the Delete button.
// Removes all selected lines from the access spec.
//
void CAccessDialog::OnBDelete()
{
	int first_highlighted_item;

	// Return immediately if nothing is selected.
	if ((first_highlighted_item = m_LAccess.GetNextItem(-1, LVNI_SELECTED)) == -1)
		return;

	// Loop through all selected items and delete them.
	while ((item_being_changed = m_LAccess.GetNextItem(-1, LVNI_SELECTED)) != -1)
		DeleteLine();

	item_being_changed = first_highlighted_item;

	if (item_being_changed != -1 && item_being_changed < m_LAccess.GetItemCount()) {
		m_LAccess.SetItemState(item_being_changed, LVIS_SELECTED, LVIS_SELECTED);
		SetAll((Access_Spec *) m_LAccess.GetItemData(item_being_changed));
	} else if (m_LAccess.GetItemCount()) {
		item_being_changed = m_LAccess.GetItemCount() - 1;
		m_LAccess.SetItemState(item_being_changed, LVIS_SELECTED, LVIS_SELECTED);
		SetAll((Access_Spec *) m_LAccess.GetItemData(item_being_changed));
	} else {
		// No more items left in the list.
		item_being_changed = -1;
	}
}
示例#5
0
void MacroCart::deleteMacroData()
{
    QListViewItem *item=rdcart_macro_list->selectedItem();

    if((item==NULL)||(item->text(0).isEmpty())) {
        return;
    }
    DeleteLine(item);
    UpdateLength();
}
示例#6
0
void LineEdit::CutLine()
{
	if(IsReadOnly()) return;
	int b, e;
	if(GetSelection(b, e) && GetLine(b) != GetLine(e)) {
		Cut();
		return;
	}
	int i = GetLine(cursor);
	int p = GetPos(i);
	WString txt = Get(p, line[i].GetLength() + 1).ToWString();
	WriteClipboardUnicodeText(txt);
	AppendClipboardText(txt.ToString());
	ClearSelection();
	DeleteLine();
}
示例#7
0
main()
{
	char choice;
	Initial();
	while(1)
	{
		choice = MenuSelect();
		switch (choice)
		{
			case 1:EnterData();
				break;
			case 2:DeleteLine();
				break;
			case 3:List();
				break;
			case 4:exit(0);
		}
	}
}
示例#8
0
void CVoIPForm::LoadFormValuesFromDataL()
    {
    TInt pageId = ActivePageId();

    // Delete all controls not saved.

    RArray<CEikCaptionedControl*> aControls;

    ControlsOnPage(aControls, pageId);

    for (TInt i = 0; i < aControls.Count(); i++)
        {
        CEikCaptionedControl* control =
                ((CEikCaptionedControl*) aControls[i]);
        DeleteLine(control->iId, EFalse);
        }

    aControls.Reset();

    // Create controls based on PhoneBook contact item.

    CVoIPAppUi* iAppUi = static_cast<CVoIPAppUi*> (iEikonEnv->EikAppUi());
    CVoIPDocument* iDocument =
            static_cast<CVoIPDocument*> (iAppUi->Document());

    TInt iModifyIndex = iDocument->ModifyIndex();
    RPointerArray<CContact> contacts = iAppUi->GetPhoneBook()->GetContactsL();

    if (iModifyIndex >= 0)
        {
        CContact* contact = contacts[iModifyIndex];

        if (contact)
            {
            CPbkContactItem* contactItem =
                    iAppUi->GetPhoneBook()->ReadContactItemLC(
                            contact->GetEntryId());

            CPbkFieldArray& fieldArray = contactItem->CardFields();

            for (TInt i = 0; i < fieldArray.Count(); i++)
                {
                TPbkContactItemField field = fieldArray[i];
                if (field.IsEmpty() == EFalse)
                    {
                    CPbkFieldInfo& fieldInfo = field.FieldInfo();
                    TInt id = fieldInfo.FieldId();
                    TAny* unused = 0;

                    if (fieldInfo.CtrlType() == EPbkFieldCtrlTypeTextEditor)
                        {
                        TInt type = EEikCtEdwin;

                        CEikEdwin * nEditor =
                                static_cast<CEikEdwin*> (ControlOrNull(id));
                        if (!nEditor)
                            {
                            CEikEdwin* edwin =
                                    (CEikEdwin*) CreateLineByTypeL(
                                            field.Label(), pageId, id, type,
                                            unused);

                            edwin->ConstructL(EEikEdwinNoHorizScrolling
                                    | EEikEdwinResizable, 10, 100, 1);

                            edwin->SetTextL(&(field.Text()));
                            }
                        }
                    else if (fieldInfo.CtrlType()
                            == EPbkFieldCtrlTypeNumberEditor)
                        {
                        TInt type = EAknCtIntegerEdwin;

                        CAknNumericEdwin
                                * nEditor =
                                        static_cast<CAknNumericEdwin*> (ControlOrNull(
                                                id));
                        if (!nEditor)
                            {
                            CAknNumericEdwin* edwin =
                                    (CAknNumericEdwin*) CreateLineByTypeL(
                                            field.Label(), pageId, id, type,
                                            unused);

                            edwin->ConstructL(EEikEdwinNoHorizScrolling
                                    | EEikEdwinResizable, 10, 100, 1);

                            edwin->SetTextL(&(field.Text()));
                            }
                        }
                    else if (fieldInfo.CtrlType()
                            == EPbkFieldCtrlTypeDateEditor)
                        {
                        TInt type = EEikCtDateEditor;

                        CEikDateEditor * nEditor =
                                static_cast<CEikDateEditor*> (ControlOrNull(
                                        id));
                        if (!nEditor)
                            {
                            CEikDateEditor* editor =
                                    (CEikDateEditor*) CreateLineByTypeL(
                                            field.Label(), pageId, id, type,
                                            unused);

                            editor->ConstructL(TTime(mindateTime), TTime(
                                    maxdateTime),
                                    field.DateTimeStorage()->Time(), ETrue);
                            }
                        Line(id)->ActivateL();
                        }
                    }
                }
            SetChangesPending(ETrue);
            UpdatePageL(ETrue);
            CleanupStack::PopAndDestroy(); //contactItem
            }
        }
    }
示例#9
0
void CTetrisGame::OnBrickDoneMove()
{
	//处理非特殊方块以及点特殊方块
	if (m_iCurShape < 19 || m_iCurShape == 22)
	{
		if (m_iCurShape == 22)
		{
			//设置行索引
			m_stCurPos.m_iRowIdx = GetEmptyPosRowIdx();
		}

		//已无法再往下移动或已到达最后一行,保存当前方块
		for (int i = 0; i < 4 && m_stCurPos.m_iRowIdx + i < ROW_NUM; ++i)
		{
			for (int j = 0; j < 4 && m_stCurPos.m_iColIdx + j < COLUMN_NUM; ++j)
			{
				if (TETRIS_SHAPE[m_iCurShape][i][j])
				{
					m_arrBrick[m_stCurPos.m_iRowIdx + i][m_stCurPos.m_iColIdx + j] = true;
				}
			}
		}
	}
	else
	{
		//如果是爆炸方块,消除底下的指定行数
		if (m_iCurShape == 21)
		{
			int iStartRowIdx = m_stCurPos.m_iRowIdx;
			int iEndRowIdx = iStartRowIdx + TETRIS_ROWCOUNT[m_iCurShape] + BOMB_DELETE_LINE_COUNT + (m_bFastMoveDown ? m_iSpeed / 4 + 1 : 0);
			iEndRowIdx = (iEndRowIdx > ROW_NUM ? ROW_NUM : iEndRowIdx);
			for (int i = iStartRowIdx; i < iEndRowIdx; ++i)
			{
				for (int j = m_stCurPos.m_iColIdx; j < m_stCurPos.m_iColIdx + TETRIS_COLCOUNT[m_iCurShape]; ++j)
				{
					m_arrBrick[i][j] = false;
					m_pGameScene->UpdateBrick(i, j, false, false);
				}
			}

			//音效
			PLAY_EFFECT(EFFECT_BOOM);

			//更新炸弹位置,需要显示在最底下消除的那一行
			//修改:炸弹改为3行,但爆炸时需要显示四行,所以需要上移一行
			m_stCurPos.m_iRowIdx = iEndRowIdx - TETRIS_ROWCOUNT[m_iCurShape] - 1;

			//进入暂停状态
			m_enGameState = GAMESTATE_PAUSE;
			m_iSelfFlashCount = 0;
			return;
		}
	}

	//检查消行
	if (!DeleteLine(true) && m_iCurShape < 19)
	{
		PLAY_EFFECT(EFFECT_ADD);
	}

	//产生新的方块
	RandNewShape();
}
示例#10
0
void CTetrisGame::OnFireBtnPressed()
{
	PLAY_EFFECT(EFFECT_CHANGE2);

	//处理特殊方块
	if (m_iCurShape == 19 || m_iCurShape == 20)
	{
		bool bAddFlag = (m_iCurShape == 19);

		//获取当前位置对应列包含的方块数量
		int iRowIdx = GetNextAddOrSubRowIdx(m_stCurPos.m_iColIdx);
		
		//要操作的方块位置
		iRowIdx += (bAddFlag ? -1 : 0);
		if (iRowIdx < m_stCurPos.m_iRowIdx + TETRIS_ROWCOUNT[m_iCurShape] || iRowIdx > ROW_NUM - 1)
		{
			return;
		}
		int iColIdx = m_stCurPos.m_iColIdx;

		//设置状态
		m_arrBrick[iRowIdx][iColIdx] = bAddFlag;
		m_pGameScene->UpdateBrick(iRowIdx, iColIdx, false, bAddFlag);

		//如果是加方块,需要检查是否可以消除行
		if (bAddFlag)
		{
			DeleteLine(false);
		}

		return;
	}


	//检查当前形状所属类型
	int iAllTypeCount = sizeof(TETRIS_TYPE_START_IDX) / sizeof(int);
	int iStartIdx = TETRIS_TYPE_START_IDX[iAllTypeCount - 1];
	int iEndIdx = GetShapeCount();
	for (int i = 0; i < iAllTypeCount; ++i)
	{
		if (m_iCurShape < TETRIS_TYPE_START_IDX[i])
		{
			iStartIdx = TETRIS_TYPE_START_IDX[i - 1];
			iEndIdx = TETRIS_TYPE_START_IDX[i];
			break;
		}
	}
	
	int iShape = m_iCurShape;
	if (++iShape >= iEndIdx)
	{
		iShape = iStartIdx;
	}

	//检查是否可以变换
	if (CheckBrickPos(iShape, m_stCurPos.m_iRowIdx, m_stCurPos.m_iColIdx))
	{
		//更新当前形状
		m_iCurShape = iShape;

		//位置修正
		if (m_stCurPos.m_iColIdx + TETRIS_COLCOUNT[m_iCurShape] > COLUMN_NUM)
		{
			m_stCurPos.m_iColIdx = COLUMN_NUM - TETRIS_COLCOUNT[m_iCurShape];
		}

		//更新显示
		m_pGameScene->UpdateBricks(m_stCurPos.m_iRowIdx, m_stCurPos.m_iColIdx,
			m_stCurPos.m_iRowIdx + 4, m_stCurPos.m_iColIdx + 4);
	}
}
示例#11
0
int ValidateWorldLinks( INDEX iWorld )
{
	GETWORLD(iWorld);
	int status = TRUE;
	int nLines;
	PFLATLAND_MYLINESEG *pLines;
	int nWalls;
	PWALL *pWalls;
	int nSectors;
	PSECTOR *pSectors;
	int nNames;
	PNAME *pNames;
	pSectors = GetLinearSectorArray( world->sectors, &nSectors );
	pWalls = GetLinearWallArray( world->walls, &nWalls );
	pLines = GetLinearLineArray( world->lines, &nLines );
	pNames = GetLinearNameArray( world->names, &nNames );
	{
   	int n, m, refcount;
		for( n = 0; n < nLines; n++ )
		{
			refcount = 0;
			for( m = 0; m < nWalls; m++ )
			{
				if( GetLine( pWalls[m]->iLine ) == pLines[n] )
				{
					if( pWalls[m]->iWallInto != INVALID_INDEX )
					{
						refcount++;
						if( refcount == 2 )
						{
							//pLines[n] = NULL;
							break;
						}
					}
				}
				else
				{
					//pLines[n] = NULL;
					break;
				}
			}
			if( m == nWalls )
			{
				status = FALSE;
				Log1( "Line %08x is unreferenced... deleting now.", pLines[n] );
				DeleteLine( world->lines, pLines[n] );
				pLines[n] = NULL;
			}
		}
		for( n = 0; n < nWalls; n++ )
		{
			if( !pWalls[n] )
				continue;
			for( m = 0; m < nLines; m++ )
			{
				if( GetLine( pWalls[n]->iLine ) == pLines[m] )
				{
					// if this line is shared - remove the other reference to it.
					/*
					if( pWalls[n]->wall_into )
					{
						int i;
						for( i = 0; i < nWalls; i++ )
						{
							if( pWalls[i] == pWalls[n]->wall_into )
								pWalls[i] = NULL;
						}
					}
					pLines[m] = NULL; // clear line reference...
					*/
					break;
				}
			}
			if( m == nLines )
			{
				status = FALSE;
				Log3( "Wall %08x in Sector %d referenced line %08x that does not exist", 
							pWalls[n], GetSector( pWalls[n]->iSector )->iName, pWalls[n]->iLine );
			}
		}
		for( n = 0; n < nLines; n++ )
		{
			int count = 0;
			if( !pLines[n]->refcount )
				Log( "Line exists with no reference count" );
			for( m = 0; m < nWalls; m++ )
			{
				if( GetLine( pWalls[m]->iLine ) == pLines[n] )
				{
					count++;
				}
			}
			if( count != pLines[n]->refcount )
			{
				Log2( "Line reference count of %d does not match actual %d"
							, pLines[n]->refcount
							, count );
			}
		}
		for( n = 0; n < nSectors; n++ )
		{
			PWALL pStart, pCur;
			int priorend = TRUE;
			if( pSectors[n]->iName != INVALID_INDEX )
			{
				int i;
				for( i = 0; i < nNames; i++ )
				{
					if( GetName( pSectors[n]->iName ) == pNames[i] )
						break;
				}
				if( i == nNames )
				{
					Log2( "Name %08x referenced by Sector %d does not exist", pSectors[n]->iName, n );
				}
			}

			pCur = pStart = GetWall( pSectors[n]->iWall );
			do
			{
				if( pCur->iLine == INVALID_INDEX )
				{
					Log1( "Wall in sector %d has an invalid line def", pSectors[n]->iName );
				}
				
				for( m = 0; m < nWalls; m++ )
				{
					if( pWalls[m] == pCur )
						break;
				}
				if( m == nWalls )
				{
					status = FALSE;
					Log4( "Sector %*.*s referenced wall %08x that does not exist",
								GetName( pSectors[n]->iName )->name[0].length,
								GetName( pSectors[n]->iName )->name[0].length,
								GetName( pSectors[n]->iName )->name[0].name, pCur );
				}
				// code goes here....
				if( priorend )
				{
					priorend = pCur->flags.wall_start_end;
					pCur = GetWall( pCur->iWallStart );
				}
				else
				{
					priorend = pCur->flags.wall_end_end;
					pCur = GetWall( pCur->iWallEnd );
				}
			}while( pCur != pStart );
		}
	}
	Release( pLines );
	Release( pWalls );
	Release( pSectors );
	Release( pNames );
	return status;
}
示例#12
0
/**
 * CFootyDoc::OnBackSpace
 * @brief BackSpaceキーが押されたときの処理を行います。
 * @return どのように再描画するのか
 * @note 適切な位置へキャレットが移動します。
 */
CFootyDoc::RedrawType CFootyDoc::OnBackSpace()
{
	// 宣言
	LinePt pLine = m_cCaretPos.GetLinePointer();
	size_t nPos = m_cCaretPos.GetPosition();
	CUndoBuffer cUndo;
	RedrawType nType;
	
	if ( IsReadOnly() ) return REDRAW_FAILED;
	
	// 場合分け
	if (IsSelecting())
	{
		nType = DeleteSelected(&cUndo);
		PushBackUndo(&cUndo);
		return nType;
	}
	else	// 選択していないとき
	{
		if (nPos != 0)			// 文字を削除
		{
			bool bIsSurrogatePair = CFootyLine::IsSurrogateTail(pLine->GetLineData()[nPos-1]);
			RedrawType nNeedRedraw = REDRAW_LINE;
			
			// アンドゥ情報を代入する
			cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_DELETE;
			if (bIsSurrogatePair)
				cUndo.m_strBefore = pLine->m_strLineData.substr(nPos-2,2);
			else	
				cUndo.m_strBefore = pLine->m_strLineData.substr(nPos-1,1);
			cUndo.m_cBeforeEnd = m_cCaretPos;
			
			// 文字列を削除する
			if (bIsSurrogatePair)
				pLine->m_strLineData.erase(nPos-2,2);
			else
				pLine->m_strLineData.erase(nPos-1,1);
			size_t nBeforeEthic = pLine->GetEthicLine();
			if (SetLineInfo(pLine, false/*改行を含むか by Tetr@pod*/))
				nNeedRedraw = REDRAW_ALL;
			if (nBeforeEthic != pLine->GetEthicLine())
				nNeedRedraw = REDRAW_ALL;
			
			// ポジションを移動して
			if (bIsSurrogatePair)
				m_cCaretPos.MoveColumnBackward(&m_lsLines,2);
			else
				m_cCaretPos.MoveColumnBackward(&m_lsLines,1);
			
			// アンドゥ情報を格納する
			cUndo.m_cBeforeStart = m_cCaretPos;
			PushBackUndo(&cUndo);
			SendMoveCaretCallBack();
			return nNeedRedraw;
		}
		else					// 改行を削除
		{
			if (pLine != m_lsLines.begin())
			{
				// 次の行ポインタ取得
				LinePt pPrevLine = pLine;
				pPrevLine--;

				// アンドゥ情報を代入しつつキャレット位置を移動する
				cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_DELETE;
				cUndo.m_strBefore = L"\r\n";
				cUndo.m_cBeforeEnd = m_cCaretPos;
				m_cCaretPos.MoveColumnBackward(&m_lsLines,1);
				cUndo.m_cBeforeStart = m_cCaretPos;
				PushBackUndo(&cUndo);

				// 行の結合
				pPrevLine->m_strLineData += pLine->GetLineData();

				// 現在の位置を削除する
				DeleteLine(pLine);

				// 情報を更新する
				LinePt pNextLine = pPrevLine;
				pNextLine++;      
				SetLineInfo(pPrevLine,pNextLine, false);  

				SendMoveCaretCallBack();
				return REDRAW_ALL;
			}
			else return REDRAW_NONE;
		}
	}
}
BLID_t ButcherProjectMaskContainerJoined::InternalRemoveLine(ButcherProjectLine *line,
    bool doremove)
{
    // prevent sending modified event until return
    ButcherProjectBaseAutoUpdate autoupdln(&lines_);
    ButcherProjectBaseAutoUpdate autoupdar(&areas_);

    BLID_t ret=0;
    if (line->CanEdit()) {
        ButcherProjectLine::ButcherProjectLineAreas::iterator areai;

        ButcherProjectLine::ButcherProjectLineAreas *a[2] = { &line->areas_before_, &line->areas_after_ };

        // for all connected areas, find and remove lines that start/end on this line
        ButcherListIdList rmlist;

        for (int al=0; al<2; al++) {
            if (!a[al]->empty())
                for (areai=a[al]->begin(); areai!=a[al]->end(); areai++)
                {
                    for (int arealn=0; arealn<(*areai)->GetLineCount(); arealn++)
                    {
                        if ((*areai)->GetLine(arealn)->Connected(line))
                            rmlist.insert((*areai)->GetLine(arealn)->GetBLId());
                    }
                }
        }
        ret=static_cast<BLID_t>(rmlist.size());

        if (!rmlist.empty())
            for (ButcherListIdList::const_iterator rmi=rmlist.begin(); rmi!=rmlist.end(); rmi++)
            {
                if (doremove)
                    DeleteLine(lines_.Get(*rmi));
                ret++;
            }

        // merge areas
        if (doremove)
            // join "before" areas with "after" ones
            if (!line->areas_before_.empty())
            {
                ButcherProjectArea* joina;
                for (areai=line->areas_before_.begin(); areai!=line->areas_before_.end(); areai++)
                {
                    joina=line->FindJoinArea(ButcherProjectLine::LAP_AFTER, *areai);
                    if (joina)
                    {
                        // "before" area end will be "after" area end
                        (*areai)->SetEnd(joina->GetEnd(line->GetOrientation()));
                        (*areai)->GetEnd(line->GetOrientation())->areas_before_.erase(joina);
                        (*areai)->GetEnd(line->GetOrientation())->areas_before_.insert(*areai);

                        // remove join area from bordering lines
                        (*areai)->GetStart(line->GetInvOrientation())->areas_after_.erase(joina);
                        (*areai)->GetEnd(line->GetInvOrientation())->areas_before_.erase(joina);

                        areas_.op_delete(joina->GetBLId());
                    } else
                        throw ButcherException(_("Could not find join area"));
                }
            }
    }
    return ret;
}