Guest User

POSNK Panel widget interface

a guest
Aug 31st, 2014
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.52 KB | None | 0 0
  1. In order to implement a new widget for the "tardis" panel one has to provide at
  2. least:
  3.  * An empty paint method to override the WTK default paint-background method
  4.  * A create-widget fucntion that sets w_mode and instantiates a WTK widget with
  5.    a correctly set width field.
  6.  
  7. An example widget implementation is provided below:
  8.  
  9. -------------------------------------------------------------------------------
  10.  
  11. #include <stdlib.h>
  12.  
  13. #include <cairo.h>
  14.  
  15. #include <wtk/widget.h>
  16.  
  17. #include "tardis.h"
  18.  
  19. /* Paint method, called whenever the widget needs to be updated */
  20. void example_paint(wtk_widget_t *w, cairo_t *context, int focused)
  21. {
  22. }
  23.  
  24. /* Process method, called periodically by the panel application, use this for *
  25.  * dynamic content */
  26. void example_process(panel_widget_t *w)
  27. {
  28. }
  29.  
  30. /* Creation method */
  31. panel_widget_t *example_create()
  32. {
  33.     /* Specify the width of the widget, the other fields are set by the *
  34.      * panel layout routine */
  35.     clara_rect_t rect = {0, 0, 200, 0};
  36.  
  37.     /* Allocate memory for the widget object */
  38.     panel_widget_t *w = malloc(sizeof(panel_widget_t));
  39.  
  40.     /* This is a fixed width widget */
  41.     w->w_mode = PANEL_W_MODE_FIXED;
  42.  
  43.     /* Instantiate the WTK widget */
  44.     w->widget = wtk_create_widget(rect);
  45.  
  46.     /* Set the callbacks */
  47.     w->widget->callbacks.paint = &example_paint;
  48.     w->process = &example_process;
  49.  
  50.     /* Optionally, set the implementation specific data pointer */
  51.     w->impl = NULL;
  52.     return w;
  53. }
  54.  
  55. -------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment