restoring scrolled state Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
awsdert
Super wx Problem Solver
Super wx Problem Solver
Posts: 324
Joined: Fri Aug 26, 2011 5:04 pm

restoring scrolled state

Post by awsdert »

I have a function that is called by various events, the function captures the current scrolled state and where the grid cursor is, it then sets a member variable of the class ( derived from a derived class of wxFrame ) it is contained within to 1, then it freezes the grid it is about to modify, then after destroying the rows and then regenerating them based on new data it sets the previously mentioned variable to 2, my on idle event detects when this variable goes above 0 where it then constantly resets the scrollbar and grid cursor after which it checks if the variable is equal to 3 and sets it to 0 then it checks if the variable is equal to 2 and sets it to 3. The problem is that while the grid cursors state is restored the scroll state is not restored, here is my code:

Code: Select all

void G::FillEditor( void )
{
	SetTime();
	if ( isEdit ) return;
	mSetEditor = 1;
	editRow = edit_G->GetGridCursorRow();
	editCol = edit_G->GetGridCursorCol();
	edit_G->GetViewStart( &editX, &editY );
	NewHook();
	edit_G->Freeze();
	++editIsRecursing;
	s8  ramNo = editRam_D->GetSelection();
	u64 ramStart = 0u;
	u64 ramEnd   = 0u;
	u32 useSize  = mGetRam( ramStart, ramEnd, ramNo );
	if ( useSize == 0u ) return;
	u64 byte     = GetHex( editGet_TXT->GetValue() );
	if ( byte > 0u )
	{
		while ( ( byte % 0x10  ) > 0 ) byte--;
		while ( ( byte % 0x100 ) > 0 ) byte -= 0x10;
	}
	u32  divByte = byte + 0x100;
	u8*  ram8    = new u8[ useSize ];
	u16* ram16   = reinterpret_cast< u16* >( ram8 );
	if ( hookApp )
	{
		GetRamX( appHandle, ramStart + byte, ram8, useSize );
	}
	else
	{
		bin_BF.Seek( ramStart + byte, wxFromStart );
		bin_BF.Read( ram8, useSize );
	}
	wxChar cAscii;
	xStr   sAscii;
	xStr   cUnicode;
	xStr   sUnicode;
	xStr   text;
	bool getUnicode = false;
	edit_G->DeleteRows( 0, edit_G->GetRows(), false );
	u32 i = 0u, i16 = 0u, row = 0u, col = 0u;
	isJustFilled = true;
	editRePainting = 0;
	edit_G->AppendRows( 0x30, false );
	for ( ; ( row < 0x30 && byte < divByte && i < useSize ); ++row )
	{
		text.Printf( hex64, byte + i );
		edit_G->SetRowLabelValue( row, text );
		sAscii.Clear();
		sUnicode.Clear();
		for ( col = 0u; ( col < 16u && i < useSize ); ++col, ++i )
		{
			cAscii = ram8[ i ];
			sAscii += cAscii;
			getUnicode = false;
			if ( getUnicode )
			{
				cUnicode.FromUTF8( reinterpret_cast< char* >( &ram16[ i16 ] ) );
				sUnicode  += cUnicode;
				getUnicode = false;
				++i16;
			}
			else getUnicode = true;
			text.Printf( hex8, ram8[ i ] );
			edit_G->SetCellValue( row, col, text );
		}
		edit_G->SetCellValue( row, 16, sAscii );
		edit_G->SetCellValue( row, 17, sUnicode );
	}
	delete [] ram8;
	DelHook();
	--editIsRecursing;
	edit_G->Thaw();
	mSetEditor = 2;
}
// Idle Function
	if ( editAdd > 0u && panelIndex == 3 )
	{
		doEvent = true;
		if ( now >= editUntil )
		{
			FillEditor();
		}
	}
	if ( mSetEditor > 0 )
	{
		edit_G->ClearSelection();
		edit_G->SetGridCursor( editRow, editCol );
		edit_G->Scroll( editX, editY );
		if ( mSetEditor == 3 ) mSetEditor = 0;
		if ( mSetEditor == 2 ) mSetEditor = 3;
	}
Does anyone have any suggestions for fixing this?
tuli
Knows some wx things
Knows some wx things
Posts: 42
Joined: Sat Dec 03, 2011 3:56 pm

Re: restoring scrolled state

Post by tuli »

Image
awsdert
Super wx Problem Solver
Super wx Problem Solver
Posts: 324
Joined: Fri Aug 26, 2011 5:04 pm

Re: restoring scrolled state

Post by awsdert »

Take a look at HackerEX and you'll know what I mean when trying to use the Editor.

Oh and great pic, every time I look at it I laugh XD
awsdert
Super wx Problem Solver
Super wx Problem Solver
Posts: 324
Joined: Fri Aug 26, 2011 5:04 pm

Re: restoring scrolled state

Post by awsdert »

Never mind, I chose a simpler route:

Code: Select all

u32 rowMax   = edit_G->GetRows();
u32 rowCount = 0x30;
if ( rowCount > rowMax ) edit_G->AppendRows( rowCount - rowMax, false );
else if ( rowCount < rowMax ) edit_G->DeleteRows( rowCount - 1, rowMax - rowCount, false );
Should've done this from the start, simple is always better - like the pic XD.
Post Reply