Esempio n. 1
0
		intptr_t ItemWidth(const T &Item)
		{
			switch(Item.Type)
			{
			case DI_TEXT:
				return TextWidth(Item);

			case DI_CHECKBOX:
			case DI_RADIOBUTTON:
			case DI_BUTTON:
				return TextWidth(Item) + 4;

			case DI_EDIT:
			case DI_FIXEDIT:
			case DI_COMBOBOX:
			case DI_LISTBOX:
			case DI_PSWEDIT:
				{
					intptr_t Width = Item.X2 - Item.X1 + 1;
					// стрелка history занимает дополнительное место, но раньше она рисовалась поверх рамки???
					if (Item.Flags & DIF_HISTORY)
						Width++;
					return Width;
				}
				break;

			default:
				break;
			}
			return 0;
		}
Esempio n. 2
0
//Create a string of text that will fit in the width provided by SetArea.  SetArea
//must be called before this, or an error will occur.
void ShortenenedText::CreateFittedText(std::string text)
{
	fulltext_.CreateTextureFromText(text);

	int textwidth = TextWidth(text);

	std::string showtext;
	if (textwidth > maxtextwidth_)
	{
		double proportiontoshow = static_cast<double>(maxtextwidth_) / static_cast<double>(textwidth);
		showtext = text.substr(0, static_cast<int>(text.length() * proportiontoshow));
		if (showtext.length() >= 3)
		{
			showtext = showtext.substr(0, showtext.length() - 3);
			showtext = showtext + "...";
		}

		CreateTextureFromText(showtext);
		isshortened_ = true;
	}
	else
	{
		showtext = text;
		CreateTextureFromText(showtext);		
	}

	SDL_Rect currentmousearea = mousefunction_->GetMouseArea();
	mousefunction_->SetMouseArea(SDL_Rect{ currentmousearea.x, currentmousearea.y, TextWidth(showtext), TextHeight() });
}
Esempio n. 3
0
unsigned short Font::FitText( const char *str, unsigned short width,
                              bool word ) const {
  int lastspace = 0, pos = 0;
  string line;

  do {
    if ( (str[pos] == ' ') || (str[pos] == '\n') || (str[pos] == '\0') ) {
      if ( TextWidth( line.c_str() ) > width ) {
        // go back to last space
        line.erase( lastspace );
        pos = lastspace;

        if ( lastspace != 0 && word ) return pos + 1;
        else {
          // add single characters until we hit the wall
          do {
            line += str[pos++];
          } while ( TextWidth( line.c_str() ) <= width );
          return pos - 1;
        }
      }

      if ( (str[pos] == '\n') || (str[pos] == '\0') ) return pos + 1;
      lastspace = pos;
      line += str[pos];
    }

    else line += str[pos];

  } while ( str[pos++] != '\0' );

  return pos;
}
Esempio n. 4
0
// adjust the font to fit within a width
void fitwidth(int width, int adj, char *s, FW * f) {
	f->tw = TextWidth(s, f->fontsize);
	while (f->tw > width) {
		f->fontsize -= adj;
		f->tw = TextWidth(s, f->fontsize);
	}
}
Esempio n. 5
0
/*--------------------------------------------------------------------------*/
void PegChart::RecalcLayout(BOOL bRedraw /*=TRUE*/)
{
    mChartRegion = mClient;
    
    if(mwExStyle & CS_DRAWXTICS)
    {
        mChartRegion.wBottom -= mwMajorTicSize;
    }

    if(mwExStyle & CS_DRAWYTICS)
    {
        mChartRegion.wLeft += mwMajorTicSize;

		if(mwExStyle & CS_DUALYTICS)
		{
			mChartRegion.wRight -= mwMajorTicSize;
		}
    }

    if (mwExStyle & CS_DRAWYLABELS)
    {
		SIGNED iSkipHeight = TextHeight(lsTEST, mpFont);
		iSkipHeight++;
		iSkipHeight >>= 1;
		mChartRegion.wTop += iSkipHeight;

		if(!(mwExStyle & CS_DRAWXLABELS))
		{
			mChartRegion.wBottom -= iSkipHeight;
		}
        
        if(mwYLabelWidth == 0)
		{
			PEGCHAR cBuffer[20];
			_ltoa(mlMinY, cBuffer, 10);
			SIGNED iMinWidth = TextWidth(cBuffer, mpFont);
			//_ltoa(mlMinY,cBuffer,10);
			_ltoa(mlMaxY, cBuffer, 10);
			SIGNED iMaxWidth = TextWidth(cBuffer, mpFont);
			/*_ltoa(mlMinY,cBuffer,10);*/
			/*_ltoa(mlMaxY,cBuffer,10);*/
			mChartRegion.wLeft += 
                iMinWidth > iMaxWidth ? iMinWidth : iMaxWidth;
            mChartRegion.wLeft += 2;

            if(mwExStyle & CS_DUALYLABELS)
            {
                mChartRegion.wRight -= 
                    iMinWidth > iMaxWidth ? iMinWidth : iMaxWidth;
                mChartRegion.wRight -= 2;
            }
		}
		else
		{
			mChartRegion.wLeft += mwYLabelWidth;
		}
    }
Esempio n. 6
0
/*--------------------------------------------------------------------------*/
void PegTextBox::DrawTextLine(SIGNED iLine, PegPoint Put, BOOL bFill)
{
    SIGNED iLineLength;
    PegRect FillRect;
    PEGCHAR *pGet = GetLineStart(iLine, &iLineLength);
    PegColor Color(muColors[PCI_NTEXT], muColors[PCI_NORMAL], CF_FILL);

    CheckBufLen(iLineLength);

    if (iLine == miMarkLine)
    {
        Color.Set(muColors[PCI_STEXT], muColors[PCI_SELECTED], CF_FILL);
        bFill = TRUE;
    }
    if (bFill)
    {
        FillRect.Set(mClient.wLeft + TB_WHITESPACE, Put.y, mClient.wRight - TB_WHITESPACE,
            Put.y + miLineHeight - 1);
        Rectangle(FillRect, Color, 0);
    }

    if (!pGet)
    {
        return;
    }

    Color.uFlags = CF_NONE;

    if (iLineLength > 0)
    {
        strncpy(mpBuf, pGet, iLineLength);
        mpBuf[iLineLength] = '\0';

        switch(Style() & TJ_MASK)
        {
        case TJ_RIGHT:
            iLineLength = TextWidth(mpBuf, mpFont);
            Put.x = mClient.wRight - iLineLength - TB_WHITESPACE;
            break;

        case TJ_CENTER:
            iLineLength = TextWidth(mpBuf, mpFont);
            Put.x = (mClient.Width() - iLineLength) / 2;
            Put.x += mClient.wLeft;
            break;

        case TJ_LEFT:
        default:
            break;
        }
        DrawText(Put, mpBuf, Color, mpFont, -1);
    }
}
Esempio n. 7
0
void SvnBlameEditor::Initialize()
{
    // Initialize some styles
    SetMarginType (0, wxSTC_MARGIN_TEXT  );
    SetMarginType (1, wxSTC_MARGIN_NUMBER);
    SetMarginWidth(1, 4 + 5*TextWidth(wxSTC_STYLE_LINENUMBER, wxT("9")));
    SetMarginWidth(2, 0);
    SetMarginWidth(3, 0);
    SetMarginWidth(4, 0);
    SetTabWidth(4);
    
    // Define some colors to use
    StyleSetBackground(MARGIN_STYLE_START + 1,  DrawingUtils::LightColour(wxT("GREEN"),      7.0));
    StyleSetBackground(MARGIN_STYLE_START + 2,  DrawingUtils::LightColour(wxT("BLUE"),       7.0));
    StyleSetBackground(MARGIN_STYLE_START + 3,  DrawingUtils::LightColour(wxT("ORANGE"),     7.0));
    StyleSetBackground(MARGIN_STYLE_START + 4,  DrawingUtils::LightColour(wxT("YELLOW"),     7.0));
    StyleSetBackground(MARGIN_STYLE_START + 5,  DrawingUtils::LightColour(wxT("PURPLE"),     7.0));
    StyleSetBackground(MARGIN_STYLE_START + 6,  DrawingUtils::LightColour(wxT("RED"),        7.0));
    StyleSetBackground(MARGIN_STYLE_START + 7,  DrawingUtils::LightColour(wxT("BROWN"),      7.0));
    StyleSetBackground(MARGIN_STYLE_START + 8,  DrawingUtils::LightColour(wxT("LIGHT GREY"), 7.0));
    StyleSetBackground(MARGIN_STYLE_START + 9,  DrawingUtils::LightColour(wxT("SIENNA"),     7.0));

    StyleSetBackground(MARGIN_STYLE_START + 10, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
    StyleSetForeground(MARGIN_STYLE_START + 10, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
}
Esempio n. 8
0
/*--------------------------------------------------------------------------*/
PegRadioButton::PegRadioButton(SIGNED iLeft, SIGNED iTop,
     const PEGCHAR *Text, WORD wId, WORD wStyle) :
     PegButton(wId, wStyle),
     PegTextThing(Text, wStyle & TT_COPY, PEG_RBUTTON_FONT)
{
    Type(TYPE_RADIOBUTTON);

    SetSignals(SIGMASK(PSF_DOT_ON));

    mReal.wLeft = iLeft;
    mReal.wTop = iTop;

    SIGNED iHeight = TextHeight(lsTEST, mpFont);
    if (gbRadioOnBitmap.wHeight > iHeight)
    {
        iHeight = gbRadioOnBitmap.wHeight;
    }
    iHeight += 4;

    if (Text)
    {
        mReal.wRight = mReal.wLeft + TextWidth(Text, mpFont) + 2;
        mReal.wRight += gbRadioOnBitmap.wWidth + RBUTTON_SPACING;
        mReal.wBottom = mReal.wTop + iHeight;
    }
    else
    {
        mReal.wRight = mReal.wLeft + 3;
        mReal.wBottom = mReal.wTop + iHeight;
    }
    mClient = mReal;
}
Esempio n. 9
0
static void ShowAllKeys(int index, int change)
{
	int x1, x2, y1, y2;
	
	x1 = CenterX((TextCharWidth('a') * 10)) / 2;
	x2 = x1 * 3;
	
	y1 = (SCREEN_HEIGHT / 2) - (TextHeight() * 10);
	y2 = (SCREEN_HEIGHT / 2) - (TextHeight() * 2);
	
	DisplayKeys(x1, x2, y1, "Player One", &gPlayer1Data, index, change);
	DisplayKeys(x1, x2, y2, "Player Two", &gPlayer2Data, index - 6, change - 6);
	
	y2 += TextHeight() * 8;
	
	TextStringAt(x1, y2, "Map");
	
	if (change == 12)
		DisplayMenuItem(x2, y2, SELECTKEY, index == 12);
	else
		DisplayMenuItem(x2, y2, SDL_GetKeyName(gOptions.mapKey), index == 12);
	
#define DONE	"Done"
	
	y2 += TextHeight () * 2;
	
	DisplayMenuItem(CenterX(TextWidth(DONE)), y2, DONE, index == 13);
}
Esempio n. 10
0
/* TextEditor::loadEntry
 * Reads the contents of [entry] into the text area, returns false
 * if the given entry is invalid
 *******************************************************************/
bool TextEditor::loadEntry(ArchiveEntry* entry)
{
	// Clear current text
	ClearAll();

	// Check that the entry exists
	if (!entry)
	{
		Global::error = "Invalid archive entry given";
		return false;
	}

	// Check that the entry has any data, if not do nothing
	if (entry->getSize() == 0 || !entry->getData())
		return true;

	// Get character entry data
	//string text = wxString::From8BitData((const char*)entry->getData(), entry->getSize());
	string text = wxString::FromUTF8((const char*)entry->getData(), entry->getSize());
	// If opening as UTF8 failed for some reason, try again as 8-bit data
	if (text.length() == 0)
		text = wxString::From8BitData((const char*)entry->getData(), entry->getSize());

	// Load text into editor
	SetText(text);

	// Update line numbers margin width
	string numlines = S_FMT("0%d", GetNumberOfLines());
	SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, numlines));

	return true;
}
Esempio n. 11
0
void IWnd_stc::UpdateMarginLineNumWidth(bool flag)
{
	BitFlags &flags(param.flags);

	if(!flags.get(FLAG_LINENUM))
	{
		if(m_nLineNumWidth==0)
		{
			return;
		}
		m_nLineNumWidth=0;
		SetMarginWidth(StcManager::LINE_NR_ID,0);
	}
	else
	{

		int _nWidth=3+(int)::log10(double(GetLineCount()));
		if(_nWidth<4) _nWidth=4;
		if(_nWidth>7) _nWidth=7;

		if(_nWidth==m_nLineNumWidth && !flag)
		{
			return;
		}
		m_nLineNumWidth=_nWidth;

		static const char* text="999999999999999";
		int wd=TextWidth (wxSTC_STYLE_LINENUMBER, wxString(text,m_nLineNumWidth));
		SetMarginWidth(StcManager::LINE_NR_ID,wd);
	}

}
Esempio n. 12
0
/////////////////////////////////////////////////////////////
//
// DrawString
//
void
nsPluginInstance::DrawString(const unsigned char* text, 
                             short width, 
                             short height, 
                             short centerX, 
                             Rect drawRect)
{
	short length, textHeight, textWidth;
 
	if(text == NULL)
		return;
	
	length = strlen((char*)text);
	TextFont(1);
	TextFace(bold);
	TextMode(srcCopy);
	TextSize(12);
	
	FontInfo fontInfo;
	GetFontInfo(&fontInfo);

	textHeight = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
	textWidth = TextWidth(text, 0, length);
		
	if (width > textWidth && height > textHeight)
	{
		MoveTo(centerX - (textWidth >> 1), height >> 1);
		DrawText(text, 0, length);
	}		
Esempio n. 13
0
/*
mVerticalPix - is height relative to bottom of the control.
*/
char* MarqueeView::draw_one_line( char* mtext, int mVerticalPix )
{
	int strLength = strlen(mtext);
	char* pos = strchr(mtext, '\n');
	int len = (pos-mtext);
	
	int length = get_num_chars_fit( mtext, right_margin-left_margin );		
	if ((pos>0) && (len<length))
		length = len;
//	printf("MarqueeView::draw_one_line width=%d num_chars=%d nl=%d\n", (right_margin-left_margin),
//					 length, pos);

	char tmp = mtext[length];
	mtext[length] = 0;

	if (style & CENTER_HORIZONTAL)
	{
		VGfloat font_width = TextWidth( mtext, *font, text_size );
		int space = (width-(font_width))/2;		
		Text(left+space, bottom+mVerticalPix, mtext, *font, text_size );
	} else {
		Text(left_margin, bottom+mVerticalPix, mtext, *font, text_size );
	}
	mtext[length] = tmp;	
	
	if (length==strLength)
		return NULL;			// Done drawing string.
	return &(mtext[length]);
}
Esempio n. 14
0
/* Here is where all redrawing will take place for your program. 
 * When the window needs to be redrawn, this function will be called.
 * When your program starts up for the first time, this function will 
 * be called and you should draw anything you need to draw in here.
 */
void do_redisplay(MyProgram *me, int width, int height) 
{
  int i;
  char *str = "My Cool Program";

  if (me->in_color_mode)
   {
     do_colorstuff();
     return;
   }

  SetBgColor(me->draw_widget, WHITE);
  ClearDrawArea();       /* start with a clean slate */

  SetColor(BLACK);
  SetBgColor(me->draw_widget, GREEN);
  DrawText(str, (width-TextWidth(me->draw_font, str))/2, height/2); 

  SetBgColor(me->draw_widget, WHITE);
  SetColor(me->col1);
  for(i=0; i < width; i+=5)
     DrawLine(0,i, i,height);

  SetColor(me->col2);
  for(i=0; i < width; i+=5)
     DrawLine(width,i, width-i,height);
}
Esempio n. 15
0
static void ShowPlayerControls(int x, struct PlayerData *data)
{
	char s[256];
	int y;

	y = SCREEN_HEIGHT - (SCREEN_HEIGHT / 6);

	if (data->controls == JOYSTICK_ONE)
		TextStringAt(x, y, "(joystick one)");
	else if (data->controls == JOYSTICK_TWO)
		TextStringAt(x, y, "(joystick two)");
	else {
		sprintf(s, "(%s, %s, %s, %s, %s and %s)",
			SDL_GetKeyName(data->keys[0]),
			SDL_GetKeyName(data->keys[1]),
			SDL_GetKeyName(data->keys[2]),
			SDL_GetKeyName(data->keys[3]),
			SDL_GetKeyName(data->keys[4]),
			SDL_GetKeyName(data->keys[5]));
		if (TextWidth(s) < 125)
			TextStringAt(x, y, s);
		else {
			sprintf(s, "(%s, %s, %s,",
				SDL_GetKeyName(data->keys[0]),
				SDL_GetKeyName(data->keys[1]),
				SDL_GetKeyName(data->keys[2]));
			TextStringAt(x, y - 10, s);
			sprintf(s, "%s, %s and %s)",
				SDL_GetKeyName(data->keys[3]),
				SDL_GetKeyName(data->keys[4]),
				SDL_GetKeyName(data->keys[5]));
			TextStringAt(x, y, s);
		}
	}
}
Esempio n. 16
0
/* TextEditor::onCharAdded
 * Called when a character is added to the text
 *******************************************************************/
void TextEditor::onCharAdded(wxStyledTextEvent& e)
{
	// Update line numbers margin width
	string numlines = S_FMT("0%d", GetNumberOfLines());
	SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, numlines));

	// Auto indent
	int currentLine = GetCurrentLine();
	if (txed_auto_indent && e.GetKey() == '\n')
	{
		// Get indentation amount
		int lineInd = 0;
		if (currentLine > 0)
			lineInd = GetLineIndentation(currentLine - 1);

		// Do auto-indent if needed
		if (lineInd != 0)
		{
			SetLineIndentation(currentLine, lineInd);

			// Skip to end of tabs
			while (1)
			{
				int chr = GetCharAt(GetCurrentPos());
				if (chr == '\t' || chr == ' ')
					GotoPos(GetCurrentPos()+1);
				else
					break;
			}
		}
	}

	// The following require a language to work
	if (language)
	{
		// Call tip
		if (e.GetKey() == '(' && txed_calltips_parenthesis)
		{
			openCalltip(GetCurrentPos());
		}

		// End call tip
		if (e.GetKey() == ')')
		{
			CallTipCancel();
		}

		// Comma, possibly update calltip
		if (e.GetKey() == ',' && txed_calltips_parenthesis)
		{
			//openCalltip(GetCurrentPos());
			//if (CallTipActive())
			updateCalltip();
		}
	}

	// Continue
	e.Skip();
}
Esempio n. 17
0
Edit::Edit (wxWindow *parent, wxWindowID id,
            const wxPoint &pos,
            const wxSize &size,
            long style)
    : wxStyledTextCtrl (parent, id, pos, size, style) {

    m_filename = wxEmptyString;

    m_LineNrID = 0;
    m_DividerID = 1;
    m_FoldingID = 2;

    // initialize language
    m_language = NULL;

    // default font for all styles
    SetViewEOL (g_CommonPrefs.displayEOLEnable);
    SetIndentationGuides (g_CommonPrefs.indentGuideEnable);
    SetEdgeMode (g_CommonPrefs.longLineOnEnable?
                 wxSTC_EDGE_LINE: wxSTC_EDGE_NONE);
    SetViewWhiteSpace (g_CommonPrefs.whiteSpaceEnable?
                       wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE);
    SetOvertype (g_CommonPrefs.overTypeInitial);
    SetReadOnly (g_CommonPrefs.readOnlyInitial);
    SetWrapMode (g_CommonPrefs.wrapModeInitial?
                 wxSTC_WRAP_WORD: wxSTC_WRAP_NONE);
    wxFont font(wxFontInfo(10).Family(wxFONTFAMILY_MODERN));
    StyleSetFont (wxSTC_STYLE_DEFAULT, font);
    StyleSetForeground (wxSTC_STYLE_DEFAULT, *wxBLACK);
    StyleSetBackground (wxSTC_STYLE_DEFAULT, *wxWHITE);
    StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (wxT("DARK GREY")));
    StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE);
    StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY")));
    InitializePrefs (DEFAULT_LANGUAGE);

    // set visibility
    SetVisiblePolicy (wxSTC_VISIBLE_STRICT|wxSTC_VISIBLE_SLOP, 1);
    SetXCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1);
    SetYCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1);

    // markers
    MarkerDefine (wxSTC_MARKNUM_FOLDER,        wxSTC_MARK_DOTDOTDOT, wxT("BLACK"), wxT("BLACK"));
    MarkerDefine (wxSTC_MARKNUM_FOLDEROPEN,    wxSTC_MARK_ARROWDOWN, wxT("BLACK"), wxT("BLACK"));
    MarkerDefine (wxSTC_MARKNUM_FOLDERSUB,     wxSTC_MARK_EMPTY,     wxT("BLACK"), wxT("BLACK"));
    MarkerDefine (wxSTC_MARKNUM_FOLDEREND,     wxSTC_MARK_DOTDOTDOT, wxT("BLACK"), wxT("WHITE"));
    MarkerDefine (wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_ARROWDOWN, wxT("BLACK"), wxT("WHITE"));
    MarkerDefine (wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY,     wxT("BLACK"), wxT("BLACK"));
    MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL,    wxSTC_MARK_EMPTY,     wxT("BLACK"), wxT("BLACK"));

    // annotations
    AnnotationSetVisible(wxSTC_ANNOTATION_BOXED);

    // miscellaneous
    m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, wxT("_999999"));
    m_FoldingMargin = 16;
    CmdKeyClear (wxSTC_KEY_TAB, 0); // this is done by the menu accelerator key
    SetLayoutCache (wxSTC_CACHE_PAGE);
    UsePopUp(wxSTC_POPUP_ALL);
}
Esempio n. 18
0
/* TextEditor::TextEditor
 * TextEditor class constructor
 *******************************************************************/
TextEditor::TextEditor(wxWindow* parent, int id)
	: wxStyledTextCtrl(parent, id), timer_update(this)
{
	// Init variables
	language = nullptr;
	ct_argset = 0;
	ct_function = nullptr;
	ct_start = 0;
	bm_cursor_last_pos = -1;
	panel_fr = nullptr;
	call_tip = new SCallTip(this);
	choice_jump_to = nullptr;
	jump_to_calculator = nullptr;

	// Set tab width
	SetTabWidth(txed_tab_width);

	// Line numbers by default
	SetMarginType(0, wxSTC_MARGIN_NUMBER);
	SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, "9999"));

	// Folding margin
	setupFoldMargin();

	// Border margin
	SetMarginWidth(2, 4);

	// Register icons for autocompletion list
	RegisterImage(1, Icons::getIcon(Icons::TEXT_EDITOR, "key"));
	RegisterImage(2, Icons::getIcon(Icons::TEXT_EDITOR, "const"));
	RegisterImage(3, Icons::getIcon(Icons::TEXT_EDITOR, "func"));

	// Init w/no language
	setLanguage(nullptr);

	// Setup various configurable properties
	setup();

	// Add to text styles editor list
	StyleSet::addEditor(this);

	// Bind events
	Bind(wxEVT_KEY_DOWN, &TextEditor::onKeyDown, this);
	Bind(wxEVT_KEY_UP, &TextEditor::onKeyUp, this);
	Bind(wxEVT_STC_CHARADDED, &TextEditor::onCharAdded, this);
	Bind(wxEVT_STC_UPDATEUI, &TextEditor::onUpdateUI, this);
	Bind(wxEVT_STC_CALLTIP_CLICK, &TextEditor::onCalltipClicked, this);
	Bind(wxEVT_STC_DWELLSTART, &TextEditor::onMouseDwellStart, this);
	Bind(wxEVT_STC_DWELLEND, &TextEditor::onMouseDwellEnd, this);
	Bind(wxEVT_LEFT_DOWN, &TextEditor::onMouseDown, this);
	Bind(wxEVT_KILL_FOCUS, &TextEditor::onFocusLoss, this);
	Bind(wxEVT_ACTIVATE, &TextEditor::onActivate, this);
	Bind(wxEVT_STC_MARGINCLICK, &TextEditor::onMarginClick, this);
	Bind(wxEVT_COMMAND_JTCALCULATOR_COMPLETED, &TextEditor::onJumpToCalculateComplete, this);
	Bind(wxEVT_STC_MODIFIED, &TextEditor::onModified, this);
	Bind(wxEVT_TIMER, &TextEditor::onUpdateTimer, this);
	Bind(wxEVT_STC_STYLENEEDED, &TextEditor::onStyleNeeded, this);
}
Esempio n. 19
0
void FB_STC::LoadSettings ( ) {
    FB_Config    * Prefs  = m_Ide->GetConfig();
    Style_STC_FB * Style  = &Prefs->Style_FB;

    // Clear all styles there might be defined
    StyleClearAll(  );
    SetLexer( 0 );
    
    // Tab and indenting
    SetTabWidth             ( Prefs->TabSize );
    SetUseTabs              ( false );
    SetTabIndents           ( true );
    SetBackSpaceUnIndents   ( true );
    SetIndent               ( Prefs->TabSize );
    SetIndentationGuides    ( Prefs->IndentGuide );
    
    // Right margin
    SetEdgeMode   ( Prefs->RightMargin ? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE );
    SetEdgeColumn ( Prefs->EdgeColumn );
    
    // Line and line ending
    SetEOLMode ( 0 );
    SetViewEOL ( Prefs->DisplayEOL );
    SetViewWhiteSpace ( Prefs->WhiteSpace ? wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE );
    
    // Misc
    CmdKeyClear (wxSTC_KEY_TAB, 0);
    #define _STYLE(nr) Style->Style[nr]
        wxFont font ( _STYLE(0).Size, wxMODERN, wxNORMAL, wxNORMAL, false, _STYLE(0).Font );

        StyleSetForeground (wxSTC_STYLE_DEFAULT,    Prefs->GetClr(_STYLE(0).Face));
        StyleSetBackground (wxSTC_STYLE_DEFAULT,    Prefs->GetClr(_STYLE(0).Back));
        StyleSetFont( wxSTC_STYLE_DEFAULT, font );

        StyleSetForeground (0,    Prefs->GetClr(_STYLE(0).Face));
        StyleSetBackground (0,    Prefs->GetClr(_STYLE(0).Back));
        StyleSetFont( 0, font );
        
        StyleSetForeground (wxSTC_STYLE_LINENUMBER, Prefs->GetClr(Style->LineNumberFace));
        StyleSetBackground (wxSTC_STYLE_LINENUMBER, Prefs->GetClr(Style->LineNumberBack));
        StyleSetFont( wxSTC_STYLE_LINENUMBER, font );
                    
        SetCaretForeground (Prefs->GetClr(Style->CaretFace));
        SetSelForeground(true, Prefs->GetClr(Style->SelectFace));
        SetSelBackground(true, Prefs->GetClr(Style->SelectBack));
    #undef STYLE

    int LineNrMargin = TextWidth(wxSTC_STYLE_LINENUMBER, _T("0001"));
    SetMarginWidth (0, Prefs->LineNumber ? LineNrMargin : 0);
    SetMarginWidth (1,0);

    if ( Prefs->CurrentLine )
    {
        SetCaretLineVisible( true );
        SetCaretLineBack( Prefs->GetClr( Style->CaretLine ) );
    }

}
Esempio n. 20
0
// advert is an ad for the package 
void advert(int w, int h) {
	VGfloat y = h/4;
	int fontsize = (w * 4) / 100;
	char *s = "github.com/ajstarks/openvg";
	char *a = "*****@*****.**";
	int imw = 110, imh = 110, rw = w/4, rh = (rw*2/3);
	VGfloat tw = TextWidth(s, fontsize);

	Start(w, h);
	makepi((w/2) - (rw/2), h/2, rw, rh);
	Fill(128, 0, 0, 1);
	Text(w / 2 - (tw / 2), y - (fontsize / 4), s, fontsize);
	y -= 100;
	tw = TextWidth(a, fontsize / 3);
	Fill(128, 128, 128, 1);
	Text(w / 2 - (tw / 2), y, a, fontsize / 3);
	Image((w / 2) - (imw / 2), 20, imw, imh, "starx.jpg");
	End();
}
Esempio n. 21
0
void message(const char *text, ...)
{
	char tmp[256];
	va_list vl;
	va_start(vl, text);
	vsprintf(tmp, text, vl);
	va_end(vl);
	tmp[strlen(tmp)] = 0;
        
	int th = TextHeight(fontstruct);
	int char_width = TextWidth(fontstruct, " ");
	int win_width = (strlen(tmp) * char_width) + (WLISTPADDING * 2);		
	int win_height = th;
	int win_x, win_y;
	switch(WLISTPOS)
		{
			case 0:
				win_x = PADDING_WEST;
				win_y = PADDING_NORTH;
				break;
			case 1:
				win_x = SCREEN_WIDTH - PADDING_EAST - win_width - (BORDER * 2);
				win_y = PADDING_NORTH;
				break;
			case 2:
				win_x = 0 + SCREEN_WIDTH - PADDING_EAST - win_width;
				win_y = 0 + SCREEN_HEIGHT - PADDING_SOUTH - win_height;
				break;
			case 3:
				win_x = PADDING_WEST;
				win_y = 0 + SCREEN_HEIGHT - PADDING_SOUTH - win_height;
				break;
			case 4:
				win_x = (SCREEN_WIDTH / 2) - (win_width / 2);
				win_y = (SCREEN_HEIGHT / 2) - (win_height / 2);
				break;
			default:
				win_x = PADDING_WEST;
				win_y = PADDING_NORTH;
				break;
		}
	Window message_window = XCreateSimpleWindow(display, root, win_x,  win_y, win_width, win_height, BORDER, name2color(FGCOLOR), name2color(BGCOLOR));
	XSetWindowBorderWidth(display, message_window, BORDER);		
	XSetWindowBorder(display, message_window, name2color(SELBGCOLOR));		
	XMapRaised(display, message_window);
	XDrawString(display, message_window, BARE_GC, WLISTPADDING, 0 + th - fontstruct->max_bounds.descent, tmp, strlen(tmp));
	XFlush(display);
	sleep(TIMEOUT);
	XFlush(display);
	if(message_window)
	{
		XDestroyWindow(display, message_window);
	}
}
Esempio n. 22
0
	int CHitDialog::GetStrWidth(std::string str)
	{
		std::string tmp,odd;
		int s = 0,e = 0,r = 0;
		int result =0;
		odd = str;
		if((int)odd.find("[") >= 0)
		{
			while(odd.length() > 0)
			{
				tmp = "";
				odd = GetBeforeStr(odd,tmp,"[");
				r += TextWidth(tmp);
				if(odd.length() > 0)
				{
					odd = GetBeforeStr(odd,tmp,"]");
					if(tmp.length() > 0)
					{
						if((int)tmp.find("img:") == 0)
						{
							r += 16;
						}else if((int)tmp.find("item:") == 0)
						{
							r += 16;
						}else if((int)tmp.find("color:") == 0 ||
							(int)tmp.find("/color") == 0 ||
							(int)tmp.find("bold:") == 0 ||
							(int)tmp.find("/bold") == 0)
						{

						}else
						{
							std::string a = "[" +tmp + "]";
							r += TextWidth( a);
						}
					}
				}
			}
		}
		return result;
	}
