/* フォーカス移動時の再描画

	@date 2001/06/21 asa-o 「スクロールバーの状態を更新する」「カーソル移動」削除
*/
void CEditView::RedrawAll()
{
	if( NULL == GetHwnd() ){
		return;
	}
	
	if( GetDrawSwitch() ){
		// ウィンドウ全体を再描画
		PAINTSTRUCT	ps;
		HDC hdc = ::GetDC( GetHwnd() );
		::GetClientRect( GetHwnd(), &ps.rcPaint );
		OnPaint( hdc, &ps, FALSE );
		::ReleaseDC( GetHwnd(), hdc );
	}

	// キャレットの表示
	GetCaret().ShowEditCaret();

	// キャレットの行桁位置を表示する
	GetCaret().ShowCaretPosInfo();

	// 親ウィンドウのタイトルを更新
	m_pcEditWnd->UpdateCaption();

	//	Jul. 9, 2005 genta	選択範囲の情報をステータスバーへ表示
	GetSelectionInfo().PrintSelectionInfoMsg();

	// スクロールバーの状態を更新する
	AdjustScrollBars();
}
/*!
	@date 2003/02/18 ai
	@param flag [in] モード(true:登録, false:解除)
*/
void CEditView::SetBracketPairPos( bool flag )
{
	int	mode;

	// 03/03/06 ai すべて置換、すべて置換後のUndo&Redoがかなり遅い問題に対応
	if( m_bDoing_UndoRedo || !GetDrawSwitch() ){
		return;
	}

	if( !m_pTypeData->m_ColorInfoArr[COLORIDX_BRACKET_PAIR].m_bDisp ){
		return;
	}

	// 対括弧の検索&登録
	/*
	bit0(in)  : 表示領域外を調べるか? 0:調べない  1:調べる
	bit1(in)  : 前方文字を調べるか?   0:調べない  1:調べる
	bit2(out) : 見つかった位置         0:後ろ      1:前
	*/
	mode = 2;

	CLayoutPoint ptColLine;

	if( flag && !GetSelectionInfo().IsTextSelected() && !GetSelectionInfo().m_bDrawSelectArea
		&& SearchBracket( GetCaret().GetCaretLayoutPos(), &ptColLine, &mode ) )
	{
		// 登録指定(flag=true)			&&
		// テキストが選択されていない	&&
		// 選択範囲を描画していない		&&
		// 対応する括弧が見つかった		場合
		if ( ( ptColLine.x >= GetTextArea().GetViewLeftCol() ) && ( ptColLine.x <= GetTextArea().GetRightCol() )
			&& ( ptColLine.y >= GetTextArea().GetViewTopLine() ) && ( ptColLine.y <= GetTextArea().GetBottomLine() ) )
		{
			// 表示領域内の場合

			// レイアウト位置から物理位置へ変換(強調表示位置を登録)
			m_pcEditDoc->m_cLayoutMgr.LayoutToLogic( ptColLine, &m_ptBracketPairPos_PHY );
			m_ptBracketCaretPos_PHY.y = GetCaret().GetCaretLogicPos().y;
			if( 0 == ( mode & 4 ) ){
				// カーソルの後方文字位置
				m_ptBracketCaretPos_PHY.x = GetCaret().GetCaretLogicPos().x;
			}else{
				// カーソルの前方文字位置
				m_ptBracketCaretPos_PHY.x = GetCaret().GetCaretLogicPos().x - 1;
			}
			return;
		}
	}

	// 括弧の強調表示位置情報初期化
	m_ptBracketPairPos_PHY.Set(CLogicInt(-1), CLogicInt(-1));
	m_ptBracketCaretPos_PHY.Set(CLogicInt(-1), CLogicInt(-1));

	return;
}
Ejemplo n.º 3
0
//! 前のブックマークを探し,見つかったら移動する.
void CViewCommander::Command_FUNCLIST_PREV(void)
{

	CLogicPoint	ptXY(0,GetCaret().GetCaretLogicPos().y);
	int			nYOld = ptXY.y;

	for(int n = 0; n < 2; n++){
		if(CFuncListManager().SearchFuncListMark(&GetDocument()->m_cDocLineMgr,
				ptXY.GetY2(), SEARCH_BACKWARD, &ptXY.y)){
			CLayoutPoint ptLayout;
			GetDocument()->m_cLayoutMgr.LogicToLayout(ptXY,&ptLayout);
			m_pCommanderView->MoveCursorSelecting( ptLayout,
				m_pCommanderView->GetSelectionInfo().m_bSelectingLock );
			if( nYOld <= ptXY.y ){
				m_pCommanderView->SendStatusMessage(LS(STR_ERR_SRPREV1));
			}
			return;
		}
		if( !GetDllShareData().m_Common.m_sSearch.m_bSearchAll ){
			break;
		}
		ptXY.y= GetDocument()->m_cDocLineMgr.GetLineCount();
	}
	m_pCommanderView->SendStatusMessage(LS(STR_ERR_SRPREV2));
	AlertNotFound( m_pCommanderView->GetHwnd(), false, LS(STR_FUCLIST_PREV_NOT_FOUND) );
	return;
}
Ejemplo n.º 4
0
void
wxLayoutWindow::Clear(int family,
    int size,
    int style,
    int weight,
    int underline,
    wxColour *fg,
    wxColour *bg)
{
    GetLayoutList()->Clear(family,size,style,weight,underline,fg,bg);
    SetBackgroundColour(GetLayoutList()->GetDefaultStyleInfo().GetBGColour());
    //wxScrolledWindow::Clear();
    ResizeScrollbars(true);
    SetDirty();
    SetModified(false);
    if ( m_Editable )
        m_CursorVisibility = 1;

#ifdef WXLAYOUT_USE_CARET
    if ( m_CursorVisibility == 1 )
        GetCaret()->Show();
#endif // WXLAYOUT_USE_CARET

    RequestUpdate((wxRect *)NULL);
}
Ejemplo n.º 5
0
//	from CViewCommander_New.cpp
//! ブックマークの設定・解除を行う(トグル動作)
void CViewCommander::Command_BOOKMARK_SET(void)
{
	CDocLine*	pCDocLine;
	if( m_pCommanderView->GetSelectionInfo().IsTextSelected() && m_pCommanderView->GetSelectionInfo().m_sSelect.GetFrom().y<m_pCommanderView->GetSelectionInfo().m_sSelect.GetTo().y ){
		CLogicPoint ptFrom;
		CLogicPoint ptTo;
		GetDocument()->m_cLayoutMgr.LayoutToLogic(
			CLayoutPoint(CLayoutInt(0), m_pCommanderView->GetSelectionInfo().m_sSelect.GetFrom().y),
			&ptFrom
		);
		GetDocument()->m_cLayoutMgr.LayoutToLogic(
			CLayoutPoint(CLayoutInt(0), m_pCommanderView->GetSelectionInfo().m_sSelect.GetTo().y  ),
			&ptTo
		);
		for(CLogicInt nY=ptFrom.GetY2();nY<=ptTo.y;nY++){
			pCDocLine=GetDocument()->m_cDocLineMgr.GetLine( nY );
			CBookmarkSetter cBookmark(pCDocLine);
			if(pCDocLine)cBookmark.SetBookmark(!cBookmark.IsBookmarked());
		}
	}
	else{
		pCDocLine=GetDocument()->m_cDocLineMgr.GetLine( GetCaret().GetCaretLogicPos().GetY2() );
		CBookmarkSetter cBookmark(pCDocLine);
		if(pCDocLine)cBookmark.SetBookmark(!cBookmark.IsBookmarked());
	}

	// 2002.01.16 hor 分割したビューも更新
	GetEditWindow()->Views_Redraw();
}
Ejemplo n.º 6
0
void wxWindowMGL::HandlePaint(MGLDevCtx *dc)
{
    if ( IsFrozen() )
    {
        // Don't paint anything if the window is frozen.
        m_refreshAfterThaw = true;
        return;
    }

#if wxDEBUG_LEVEL >= 2
    // FIXME_MGL -- debugging stuff, to be removed!
    static int debugPaintEvents = -1;
    if ( debugPaintEvents == -1 )
        debugPaintEvents = wxGetEnv(wxT("WXMGL_DEBUG_PAINT_EVENTS"), NULL);
    if ( debugPaintEvents )
    {
        dc->setColorRGB(255,0,255);
        dc->fillRect(-1000,-1000,2000,2000);
        wxMilliSleep(50);
    }
#endif // wxDEBUG_LEVEL >= 2

    MGLRegion clip;
    dc->getClipRegion(clip);
    m_updateRegion = wxRegion(clip);
    m_paintMGLDC = dc;

#if wxUSE_CARET
    // must hide caret temporarily, otherwise we'd get rendering artifacts
    wxCaret *caret = GetCaret();
    if ( caret )
        caret->Hide();
#endif // wxUSE_CARET

    if ( m_eraseBackground != 0 )
    {
        wxWindowDC dc((wxWindow*)this);
        wxEraseEvent eventEr(m_windowId, &dc);
        eventEr.SetEventObject(this);
        HandleWindowEvent(eventEr);
    }
    m_eraseBackground = -1;

    wxNcPaintEvent eventNc(GetId());
    eventNc.SetEventObject(this);
    HandleWindowEvent(eventNc);

    wxPaintEvent eventPt(GetId());
    eventPt.SetEventObject(this);
    HandleWindowEvent(eventPt);

#if wxUSE_CARET
    if ( caret )
        caret->Show();
#endif // wxUSE_CARET

    m_paintMGLDC = NULL;
    m_updateRegion.Clear();
}
void CEditView::DrawBracketCursorLine(bool bDraw)
{
	if( bDraw ){
		GetCaret().m_cUnderLine.CaretUnderLineON(true, true);
		DrawBracketPair(false);
		SetBracketPairPos(true);
		DrawBracketPair(true);
	}
}
Ejemplo n.º 8
0
/* 現在位置の単語選択 */
bool CViewCommander::Command_SELECTWORD( CLayoutPoint* pptCaretPos )
{
	CLayoutRange sRange;
	CLogicInt	nIdx;
	if( m_pCommanderView->GetSelectionInfo().IsTextSelected() ){	/* テキストが選択されているか */
		/* 現在の選択範囲を非選択状態に戻す */
		m_pCommanderView->GetSelectionInfo().DisableSelectArea( true );
	}
	CLayoutPoint ptCaretPos = (NULL == pptCaretPos ? GetCaret().GetCaretLayoutPos() : *pptCaretPos);
	const CLayout*	pcLayout = GetDocument()->m_cLayoutMgr.SearchLineByLayoutY( ptCaretPos.GetY2() );
	if( NULL == pcLayout ){
		return false;	//	単語選択に失敗
	}
	/* 指定された桁に対応する行のデータ内の位置を調べる */
	nIdx = m_pCommanderView->LineColumnToIndex( pcLayout, ptCaretPos.GetX2() );

	/* 現在位置の単語の範囲を調べる */
	if( GetDocument()->m_cLayoutMgr.WhereCurrentWord(	ptCaretPos.GetY2(), nIdx, &sRange, NULL, NULL ) ){

		// 指定された行のデータ内の位置に対応する桁の位置を調べる
		// 2007.10.15 kobake 既にレイアウト単位なので変換は不要
		/*
		pcLayout = GetDocument()->m_cLayoutMgr.SearchLineByLayoutY( sRange.GetFrom().GetY2() );
		sRange.SetFromX( m_pCommanderView->LineIndexToColumn( pcLayout, sRange.GetFrom().x ) );
		pcLayout = GetDocument()->m_cLayoutMgr.SearchLineByLayoutY( sRange.GetTo().GetY2() );
		sRange.SetToX( m_pCommanderView->LineIndexToColumn( pcLayout, sRange.GetTo().x ) );
		*/

		/* 選択範囲の変更 */
		//	2005.06.24 Moca
		m_pCommanderView->GetSelectionInfo().SetSelectArea( sRange );
		/* 選択領域描画 */
		m_pCommanderView->GetSelectionInfo().DrawSelectArea();

		/* 単語の先頭にカーソルを移動 */
		GetCaret().MoveCursor( sRange.GetTo(), true );
		GetCaret().m_nCaretPosX_Prev = GetCaret().GetCaretLayoutPos().GetX2();

		return true;	//	単語選択に成功。
	}
	else {
		return false;	//	単語選択に失敗
	}
}
Ejemplo n.º 9
0
void wxHexDataPanel::OnChar(wxKeyEvent &evt)
{
	switch (evt.GetKeyCode())
	{
	case WXK_LEFT:
		break;

	case WXK_RIGHT:
		{
			wxPoint caretPos = GetCaret()->GetPosition();
			caretPos.x += 20;
			GetCaret()->Move(caretPos);
		}
		break;

	default:
		break;
	}
}
Ejemplo n.º 10
0
/*!	1行選択
	@brief カーソル位置を1行選択する
	@param lparam [in] マクロから使用する拡張フラグ(拡張用に予約)

	note 改行単位で選択を行う。

	@date 2007.11.15 nasukoji	新規作成
*/
void CViewCommander::Command_SELECTLINE( int lparam )
{
	// 改行単位で1行選択する
	Command_GOLINETOP( false, 0x9 );	// 物理行頭に移動

	m_pCommanderView->GetSelectionInfo().m_bBeginLineSelect = true;		// 行単位選択中

	CLayoutPoint ptCaret;

	// 最下行(物理行)でない
	if(GetCaret().GetCaretLogicPos().y < GetDocument()->m_cDocLineMgr.GetLineCount() ){
		// 1行先の物理行からレイアウト行を求める
		GetDocument()->m_cLayoutMgr.LogicToLayout( CLogicPoint(0, GetCaret().GetCaretLogicPos().y + 1), &ptCaret );

		// カーソルを次の物理行頭へ移動する
		m_pCommanderView->MoveCursorSelecting( ptCaret, TRUE );

		// 移動後のカーソル位置を取得する
		ptCaret = GetCaret().GetCaretLayoutPos().Get();
	}else{
		// カーソルを最下行(レイアウト行)へ移動する
		m_pCommanderView->MoveCursorSelecting( CLayoutPoint(CLayoutInt(0), GetDocument()->m_cLayoutMgr.GetLineCount()), TRUE );
		Command_GOLINEEND( true, 0, 0 );	// 行末に移動

		// 選択するものが無い([EOF]のみの行)時は選択状態としない
		if(( ! m_pCommanderView->GetSelectionInfo().IsTextSelected() )&&
		   ( GetCaret().GetCaretLogicPos().y >= GetDocument()->m_cDocLineMgr.GetLineCount() ))
		{
			// 現在の選択範囲を非選択状態に戻す
			m_pCommanderView->GetSelectionInfo().DisableSelectArea( true );
		}
	}

	if( m_pCommanderView->GetSelectionInfo().m_bBeginLineSelect ){
		// 範囲選択開始行・カラムを記憶
		m_pCommanderView->GetSelectionInfo().m_sSelect.SetTo( ptCaret );
		m_pCommanderView->GetSelectionInfo().m_sSelectBgn.SetTo( ptCaret );
	}

	return;
}
Ejemplo n.º 11
0
void DocEdit::PlaceCaret(bool scroll) {
	Point cr = GetCaret(cursor);
	int fy = font.Info().GetLineHeight();
	if(scroll) {
		if(cursor == total)
			sb.End();
		else
			sb.ScrollInto(cr.y, fy + 2);
	}
	SetCaret(cr.x + 1, cr.y - sb, 1, fy);
	WhenSel();
}
Ejemplo n.º 12
0
/* すべて選択 */
void CViewCommander::Command_SELECTALL( void )
{
	if( m_pCommanderView->GetSelectionInfo().IsTextSelected() ){	/* テキストが選択されているか */
		/* 現在の選択範囲を非選択状態に戻す */
		m_pCommanderView->GetSelectionInfo().DisableSelectArea( true );
	}

	/* 先頭へカーソルを移動 */
	//	Sep. 8, 2000 genta
	m_pCommanderView->AddCurrentLineToHistory();
	GetCaret().m_nCaretPosX_Prev = GetCaret().GetCaretLayoutPos().GetX2();

	//	Jul. 29, 2006 genta 選択位置の末尾を正確に取得する
	//	マクロから取得した場合に正しい範囲が取得できないため
	//int nX, nY;
	CLayoutRange sRange;
	sRange.SetFrom(CLayoutPoint(0,0));
	GetDocument()->m_cLayoutMgr.GetEndLayoutPos(sRange.GetToPointer());
	m_pCommanderView->GetSelectionInfo().SetSelectArea( sRange );

	/* 選択領域描画 */
	m_pCommanderView->GetSelectionInfo().DrawSelectArea(false);
}
Ejemplo n.º 13
0
void wxWindowMGL::SetFocus()
{
    if ( gs_focusedWindow == this ) return;

    wxWindowMGL *oldFocusedWindow = gs_focusedWindow;

    if ( gs_focusedWindow )
    {
        gs_toBeFocusedWindow = (wxWindow*)this;
        gs_focusedWindow->KillFocus();
        gs_toBeFocusedWindow = NULL;
    }

    gs_focusedWindow = this;

    MGL_wmCaptureEvents(GetHandle(), EVT_KEYEVT, wxMGL_CAPTURE_KEYB);

    wxWindowMGL *active = wxGetTopLevelParent(this);
    if ( !(m_windowStyle & wxPOPUP_WINDOW) && active != gs_activeFrame )
    {
        if ( gs_activeFrame )
        {
            wxActivateEvent event(wxEVT_ACTIVATE, false, gs_activeFrame->GetId());
            event.SetEventObject(gs_activeFrame);
            gs_activeFrame->HandleWindowEvent(event);
        }

        gs_activeFrame = active;
        wxActivateEvent event(wxEVT_ACTIVATE, true, gs_activeFrame->GetId());
        event.SetEventObject(gs_activeFrame);
        gs_activeFrame->HandleWindowEvent(event);
    }

    // notify the parent keeping track of focus for the kbd navigation
    // purposes that we got it
    wxChildFocusEvent eventFocus((wxWindow*)this);
    HandleWindowEvent(eventFocus);

    wxFocusEvent event(wxEVT_SET_FOCUS, GetId());
    event.SetEventObject(this);
    event.SetWindow((wxWindow*)oldFocusedWindow);
    HandleWindowEvent(event);

#if wxUSE_CARET
    // caret needs to be informed about focus change
    wxCaret *caret = GetCaret();
    if ( caret )
        caret->OnSetFocus();
#endif // wxUSE_CARET
}
Ejemplo n.º 14
0
void DocEdit::VertMove(int delta, bool select, bool scs) {
	int hy = GetY(para.GetCount());
	Point p = GetCaret(cursor);
	int yy = p.y;
	for(;;) {
		p.y += delta;
		if(p.y > hy) p.y = hy - 1;
		if(p.y < 0) p.y = 0;
		int q = GetCursorPos(p);
		if(q >= 0 && q != cursor && (delta < 0) == (q < cursor) && GetCaret(q).y != yy) {
			PlaceCaret(q, select);
			break;
		}
		if(p.y == 0 || p.y >= hy - 1) {
			PlaceCaret(delta > 0 ? total : 0, select);
			break;
		}
		delta = sgn(delta) * 4;
	}
	if(scs)
		sb = GetCaret(cursor).y - (yy - sb);
	PlaceCaret(true);
}
Ejemplo n.º 15
0
void DocEdit::DragAndDrop(Point p, PasteClip& d)
{
	if(IsReadOnly()) return;
	int c = GetMousePos(p);
	if(AcceptText(d)) {
		NextUndo();
		int a = sb;
		int sell, selh;
		WString txt = GetWString(d);
		if(GetSelection(sell, selh)) {
			if(c >= sell && c < selh) {
				if(!IsReadOnly())
					RemoveSelection();
				if(IsDragAndDropSource())
					d.SetAction(DND_COPY);
				c = sell;
			}
			else
			if(d.GetAction() == DND_MOVE && IsDragAndDropSource()) {
				if(c > sell)
					c -= selh - sell;
				if(!IsReadOnly())
					RemoveSelection();
				d.SetAction(DND_COPY);
			}
		}
		int count = Insert(c, txt);
		sb = a;
		SetFocus();
		SetSelection(c, c + count);
		Action();
		return;
	}
	if(!d.IsAccepted()) return;
	Point dc = Null;
	if(c >= 0) {
		Point cr = GetCaret(c);
		dc = Point(cr.x + 1, cr.y);
	}
	if(dc != dropcaret) {
		RefreshDropCaret();
		dropcaret = dc;
		RefreshDropCaret();
	}
}
Ejemplo n.º 16
0
void wxWindowDFB::SetFocus()
{
    if ( gs_focusedWindow == this )
        return; // nothing to do, focused already

    wxWindowDFB *oldFocusedWindow = gs_focusedWindow;

    if ( gs_focusedWindow )
    {
        gs_toBeFocusedWindow = (wxWindow*)this;
        gs_focusedWindow->DFBKillFocus();
        gs_toBeFocusedWindow = NULL;
    }

    gs_focusedWindow = this;

    if ( IsShownOnScreen() &&
         (!oldFocusedWindow || oldFocusedWindow->GetTLW() != m_tlw) )
    {
        m_tlw->SetDfbFocus();
    }
    // else: do nothing, because DirectFB windows cannot have focus if they
    //       are hidden; when the TLW becomes visible, it will set the focus
    //       to use from wxTLW::Show()

    // notify the parent keeping track of focus for the kbd navigation
    // purposes that we got it
    wxChildFocusEvent eventFocus((wxWindow*)this);
    HandleWindowEvent(eventFocus);

    wxFocusEvent event(wxEVT_SET_FOCUS, GetId());
    event.SetEventObject(this);
    event.SetWindow((wxWindow*)oldFocusedWindow);
    HandleWindowEvent(event);

#if wxUSE_CARET
    // caret needs to be informed about focus change
    wxCaret *caret = GetCaret();
    if ( caret )
        caret->OnSetFocus();
#endif // wxUSE_CARET
}
Ejemplo n.º 17
0
/* 範囲選択開始 */
void CViewCommander::Command_BEGIN_SELECT( void )
{
	if( !m_pCommanderView->GetSelectionInfo().IsTextSelected() ){	/* テキストが選択されているか */
		/* 現在のカーソル位置から選択を開始する */
		m_pCommanderView->GetSelectionInfo().BeginSelectArea();
	}

	//	ロックの解除切り替え
	if ( m_pCommanderView->GetSelectionInfo().m_bSelectingLock ) {
		m_pCommanderView->GetSelectionInfo().m_bSelectingLock = false;	/* 選択状態のロック解除 */
	}
	else {
		m_pCommanderView->GetSelectionInfo().m_bSelectingLock = true;	/* 選択状態のロック */
	}
	if( GetSelect().IsOne() ){
		GetCaret().m_cUnderLine.CaretUnderLineOFF(true);
	}
	m_pCommanderView->GetSelectionInfo().PrintSelectionInfoMsg();
	return;
}
/*!
	カーソル行をクリップボードにコピーする

	@date 2007.10.08 ryoji 新規(Command_COPY()から処理抜き出し)
*/
void CEditView::CopyCurLine(
	bool			bAddCRLFWhenCopy,		//!< [in] 折り返し位置に改行コードを挿入するか?
	EEolType		neweol,					//!< [in] コピーするときのEOL。
	bool			bEnableLineModePaste	//!< [in] ラインモード貼り付けを可能にする
)
{
	if( GetSelectionInfo().IsTextSelected() ){
		return;
	}

	const CLayout*	pcLayout = m_pcEditDoc->m_cLayoutMgr.SearchLineByLayoutY( GetCaret().GetCaretLayoutPos().y );
	if( NULL == pcLayout ){
		return;
	}

	/* クリップボードに入れるべきテキストデータを、cmemBufに格納する */
	CNativeW cmemBuf;
	cmemBuf.SetString( pcLayout->GetPtr(), pcLayout->GetLengthWithoutEOL() );
	if( pcLayout->GetLayoutEol().GetLen() != 0 ){
		cmemBuf.AppendString(
			( neweol == EOL_UNKNOWN ) ?
				pcLayout->GetLayoutEol().GetValue2() : CEol(neweol).GetValue2()
		);
	}else if( bAddCRLFWhenCopy ){	// 2007.10.08 ryoji bAddCRLFWhenCopy対応処理追加
		cmemBuf.AppendString(
			( neweol == EOL_UNKNOWN ) ?
				WCODE::CRLF : CEol(neweol).GetValue2()
		);
	}

	/* クリップボードにデータcmemBufの内容を設定 */
	BOOL bSetResult = MySetClipboardData(
		cmemBuf.GetStringPtr(),
		cmemBuf.GetStringLength(),
		false,
		bEnableLineModePaste
	);
	if( !bSetResult ){
		ErrorBeep();
	}
}
Ejemplo n.º 19
0
void wxWindowMGL::KillFocus()
{
    if ( gs_focusedWindow != this ) return;
    gs_focusedWindow = NULL;

    if ( m_isBeingDeleted ) return;

    MGL_wmUncaptureEvents(GetHandle(), wxMGL_CAPTURE_KEYB);

#if wxUSE_CARET
    // caret needs to be informed about focus change
    wxCaret *caret = GetCaret();
    if ( caret )
        caret->OnKillFocus();
#endif // wxUSE_CARET

    wxFocusEvent event(wxEVT_KILL_FOCUS, GetId());
    event.SetEventObject(this);
    event.SetWindow(gs_toBeFocusedWindow);
    HandleWindowEvent(event);
}
Ejemplo n.º 20
0
void wxWindowDFB::DFBKillFocus()
{
    wxCHECK_RET( gs_focusedWindow == this,
                 "killing focus on window that doesn't have it" );

    gs_focusedWindow = NULL;

    if ( m_isBeingDeleted )
        return; // don't send any events from dtor

#if wxUSE_CARET
    // caret needs to be informed about focus change
    wxCaret *caret = GetCaret();
    if ( caret )
        caret->OnKillFocus();
#endif // wxUSE_CARET

    wxFocusEvent event(wxEVT_KILL_FOCUS, GetId());
    event.SetEventObject(this);
    event.SetWindow(gs_toBeFocusedWindow);
    HandleWindowEvent(event);
}
Ejemplo n.º 21
0
void CLogTextCtrl::pushLog(const CMessage* log)
{
    this->Freeze();
    if (typeid(*log) == typeid(CChatMessage)){
        pushLog(dynamic_cast<const CChatMessage*>(log));
    } else if (typeid(*log) == typeid(CJoinMessage)){
        pushLog(dynamic_cast<const CJoinMessage*>(log));
    } else if (typeid(*log) == typeid(CPartMessage)){
        pushLog(dynamic_cast<const CPartMessage*> (log));
    } else if (typeid(*log) == typeid(CTopicMessage)){
        pushLog(dynamic_cast<const CTopicMessage*>(log));
    } else if (typeid(*log) == typeid(CMemberMessage)){
        pushLog(dynamic_cast<const CMemberMessage*>(log));
    } else if (typeid(*log) == typeid(CInviteMessage)){
        pushLog(dynamic_cast<const CInviteMessage*>(log));
    } else if (typeid(*log) == typeid(CKickMessage)){
        pushLog(dynamic_cast<const CKickMessage*>( log));
    }
    this->Newline();
    GetCaret()->Hide();
    this->Thaw();
}
Ejemplo n.º 22
0
/* 矩形範囲選択開始 */
void CViewCommander::Command_BEGIN_BOXSELECT( bool bSelectingLock )
{
	if( !GetDllShareData().m_Common.m_sView.m_bFontIs_FIXED_PITCH ){	/* 現在のフォントは固定幅フォントである */
		return;
	}

//@@@ 2002.01.03 YAZAKI 範囲選択中にShift+F6を実行すると選択範囲がクリアされない問題に対処
	if( m_pCommanderView->GetSelectionInfo().IsTextSelected() ){	/* テキストが選択されているか */
		/* 現在の選択範囲を非選択状態に戻す */
		m_pCommanderView->GetSelectionInfo().DisableSelectArea( true );
	}

	/* 現在のカーソル位置から選択を開始する */
	m_pCommanderView->GetSelectionInfo().BeginSelectArea();

	m_pCommanderView->GetSelectionInfo().m_bSelectingLock = bSelectingLock;	/* 選択状態のロック */
	m_pCommanderView->GetSelectionInfo().SetBoxSelect(true);	/* 矩形範囲選択中 */

	m_pCommanderView->GetSelectionInfo().PrintSelectionInfoMsg();
	GetCaret().m_cUnderLine.CaretUnderLineOFF(true);
	return;
}
Ejemplo n.º 23
0
//	from CViewCommander_New.cpp
//! 前のブックマークを探し,見つかったら移動する.
void CViewCommander::Command_BOOKMARK_PREV(void)
{
	int			nYOld;				// hor
	BOOL		bFound	=	FALSE;	// hor
	BOOL		bRedo	=	TRUE;	// hor

	CLogicPoint	ptXY(0,GetCaret().GetCaretLogicPos().y);
	CLogicInt tmp_y;

	nYOld=ptXY.y;						// hor

re_do:;								// hor
	if(CBookmarkManager(&GetDocument()->m_cDocLineMgr).SearchBookMark(ptXY.GetY2(), SEARCH_BACKWARD, &tmp_y)){
		ptXY.y = tmp_y;
		bFound = TRUE;				// hor
		CLayoutPoint ptLayout;
		GetDocument()->m_cLayoutMgr.LogicToLayout(ptXY,&ptLayout);
		//	2006.07.09 genta 新規関数にまとめた
		m_pCommanderView->MoveCursorSelecting( ptLayout, m_pCommanderView->GetSelectionInfo().m_bSelectingLock );
	}
    // 2002.01.26 hor
	if(GetDllShareData().m_Common.m_sSearch.m_bSearchAll){
		if(!bFound	&&	// 見つからなかった
			bRedo		// 最初の検索
		){
			// 2011.02.02 m_cLayoutMgr→m_cDocLineMgr
			ptXY.y= GetDocument()->m_cDocLineMgr.GetLineCount();	// 2002/06/01 MIK
			bRedo=FALSE;
			goto re_do;	// 末尾から再検索
		}
	}
	if(bFound){
		if(nYOld <= ptXY.y)m_pCommanderView->SendStatusMessage(LS(STR_ERR_SRPREV1));
	}else{
		m_pCommanderView->SendStatusMessage(LS(STR_ERR_SRPREV2));
		AlertNotFound( m_pCommanderView->GetHwnd(), false, LS(STR_BOOKMARK_PREV_NOT_FOUND) );
	}
	return;
}
Ejemplo n.º 24
0
bool GHOST_ImeWin32::GetComposition(HWND window_handle, LPARAM lparam, ImeComposition *composition)
{
	bool result = false;
	HIMC imm_context = ::ImmGetContext(window_handle);
	if (imm_context) {
		/* Copy the composition string to the ImeComposition object. */
		result = GetString(imm_context, lparam, GCS_COMPSTR, composition);

		/* Retrieve the cursor position in the IME composition. */
		int cursor_position = ::ImmGetCompositionStringW(imm_context, GCS_CURSORPOS, NULL, 0);
		composition->cursor_position = cursor_position;
		composition->target_start = -1;
		composition->target_end = -1;

		/* Retrieve the target selection and Update the ImeComposition object. */
		GetCaret(imm_context, lparam, composition);

		/* Mark that there is an ongoing composition. */
		is_composing_ = true;

		::ImmReleaseContext(window_handle, imm_context);
	}
	return result;
}
/*!
	対括弧の強調表示
	@date 2002/09/18 ai
	@date 2003/02/18 ai 再描画対応の為大改造
*/
void CEditView::DrawBracketPair( bool bDraw )
{
	// 03/03/06 ai すべて置換、すべて置換後のUndo&Redoがかなり遅い問題に対応
	if( m_bDoing_UndoRedo || !GetDrawSwitch() ){
		return;
	}

	if( !m_pTypeData->m_ColorInfoArr[COLORIDX_BRACKET_PAIR].m_bDisp ){
		return;
	}

	// 括弧の強調表示位置が未登録の場合は終了
	if( m_ptBracketPairPos_PHY.HasNegative() || m_ptBracketCaretPos_PHY.HasNegative() ){
		return;
	}

	// 描画指定(bDraw=true)				かつ
	// ( テキストが選択されている		又は
	//   選択範囲を描画している			又は
	//   フォーカスを持っていない		又は
	//   アクティブなペインではない )	場合は終了
	if( bDraw
	 &&( GetSelectionInfo().IsTextSelected() || GetSelectionInfo().m_bDrawSelectArea || !m_bDrawBracketPairFlag
	 || ( m_pcEditWnd->GetActivePane() != m_nMyIndex ) ) ){
		return;
	}

	CGraphics gr;
	gr.Init(::GetDC(GetHwnd()));
	bool bCaretChange = false;
	gr.SetTextBackTransparent(true);

	for( int i = 0; i < 2; i++ )
	{
		// i=0:対括弧,i=1:カーソル位置の括弧
		// 2011.11.23 ryoji 対括弧 -> カーソル位置の括弧 の順に処理順序を変更
		//   # { と } が異なる行にある場合に { を BS で消すと } の強調表示が解除されない問題(Wiki BugReport/89)の対策
		//   # この順序変更によりカーソル位置が括弧でなくなっていても対括弧があれば対括弧側の強調表示は解除される

		CLayoutPoint	ptColLine;

		if( i == 0 ){
			m_pcEditDoc->m_cLayoutMgr.LogicToLayout( m_ptBracketPairPos_PHY,  &ptColLine );
		}else{
			m_pcEditDoc->m_cLayoutMgr.LogicToLayout( m_ptBracketCaretPos_PHY, &ptColLine );
		}

		if ( ( ptColLine.x >= GetTextArea().GetViewLeftCol() ) && ( ptColLine.x <= GetTextArea().GetRightCol() )
			&& ( ptColLine.y >= GetTextArea().GetViewTopLine() ) && ( ptColLine.y <= GetTextArea().GetBottomLine() ) )
		{	// 表示領域内の場合
			if( !bDraw && GetSelectionInfo().m_bDrawSelectArea && ( 0 == IsCurrentPositionSelected( ptColLine ) ) )
			{	// 選択範囲描画済みで消去対象の括弧が選択範囲内の場合
				continue;
			}
			const CLayout* pcLayout;
			CLogicInt		nLineLen;
			const wchar_t*	pLine = m_pcEditDoc->m_cLayoutMgr.GetLineStr( ptColLine.GetY2(), &nLineLen, &pcLayout );
			if( pLine )
			{
				EColorIndexType		nColorIndex;
				CLogicInt	OutputX = LineColumnToIndex( pcLayout, ptColLine.GetX2() );
				if( bDraw )	{
					nColorIndex = COLORIDX_BRACKET_PAIR;
				}
				else{
					if( IsBracket( pLine, OutputX, CLogicInt(1) ) ){
						DispPos _sPos(0,0); // 注意:この値はダミー。CheckChangeColorでの参照位置は不正確
						SColorStrategyInfo _sInfo;
						SColorStrategyInfo* pInfo = &_sInfo;
						pInfo->m_pDispPos = &_sPos;
						pInfo->m_pcView = this;

						// 03/10/24 ai 折り返し行のColorIndexが正しく取得できない問題に対応
						// 2009.02.07 ryoji GetColorIndex に渡すインデックスの仕様変更(元はこっちの仕様だった模様)
						CColor3Setting cColor = GetColorIndex( pcLayout, ptColLine.GetY2(), OutputX, pInfo );
						nColorIndex = cColor.eColorIndex2;
					}
					else{
						SetBracketPairPos( false );
						break;
					}
				}
				CTypeSupport    cCuretLineBg(this,COLORIDX_CARETLINEBG);
				EColorIndexType nColorIndexBg = (cCuretLineBg.IsDisp() && ptColLine.GetY2() == GetCaret().GetCaretLayoutPos().GetY2()
					? COLORIDX_CARETLINEBG
					: CTypeSupport(this,COLORIDX_EVENLINEBG).IsDisp() && ptColLine.GetY2() % 2 == 1
						? COLORIDX_EVENLINEBG
						: COLORIDX_TEXT);
				// 03/03/03 ai カーソルの左に括弧があり括弧が強調表示されている状態でShift+←で選択開始すると
				//             選択範囲内に反転表示されない部分がある問題の修正
				CLayoutInt caretX = GetCaret().GetCaretLayoutPos().GetX2();
				bool bCaretHide = (!bCaretChange && (ptColLine.x == caretX || ptColLine.x + 1 == caretX) && GetCaret().GetCaretShowFlag());
				if( bCaretHide ){
					bCaretChange = true;
					GetCaret().HideCaret_( GetHwnd() );	// キャレットが一瞬消えるのを防止
				}
				{
					int nWidth  = GetTextMetrics().GetHankakuDx();
					int nHeight = GetTextMetrics().GetHankakuDy();
					int nLeft = (GetTextArea().GetDocumentLeftClientPointX()) + GetTextMetrics().GetCharPxWidth(ptColLine.x);
					int nTop  = (Int)( ptColLine.GetY2() - GetTextArea().GetViewTopLine() ) * nHeight + GetTextArea().GetAreaTop();
					CLayoutXInt charsWidth = m_pcEditDoc->m_cLayoutMgr.GetLayoutXOfChar(pLine, nLineLen, OutputX);

					//色設定
					CTypeSupport cTextType(this,COLORIDX_TEXT);
					cTextType.SetGraphicsState_WhileThisObj(gr);
					// 2013.05.24 背景色がテキストの背景色と同じならカーソル行の背景色を適用
					CTypeSupport cColorIndexType(this,nColorIndex);
					CTypeSupport cColorIndexBgType(this,nColorIndexBg);
					CTypeSupport* pcColorBack = &cColorIndexType;
					if( cColorIndexType.GetBackColor() == cTextType.GetBackColor() && nColorIndexBg != COLORIDX_TEXT ){
						pcColorBack = &cColorIndexBgType;
					}

					SetCurrentColor( gr, nColorIndex, nColorIndex, nColorIndexBg );
					bool bTrans = false;
					// DEBUG_TRACE( _T("DrawBracket %d %d ") , ptColLine.y, ptColLine.x );
					if( IsBkBitmap() &&
							cTextType.GetBackColor() == pcColorBack->GetBackColor() ){
						bTrans = true;
						RECT rcChar;
						rcChar.left  = nLeft;
						rcChar.top = nTop;
						rcChar.right = nLeft + GetTextMetrics().GetCharPxWidth(charsWidth);
						rcChar.bottom = nTop + nHeight;
						HDC hdcBgImg = ::CreateCompatibleDC(gr);
						HBITMAP hBmpOld = (HBITMAP)::SelectObject(hdcBgImg, m_pcEditDoc->m_hBackImg);
						DrawBackImage(gr, rcChar, hdcBgImg);
						::SelectObject(hdcBgImg, hBmpOld);
						::DeleteDC(hdcBgImg);
					}
					DispPos sPos(nWidth, nHeight);
					sPos.InitDrawPos(CMyPoint(nLeft, nTop));
					GetTextDrawer().DispText(gr, &sPos, 0, &pLine[OutputX], 1, bTrans);
					GetTextDrawer().DispNoteLine(gr, nTop, nTop + nHeight, nLeft, nLeft + (Int)charsWidth * nWidth);
					// 2006.04.30 Moca 対括弧の縦線対応
					GetTextDrawer().DispVerticalLines(gr, nTop, nTop + nHeight, ptColLine.x, ptColLine.x + charsWidth); //※括弧が全角幅である場合を考慮
					cTextType.RewindGraphicsState(gr);
				}

				if( ( m_pcEditWnd->GetActivePane() == m_nMyIndex )
					&& ( ( ptColLine.y == GetCaret().GetCaretLayoutPos().GetY() ) || ( ptColLine.y - 1 == GetCaret().GetCaretLayoutPos().GetY() ) ) ){	// 03/02/27 ai 行の間隔が"0"の時にアンダーラインが欠ける事がある為修正
					GetCaret().m_cUnderLine.CaretUnderLineON( true, false );
				}
			}
		}
	}
	if( bCaretChange ){
		GetCaret().ShowCaret_( GetHwnd() );	// キャレットが一瞬消えるのを防止
	}

	::ReleaseDC( GetHwnd(), gr );
}
Ejemplo n.º 26
0
void DocEdit::HomeEnd(int x, bool select) {
	Point p = GetCaret(cursor);
	p.x = x;
	PlaceCaret(GetCursorPos(p), select);
}
// トグル用のフラグに変更 20060201 aroka
BOOL CViewCommander::Command_FUNCLIST(
	int nAction,
	int _nOutlineType = OUTLINE_DEFAULT
)
{
	static bool bIsProcessing = false;	//アウトライン解析処理中フラグ

	//アウトラインプラグイン内でのEditor.Outline呼び出しによる再入を禁止する
	if( bIsProcessing )return FALSE;

	bIsProcessing = true;

	// 自プロセスが前面にいるかどうか調べる
	DWORD dwPid1, dwPid2;
	dwPid1 = ::GetCurrentProcessId();
	::GetWindowThreadProcessId( ::GetForegroundWindow(), &dwPid2 );
	bool bForeground = (dwPid1 == dwPid2);

	EOutlineType nOutlineType = (EOutlineType)_nOutlineType; //2007.11.29 kobake

//	if( bCheckOnly ){
//		return TRUE;
//	}

	static CFuncInfoArr	cFuncInfoArr;
//	int		nLine;
//	int		nListType;
	std::tstring sTitleOverride;				//プラグインによるダイアログタイトル上書き

	//	2001.12.03 hor & 2002.3.13 YAZAKI
	if( nOutlineType == OUTLINE_DEFAULT ){
		/* タイプ別に設定されたアウトライン解析方法 */
		nOutlineType = m_pCommanderView->m_pTypeData->m_eDefaultOutline;
		if( nOutlineType == OUTLINE_CPP ){
			if( CheckEXT( GetDocument()->m_cDocFile.GetFilePath(), _T("c") ) ){
				nOutlineType = OUTLINE_C;	/* これでC関数一覧リストビューになる */
			}
		}
	}

	if( NULL != GetEditWindow()->m_cDlgFuncList.GetHwnd() && nAction != SHOW_RELOAD ){
		switch(nAction ){
		case SHOW_NORMAL: // アクティブにする
			//	開いているものと種別が同じならActiveにするだけ.異なれば再解析
			GetEditWindow()->m_cDlgFuncList.SyncColor();
			if( GetEditWindow()->m_cDlgFuncList.CheckListType( nOutlineType )){
				if( bForeground ){
					::SetFocus( GetEditWindow()->m_cDlgFuncList.GetHwnd() );
				}
				bIsProcessing = false;
				return TRUE;
			}
			break;
		case SHOW_TOGGLE: // 閉じる
			//	開いているものと種別が同じなら閉じる.異なれば再解析
			if( GetEditWindow()->m_cDlgFuncList.CheckListType( nOutlineType )){
				if( GetEditWindow()->m_cDlgFuncList.IsDocking() )
					::DestroyWindow( GetEditWindow()->m_cDlgFuncList.GetHwnd() );
				else
					::SendMessageAny( GetEditWindow()->m_cDlgFuncList.GetHwnd(), WM_CLOSE, 0, 0 );
				bIsProcessing = false;
				return TRUE;
			}
			break;
		default:
			break;
		}
	}

	/* 解析結果データを空にする */
	cFuncInfoArr.Empty();
	int		nListType = nOutlineType;			//2011.06.25 syat

	switch( nOutlineType ){
	case OUTLINE_C:			// C/C++ は MakeFuncList_C
	case OUTLINE_CPP:		GetDocument()->m_cDocOutline.MakeFuncList_C( &cFuncInfoArr );break;
	case OUTLINE_PLSQL:		GetDocument()->m_cDocOutline.MakeFuncList_PLSQL( &cFuncInfoArr );break;
	case OUTLINE_JAVA:		GetDocument()->m_cDocOutline.MakeFuncList_Java( &cFuncInfoArr );break;
	case OUTLINE_COBOL:		GetDocument()->m_cDocOutline.MakeTopicList_cobol( &cFuncInfoArr );break;
	case OUTLINE_ASM:		GetDocument()->m_cDocOutline.MakeTopicList_asm( &cFuncInfoArr );break;
	case OUTLINE_PERL:		GetDocument()->m_cDocOutline.MakeFuncList_Perl( &cFuncInfoArr );break;	//	Sep. 8, 2000 genta
	case OUTLINE_VB:		GetDocument()->m_cDocOutline.MakeFuncList_VisualBasic( &cFuncInfoArr );break;	//	June 23, 2001 N.Nakatani
	case OUTLINE_WZTXT:		GetDocument()->m_cDocOutline.MakeTopicList_wztxt(&cFuncInfoArr);break;		// 2003.05.20 zenryaku 階層付テキスト アウトライン解析
	case OUTLINE_HTML:		GetDocument()->m_cDocOutline.MakeTopicList_html(&cFuncInfoArr, false);break;		// 2003.05.20 zenryaku HTML アウトライン解析
	case OUTLINE_TEX:		GetDocument()->m_cDocOutline.MakeTopicList_tex(&cFuncInfoArr);break;		// 2003.07.20 naoh TeX アウトライン解析
	case OUTLINE_BOOKMARK:	GetDocument()->m_cDocOutline.MakeFuncList_BookMark( &cFuncInfoArr );break;	//	2001.12.03 hor
	case OUTLINE_FILE:		GetDocument()->m_cDocOutline.MakeFuncList_RuleFile( &cFuncInfoArr, sTitleOverride );break;	//	2002.04.01 YAZAKI アウトライン解析にルールファイルを導入
//	case OUTLINE_UNKNOWN:	//Jul. 08, 2001 JEPRO 使わないように変更
	case OUTLINE_PYTHON:	GetDocument()->m_cDocOutline.MakeFuncList_python(&cFuncInfoArr);break;		// 2007.02.08 genta
	case OUTLINE_ERLANG:	GetDocument()->m_cDocOutline.MakeFuncList_Erlang(&cFuncInfoArr);break;		// 2009.08.10 genta
	case OUTLINE_XML:		GetDocument()->m_cDocOutline.MakeTopicList_html(&cFuncInfoArr, true);break;		// 2014.12.25 Moca
	case OUTLINE_FILETREE:	/* 特に何もしない*/ ;break;	// 2013.12.08 Moca
	case OUTLINE_TEXT:
		//	fall though
		//	ここには何も入れてはいけない 2007.02.28 genta 注意書き
	default:
		//プラグインから検索する
		{
			CPlug::Array plugs;
			CJackManager::getInstance()->GetUsablePlug( PP_OUTLINE, nOutlineType, &plugs );

			if( plugs.size() > 0 ){
				assert_warning( 1 == plugs.size() );
				//インタフェースオブジェクト準備
				CWSHIfObj::List params;
				COutlineIfObj* objOutline = new COutlineIfObj( cFuncInfoArr );
				objOutline->AddRef();
				params.push_back( objOutline );
				//プラグイン呼び出し
				( *plugs.begin() )->Invoke( m_pCommanderView, params );

				nListType = objOutline->m_nListType;			//ダイアログの表示方法をを上書き
				sTitleOverride = objOutline->m_sOutlineTitle;	//ダイアログタイトルを上書き

				objOutline->Release();
				break;
			}
		}

		//それ以外
		GetDocument()->m_cDocOutline.MakeTopicList_txt( &cFuncInfoArr );
		break;
	}

	/* 解析対象ファイル名 */
	_tcscpy( cFuncInfoArr.m_szFilePath, GetDocument()->m_cDocFile.GetFilePath() );

	/* アウトライン ダイアログの表示 */
	CLayoutPoint poCaret = GetCaret().GetCaretLayoutPos();
	if( NULL == GetEditWindow()->m_cDlgFuncList.GetHwnd() ){
		GetEditWindow()->m_cDlgFuncList.DoModeless(
			G_AppInstance(),
			m_pCommanderView->GetHwnd(),
			(LPARAM)m_pCommanderView,
			&cFuncInfoArr,
			poCaret.GetY2() + CLayoutInt(1),
			poCaret.GetX2() + CLayoutInt(1),
			nOutlineType,
			nListType,
			m_pCommanderView->m_pTypeData->m_bLineNumIsCRLF	/* 行番号の表示 false=折り返し単位/true=改行単位 */
		);
	}else{
		/* アクティブにする */
		GetEditWindow()->m_cDlgFuncList.Redraw( nOutlineType, nListType, &cFuncInfoArr, poCaret.GetY2() + 1, poCaret.GetX2() + 1 );
		if( bForeground ){
			::SetFocus( GetEditWindow()->m_cDlgFuncList.GetHwnd() );
		}
	}

	// ダイアログタイトルを上書き
	if( ! sTitleOverride.empty() ){
		GetEditWindow()->m_cDlgFuncList.SetWindowText( sTitleOverride.c_str() );
	}

	// 解析結果を折りたたみに反映する
	if (m_pCommanderView->m_pTypeData->m_ColorInfoArr[COLORIDX_FOLDING].m_bDisp
		&& nOutlineType != OUTLINE_BOOKMARK && nOutlineType != OUTLINE_FILETREE) {
		CDocFoldMgr::getInstance()->RefreshFromOutline(&cFuncInfoArr, m_pCommanderView->GetDocument()->m_cDocLineMgr);

		if (m_pCommanderView->m_pTypeData->m_ColorInfoArr[COLORIDX_FOLDING].m_bDisp) {
			m_pCommanderView->m_pcEditDoc->OnChangeSetting();
		}
	}

	bIsProcessing = false;
	return TRUE;
}
Ejemplo n.º 28
0
wxRect wxWindow::ScrollNoRefresh(int dx, int dy, const wxRect *rectTotal)
{
    wxASSERT_MSG( !dx || !dy, wxT("can't be used for diag scrolling") );

    // the rect to refresh (which we will calculate)
    wxRect rect;

    if ( !dx && !dy )
    {
        // nothing to do
        return rect;
    }

    // calculate the part of the window which we can just redraw in the new
    // location
    wxSize sizeTotal = rectTotal ? rectTotal->GetSize() : GetClientSize();

    wxLogTrace(wxT("scroll"), wxT("rect is %dx%d, scroll by %d, %d"),
               sizeTotal.x, sizeTotal.y, dx, dy);

    // the initial and end point of the region we move in client coords
    wxPoint ptSource, ptDest;
    if ( rectTotal )
    {
        ptSource = rectTotal->GetPosition();
        ptDest = rectTotal->GetPosition();
    }

    // the size of this region
    wxSize size;
    size.x = sizeTotal.x - abs(dx);
    size.y = sizeTotal.y - abs(dy);
    if ( size.x <= 0 || size.y <= 0 )
    {
        // just redraw everything as nothing of the displayed image will stay
        wxLogTrace(wxT("scroll"), wxT("refreshing everything"));

        rect = rectTotal ? *rectTotal : wxRect(0, 0, sizeTotal.x, sizeTotal.y);
    }
    else // move the part which doesn't change to the new location
    {
        // note that when we scroll the canvas in some direction we move the
        // block which doesn't need to be refreshed in the opposite direction

        if ( dx < 0 )
        {
            // scroll to the right, move to the left
            ptSource.x -= dx;
        }
        else
        {
            // scroll to the left, move to the right
            ptDest.x += dx;
        }

        if ( dy < 0 )
        {
            // scroll down, move up
            ptSource.y -= dy;
        }
        else
        {
            // scroll up, move down
            ptDest.y += dy;
        }

#if wxUSE_CARET
        // we need to hide the caret before moving or it will erase itself at
        // the wrong (old) location
        wxCaret *caret = GetCaret();
        if ( caret )
            caret->Hide();
#endif // wxUSE_CARET

        // do move
        wxClientDC dc(this);
        wxBitmap bmp(size.x, size.y);
        wxMemoryDC dcMem;
        dcMem.SelectObject(bmp);

        dcMem.Blit(wxPoint(0,0), size, &dc, ptSource
#if defined(__WXGTK__) && !defined(wxHAS_WORKING_GTK_DC_BLIT)
                + GetClientAreaOrigin()
#endif // broken wxGTK wxDC::Blit
                  );
        dc.Blit(ptDest, size, &dcMem, wxPoint(0,0));

        wxLogTrace(wxT("scroll"),
                   wxT("Blit: (%d, %d) of size %dx%d -> (%d, %d)"),
                   ptSource.x, ptSource.y,
                   size.x, size.y,
                   ptDest.x, ptDest.y);

        // and now repaint the uncovered area

        // FIXME: We repaint the intersection of these rectangles twice - is
        //        it bad? I don't think so as it is rare to scroll the window
        //        diagonally anyhow and so adding extra logic to compute
        //        rectangle intersection is probably not worth the effort

        rect.x = ptSource.x;
        rect.y = ptSource.y;

        if ( dx )
        {
            if ( dx < 0 )
            {
                // refresh the area along the right border
                rect.x += size.x + dx;
                rect.width = -dx;
            }
            else
            {
                // refresh the area along the left border
                rect.width = dx;
            }

            rect.height = sizeTotal.y;

            wxLogTrace(wxT("scroll"), wxT("refreshing (%d, %d)-(%d, %d)"),
                       rect.x, rect.y,
                       rect.GetRight() + 1, rect.GetBottom() + 1);
        }

        if ( dy )
        {
            if ( dy < 0 )
            {
                // refresh the area along the bottom border
                rect.y += size.y + dy;
                rect.height = -dy;
            }
            else
            {
                // refresh the area along the top border
                rect.height = dy;
            }

            rect.width = sizeTotal.x;

            wxLogTrace(wxT("scroll"), wxT("refreshing (%d, %d)-(%d, %d)"),
                       rect.x, rect.y,
                       rect.GetRight() + 1, rect.GetBottom() + 1);
        }

#if wxUSE_CARET
        if ( caret )
            caret->Show();
#endif // wxUSE_CARET
    }

    return rect;
}
Ejemplo n.º 29
0
void
wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
{
    wxClientDC dc( this );
    PrepareDC( dc );
    if ( (eventId != WXLOWIN_MENU_MOUSEMOVE
#ifndef __WXMSW__
        || m_FocusFollowMode
#endif
        )
        && (wxWindow::FindFocus() != this) )
    {
        SetFocus();
    }

    wxPoint findPos;
    findPos.x = dc.DeviceToLogicalX(event.GetX());
    findPos.y = dc.DeviceToLogicalY(event.GetY());

    findPos.x -= WXLO_XOFFSET;
    findPos.y -= WXLO_YOFFSET;

    if(findPos.x < 0)
        findPos.x = 0;

    if(findPos.y < 0)
        findPos.y = 0;

    m_ClickPosition = wxPoint(event.GetX(), event.GetY());

    // Scroll the window if the mouse is at the end of it:
    if(m_Selecting && eventId == WXLOWIN_MENU_MOUSEMOVE)
    {
        //WXLO_DEBUG(("selecting at : %d/%d", (int) event.GetX(), (int)event.GetY()));
        int left, top;
        GetViewStart(&left, &top);
        wxSize size = GetClientSize();
        int xdelta, ydelta;

        if(event.GetX() < WXLO_SCROLLMARGIN_X)
            xdelta = -(WXLO_SCROLLMARGIN_X-event.GetX());
        else if(event.GetX() > size.x-WXLO_SCROLLMARGIN_X)
            xdelta = event.GetX()-size.x+WXLO_SCROLLMARGIN_X;
        else
            xdelta = 0;

        if(event.GetY() < WXLO_SCROLLMARGIN_Y)
            ydelta = -(WXLO_SCROLLMARGIN_Y-event.GetY());
        else if(event.GetY() > size.y-WXLO_SCROLLMARGIN_Y)
            ydelta = event.GetY()-size.y+WXLO_SCROLLMARGIN_Y;
        else
            ydelta = 0;

        //WXLO_DEBUG(("xdelta: %d", (int) xdelta));
        if(xdelta != 0 || ydelta != 0)
        {
            top  += ydelta; if(top < 0) top = 0;
            left += xdelta; if(left < 0) left = 0;
            Scroll(left, top);
        }
    }

    wxPoint cursorPos;
    bool found;
    wxLayoutObject *obj = m_llist->FindObjectScreen(dc, findPos,
        &cursorPos, &found);
    wxLayoutObject::UserData *u = obj ? obj->GetUserData() : NULL;

    // has the mouse only been moved?
    switch ( eventId )
    {
    case WXLOWIN_MENU_MOUSEMOVE:
    {
        // this variables is used to only erase the message in the status
        // bar if we had put it there previously - otherwise empting status
        // bar might be undesirable
#if wxUSE_STATUSBAR
        static bool s_hasPutMessageInStatusBar = false;
#endif // wxUSE_STATUSBAR

        // found is only true if we are really over an object, not just
        // behind it
        if(found && u && ! m_Selecting)
        {
            if(!m_HandCursor)
                SetCursor(wxCURSOR_HAND);
            m_HandCursor = true;
#if wxUSE_STATUSBAR
            if(m_StatusBar && m_StatusFieldLabel != -1)
            {
                const wxString &label = u->GetLabel();
                if(label.Length())
                {
                    m_StatusBar->SetStatusText(label,m_StatusFieldLabel);
                    s_hasPutMessageInStatusBar = true;
                }
            }
#endif // wxUSE_STATUSBAR
        }
        else
        {
            if(m_HandCursor)
                SetCursor(wxCURSOR_IBEAM);
            m_HandCursor = false;
#if wxUSE_STATUSBAR
            if( m_StatusBar && m_StatusFieldLabel != -1 &&
                s_hasPutMessageInStatusBar )
            {
                m_StatusBar->SetStatusText(wxEmptyString, m_StatusFieldLabel);
            }
#endif // wxUSE_STATUSBAR
        }
    }

    // selecting?
    if ( event.LeftIsDown() )
    {
        // m_Selecting might not be set if the button got pressed
        // outside this window, so check for it:
        if( m_Selecting )
        {
            m_llist->ContinueSelection(cursorPos, m_ClickPosition);
            RequestUpdate();  // TODO: we don't have to redraw everything!
        }
    }

    if ( u )
    {
        u->DecRef();
        u = NULL;
    }
    break;

    case WXLOWIN_MENU_LDOWN:
    {
        // always move cursor to mouse click:
        m_llist->MoveCursorTo(cursorPos);

        // clicking a mouse removes the selection
        if ( m_llist->HasSelection() )
        {
            m_llist->DiscardSelection();
            m_Selecting = false;
            RequestUpdate();     // TODO: we don't have to redraw everything!
        }

        // Calculate where the top of the visible area is:
        int x0, y0;
        GetViewStart(&x0,&y0);
        int dx, dy;
        GetScrollPixelsPerUnit(&dx, &dy);
        x0 *= dx; y0 *= dy;

        wxPoint offset(-x0+WXLO_XOFFSET, -y0+WXLO_YOFFSET);

        if(m_CursorVisibility == -1)
            m_CursorVisibility = 1;

#ifdef WXLAYOUT_USE_CARET
        if ( m_CursorVisibility == 1 )
            GetCaret()->Show();
#endif // WXLAYOUT_USE_CARET

        if(m_CursorVisibility)
        {
            // draw a thick cursor for editable windows with focus
            m_llist->DrawCursor(dc, m_HaveFocus && IsEditable(), offset);
        }

#ifdef __WXGTK__
        RequestUpdate(); // RequestUpdate suppresses flicker under GTK
#endif // wxGTK

        // start selection
        m_llist->StartSelection(wxPoint(-1, -1), m_ClickPosition);
        m_Selecting = true;
    }
    break;

    case WXLOWIN_MENU_LUP:
        if ( m_Selecting )
        {
            // end selection at the cursor position corresponding to the
            // current mouse position, but don´t move cursor there.
            m_llist->EndSelection(cursorPos,m_ClickPosition);
            m_Selecting = false;

            RequestUpdate();     // TODO: we don't have to redraw everything!
        }
        break;

    case WXLOWIN_MENU_MDOWN:
        Paste(true);
        break;

    case WXLOWIN_MENU_DBLCLICK:
        // select a word under cursor
        m_llist->MoveCursorTo(cursorPos);
        m_llist->MoveCursorWord(-1);
        m_llist->StartSelection();
        m_llist->MoveCursorWord(1, false);
        m_llist->EndSelection();
        m_Selecting = false;
        RequestUpdate();     // TODO: we don't have to redraw everything!
        break;
    }

    // notify about mouse events?
    if( m_doSendEvents )
    {
        // only do the menu if activated, editable and not on a clickable object
        if(eventId == WXLOWIN_MENU_RCLICK
            && IsEditable()
            && (! obj || u == NULL))
        {
            PopupMenu(m_PopupMenu, m_ClickPosition.x, m_ClickPosition.y);
            if(u) u->DecRef();
            return;
        }

        // find the object at this position
        if(obj)
        {
            wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, eventId);
            commandEvent.SetEventObject( this );
            commandEvent.SetClientData((char *)obj);
            GetEventHandler()->ProcessEvent(commandEvent);
        }
    }

    if( u ) u->DecRef();
}
Ejemplo n.º 30
0
void CFX_ListCtrl::OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl)
{
	OnVK(IsMultipleSel() ? GetCaret()+1 : GetSelect()+1, bShift, bCtrl);
}