// C++ code Copyright (C) David R. Evans G4AMJ/NQ0I

// the icon class

#ifndef ICONH
#define ICONH

#include <DREstring.h>
#include <suntool/icon_load.h>

class myicon
{ friend class frame;
  Icon i;

public:
  myicon(void) { i = icon_create(0); }
  myicon(Pixrect* pr) { i = icon_create(ICON_IMAGE, &pr, 0); }
  myicon(DREstring& filename)
  { i = icon_create(0); icon_load(i, (char*)filename, NULL); }

  ~myicon(void) { icon_destroy(i); }

// access functions -- set
  myicon& font(Pixfont* pf) { icon_set(i, ICON_FONT, pf, 0); return *this; }
  myicon& height(int n) { icon_set(i, ICON_HEIGHT, n, 0); return *this; }
  myicon& image(Pixrect* pr) { icon_set(i, ICON_IMAGE, pr, 0); return *this; }
  myicon& image_rect(Rect* r) { icon_set(i, ICON_IMAGE_RECT, r, 0); return *this; }
  myicon& label(char* c) { icon_set(i, ICON_LABEL, c, 0); return *this; }
  myicon& label_rect(Rect* r) { icon_set(i, ICON_LABEL_RECT, r, 0); return *this; }
  myicon& width(int n) { icon_set(i, ICON_WIDTH, n, 0); return *this; }

// access functions -- get
  Pixfont* font(void) { return (Pixfont*)icon_get(i, ICON_FONT); }
  int height(void) { return (int)icon_get(i, ICON_HEIGHT); }
  Pixrect* image(void) { return (Pixrect*)icon_get(i, ICON_IMAGE); }
  Rect* image_rect(void) { return (Rect*)icon_get(i, ICON_IMAGE_RECT); }
  char* label(void) { return (char*)icon_get(i, ICON_LABEL); }
  Rect* label_rect(void) { return (Rect*)icon_get(i, ICON_LABEL_RECT); }
  int width(void) { return (int)icon_get(i, ICON_WIDTH); }

};

#endif