Esempio n. 23
0
int Font::WriteEllipsis( const char *str, Surface *dest, short x, short y,
                  const Rect &clip ) const {
  if ( (y + height < clip.y) || (y >= clip.y + clip.h) ||
       (x >= clip.x + clip.w) ) return 0;

  if ( TextWidth( str ) + x - clip.x > clip.w ) {
    const char *dots = "...";
    int w, addw = TextWidth( dots ) + x - clip.x;

    string text( str );

    do {
      text.erase( text.length() - 1 );
      w = TextWidth( text.c_str() ) + addw;
    } while ( (w > clip.w) && (text.length() > 1) );

    text.append( dots );
    str = text.c_str();
  }
  return Write( str, dest, x, y, clip );
}
int toResultViewMLine::realWidth(const QFontMetrics &fm, const toTreeWidget *top, int column, const QString &txt) const
{
    if (!MaxColDisp)
    {
        MaxColDisp = toConfigurationSingle::Instance().maxColDisp();
        Gridlines = toConfigurationSingle::Instance().displayGridlines();
    }
    QString t = text(column);
    if (t.isNull())
        t = txt;
    return std::min(TextWidth(fm, t), MaxColDisp) + top->itemMargin() * 2 - fm.minLeftBearing() - fm.minRightBearing() + 1;
}
Esempio n. 25
0
fbtTextFile::fbtTextFile(fbtMainFrame* parent, fbtText* fp, int id)
	:   wxStyledTextCtrl(parent, FBT_WINDOW_TXT),
	    m_file(fp), m_parent(parent)
{

	SetViewEOL(false);
	SetIndentationGuides(false);
	SetEdgeMode(wxSTC_EDGE_NONE);
	SetViewWhiteSpace(wxSTC_WS_INVISIBLE);

	SetReadOnly(false);
	SetTabWidth(4);
	SetWrapMode(wxSTC_WRAP_NONE);

	wxFont font (10, wxMODERN, wxNORMAL, wxNORMAL);
	StyleSetFont(wxSTC_STYLE_DEFAULT, font);


	StyleSetForeground(wxSTC_STYLE_DEFAULT,     *wxBLACK);
	StyleSetBackground(wxSTC_STYLE_DEFAULT,     *wxWHITE);
	StyleSetForeground(wxSTC_STYLE_LINENUMBER,  wxColour (wxT("DARK GREY")));
	StyleSetBackground(wxSTC_STYLE_LINENUMBER,  *wxWHITE);
	StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY")));


	SetMarginType(0, wxSTC_MARGIN_NUMBER);
	SetMarginWidth(0, TextWidth (wxSTC_STYLE_LINENUMBER, wxT("_99999")));

	SetVisiblePolicy(wxSTC_VISIBLE_STRICT | wxSTC_VISIBLE_SLOP, 1);
	SetXCaretPolicy(wxSTC_CARET_EVEN | wxSTC_VISIBLE_STRICT | wxSTC_CARET_SLOP, 1);
	SetYCaretPolicy(wxSTC_CARET_EVEN | wxSTC_VISIBLE_STRICT | wxSTC_CARET_SLOP, 1);


	SetLexer(wxSTC_LEX_CPP);

	StyleSetForeground(wxSTC_C_COMMENT,         COMMENT_COLOR);
	StyleSetForeground(wxSTC_C_COMMENTLINEDOC,  COMMENT_COLOR);
	StyleSetForeground(wxSTC_C_COMMENTLINE,     COMMENT_COLOR);
	StyleSetForeground(wxSTC_C_COMMENTDOC,      COMMENT_COLOR);
	StyleSetForeground(wxSTC_C_NUMBER,          NUMBER_COLOR);
	StyleSetForeground(wxSTC_C_OPERATOR,        OPERATOR_COLOR);
	StyleSetForeground(wxSTC_C_WORD,            WORD_COLOR);
	StyleSetForeground(wxSTC_C_PREPROCESSOR,    WORD_COLOR);

	SetKeyWords(0, WORDS);

	SetSelBackground(true, wxColor(51, 94, 168));
	SetSelForeground(true, wxColor(255, 255, 255));

	m_file->m_textFile = this;
	m_file->m_flag |= fbtText::FILE_IS_OPEN;
}
Esempio n. 26
0
static int DisplayEntry(int x, int y, int index, struct Entry *e,
			int hilite)
{
	char s[10];

#define INDEX_OFFSET     15
#define SCORE_OFFSET     40
#define MISSIONS_OFFSET  60
#define MISSION_OFFSET   80
#define NAME_OFFSET      85

	sprintf(s, "%d.", index + 1);
	DisplayAt(x + INDEX_OFFSET - TextWidth(s), y, s, hilite);
	sprintf(s, "%d", e->score);
	DisplayAt(x + SCORE_OFFSET - TextWidth(s), y, s, hilite);
	sprintf(s, "%d", e->missions);
	DisplayAt(x + MISSIONS_OFFSET - TextWidth(s), y, s, hilite);
	sprintf(s, "(%d)", e->lastMission + 1);
	DisplayAt(x + MISSION_OFFSET - TextWidth(s), y, s, hilite);
	DisplayAt(x + NAME_OFFSET, y, e->name, hilite);

	return 1 + TextHeight();
}
Esempio n. 27
0
int  MenuWidth(const char **table, int count)
{
	int i;
	int len, max;
	
	len = max = 0;
	
	for (i = 0; i < count; i++) {
		if ( ( len = TextWidth(table[i]) ) > max)
			max = len;
	}
	
	return max;
}
Esempio n. 28
0
/* 
 * DrawHeader() 
 *	- draws header label within main drawing area
 *
 * PARAMETERS
 *	data	- pointer to MyProgram structure
 *
 * RETURNS
 *	nothing
 */
