Why didn't I do this sooner?

new topic     » topic index » view thread      » older message » newer message

Have you ever had one of those epiphanic* moments where you think, "why didn't I do this sooner?" or "where has this been all my life?"

*ep-i-phan-ic adj. of or pertaining to an epiphany.

For me that came this evening while looking at a piece of code in Win32Lib compared to its sibling in wxEuphoria. In Win32Lib, I can create a MenuItem separator by simply passing the text as a single hyphen "-". In wxEuphoria, I have to either insert my separators later using insert_separator() or break my constant block, call append_separator(), then declare a new constant block and continue on.

So I added a few lines to wxMenu.cpp. smile

    parentMenu = (wxMenu *) get_int( params, 1 ); 
    if ( text == wxT("-") ) { 
        /* added this */ 
        item = NULL; 
        parentMenu->AppendSeparator(); 
    } 
    else { 
        /* original code */ 
        item = new wxMenuItem( parentMenu, id, text, helpString, kind, subMenu ); 
        if (use_bitmap) item->SetBitmap( bitmap ); 
        parentMenu->Append( item ); 
    } 

And now this...

include "wxeu/wxeud.e" 
without warning 
 
constant  
    frmMain         = create( wxFrame, {0, -1, "Menu Demo", -1, -1, 640, 480} ), 
    mbrMain         = create( wxMenuBar, {frmMain} ), 
    mnuFile         = create( wxMenu, {mbrMain, "&File"} ), 
    mnuFile_Prefs   = create( wxMenuItem, {mnuFile, -1, "&Preferences"} ), 
    mnuFile_Exit    = create( wxMenuItem, {mnuFile, wxID_EXIT, "E&xit"} ), 
    $ 
 
insert_separator( mnuFile, 1 ) 
 
wxMain( frmMain ) 

Becomes this...

include "wxeu/wxeud.e" 
without warning 
 
constant  
    frmMain         = create( wxFrame, {0, -1, "Menu Demo", -1, -1, 640, 480} ), 
    mbrMain         = create( wxMenuBar, {frmMain} ), 
    mnuFile         = create( wxMenu, {mbrMain, "&File"} ), 
    mnuFile_Prefs   = create( wxMenuItem, {mnuFile, -1, "&Preferences"} ), 
    mnuFile_Sep1    = create( wxMenuItem, {mnuFile, -1, "-"} ), 
    mnuFile_Exit    = create( wxMenuItem, {mnuFile, wxID_EXIT, "E&xit"} ), 
    $ 
 
wxMain( frmMain ) 

-Greg

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu