Re: Issues installing Euphoria

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

Well shucks, that looks great so far! smile

dcuny said...

void WXEUAPI set_scrollbar( intptr_ this_ptr, int position, int thumbSize, int range, int pageSize, ??? refresh )
{
((wxScrollBar*)this_ptr)->SetScrollbar( position, thumbSize, range, pageSize, refresh );
}

The ?? indicates places where I haven't yet figured out how wxEuphoria casts the types. I haven't had time to figure out if a bool is cast as an int, or a bool.

You could just pass that through as C_BOOL. No casting required. Although currently it would probably be intptr_t and then cast to bool.

dcuny said...

My "SWIG" code actually a fairly clever, since it knows that an int * needs to be handled by sending it back as a sequence parameter, and so it automatically converts:

virtual void GetTextExtent(const wxString& string, int* x, int* y, int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL ) const

into:

object WXEUAPI get_text_extent( intptr_ this_ptr, ??? string, ??? font ){
int x, y, descent, externalLeading;
seq1_ptr seq = NewS1( 4 );
((wxScrollBar*)this_ptr)->GetTextExtent( string, &x, &y, &descent, &externalLeading, font );

seq->base[1] = x;
seq->base[2] = y;
seq->base[3] = descent;
seq->base[4] = externalLeading;

return MAKE_SEQ( seq );
}

That would look something like this. You can use get_string() to return a wxString from an object. Just remember to dereference the object with wxDeRef().

object WXEUAPI get_text_extent( intptr_t this_ptr, object string, intptr_t font ) { 
    int x, y, descent, externalLeading; 
    seq1_ptr seq = NewS1( 4 ); 
    ((wxScrollBar*)this_ptr)->GetTextExtent( get_string(string), &x, &y, &descent, &externalLeading, (wxFont*)font ); 
    wxDeRef( string ); 
 
    seq->base[1] = x; 
    seq->base[2] = y; 
    seq->base[3] = descent; 
    seq->base[4] = externalLeading; 
 
    return MAKE_SEQ( seq ); 
} 

dcuny said...

How are events handled?

Here's my understanding of the event flow. It's basically a single event handler that proxies the routine calls back into Euphoria.

  1. initialize() in wxeud.e (around line 7500) is called to start the process
    • passes call-backs for the C++ code to call routines in Euphoria by proxy
    • this then calls...
  2. initialize() in wxEuphoria.cpp (around line 715)
    • creates EuApp instance and stores call-back pointers
  3. user code calls set_event_handler() in wxEuphoria.cpp (around line 220)
    • establishes the "proper" parent for the event (quirky behavior for wxMenu)
    • creates a wxEuClientData() object and adds the values to its list
    • connects the generic EuEvent::Handler function to the event
  4. when an event is triggered, wxWidgets calls EuEvent::Handler in wxEuphoria.cpp (around line 140)
    • gets the wxEuClientData object associated with the event handler
    • builds a sequence to hold the event handler values
    • calls EuApp::wxEuApp->proc() to call the Euphoria call-back
  5. some event handlers require calls to other functions to get more event data (e.g. mouse_event_position())
dcuny said...

How are the wxWidgets constants exposed to wxEuphoria?

Static constants are just declared outright in wxeud.e, starting around line 2763 through line 4450. These are copied directly from wxWidgets include files.

The wxEVT_ values are a bit different. They are stored in a top-level int[] array in wxeu.cpp around line 290. Starting around line 2260 in wxeud.e, a function called next_event() peeks these values from memory. The corresponding wxEVT_ lines between wxeu.cpp and wxeud.e must be in the correct order for obvious reasons. I believe Matt had to do this differently because the wxEVT_ values are dynamically generated by macros.

dcuny said...

How are pointers to wxWidgets objects passed?

The function box_int() in wxeu.h (and its macro BOX_INT()) returns a Euphoria integer where applicable or an atom (via NewDouble()). This BOX_INT() macro is quite ubiquitous in wxEuphoria to ensure values are passed correctly back to Euphoria. Conversely, when Euphoria objects are passed into wxEuphoria, the object pointers come in as intptr_t and are then cast directly to the appropriate class pointer (which it seems you've already discovered). The wxDeRef() macro decrements the ref count on atoms and sequences to keep Euphoria happy.

-Greg

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

Search



Quick Links

User menu

Not signed in.

Misc Menu