All pastes #259596 Raw Edit

Miscellany

public text v1 · immutable
#259596 ·published 2006-11-27 16:07 UTC
rendered paste body
stuct Ewl_Stock_Funcs
{ 
  struct  
   {
     void (*txt)(Ewl_Stock *s, const char *txt);
     void (*alt_txt)(Ewl_Stock *s, const char *txt);
     void (*tooltip)(Ewl_Stock *s, const char *tooltip);
     void (*img)(Ewl_Stock *s, const char *path, const char *key);
   } set;

   struct
   {
     const char *(*txt)(Ewl_Stock *s);
     const char *(*alt_txt)(Ewl_Stock *s);
     const char *(*tooltip)(Ewl_Stock *s);
     const char *(*img_path)(Ewl_Stock *s);
     const char *(*img_name)(Ewl_Stock *s);
   } get;
};

stuct Ewl_Stock
{
   Ewl_Box b;
   Ewl_Stock_Funcs *funcs;
};

void ewl_stock_text_cb_set(Ewl_Stock *s, void (*set_txt)(Ewl_Stock *s, const char *txt));
void ewl_stock_image_cb_set(Ewl_Stock *s, void (*set_txt)(Ewl_Stock *s, const char *path, const char *key))


void ewl_stock_functions_set(Ewl_Stock *s, Ewl_Stock_Funcs *funcs)
{
   s->funcs = ewl_stock_funcs_register(funcs);
}


# ewL_stock_funcs_regstier would use ref_counts and a cache so that we only ahve one set of each of these in memory so, we'd end up with one for buttons and one for icons.


-----------------------
struct Ewl_Button
{
  Ewl_Stock s;
  Ewl_Label *label;
}

Ewl_Stock_Funcs funcs;

b = ewl_button_new();

funcs.get.txt = ewl_button_cb_stock_text_get;
funcs.set.txt = ewl_button_cb_stock_text_set;
...

ewl_stock_functions_set(EWL_STOCK(b), &funcs);