// Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // // Copyright(C) 2005,2006 Simon Howard // // 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., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. // #include #include #include "txt_gui.h" #include "txt_io.h" #include "txt_main.h" typedef struct txt_cliparea_s txt_cliparea_t; struct txt_cliparea_s { int x1, x2; int y1, y2; txt_cliparea_t *next; }; // Array of border characters for drawing windows. The array looks like this: // // +-++ // | || // +-++ // +-++ static const int borders[4][4] = { {0xda, 0xc4, 0xc2, 0xbf}, {0xb3, ' ', 0xb3, 0xb3}, {0xc3, 0xc4, 0xc5, 0xb4}, {0xc0, 0xc4, 0xc1, 0xd9}, }; static txt_cliparea_t *cliparea = NULL; #define VALID_X(x) ((x) >= cliparea->x1 && (x) < cliparea->x2) #define VALID_Y(y) ((y) >= cliparea->y1 && (y) < cliparea->y2) void TXT_DrawDesktopBackground(const char *title) { int i; unsigned char *screendata; unsigned char *p; screendata = TXT_GetScreenData(); // Fill the screen with gradient characters p = screendata; for (i=0; i 1) { cursor_x += (cursor * (w - 3)) / (range - 1); } if (cursor_x > x + w - 2) { cursor_x = x + w - 2; } for (x1=x+1; x1 y + h - 2) { cursor_y = y + h - 2; } if (range > 1) { cursor_y += (cursor * (h - 3)) / (range - 1); } for (y1=y+1; y1x1 = 0; cliparea->x2 = TXT_SCREEN_W; cliparea->y1 = 1; cliparea->y2 = TXT_SCREEN_H - 1; cliparea->next = NULL; } } void TXT_PushClipArea(int x1, int x2, int y1, int y2) { txt_cliparea_t *newarea; newarea = malloc(sizeof(txt_cliparea_t)); // Set the new clip area to the intersection of the old // area and the new one. newarea->x1 = cliparea->x1; newarea->x2 = cliparea->x2; newarea->y1 = cliparea->y1; newarea->y2 = cliparea->y2; if (x1 > newarea->x1) newarea->x1 = x1; if (x2 < newarea->x2) newarea->x2 = x2; if (y1 > newarea->y1) newarea->y1 = y1; if (y2 < newarea->y2) newarea->y2 = y2; #if 0 printf("New scrollable area: %i,%i-%i,%i\n", x1, y1, x2, y2); #endif // Hook into the list newarea->next = cliparea; cliparea = newarea; } void TXT_PopClipArea(void) { txt_cliparea_t *next_cliparea; // Never pop the last entry if (cliparea->next == NULL) return; // Unlink the last entry and delete next_cliparea = cliparea->next; free(cliparea); cliparea = next_cliparea; }