/* -*- c -*- */ /* elmo - ELectronic Mail Operator Copyright (C) 2003, 2004 rzyjontko 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; version 2. 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define FOCUS @focus@ #define LABEL_TXT @label_have_txt@ #define LABEL_DEF @label_def@ #ifndef GET_COLOR_DEFINED #define GET_COLOR_DEFINED 1 static chtype get_color (ask_t *ask, const char *fg_field, const char *bg_field, const char *fg_def, const char *bg_def) { char *fg; char *bg; fg = ask_get_field (ask, fg_field); bg = ask_get_field (ask, bg_field); if (fg && bg){ return color_from_str (fg, bg); } else if (fg){ return color_from_str (fg, bg_def); } else if (bg){ return color_from_str (fg_def, bg); } return color_from_str (fg_def, bg_def); } #endif static WINDOW * @fun@ (void) { ask_t *ask = ask_select_default ("win_@name@"); int height = @height@; int width = @width@; int top = @top@; int left = @left@; int maxheight = LINES; int maxwidth = COLS; WINDOW *win; @VARS@ if (height <= 0) height += maxheight; if (width <= 0) width += maxwidth; if (top < 0) top += maxheight; if (left < 0) left += maxwidth; if (height > maxheight) height = maxheight; if (width > maxwidth) width = maxwidth; if (top + height > maxheight) top = maxheight - height; if (left + width > maxwidth) left = maxwidth - width; win = window_create ("@name@", height, width, top, left, @focus@); if (ask){ #if FOCUS if (ask_get_field_int_default (ask, "label", @label_def@)){ @label_name@ = label_create (win); } else { @label_name@ = NULL; } #endif /* FOCUS */ ask_destroy (ask); } #if LABEL_DEF else { @label_name@ = label_create (win); } #endif /* LABEL_DEF */ #if LABEL_TXT if (label){ label_set_text (@label_name@, @label_txt@); } #endif /* LABEL_TXT */ wattrset (win, text_color); return win; }