void
DrawHeader(MyProgram *data)
{
   pointType	label_pos;

   int		width, height;
   XFont	font;


   font = GetWidgetFont( data->draw_area_widget );
   height = FontHeight( font );

   label_pos.x = DEFAULT_PROJ_LABEL_X;
   label_pos.y = DEFAULT_PROJ_LABEL_y;
   DrawText("Project:", label_pos.x, InvertY(label_pos.y));

   width = TextWidth( font, "Project:" );
   label_pos.x += (width + DEFAULT_LABEL_SPACING1);
   DrawText(data->proj.projname_str, label_pos.x, InvertY(label_pos.y));

   width = TextWidth( font, data->proj.projname_str );
   label_pos.x += (width + DEFAULT_LABEL_SPACING2);
   DrawText("Act:", label_pos.x, InvertY(label_pos.y));

   width = TextWidth( font, "Act:" );
   label_pos.x += (width + DEFAULT_LABEL_SPACING1);
   DrawText("1", label_pos.x, InvertY(label_pos.y));

   width = TextWidth( font, "1" );
   label_pos.x += (width + DEFAULT_LABEL_SPACING2);
   DrawText("Scene:", label_pos.x, InvertY(label_pos.y));

   width = TextWidth( font, "Scene:" );
   label_pos.x += (width + DEFAULT_LABEL_SPACING1);
   DrawText("1", label_pos.x, InvertY(label_pos.y));

}
Esempio n. 29
0
/* TextEditor::TextEditor
 * TextEditor class constructor
 *******************************************************************/
TextEditor::TextEditor(wxWindow* parent, int id)
	: wxStyledTextCtrl(parent, id)
{
	// Init variables
	language = NULL;
	ct_argset = 0;
	ct_function = NULL;
	ct_start = 0;

	// Set tab width
	SetTabWidth(txed_tab_width);

	// Line numbers by default
	SetMarginType(0, wxSTC_MARGIN_NUMBER);
	SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, "9999"));
	SetMarginWidth(1, 4);

	// Register icons for autocompletion list
	RegisterImage(1, getIcon("ac_key"));
	RegisterImage(2, getIcon("ac_const"));
	RegisterImage(3, getIcon("ac_func"));

	// Init w/no language
	setLanguage(NULL);

	// Find+Replace dialog
	dlg_fr = new FindReplaceDialog(this);

	// Setup various configurable properties
	setup();

	// Bind events
	Bind(wxEVT_KEY_DOWN, &TextEditor::onKeyDown, this);
	Bind(wxEVT_KEY_UP, &TextEditor::onKeyUp, this);
	Bind(wxEVT_STC_CHARADDED, &TextEditor::onCharAdded, this);
	Bind(wxEVT_STC_UPDATEUI, &TextEditor::onUpdateUI, this);
	Bind(wxEVT_STC_CALLTIP_CLICK, &TextEditor::onCalltipClicked, this);
	Bind(wxEVT_STC_DWELLSTART, &TextEditor::onMouseDwellStart, this);
	Bind(wxEVT_STC_DWELLEND, &TextEditor::onMouseDwellEnd, this);
	Bind(wxEVT_LEFT_DOWN, &TextEditor::onMouseDown, this);
	Bind(wxEVT_KILL_FOCUS, &TextEditor::onFocusLoss, this);
	Bind(wxEVT_ACTIVATE, &TextEditor::onActivate, this);
	dlg_fr->getBtnFindNext()->Bind(wxEVT_BUTTON, &TextEditor::onFRDBtnFindNext, this);
	dlg_fr->getBtnReplace()->Bind(wxEVT_BUTTON, &TextEditor::onFRDBtnReplace, this);
	dlg_fr->getBtnReplaceAll()->Bind(wxEVT_BUTTON, &TextEditor::onFRDBtnReplaceAll, this);
	//dlg_fr->getTextFind()->Bind(wxEVT_BUTTON, &TextEditor::onFRDBtnFindNext, this);
	//dlg_fr->getTextReplace()->Bind(wxEVT_BUTTON, &TextEditor::onFRDBtnReplace, this);
	dlg_fr->Bind(wxEVT_CHAR_HOOK, &TextEditor::onFRDKeyDown, this);
}
int toResultViewMLCheck::realWidth(const QFontMetrics &fm, const toTreeWidget *top, int column, const QString &txt) const
{
    if (!MaxColDisp)
    {
        MaxColDisp = toConfigurationSingle::Instance().maxColDisp();
        Gridlines = toConfigurationSingle::Instance().displayGridlines();
    }
    QString t = text(column);
    if (t.isNull())
        t = txt;
    int wx = top->itemMargin() * 2 - fm.minLeftBearing() - fm.minRightBearing() + 1;
    if (column == 0)
        wx += top->style()->pixelMetric(QStyle::PM_CheckListButtonSize) + 4 + top->itemMargin();

    return std::min(TextWidth(fm, t), MaxColDisp) + wx;
}