/*
 * UPIWIN - Micro Pi Windowing Framework Kernel
 * Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *-------------------------------------------------------------------------
 */
#include <stddef.h>
#include <string.h>
#include "wintype.h"
#include "bitmap.h"

/* references to the icon data */
extern uint8_t _binary_i_freehand_bin_start[];
extern uint8_t _binary_i_freehand_bin_end;
extern uint8_t _binary_i_freehand_bin_size;

extern uint8_t _binary_i_line_bin_start[];
extern uint8_t _binary_i_line_bin_end;
extern uint8_t _binary_i_line_bin_size;

extern uint8_t _binary_i_rect_bin_start[];
extern uint8_t _binary_i_rect_bin_end;
extern uint8_t _binary_i_rect_bin_size;

extern uint8_t _binary_i_fillrect_bin_start[];
extern uint8_t _binary_i_fillrect_bin_end;
extern uint8_t _binary_i_fillrect_bin_size;

extern uint8_t _binary_i_undo_bin_start[];
extern uint8_t _binary_i_undo_bin_end;
extern uint8_t _binary_i_undo_bin_size;

extern uint8_t _binary_i_clear_bin_start[];
extern uint8_t _binary_i_clear_bin_end;
extern uint8_t _binary_i_clear_bin_size;

typedef struct tagSTOCKBITMAPDESC {
  PCSTR name;
  INT32 width;
  INT32 height;
  const void *data;
} STOCKBITMAPDESC;

static const STOCKBITMAPDESC stock_bitmaps[] = {
  {"freehand", 48, 48, _binary_i_freehand_bin_start },
  {"line", 48, 48, _binary_i_line_bin_start },
  {"rect", 48, 48, _binary_i_rect_bin_start },
  {"fillrect", 48, 48, _binary_i_fillrect_bin_start },
  {"undo", 48, 48, _binary_i_undo_bin_start },
  {"clear", 48, 48, _binary_i_clear_bin_start },
  {NULL, 0, 0, NULL }
};

PBITMAP _BMP_GetStock(PCSTR name)
{
  INT32 i;

  for (i = 0; stock_bitmaps[i].name; ++i)
    if (strcmp(name, stock_bitmaps[i].name) == 0)
      return BMP_Create(stock_bitmaps[i].width, stock_bitmaps[i].height, stock_bitmaps[i].data);
  return NULL;
}
