added hide scroll-bars option

This commit is contained in:
chombier 2002-03-24 16:10:21 +00:00
parent e6be3372d1
commit da1e19daec
4 changed files with 308 additions and 98 deletions

View File

@ -101,6 +101,8 @@ struct RSdata {
cursType; cursType;
RGBColor RGBColor
savedColors[16]; savedColors[16];
Boolean
hideScrollBars;
}; };
typedef struct RSdata RSdata; typedef struct RSdata RSdata;

View File

@ -75,6 +75,7 @@ SIMPLE_UPP(ScrollProc,ControlAction);
SIMPLE_UPP(ActiveScrollProc,ControlAction); SIMPLE_UPP(ActiveScrollProc,ControlAction);
static void HandleDoubleClick(short w, short modifiers); static void HandleDoubleClick(short w, short modifiers);
static void HandleTripleClick(short w, short modifiers);
void RSunload(void) {} void RSunload(void) {}
@ -97,6 +98,7 @@ void RSselect( short w, Point pt, EventRecord theEvent)
{ {
static long lastClick = 0; static long lastClick = 0;
static Point lastClickLoc = {0,0}; static Point lastClickLoc = {0,0};
static Boolean sDblClick = false;
GrafPtr tempwndo; GrafPtr tempwndo;
Point curr, temp, lastm; Point curr, temp, lastm;
long clickTime; long clickTime;
@ -115,100 +117,124 @@ void RSselect( short w, Point pt, EventRecord theEvent)
&& EqualPt(curr, lastClickLoc) ) { && EqualPt(curr, lastClickLoc) ) {
/* NCSA: SB - check to see if this is a special click */ /* NCSA: SB - check to see if this is a special click */
/* NCSA: SB - It has to be in the right time interval, and in the same spot */ /* NCSA: SB - It has to be in the right time interval, and in the same spot */
curr = RSlocal[w].anchor = RSlocal[w].last = normalize(pt, w, TRUE); if ( !sDblClick ) {
HandleDoubleClick(w, theEvent.modifiers); curr = RSlocal[w].anchor = RSlocal[w].last = normalize(pt, w, TRUE);
RSlocal[w].selected = 1; HandleDoubleClick(w, theEvent.modifiers);
RSlocal[w].selected = 1;
// doesn't work yet. need to change WaitMouseMoved in DragText
// sDblClick = true;
} else {
// unhighlight current selection
RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &noConst);
curr = RSlocal[w].anchor = RSlocal[w].last = normalize(pt, w, TRUE);
HandleTripleClick(w, theEvent.modifiers);
RSlocal[w].selected = 1;
sDblClick = false;
}
lastClick = clickTime; lastClick = clickTime;
lastClickLoc = curr; lastClickLoc = curr;
} else if ((theEvent.modifiers & cmdKey)) { } else if (sDblClick
// a command click means we should look for a url && clickTime - lastClick <= GetDblTime()
if ( RSTextSelected(w) && PointInSelection(curr, w) ) { && EqualPt(curr, lastClickLoc) ) {
// we have a selection already // unhighlight current selection
HandleURL(w); RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &noConst);
} else { curr = RSlocal[w].anchor = RSlocal[w].last = normalize(pt, w, TRUE);
// we need to find the url around this pnt HandleTripleClick(w, theEvent.modifiers);
if (FindURLAroundPoint(curr, w)) RSlocal[w].selected = 1;
HandleURL(w); sDblClick = false;
else
SysBeep(1);
}
} else { } else {
lastClick = clickTime; sDblClick = false;
lastClickLoc = curr; if ((theEvent.modifiers & cmdKey)) {
if (RSlocal[w].selected) { // a command click means we should look for a url
if (!shift) { if ( RSTextSelected(w) && PointInSelection(curr, w) ) {
RSlocal[w].selected = 0; // we have a selection already
// unhighlight current selection HandleURL(w);
RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &noConst);
// start new selection
curr = normalize(pt, w, TRUE);
RSlocal[w].last = RSlocal[w].anchor = curr;
} else { } else {
RSsortAnchors(w); // we need to find the url around this pnt
if ((curr.v < RSlocal[w].anchor.v) || ((curr.v == RSlocal[w].anchor.v) && (curr.h < RSlocal[w].anchor.h))) { if (FindURLAroundPoint(curr, w))
temp = RSlocal[w].anchor; HandleURL(w);
RSlocal[w].anchor = RSlocal[w].last; else
RSlocal[w].last = temp; SysBeep(1);
}
} }
} else { } else {
// start new selection lastClick = clickTime;
curr = normalize(pt, w, TRUE); lastClickLoc = curr;
RSlocal[w].anchor = RSlocal[w].last = curr;
}
if (EqualPt(RSlocal[w].anchor, RSlocal[w].last) && RSlocal[w].anchor.h > -1) { if (RSlocal[w].selected) {
if (VSgetattr(w, RSlocal[w].anchor.h - 1, curr.v, RSlocal[w].anchor.h, curr.v, &attrib, sizeof(VSAttrib))) { if (!shift) {
if (VSisansi2b(attrib)) { RSlocal[w].selected = 0;
--RSlocal[w].anchor.h; // unhighlight current selection
--RSlocal[w].last.h; RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &noConst);
} // start new selection
} curr = normalize(pt, w, TRUE);
} RSlocal[w].last = RSlocal[w].anchor = curr;
} else {
while ( StillDown() ) { RSsortAnchors(w);
// wait for mouse position to change if ((curr.v < RSlocal[w].anchor.v) || ((curr.v == RSlocal[w].anchor.v) && (curr.h < RSlocal[w].anchor.h))) {
do { temp = RSlocal[w].anchor;
unsigned long finalTicks; RSlocal[w].anchor = RSlocal[w].last;
temp = getlocalmouse(tempwndo); RSlocal[w].last = temp;
// FIXME: I'm lazy. this could be tiny.
if (temp.v < -30) {
// no delay
} else if (temp.v < -20 ) {
Delay( 2, &finalTicks);
} else if (temp.v < -10 ) {
Delay( 6, &finalTicks);
} else if (temp.v < 0 ) {
Delay( 10, &finalTicks);
} else if (temp.v > RSlocal[w].height + 30) {
// no delay
} else if (temp.v > RSlocal[w].height + 20) {
Delay( 2, &finalTicks);
} else if (temp.v > RSlocal[w].height + 10) {
Delay( 6, &finalTicks);
} else if (temp.v > RSlocal[w].height) {
Delay( 10, &finalTicks);
}
curr = normalize(temp, w,TRUE);
if ( curr.h > -1 ) {
if (VSgetattr(w, curr.h - 1, curr.v, curr.h, curr.v, &attrib, sizeof(VSAttrib))) {
if (VSisansi2b(attrib)) {
++curr.h;
}
} }
} }
} else {
// start new selection
curr = normalize(pt, w, TRUE);
RSlocal[w].anchor = RSlocal[w].last = curr;
}
} while (StillDown() && (EqualPt(curr, RSlocal[w].last) /*|| EqualPt(pt, temp)*/)); if (EqualPt(RSlocal[w].anchor, RSlocal[w].last) && RSlocal[w].anchor.h > -1) {
if (VSgetattr(w, RSlocal[w].anchor.h - 1, curr.v, RSlocal[w].anchor.h, curr.v, &attrib, sizeof(VSAttrib))) {
if (VSisansi2b(attrib)) {
--RSlocal[w].anchor.h;
--RSlocal[w].last.h;
}
}
}
RSlocal[w].selected = !EqualPt(RSlocal[w].anchor, curr); while ( StillDown() ) {
// wait for mouse position to change
do {
unsigned long finalTicks;
temp = getlocalmouse(tempwndo);
if ( !EqualPt(pt, temp) || RSlocal[w].selected ) { // FIXME: I'm lazy. this could be tiny.
// toggle highlight state of text between current and last mouse positions if (temp.v < -30) {
RSinvText(w, curr, RSlocal[w].last, &noConst); // no delay
RSlocal[w].last = curr; } else if (temp.v < -20 ) {
pt = temp; Delay( 2, &finalTicks);
} else if (temp.v < -10 ) {
Delay( 6, &finalTicks);
} else if (temp.v < 0 ) {
Delay( 10, &finalTicks);
} else if (temp.v > RSlocal[w].height + 30) {
// no delay
} else if (temp.v > RSlocal[w].height + 20) {
Delay( 2, &finalTicks);
} else if (temp.v > RSlocal[w].height + 10) {
Delay( 6, &finalTicks);
} else if (temp.v > RSlocal[w].height) {
Delay( 10, &finalTicks);
}
curr = normalize(temp, w,TRUE);
if ( curr.h > -1 ) {
if (VSgetattr(w, curr.h - 1, curr.v, curr.h, curr.v, &attrib, sizeof(VSAttrib))) {
if (VSisansi2b(attrib)) {
++curr.h;
}
}
}
} while (StillDown() && (EqualPt(curr, RSlocal[w].last) /*|| EqualPt(pt, temp)*/));
RSlocal[w].selected = !EqualPt(RSlocal[w].anchor, curr);
if ( !EqualPt(pt, temp) || RSlocal[w].selected ) {
// toggle highlight state of text between current and last mouse positions
RSinvText(w, curr, RSlocal[w].last, &noConst);
RSlocal[w].last = curr;
pt = temp;
}
} }
} }
} }
@ -305,7 +331,7 @@ Boolean RSisInFront(short w)
void RSdrawlocker(short w, RgnHandle visRgn) void RSdrawlocker(short w, RgnHandle visRgn)
{ {
/* draw locker icon */ /* draw locker icon */
if ( RSlocal[w].left ) { if ( RSlocal[w].left && !RSlocal[w].hideScrollBars ) {
short sn = findbyVS(w); short sn = findbyVS(w);
if ( sn >= 0 && screens[sn].protocol == 4 ) { if ( sn >= 0 && screens[sn].protocol == 4 ) {
Rect iconRect = (**RSlocal[w].left).contrlRect; Rect iconRect = (**RSlocal[w].left).contrlRect;
@ -387,7 +413,7 @@ short RSupdate
DrawGrowIcon(wind); DrawGrowIcon(wind);
if (RSlocal[w].active) { if (RSlocal[w].active && !RSlocal[w].hideScrollBars) {
UpdateControls(wind, wind->visRgn); UpdateControls(wind, wind->visRgn);
} else { } else {
ControlHandle ctrl; ControlHandle ctrl;
@ -834,6 +860,8 @@ short RSnewwindow
pRect.bottom = pRect.top + RMAXWINDOWHEIGHT; pRect.bottom = pRect.top + RMAXWINDOWHEIGHT;
RScurrent->hideScrollBars = ((flags & RSWHideScroll) != 0);
/* create scroll bars for window */ /* create scroll bars for window */
pRect.top = -1 + CVO; pRect.top = -1 + CVO;
pRect.bottom = wheight - 14 + CVO; pRect.bottom = wheight - 14 + CVO;
@ -1174,11 +1202,14 @@ void RSactivate( short w )
/* display the grow icon */ /* display the grow icon */
DrawGrowIcon(RSlocal[w].window); DrawGrowIcon(RSlocal[w].window);
/* and activate the scroll bars */ /* and activate the scroll bars */
if (RSlocal[w].scroll != 0L) {
ShowControl(RSlocal[w].scroll); if ( !RSlocal[w].hideScrollBars ) {
} if (RSlocal[w].scroll != 0L) {
if (RSlocal[w].left != 0L) { ShowControl(RSlocal[w].scroll);
ShowControl(RSlocal[w].left); }
if (RSlocal[w].left != 0L) {
ShowControl(RSlocal[w].left);
}
} }
RSlocal[w].active = 1; RSlocal[w].active = 1;
@ -1211,12 +1242,14 @@ void RSdeactivate( short w )
BackColor(whiteColor); BackColor(whiteColor);
/* deactivate the scroll bars */ if ( !RSlocal[w].hideScrollBars ) {
if (RSlocal[w].scroll != 0L) { /* deactivate the scroll bars */
HideControl(RSlocal[w].scroll); if (RSlocal[w].scroll != 0L) {
} HideControl(RSlocal[w].scroll);
if (RSlocal[w].left != 0L) { }
HideControl(RSlocal[w].left); if (RSlocal[w].left != 0L) {
HideControl(RSlocal[w].left);
}
} }
/* update the appearance of the grow icon */ /* update the appearance of the grow icon */
@ -1700,6 +1733,178 @@ static void HandleDoubleClick(short w, short modifiers)
} }
} }
/*--------------------------------------------------------------------------*/
/* HandleTripleClick */
/* This is the routine that does the real dirty work. Since it is not a */
/* true TextEdit window, we have to kinda "fake" the double clicking. By */
/* this time, we already know that a double click has taken place, so check */
/* the chars to the left and right of our location, and select all chars */
/* that are appropriate -- SMB */
/*--------------------------------------------------------------------------*/
static void HandleTripleClick(short w, short modifiers)
{
Point leftLoc, rightLoc, curr, oldcurr;
long mySize;
char theChar;
short mode = -1, newmode, foundEnd;
Point pt;
Point temp;
VSAttrib attrib;
short mw;
VSlinePtr ypt;
RSsetConst(w); // get window dims
leftLoc = RSlocal[w].anchor; // these two should be the same
rightLoc = RSlocal[w].last;
mw = VSgetcols(w);
rightLoc.h = mw;
ypt = VSIGetLineStart(w, rightLoc.v);
foundEnd = 0;
while ( !foundEnd ) {
// scan to the right first
if ( rightLoc.v == 0 ) {
ypt = VSIGetLineStart(w, rightLoc.v);
}
if ( ypt && VSiswrap(ypt->lattr) ) {
ypt = ypt->next;
++rightLoc.v;
} else {
foundEnd = 1;
}
}
leftLoc.h = -1;
ypt = VSIGetLineStart(w, leftLoc.v);
foundEnd = 0;
while ( !foundEnd ) {
// ...and then scan to the left
if ( leftLoc.v == -1 ) {
ypt = VSIGetLineStart(w, leftLoc.v);
}
if ( ypt && VSiswrap(ypt->prev->lattr) ) {
ypt = ypt->prev;
--leftLoc.v;
} else {
foundEnd = 1;
}
/*
// ...and then scan to the left
mySize = VSgettext(w, leftLoc.h-1, leftLoc.v, leftLoc.h, leftLoc.v,
&theChar, (long)1, "\015", 0, 0);
if ( mySize == 0 || isspace(theChar) ) { // STOP!
foundEnd = 1;
} else if ( --leftLoc.h < 0 ) {
if ( leftLoc.v == -1 ) {
ypt = VSIGetLineStart(w, leftLoc.v);
}
if ( ypt && VSiswrap(ypt->prev->lattr) ) {
ypt = ypt->prev;
leftLoc.h = mw;
--leftLoc.v;
} else {
foundEnd = 1;
}
}
*/
}
syslog(0, "leftLoc.h:%d rightLoc.h:%d\n", leftLoc.h, rightLoc.h);
if (leftLoc.h != rightLoc.h) { // we selected something
HiliteThis(w, leftLoc, rightLoc);
if (modifiers & cmdKey) // Possible URL selection
HandleURL(w);
else {
curr.h = 0; curr.v = 0;
pt = getlocalmouse(RSlocal[w].window);
while (StillDown()) {
// wait for mouse position to change
do {
oldcurr = curr;
temp = getlocalmouse(RSlocal[w].window);
curr = normalize(temp, w,TRUE);
if ( curr.h > -1 ) {
if (VSgetattr(w, curr.h - 1, curr.v, curr.h, curr.v, &attrib, sizeof(VSAttrib))) {
if (VSisansi2b(attrib)) {
++curr.h;
}
}
}
} while (StillDown() && (EqualPt(curr, oldcurr) || EqualPt(pt, temp)));
if ( !EqualPt(pt, temp) /*|| RSlocal[w].selected*/ ) {
pt = temp;
if ((curr.v < leftLoc.v) || ((curr.v == leftLoc.v) && (curr.h < leftLoc.h))) {
newmode = 1; // up
} else if ((curr.v > leftLoc.v) || ((curr.v == leftLoc.v) && (curr.h > rightLoc.h))) {
newmode = 2; // down
} else
newmode = -1; // inside dbl-clicked word
/* toggle highlight state of text between current and last mouse positions */
if (mode == -1) {
if (newmode == 2) {
RSlocal[w].anchor = leftLoc;
RSinvText(w, curr, rightLoc, &noConst);
RSlocal[w].last = curr;
}
if (newmode == 1) {
RSlocal[w].anchor = rightLoc;
RSinvText(w, curr, leftLoc, &noConst);
RSlocal[w].last = curr;
}
}
if (mode == 1) {
if (newmode == 2) {
RSlocal[w].anchor = leftLoc;
RSinvText(w, oldcurr, leftLoc, &noConst);
RSinvText(w, rightLoc, curr, &noConst);
RSlocal[w].last = curr;
}
if (newmode == -1) {
RSlocal[w].anchor = leftLoc;
RSinvText(w, oldcurr, leftLoc, &noConst);
RSlocal[w].last = rightLoc;
}
if (newmode == mode) {
RSinvText(w, oldcurr, curr, &noConst);
RSlocal[w].last = curr;
}
}
if (mode == 2) {
if (newmode == 1) {
RSlocal[w].anchor = rightLoc;
RSinvText(w, oldcurr, rightLoc, &noConst);
RSinvText(w, leftLoc, curr, &noConst);
RSlocal[w].last = curr;
}
if (newmode == -1) {
RSlocal[w].anchor = leftLoc;
RSinvText(w, oldcurr, rightLoc, &noConst);
RSlocal[w].last = rightLoc;
}
if (newmode == mode) {
RSinvText(w, oldcurr, curr, &noConst);
RSlocal[w].last = curr;
}
}
mode = newmode;
}
}
}
}
}
Point getlocalmouse(GrafPtr wind) Point getlocalmouse(GrafPtr wind)
/* returns the current mouse position in coordinates local /* returns the current mouse position in coordinates local
to the specified window. Leaves the current grafPort set to the specified window. Leaves the current grafPort set

View File

@ -14,7 +14,8 @@ enum {
RSWoldscrollback = 0x00000100, RSWoldscrollback = 0x00000100,
RSWjumpscroll = 0x00000200, RSWjumpscroll = 0x00000200,
RSWrealBlink = 0x00000400, RSWrealBlink = 0x00000400,
RSWvt7bit = 0x00000800 RSWvt7bit = 0x00000800,
RSWHideScroll = 0x00001000
}; };

View File

@ -1323,7 +1323,8 @@ void RSsetsize( short w, short v, short h, short screenIndex)
if (RSlocal[w].scroll != NULL ) { if (RSlocal[w].scroll != NULL ) {
SizeControl(RSlocal[w].scroll, 16, (v - 13)); SizeControl(RSlocal[w].scroll, 16, (v - 13));
MoveControl(RSlocal[w].scroll, (h - 15) + CHO, -1 + CVO); MoveControl(RSlocal[w].scroll, (h - 15) + CHO, -1 + CVO);
ShowControl(RSlocal[w].scroll); if (!RSlocal[w].hideScrollBars)
ShowControl(RSlocal[w].scroll);
} }
if ( RSlocal[w].left != NULL ) { if ( RSlocal[w].left != NULL ) {
short i; short i;
@ -1336,7 +1337,8 @@ void RSsetsize( short w, short v, short h, short screenIndex)
} }
SizeControl(RSlocal[w].left, (h - 13) - i, 16); SizeControl(RSlocal[w].left, (h - 13) - i, 16);
MoveControl(RSlocal[w].left, -1 + CHO + i, (v - 15) + CVO); MoveControl(RSlocal[w].left, -1 + CHO + i, (v - 15) + CVO);
ShowControl(RSlocal[w].left); if (!RSlocal[w].hideScrollBars)
ShowControl(RSlocal[w].left);
} }
/* draw the locker once the scrollbars has moved */ /* draw the locker once the scrollbars has moved */