Listing 7

struct edit : wnd_extend<window_base,edit> {
  ...
};

// notifications
struct ev { template <int id> struct edit {
  // received when the edit box loses focus
  struct kill_focus : unique_event<kill_focus> {
    kill_focus(wnd<> w) : new_focus(w) {}
    wnd<> new_focus;
  };

  // received when the edit box gains focus
  struct set_focus : unique_event<set_focus> {
    set_focus(wnd<> w) : old_focus(w) {}
    wnd<> old_focus;
  };
  ...
}; };

// events
struct wm {
  // call this to find out the current selection
  struct get_sel : unique_event<get_sel> {
    get_sel(int &s, int &e) : start(s), end(e) {}
    int &start, &end;
  };

  // call this to set the current selection
  struct set_sel : unique_event<set_sel> {
    set_sel(int s, int e) : start(s), end(e) {}
    int start, end;
  };
  ...
};


template<int ctrl_id> 
  struct events_for_class<ctrl_id,edit> 
    : public ev::edit<ctrl_id> {};