mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-22 23:05:24 +00:00
Moved sb_* variables to sb.c.
This commit is contained in:
11
curses.h
11
curses.h
@@ -28,7 +28,7 @@ Defined by this header:
|
||||
**man-end****************************************************************/
|
||||
|
||||
#define PDCURSES 1
|
||||
#define PDC_BUILD 3900
|
||||
#define PDC_BUILD 3901
|
||||
#define PDC_VER_MAJOR 3
|
||||
#define PDC_VER_MINOR 9
|
||||
#define PDC_VERDOT "3.9"
|
||||
@@ -347,15 +347,6 @@ typedef struct
|
||||
bool key_code; /* TRUE if last key is a special key;
|
||||
used internally by get_wch() */
|
||||
MOUSE_STATUS mouse_status; /* last returned mouse status */
|
||||
#ifdef XCURSES
|
||||
bool sb_on;
|
||||
int sb_viewport_y;
|
||||
int sb_viewport_x;
|
||||
int sb_total_y;
|
||||
int sb_total_x;
|
||||
int sb_cur_y;
|
||||
int sb_cur_x;
|
||||
#endif
|
||||
short line_color; /* color of line attributes - default -1 */
|
||||
attr_t termattrs; /* attribute capabilities */
|
||||
WINDOW *lastscr; /* the last screen image */
|
||||
|
||||
@@ -475,7 +475,6 @@ static void _pointer_setup(void)
|
||||
int PDC_scr_open(int argc, char **argv)
|
||||
{
|
||||
char *myargv[] = {"PDCurses", NULL};
|
||||
extern bool sb_started;
|
||||
|
||||
bool italic_font_valid, bold_font_valid;
|
||||
int minwidth, minheight;
|
||||
@@ -642,13 +641,6 @@ int PDC_scr_open(int argc, char **argv)
|
||||
|
||||
SP->cursrow = SP->curscol = 0;
|
||||
SP->orig_attr = FALSE;
|
||||
SP->sb_on = sb_started;
|
||||
SP->sb_total_y = 0;
|
||||
SP->sb_viewport_y = 0;
|
||||
SP->sb_cur_y = 0;
|
||||
SP->sb_total_x = 0;
|
||||
SP->sb_viewport_x = 0;
|
||||
SP->sb_cur_x = 0;
|
||||
|
||||
atexit(PDC_scr_free);
|
||||
|
||||
|
||||
82
x11/sb.c
82
x11/sb.c
@@ -57,14 +57,16 @@ bool sb_started = FALSE;
|
||||
#endif
|
||||
|
||||
static Widget scrollBox, scrollVert, scrollHoriz;
|
||||
static int sb_viewport_y, sb_viewport_x;
|
||||
static int sb_total_y, sb_total_x, sb_cur_y, sb_cur_x;
|
||||
|
||||
static void _scroll_up_down(Widget w, XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
int pixels = (long) call_data;
|
||||
int total_y = SP->sb_total_y * pdc_fheight;
|
||||
int viewport_y = SP->sb_viewport_y * pdc_fheight;
|
||||
int cur_y = SP->sb_cur_y * pdc_fheight;
|
||||
int total_y = sb_total_y * pdc_fheight;
|
||||
int viewport_y = sb_viewport_y * pdc_fheight;
|
||||
int cur_y = sb_cur_y * pdc_fheight;
|
||||
|
||||
/* When pixels is negative, right button pressed, move data down,
|
||||
thumb moves up. Otherwise, left button pressed, pixels positive,
|
||||
@@ -80,7 +82,7 @@ static void _scroll_up_down(Widget w, XtPointer client_data,
|
||||
if (cur_y > (total_y - viewport_y))
|
||||
cur_y = total_y - viewport_y;
|
||||
|
||||
SP->sb_cur_y = cur_y / pdc_fheight;
|
||||
sb_cur_y = cur_y / pdc_fheight;
|
||||
|
||||
XawScrollbarSetThumb(w, (double)((double)cur_y / (double)total_y),
|
||||
(double)((double)viewport_y / (double)total_y));
|
||||
@@ -90,9 +92,9 @@ static void _scroll_left_right(Widget w, XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
int pixels = (long) call_data;
|
||||
int total_x = SP->sb_total_x * pdc_fwidth;
|
||||
int viewport_x = SP->sb_viewport_x * pdc_fwidth;
|
||||
int cur_x = SP->sb_cur_x * pdc_fwidth;
|
||||
int total_x = sb_total_x * pdc_fwidth;
|
||||
int viewport_x = sb_viewport_x * pdc_fwidth;
|
||||
int cur_x = sb_cur_x * pdc_fwidth;
|
||||
|
||||
cur_x += pixels;
|
||||
|
||||
@@ -104,7 +106,7 @@ static void _scroll_left_right(Widget w, XtPointer client_data,
|
||||
if (cur_x > (total_x - viewport_x))
|
||||
cur_x = total_x - viewport_x;
|
||||
|
||||
SP->sb_cur_x = cur_x / pdc_fwidth;
|
||||
sb_cur_x = cur_x / pdc_fwidth;
|
||||
|
||||
XawScrollbarSetThumb(w, (double)((double)cur_x / (double)total_x),
|
||||
(double)((double)viewport_x / (double)total_x));
|
||||
@@ -114,19 +116,19 @@ static void _thumb_up_down(Widget w, XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
double percent = *(double *) call_data;
|
||||
double total_y = (double)SP->sb_total_y;
|
||||
double viewport_y = (double)SP->sb_viewport_y;
|
||||
int cur_y = SP->sb_cur_y;
|
||||
double total_y = (double) sb_total_y;
|
||||
double viewport_y = (double) sb_viewport_y;
|
||||
int cur_y = sb_cur_y;
|
||||
|
||||
/* If the size of the viewport is > overall area simply return,
|
||||
as no scrolling is permitted. */
|
||||
|
||||
if (SP->sb_viewport_y >= SP->sb_total_y)
|
||||
if (sb_viewport_y >= sb_total_y)
|
||||
return;
|
||||
|
||||
if ((SP->sb_cur_y = (int)((double)total_y * percent)) >=
|
||||
if ((sb_cur_y = (int)((double)total_y * percent)) >=
|
||||
(total_y - viewport_y))
|
||||
SP->sb_cur_y = total_y - viewport_y;
|
||||
sb_cur_y = total_y - viewport_y;
|
||||
|
||||
XawScrollbarSetThumb(w, (double)(cur_y / total_y),
|
||||
(double)(viewport_y / total_y));
|
||||
@@ -136,16 +138,16 @@ static void _thumb_left_right(Widget w, XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
double percent = *(double *) call_data;
|
||||
double total_x = (double)SP->sb_total_x;
|
||||
double viewport_x = (double)SP->sb_viewport_x;
|
||||
int cur_x = SP->sb_cur_x;
|
||||
double total_x = (double) sb_total_x;
|
||||
double viewport_x = (double) sb_viewport_x;
|
||||
int cur_x = sb_cur_x;
|
||||
|
||||
if (SP->sb_viewport_x >= SP->sb_total_x)
|
||||
if (sb_viewport_x >= sb_total_x)
|
||||
return;
|
||||
|
||||
if ((SP->sb_cur_x = (int)((float)total_x * percent)) >=
|
||||
if ((sb_cur_x = (int)((float)total_x * percent)) >=
|
||||
(total_x - viewport_x))
|
||||
SP->sb_cur_x = total_x - viewport_x;
|
||||
sb_cur_x = total_x - viewport_x;
|
||||
|
||||
XawScrollbarSetThumb(w, (double)(cur_x / total_x),
|
||||
(double)(viewport_x / total_x));
|
||||
@@ -201,6 +203,8 @@ int sb_init(void)
|
||||
return ERR;
|
||||
|
||||
sb_started = TRUE;
|
||||
sb_viewport_y = sb_viewport_x = 0;
|
||||
sb_total_y = sb_total_x = sb_cur_y = sb_cur_x = 0;
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -219,9 +223,9 @@ int sb_set_horz(int total, int viewport, int cur)
|
||||
if (!SP)
|
||||
return ERR;
|
||||
|
||||
SP->sb_total_x = total;
|
||||
SP->sb_viewport_x = viewport;
|
||||
SP->sb_cur_x = cur;
|
||||
sb_total_x = total;
|
||||
sb_viewport_x = viewport;
|
||||
sb_cur_x = cur;
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -240,9 +244,9 @@ int sb_set_vert(int total, int viewport, int cur)
|
||||
if (!SP)
|
||||
return ERR;
|
||||
|
||||
SP->sb_total_y = total;
|
||||
SP->sb_viewport_y = viewport;
|
||||
SP->sb_cur_y = cur;
|
||||
sb_total_y = total;
|
||||
sb_viewport_y = viewport;
|
||||
sb_cur_y = cur;
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -261,11 +265,11 @@ int sb_get_horz(int *total, int *viewport, int *cur)
|
||||
return ERR;
|
||||
|
||||
if (total)
|
||||
*total = SP->sb_total_x;
|
||||
*total = sb_total_x;
|
||||
if (viewport)
|
||||
*viewport = SP->sb_viewport_x;
|
||||
*viewport = sb_viewport_x;
|
||||
if (cur)
|
||||
*cur = SP->sb_cur_x;
|
||||
*cur = sb_cur_x;
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -284,11 +288,11 @@ int sb_get_vert(int *total, int *viewport, int *cur)
|
||||
return ERR;
|
||||
|
||||
if (total)
|
||||
*total = SP->sb_total_y;
|
||||
*total = sb_total_y;
|
||||
if (viewport)
|
||||
*viewport = SP->sb_viewport_y;
|
||||
*viewport = sb_viewport_y;
|
||||
if (cur)
|
||||
*cur = SP->sb_cur_y;
|
||||
*cur = sb_cur_y;
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -302,20 +306,20 @@ int sb_refresh(void)
|
||||
if (!SP)
|
||||
return ERR;
|
||||
|
||||
if (SP->sb_on)
|
||||
if (sb_started)
|
||||
{
|
||||
PDC_SCROLLBAR_TYPE total_y = SP->sb_total_y;
|
||||
PDC_SCROLLBAR_TYPE total_x = SP->sb_total_x;
|
||||
PDC_SCROLLBAR_TYPE total_y = sb_total_y;
|
||||
PDC_SCROLLBAR_TYPE total_x = sb_total_x;
|
||||
|
||||
if (total_y)
|
||||
XawScrollbarSetThumb(scrollVert,
|
||||
(PDC_SCROLLBAR_TYPE)(SP->sb_cur_y) / total_y,
|
||||
(PDC_SCROLLBAR_TYPE)(SP->sb_viewport_y) / total_y);
|
||||
(PDC_SCROLLBAR_TYPE)(sb_cur_y) / total_y,
|
||||
(PDC_SCROLLBAR_TYPE)(sb_viewport_y) / total_y);
|
||||
|
||||
if (total_x)
|
||||
XawScrollbarSetThumb(scrollHoriz,
|
||||
(PDC_SCROLLBAR_TYPE)(SP->sb_cur_x) / total_x,
|
||||
(PDC_SCROLLBAR_TYPE)(SP->sb_viewport_x) / total_x);
|
||||
(PDC_SCROLLBAR_TYPE)(sb_cur_x) / total_x,
|
||||
(PDC_SCROLLBAR_TYPE)(sb_viewport_x) / total_x);
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
Reference in New Issue
Block a user