コード例 #1
0
ファイル: dohexeditor.cpp プロジェクト: AGoodPerson/Ascent
void DOHexEditor::del(U32 first_pos, U32 last_pos, BOOL undoable)
{
	if(first_pos > mValue.size() || last_pos > mValue.size())
	{
		llwarns << "pos outside data!" << llendl;
		return;
	}

	deselect();

	std::vector<U8>::iterator first = mValue.begin() + first_pos;
	std::vector<U8>::iterator last = mValue.begin() + last_pos;

	std::vector<U8> old_data;
	if(last_pos > 0) old_data = std::vector<U8>(first, last + 1);

	if(undoable)
	{
		DOUndoHex* action = (DOUndoHex*)(mUndoBuffer->getNextAction());
		action->set(this, &(DOUndoHex::undoDel), &(DOUndoHex::redoDel), first_pos, last_pos, old_data, std::vector<U8>());
	}
	
	mValue.erase(first, last + 1);

	changedLength();
}
コード例 #2
0
ファイル: dohexeditor.cpp プロジェクト: AGoodPerson/Ascent
DOHexEditor::DOHexEditor(const std::string& name, const LLRect& rect)
:	LLUICtrl(name, rect, TRUE, NULL, NULL),
	LLEditMenuHandler(),
	mColumns(16),
	mCursorPos(0),
	mSecondNibble(FALSE),
	mSelecting(FALSE),
	mHasSelection(FALSE),
	mInData(FALSE),
	mSelectionStart(0),
	mSelectionEnd(0)
{
	mGLFont = LLFontGL::getFontMonospace();

	mTextRect.setOriginAndSize( 
		5, // border + padding
		1, // border
		getRect().getWidth() - SCROLLBAR_SIZE - 6,
		getRect().getHeight() - 5);

	S32 line_height = llround( mGLFont->getLineHeight() );
	S32 page_size = mTextRect.getHeight() / line_height;

	// Init the scrollbar
	LLRect scroll_rect;
	scroll_rect.setOriginAndSize( 
		getRect().getWidth() - SCROLLBAR_SIZE,
		1,
		SCROLLBAR_SIZE,
		getRect().getHeight() - 1);
	S32 lines_in_doc = getLineCount();
	mScrollbar = new LLScrollbar( std::string("Scrollbar"), scroll_rect,
		LLScrollbar::VERTICAL,
		lines_in_doc,						
		0,						
		page_size,
		NULL, this );
	mScrollbar->setFollowsRight();
	mScrollbar->setFollowsTop();
	mScrollbar->setFollowsBottom();
	mScrollbar->setEnabled( TRUE );
	mScrollbar->setVisible( TRUE );
	mScrollbar->setOnScrollEndCallback(NULL, NULL);
	addChild(mScrollbar);

	mBorder = new LLViewBorder( std::string("text ed border"),
							LLRect(0, getRect().getHeight(), getRect().getWidth(), 0),
							LLViewBorder::BEVEL_IN,
							LLViewBorder::STYLE_LINE,
							1 ); // border width
	addChild( mBorder );

	changedLength();

	mUndoBuffer = new LLUndoBuffer(DOUndoHex::create, 128);
}
コード例 #3
0
ファイル: dohexeditor.cpp プロジェクト: AGoodPerson/Ascent
void DOHexEditor::reshape(S32 width, S32 height, BOOL called_from_parent)
{
	LLView::reshape( width, height, called_from_parent );
	mTextRect.setOriginAndSize( 
		5, // border + padding
		1, // border
		getRect().getWidth() - SCROLLBAR_SIZE - 6,
		getRect().getHeight() - 5);
	LLRect scrollrect;
	scrollrect.setOriginAndSize( 
		getRect().getWidth() - SCROLLBAR_SIZE,
		1,
		SCROLLBAR_SIZE,
		getRect().getHeight() - 1);
	mScrollbar->setRect(scrollrect);
	mBorder->setRect(LLRect(0, getRect().getHeight(), getRect().getWidth(), 0));
	changedLength();
}
コード例 #4
0
ファイル: dohexeditor.cpp プロジェクト: AGoodPerson/Ascent
void DOHexEditor::insert(U32 pos, std::vector<U8> new_data, BOOL undoable)
{
	if(pos > mValue.size())
	{
		llwarns << "pos outside data!" << llendl;
		return;
	}

	deselect();

	if(undoable)
	{
		DOUndoHex* action = (DOUndoHex*)(mUndoBuffer->getNextAction());
		action->set(this, &(DOUndoHex::undoInsert), &(DOUndoHex::redoInsert), pos, pos, std::vector<U8>(), new_data);
	}

	std::vector<U8>::iterator wheres = mValue.begin() + pos;

	mValue.insert(wheres, new_data.begin(), new_data.end());

	changedLength();
}
コード例 #5
0
ファイル: preferences.cpp プロジェクト: sigidagi/chimpanse
 void Preferences::accept()
 {
     changedTime();
     changedLength();
     this->close();
 }
コード例 #6
0
ファイル: dohexeditor.cpp プロジェクト: AGoodPerson/Ascent
void DOHexEditor::setColumns(U8 columns)
{
	//mColumns = columns;
	mColumns = llclamp<U8>(llfloor(columns), 8, 64); //clamp this ffs
	changedLength();
}
コード例 #7
0
ファイル: dohexeditor.cpp プロジェクト: AGoodPerson/Ascent
void DOHexEditor::setValue(const LLSD& value)
{
	mValue = value.asBinary();
	changedLength();
}