void FMEDITAPI UpdateScroll( void ) /*********************************/ { RECT newrect; RECT clrect; POINT offset; HWND wnd; if( GetScrollConfig() == SCROLL_NONE ) { return; } wnd = GetAppWnd(); GetClientRect( wnd, &clrect ); newrect = clrect; RequestScrollRect( &newrect ); SetScrollRect( newrect ); GetOffset( &offset ); if( GetScrollConfig() & SCROLL_HORZ ) { SetScrollRange( wnd, SB_HORZ, newrect.left, newrect.right - clrect.right, FALSE ); SetScrollPos( wnd, SB_HORZ, offset.x, TRUE ); } if( GetScrollConfig() & SCROLL_VERT ) { SetScrollRange( wnd, SB_VERT, newrect.top, newrect.bottom - clrect.bottom, FALSE ); SetScrollPos( wnd, SB_VERT, offset.y, TRUE ); } }
extern void VerticalScroll( WPARAM wparam, LPARAM lparam, HWND wnd ) /******************************************************************/ { int ydel; RECT clrect; POINT offset; RECT scrollrect; wparam = wparam; lparam = lparam; if( !(GetScrollConfig() & SCROLL_VERT) ) { return; } GetClientRect( GetAppWnd(), &clrect ); scrollrect = GetScrollRect(); ydel = 0; GetOffset( &offset ); switch( LOWORD( wparam ) ) { case SB_BOTTOM: ydel = scrollrect.bottom - offset.y - clrect.bottom; break; case SB_LINEDOWN: ydel = LN_SC_AMOUNT; break; case SB_LINEUP: ydel = -LN_SC_AMOUNT; break; case SB_PAGEDOWN: ydel = (long)clrect.bottom * PG_SC_PERCENT / 100; break; case SB_PAGEUP: ydel = -((long)clrect.bottom * PG_SC_PERCENT / 100); break; case SB_THUMBPOSITION: //ydel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.y - clrect.bottom; ydel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.y; break; case SB_TOP: ydel = -offset.y; break; default: break; } // make sure we do not expose area's not in the scroll rect if( clrect.bottom <= scrollrect.bottom && clrect.top >= scrollrect.top ) { if( ydel ) { if( clrect.bottom + offset.y + ydel > scrollrect.bottom ) { ydel = scrollrect.bottom - clrect.bottom - offset.y; } } else { if( clrect.top + offset.y + ydel < scrollrect.top ) { ydel = clrect.top + offset.y - scrollrect.top; } } } DoScroll( wnd, 0, ydel, TRUE ); }
extern void HorizontalScroll( WPARAM wparam, LPARAM lparam, HWND wnd ) /********************************************************************/ { int xdel; RECT clrect; POINT offset; RECT scrollrect; wparam = wparam; lparam = lparam; if( !(GetScrollConfig() & SCROLL_HORZ) ) { return; } GetClientRect( GetAppWnd(), &clrect ); scrollrect = GetScrollRect(); xdel = 0; GetOffset( &offset ); switch( LOWORD( wparam ) ) { case SB_BOTTOM: xdel = scrollrect.right - offset.x - clrect.right; break; case SB_LINEDOWN: xdel = LN_SC_AMOUNT; break; case SB_LINEUP: xdel = -LN_SC_AMOUNT; break; case SB_PAGEDOWN: xdel = (long)clrect.right * PG_SC_PERCENT / 100; break; case SB_PAGEUP: xdel = -(long)clrect.right * PG_SC_PERCENT / 100; break; case SB_THUMBPOSITION: //xdel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.x - clrect.right; xdel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.x; break; case SB_TOP: xdel = -offset.x; break; default: break; } // make sure we do not expose area's not in the scroll rect if( clrect.right <= scrollrect.right && clrect.left >= scrollrect.left ) { if( xdel ) { if( clrect.right + offset.x + xdel > scrollrect.right ) { xdel = scrollrect.right - clrect.right - offset.x; } } else { if( clrect.left + offset.x + xdel < scrollrect.left ) { xdel = clrect.left + offset.x - scrollrect.left; } } } DoScroll( wnd, xdel, 0, TRUE ); }
static void GetScrollBounds( LPRECT rect, BOOL lock ) /***************************************************/ { // if this is a locked scrolling the scroll bound is the scroll rect, // otherwise the bottom and right of bounds are the largest possible that // will satisfy the following: // 1. They are both shorts (i.e. in the range SHRT_MIN to SHRT_MAX). // 2. The maximum distance that you can scroll away from the top, left // corner of the scroll rect is SHRT_MAX - UNLOCK_SCROLL_FUDGE. RECT clrect; long bound; *rect = GetScrollRect(); if( !lock ) { GetClientRect( GetAppWnd(), &clrect ); bound = (long)rect->left + SHRT_MAX - clrect.right - UNLOCK_SCROLL_FUDGE; if( bound > (long)SHRT_MAX ) { rect->right = SHRT_MAX; } else if( bound < (long)SHRT_MIN ) { rect->right = SHRT_MIN; } else { rect->right = bound; } bound = (long)rect->top + SHRT_MAX - clrect.bottom - UNLOCK_SCROLL_FUDGE; if( bound > (long)SHRT_MAX ) { rect->bottom = SHRT_MAX; } else if( bound < (long)SHRT_MIN ) { rect->bottom = SHRT_MIN; } else { rect->bottom = bound; } } }
extern void AutoScroll( RECT eatom, POINT delta ) /***********************************************/ { POINT offset; RECT clrect; HWND wnd; int xdel; int ydel; POINT mouse; eatom = eatom; /* ref'd to avoid warnings */ if( GetScrollConfig() == SCROLL_NONE ) { return; } wnd = GetAppWnd(); GetClientRect( wnd, &clrect ); GetOffset( &offset ); OffsetRect( &clrect, offset.x, offset.y ); xdel = 0; ydel = 0; mouse = GetPrevMouse(); mouse.x += delta.x; mouse.y += delta.y; if( (delta.x > 0 && (abs( mouse.x - clrect.right ) < GetHorizontalInc() || mouse.x > clrect.right)) || (delta.x < 0 && (abs( mouse.x - clrect.left ) < GetHorizontalInc() || mouse.x < clrect.left)) ) { xdel = delta.x; if( xdel > 0 ) { xdel = __max( 1, (xdel * SLOW_DOWN_N) / SLOW_DOWN_D ); } else { xdel = __min( -1, (xdel * SLOW_DOWN_N) / SLOW_DOWN_D ); } } if( (delta.y > 0 && (abs( mouse.y - clrect.bottom ) < GetVerticalInc() || mouse.y > clrect.bottom)) || (delta.y < 0 && (abs( mouse.y - clrect.top ) < GetVerticalInc() || mouse.y < clrect.top)) ) { ydel = delta.y; if( ydel > 0 ) { ydel = __max( 1, (ydel * SLOW_DOWN_N) / SLOW_DOWN_D ); } else { ydel = __min( -1, (ydel * SLOW_DOWN_N) / SLOW_DOWN_D ); } } if( !(GetScrollConfig() & SCROLL_VERT) ) { ydel = 0; } if( !(GetScrollConfig() & SCROLL_HORZ) ) { xdel = 0; } DoScroll( wnd, xdel, ydel, TRUE ); UpdateWindow( wnd ); }
void FMEDITAPI NewOffset( POINT point ) /*************************************/ { // Set the offset to 'point' and reset the scrolling stuff SetOffset( point ); UpdateScroll(); InvalidateRect( GetAppWnd(), NULL, TRUE ); }
void ReportPending( void ) { if( ShowError() && State->error != NULL ) { MessageBox( GetAppWnd(), (LPSTR) State->error, NULL, MB_ICONEXCLAMATION | MB_OK ); EdFree( State->error ); State->error = NULL; } }
void FMEDITAPI DisplayError( char * msg ) { /* report an error message */ if( msg != NULL ) { if( ShowError() ) { MessageBox( GetAppWnd(), (LPSTR) msg, NULL, MB_ICONEXCLAMATION | MB_OK ); } else { State->error = EdAlloc( strlen( msg ) + 1 ); strcpy( State->error, msg ); } } }
void FMEDITAPI ResetCurrObject( bool draw ) /*****************************************/ { /* reset the current object */ OBJPTR currobj; OBJPTR nextobj; for( currobj = GetEditCurrObject(); currobj != NULL; currobj = nextobj ) { nextobj = GetNextEditCurrObject( currobj ); if( draw ) { if( GetObjptr( currobj ) != GetMainObject() ) { ObjMark( currobj ); } } DeleteCurrObject( currobj ); } if( draw ) { UpdateWindow( GetAppWnd() ); } }
void InitEditMenu( HWND wnd, int bitmap ) /***************************************/ { HMENU submenu; int nummenus; char menuname[MAX_MENU + 1]; int i; bool editfound; int len; HMENU mainmenu; if( bitmap != MENU_NONE ) { mainmenu = GetMenu( wnd ); if( mainmenu == NULL ) { return; } nummenus = GetMenuItemCount( mainmenu ); if( bitmap & EDIT_MENU_FLAGS ) { editfound = false; for( i = 0; i < nummenus; ++i ) { len = GetMenuString( mainmenu, i, menuname, MAX_MENU, MF_BYPOSITION ); FixMenuName( menuname, len ); if( !editfound && stricmp( menuname, "EDIT" ) == 0 ) { editfound = true; AddFMEditMenus( GetSubMenu( mainmenu, i ), bitmap ); } } if( !editfound ) { submenu = CreatePopupMenu(); AddFMEditMenus( submenu, bitmap ); InsertMenu( mainmenu, nummenus - 1, MF_BYPOSITION | MF_POPUP, (UINT_PTR)submenu, "&Edit" ); ++nummenus; } } if( bitmap & MENU_SETUP ) { submenu = LoadMenu( GetInst(), "SetupMenu" ); InsertMenu( mainmenu, nummenus - 1, MF_BYPOSITION | MF_POPUP, (UINT_PTR)submenu, "&Setup" ); DrawMenuBar( GetAppWnd() ); } } }
void ObjMark( OBJPTR obj ) /************************/ { /* invalidate the objects location for painting */ RECT rect; HRGN little; HRGN large; POINT offset; if( !IsMarkValid( obj )) { return; } Location( obj, &rect ); GetOffset( &offset ); OffsetRect( &rect, -offset.x, -offset.y ); little = CreateRectRgn( rect.left, rect.top, rect.right, rect.bottom ); InflateRect( &rect, SQUAREWIDTH / 2, SQUAREWIDTH / 2 ); large = CreateRectRgn( rect.left, rect.top, rect.right, rect.bottom ); CombineRgn( large, large, little, RGN_DIFF ); InvalidateRgn( GetAppWnd(), large, TRUE ); DeleteObject( large ); DeleteObject( little ); }