home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gwm18a.zip / wl_bar.c < prev    next >
C/C++ Source or Header  |  1995-07-03  |  2KB  |  104 lines

  1. /* Copyright 1989 GROUPE BULL -- See license conditions in file COPYRIGHT
  2.  * Copyright 1989 Massachusetts Institute of Technology
  3.  */
  4. /*********************\
  5. *               *
  6. *  WOOL_OBJECT: Bar  *
  7. *  BODY              *
  8. *               *
  9. \*********************/
  10.  
  11. #include "EXTERN.h"
  12. #include <stdio.h>
  13. #include "wool.h"
  14. #include "wl_atom.h"
  15. #include "wl_number.h"
  16. #include "wl_string.h"
  17. #include "gwm.h"
  18. #include "wl_event.h"
  19. #include "wl_fsm.h"
  20. #include "wl_plug.h"
  21. #include "INTERN.h"
  22. #include "wl_bar.h"
  23.  
  24. /*
  25.  * Constructor: wool_bar_make callable from wool
  26.  * (BAR min-width max-width plugs...)
  27.  */
  28.  
  29. WOOL_Bar
  30. wool_bar_make(argc, argv)
  31. int    argc;
  32. WOOL_Plug *argv;
  33. {
  34.     int             i;
  35.     WOOL_Bar        bar;
  36.  
  37.     bar = (WOOL_Bar) Malloc(sizeof(struct _WOOL_Bar) +
  38.                 sizeof(WOOL_OBJECT) * Max(0, argc - 1));
  39.     zrt_put(bar);
  40.     bar -> type = WLBar;
  41.     bar -> min_width = DefaultBarMinWidth;
  42.     bar -> max_width = DefaultBarMaxWidth;
  43.     bar -> borderwidth = DefaultBorderWidth;
  44.     bar -> borderpixel = Context -> pixel.Border;
  45.     bar -> background = Context -> pixel.Back;
  46.     bar -> plug_separator = DefaultPlugSeparator;
  47.     get_val_from_context(bar -> bordertile, WA_bordertile);
  48.     get_val_from_context(bar -> fsm, WA_fsm);
  49.     get_val_from_context(bar -> menu, WA_menu);
  50.     get_val_from_context(bar -> cursor, WA_cursor);
  51.     get_val_from_context(bar -> tile, WA_tile);
  52.     get_val_from_context(bar -> property, WA_property);
  53.  
  54.     fix_fsm(&(bar -> fsm));
  55.     bar -> plugs_size = argc;
  56.     for (i = 0; i < argc; i++) {
  57.     increase_reference(bar -> plugs[i] = argv[i]);
  58.     }
  59.     return bar;
  60. }
  61.  
  62. /*
  63.  * WLBar_print:
  64.  * BAR(text)
  65.  */
  66.  
  67. WOOL_OBJECT
  68. WLBar_print(obj)
  69. WOOL_Bar        obj;
  70. {
  71.     int             i;
  72.  
  73.     wool_printf("{BAR 0x%x: ", obj);
  74.     for (i = 0; i < obj -> plugs_size; i++) {
  75.     wool_print((obj -> plugs)[i]);
  76.     wool_puts(" ");
  77.     }
  78.     wool_puts("}");
  79.     return (WOOL_OBJECT) obj;
  80. }
  81.  
  82. /*
  83.  * WLBar_free:
  84.  * recursivly free fsm
  85.  */
  86.  
  87. WOOL_OBJECT
  88. WLBar_free(obj)
  89. WOOL_Bar        obj;
  90. {
  91.     int    i;
  92.  
  93.     decrease_reference(obj -> bordertile);
  94.     decrease_reference(obj -> fsm);
  95.     decrease_reference(obj -> menu);
  96.     decrease_reference(obj -> cursor);
  97.     decrease_reference(obj -> tile);
  98.     decrease_reference(obj -> property);
  99.     for (i = 0; i < obj -> plugs_size; i++)
  100.     decrease_reference(obj -> plugs[i]);
  101.     Free(obj);
  102.     return NULL;
  103. }
  104.