Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: ascii_moe on September 30, 2010, 12:20:01 pm

Title: Change order when adding code in "Extra code" property field?
Post by: ascii_moe on September 30, 2010, 12:20:01 pm
Hi all,

I'm currently facing the following problem:

I've added a wxGrid in Code::Blocks, set the column lables, etc.
Since some label values are bigger than the column width, these labels are "cut" at the beginning and the end.
So, I've added "AutoSizeColumns()" manually to the code, compiled it and it works - ok.

But every time I do some changes on this grid in Code::Blocks, it deletes the "AutoSizeColumns()" line and I have to add it, again... :-/

I figured out, that entering "Grid_MgUeb->AutoSizeColumns();" into the "Extra code" property will add this line of code when creating this object, but on the wrong place.

Manually I tried it that way (creating the grid, setting the column labels and AFTER this, resizing the columns):
Code
    Grid_MgUeb = new wxGrid(Panel4, ID_GRID1, wxDefaultPosition, wxSize(1050,344), 0, _T("ID_GRID1"));
    Grid_MgUeb->CreateGrid(16,8);
    Grid_MgUeb->Disable();
    Grid_MgUeb->EnableEditing(false);
    Grid_MgUeb->EnableGridLines(true);
    Grid_MgUeb->SetDefaultRowSize(20, true);
    Grid_MgUeb->SetColLabelValue(0, _("Nachname"));
    Grid_MgUeb->SetColLabelValue(1, _("Vorname"));
[...]
    Grid_MgUeb->SetDefaultCellFont( Grid_MgUeb->GetFont() );
    Grid_MgUeb->SetDefaultCellTextColour( Grid_MgUeb->GetForegroundColour() );
    Grid_MgUeb->AutoSizeColumns(); <- !!!

But Code::Blocks does it that way (creating the grid, THEN resizing the columns and at least setting the column labels):
Code
    Grid_MgUeb = new wxGrid(Panel4, ID_GRID1, wxDefaultPosition, wxSize(1050,344), 0, _T("ID_GRID1"));
    Grid_MgUeb->CreateGrid(16,8);
    Grid_MgUeb->Disable();
    Grid_MgUeb->AutoSizeColumns(); <- !!!
    Grid_MgUeb->EnableEditing(false);
    Grid_MgUeb->EnableGridLines(true);
    Grid_MgUeb->SetDefaultRowSize(20, true);
    Grid_MgUeb->SetColLabelValue(0, _("Nachname"));
    Grid_MgUeb->SetColLabelValue(1, _("Vorname"));
[...]
    Grid_MgUeb->SetDefaultCellFont( Grid_MgUeb->GetFont() );
    Grid_MgUeb->SetDefaultCellTextColour( Grid_MgUeb->GetForegroundColour() );
After this the column width is smaller than without any resizing!

Is there any option to tell Code::Blocks to add this code line at the END of the generated code?

Thanks in advance!
/T
Title: Re: Change order when adding code in "Extra code" property field?
Post by: Jenna on September 30, 2010, 01:50:19 pm
As far as I know, there is no such option, but as workaround you can add the code after the closing //*)-tag.
Code aout side these tags ( //(* and //*) ) will not be changed by wxSmith.
Title: Re: Change order when adding code in "Extra code" property field?
Post by: ascii_moe on September 30, 2010, 02:26:00 pm
Hmm..., not nice, but it works.  ;-)

Thanks, Jens!