예제 #1
0
void wxLuaConsole::AppendTextWithAttr(const wxString& msg, const wxTextAttr& attr)
{
    wxTextAttr oldAttr = m_textCtrl->GetDefaultStyle();

    m_textCtrl->SetDefaultStyle(attr);
    AppendText(msg);
    m_textCtrl->SetDefaultStyle(oldAttr);

    SetMaxLines(m_max_lines);
}
예제 #2
0
void wxSTEditorShell::AppendText(const wxString &text)
{
    BeginWriteable();                   // make it writeable

    wxSTEditor::AppendText(text);       // write the text
    SetMaxLines(GetMaxLines());         // check for line count overflow
    GotoPos(GetLength());               // put cursor at end
    EmptyUndoBuffer();                  // don't let them undo what you wrote!
                                        //   but they can undo their own typing

    EndWriteable();                     // end the writeable state
}
예제 #3
0
void wxLuaConsole::OnMenu(wxCommandEvent& event)
{
    switch (event.GetId())
    {
    case wxID_NEW :
    {
        m_textCtrl->Clear();
        break;
    }
    case wxID_SAVEAS :
    {
        wxString filename = wxFileSelector(wxT("Select file to save output to"),
                                           m_saveFilename.GetPath(),
                                           m_saveFilename.GetFullName(),
                                           wxT("txt"),
                                           wxT("Text files (*.txt)|*.txt|All files|*.*"),
                                           wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
                                           this);

        if (!filename.IsEmpty())
        {
            m_saveFilename = wxFileName(filename);

            m_textCtrl->SaveFile(filename);
        }
        break;
    }
    case wxID_COPY :
    {
        long from = 0, to = 0;
        m_textCtrl->GetSelection(&from, &to);
        m_textCtrl->SetSelection(-1, -1);
        m_textCtrl->Copy();
        m_textCtrl->SetSelection(from, to);
        break;
    }
    case ID_WXLUACONSOLE_SCROLLBACK_LINES :
    {
        long lines = wxGetNumberFromUser(wxT("Set the number of printed lines to remember, 0 to 10000.\nSet to 0 for infinite history."),
                                         wxT("Lines : "),
                                         wxT("Set Number of Scrollback Lines"),
                                         m_max_lines, 0, 10000,
                                         this);
        if (lines >= 0)
            SetMaxLines(lines);

        break;
    }
    default :
        break;
    }
}
예제 #4
0
void wxLuaConsole::AppendText(const wxString& msg)
{
    m_textCtrl->Freeze();

    // Probably the best we can do to maintain the cursor pos while appending
    // The wxStyledTextCtrl can do a much better job...
    long pos          = m_textCtrl->GetInsertionPoint();
    int  num_lines    = m_textCtrl->GetNumberOfLines();
    long pos_near_end = m_textCtrl->XYToPosition(0, wxMax(0, num_lines - 5));
    bool is_near_end  = (pos >= pos_near_end);

    m_textCtrl->AppendText(msg);
    m_textCtrl->SetInsertionPoint(is_near_end ? m_textCtrl->GetLastPosition() : pos);

    m_textCtrl->Thaw();

    SetMaxLines(m_max_lines);
}
예제 #5
0
void DialogTitle::OnMeasure(
    /* [in] */ Int32 widthMeasureSpec,
    /* [in] */ Int32 heightMeasureSpec)
{
    TextView::OnMeasure(widthMeasureSpec, heightMeasureSpec);

    AutoPtr<ILayout> layout = GetLayout();
    if (layout != NULL) {
        Int32 lineCount;
        layout->GetLineCount(&lineCount);

        if (lineCount > 0) {
            Int32 ellipsisCount;
            layout->GetEllipsisCount(lineCount - 1, &ellipsisCount);

            if (ellipsisCount > 0) {
                SetSingleLine(FALSE);
                SetMaxLines(2);

                AutoPtr<ArrayOf<Int32> > attrIds = ArrayOf<Int32>::Alloc(
                    const_cast<Int32 *>(R::styleable::TextAppearance),
                    ARRAY_SIZE(R::styleable::TextAppearance));
                AutoPtr<ITypedArray> a;
                ASSERT_SUCCEEDED(mContext->ObtainStyledAttributes(
                        NULL, attrIds, R::attr::textAppearanceMedium,
                        R::style::TextAppearance_Medium, (ITypedArray**)&a));

                Int32 textSize;
                a->GetDimensionPixelSize(
                    R::styleable::TextAppearance_textSize, 0, &textSize);

                if (textSize != 0) {
                    // textSize is already expressed in pixels
                    SetTextSize(ITypedValue::COMPLEX_UNIT_PX, textSize);
                }
                a->Recycle();

                TextView::OnMeasure(widthMeasureSpec, heightMeasureSpec);
            }
        }
    }
}
예제 #6
0
/**
*
* Sets up the radial menu.
*
* @author Jade Abbott
* @param _pRenderer Required for the surface manager, device manager, etc.
* @param _pHud The Heads Up Display, which will be told to display certain information when the Radial Menu is open.
* @param _uiMaximumDiameter Maximum diameter the radial menu can be (but is capped at 512); Must be even.
* @param _uiMaxLines Maximum nuimber of lines used to define the shape of the inner circle.
* @param _fLineWidth The width of the dividing lines drawn.
* @param _fInnerCircleScalar Scalar value to set how much of the Radial Menu is taken by the centre button.
* @param _fDrawPositionX The centre X coordinate where the Radial Menu will be drawn on screen.
* @param _fDrawPositionY The centre Y coordinate where the Radial Menu will be drawn on screen.
* @return True if initialisation was successful.
*
*/
bool
CRadialMenu::Initialise(CD3DRenderer* _pRenderer,
						CHud* _pHud,
						unsigned int _uiMaximumDiameter,
						unsigned int _uiMaxLines,
						float _fLineWidth,
						float _fInnerCircleScalar,
						float _fDrawPositionX,
						float _fDrawPositionY)
{
	assert(_pRenderer);
	assert(!m_pRenderer);

	m_pRenderer = _pRenderer;
	m_pHud = _pHud;

	// Get default data; This is only to breakproof it.
	m_dwOriginalStencilState = _pRenderer->GetDeviceManager().GetRenderStateValue(D3DRS_STENCILENABLE);

	// Initialise resolution-based data.
	bool bSuccess = OnResolutionChange(_uiMaximumDiameter, _fDrawPositionX, _fDrawPositionY);

	// Set the radius of the inner circle.
	SetInnerCircleRadius(_fInnerCircleScalar * (m_uiDiameter * 0.5f));

	// Create vertex buffer so ID3DXLine can draw into the stencil.
	bSuccess = SetMaxLines(_uiMaxLines) ? bSuccess : false;

	// Create line for stencil masking.
	bSuccess = CreateLine(_fLineWidth) ? bSuccess : false;
	assert(bSuccess);

	// Create dynamic vertex buffer, which is a screen-space textured quad.
	bSuccess = CreateVertexBufferQuad() ? bSuccess : false;
	assert(bSuccess);

	// Create dynamic vertex buffer for masking.
	bSuccess = CreateVertexBufferMask(_uiMaxLines) ? bSuccess : false;
	assert(bSuccess);

	return bSuccess;
}