2011-02-06 05:44:45 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2010-04-01 05:28:00 +00:00
|
|
|
#include <malloc.h>
|
2011-02-06 05:44:45 +00:00
|
|
|
#include <errno.h>
|
2011-06-03 05:48:26 +00:00
|
|
|
|
2010-04-01 05:28:00 +00:00
|
|
|
#include "frame.h"
|
2011-05-08 23:20:22 +00:00
|
|
|
#include "common.h"
|
2010-04-01 05:28:00 +00:00
|
|
|
|
2010-04-05 07:33:10 +00:00
|
|
|
void allocate_frame(struct frame **frame) {
|
2011-02-06 05:44:45 +00:00
|
|
|
if (!(*frame = malloc(sizeof(**frame)))) {
|
2011-05-08 23:20:22 +00:00
|
|
|
fprintf(stderr, tty_solitaire_error_message(errno, __FILE__, __LINE__));
|
2011-02-06 05:44:45 +00:00
|
|
|
exit(errno);
|
|
|
|
}
|
2011-05-29 18:19:00 +00:00
|
|
|
(*frame)->window = newwin(FRAME_HEIGHT, FRAME_WIDTH, 0, 0);
|
2010-04-05 07:33:10 +00:00
|
|
|
}
|
2010-04-01 05:28:00 +00:00
|
|
|
|
2010-04-05 07:33:10 +00:00
|
|
|
void initialize_frame(struct frame *frame) {
|
2011-05-09 03:38:31 +00:00
|
|
|
frame->begin_y = 0;
|
|
|
|
frame->begin_x = 0;
|
2010-04-01 05:28:00 +00:00
|
|
|
}
|
|
|
|
|
2011-02-14 02:10:47 +00:00
|
|
|
void free_frame(struct frame *frame) {
|
2011-06-03 05:48:26 +00:00
|
|
|
delwin(frame->window);
|
2010-04-01 05:28:00 +00:00
|
|
|
free(frame);
|
|
|
|
}
|
|
|
|
|
2011-05-09 03:38:31 +00:00
|
|
|
void set_frame(struct frame *frame, int begin_y, int begin_x) {
|
|
|
|
frame->begin_y = begin_y;
|
|
|
|
frame->begin_x = begin_x;
|
2011-05-29 18:19:00 +00:00
|
|
|
mvwin(frame->window, begin_y, begin_x);
|
2010-04-01 05:28:00 +00:00
|
|
|
}
|
2011-06-03 05:48:26 +00:00
|
|
|
|
|
|
|
struct frame *duplicate_frame(struct frame *frame) {
|
|
|
|
struct frame *new_frame;
|
|
|
|
|
|
|
|
allocate_frame(&new_frame);
|
|
|
|
set_frame(new_frame, frame->begin_y, frame->begin_x);
|
|
|
|
|
|
|
|
return(new_frame);
|
|
|
|
}
|