int scContUnit::ReplaceToken( const stUnivString& ustr, int32 start, int32& end ) { ForceRepaint( start, end ); Mark( scREBREAK ); if ( ustr.len == (ulong)(end - start) && fCharArray.ReplaceToken( ustr, start, end ) ) { fCharArray.RepairText( fSpecRun, start, end ); } else if ( fCharArray.Insert( ustr, start, end ) ) { int32 diff = ( ustr.len - ( end - start ) ); fSpecRun.BumpOffset( start, diff ); end += diff; TypeSpec ts; fCharArray.Retabulate( fSpecRun, start, end, ts, fCharArray.GetContentSize() ); } else { scAssert( 0 ); } #if SCDEBUG > 0 fCharArray.Validate(); fSpecRun.DebugRun( "ReplaceToken" ); #endif return 1; }
/*------------------------------------------------------------------------ Procedure: CallChangeFont ID:1 Purpose: Calls the standard windows font change dialog. If the user validates a font, it will destroy the current font, and recreate a new font with the given parameters. Input: The calling window handle Output: Zero if the user cancelled, 1 otherwise. Errors: None ------------------------------------------------------------------------*/ static int CallChangeFont(HWND hwnd) { LOGFONT lf; CHOOSEFONT cf; int r; HWND hwndChild; memset(&cf, 0, sizeof(CHOOSEFONT)); memcpy(&lf, &CurrentFont, sizeof(LOGFONT)); cf.lStructSize = sizeof(CHOOSEFONT); cf.hwndOwner = hwnd; cf.lpLogFont = &lf; cf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_APPLY | CF_INITTOLOGFONTSTRUCT; cf.nFontType = SCREEN_FONTTYPE; r = ChooseFont(&cf); if (!r) return (0); DeleteObject(ProgramParams.hFont); memcpy(&CurrentFont, &lf, sizeof(LOGFONT)); ProgramParams.hFont = CreateFontIndirect(&CurrentFont); strcpy(CurrentFontName, CurrentFont.lfFaceName); CurrentFontFamily = lf.lfPitchAndFamily; CurrentFontStyle = lf.lfWeight; hwndChild = (HWND) GetWindowLongPtr(hwndSession, DWLP_USER); SendMessage(hwndChild,WM_SETFONT,(WPARAM)ProgramParams.hFont,0); ForceRepaint(); return (1); }
void iNWSliderBar::SetMinMax(sint32 min, sint32 max) { m_Min = iMIN(min,max); m_Max = iMAX(min,max); m_Cur = iCLAMP(m_Min,m_Max,m_Cur); ForceRepaint(); }
void AsyncPanZoomController::TrackTouch(const MultiTouchEvent& event) { SingleTouchData& touch = GetTouchFromEvent(event); nsIntPoint point = touch.mScreenPoint; PRInt32 xPos = point.x, yPos = point.y, timeDelta = event.mTime - mLastEventTime; // Probably a duplicate event, just throw it away. if (!timeDelta) { return; } { ReentrantMonitorAutoEnter monitor(mReentrantMonitor); mX.UpdateWithTouchAtDevicePoint(xPos, timeDelta); mY.UpdateWithTouchAtDevicePoint(yPos, timeDelta); float scale = mFrameMetrics.mResolution.width; PRInt32 xDisplacement = mX.UpdateAndGetDisplacement(scale); PRInt32 yDisplacement = mY.UpdateAndGetDisplacement(scale); if (!xDisplacement && !yDisplacement) { return; } ScrollBy(nsIntPoint(xDisplacement, yDisplacement)); ForceRepaint(); if (event.mTime - mLastRepaint >= REPAINT_INTERVAL) { SendViewportChange(); mLastRepaint = event.mTime; } } }
void scContUnit::SetDefaultSpec( TypeSpec& ts ) { if ( ts.ptr() != defspec_.ptr() ) { defspec_ = ts; Mark( scREBREAK ); } ForceRepaint( 0, LONG_MAX ); }
void iNWSliderBar::OnMouseMove(const iPoint& pos) { if (m_bTracking) { m_TrackPos = Pix2Pos(pos.x); GetOwner()->ControlMessage(iNWMessage((iNWElementI*)this, NWMSG_SLDPOS_TRACKING,0,&m_TrackPos)); ForceRepaint(); } iNWControl::OnMouseMove(pos); }
nsEventStatus AsyncPanZoomController::OnScaleEnd(const PinchEvent& event) { mState = PANNING; mX.StartTouch(event.mFocusPoint.x); mY.StartTouch(event.mFocusPoint.y); { ReentrantMonitorAutoEnter monitor(mReentrantMonitor); ForceRepaint(); SendViewportChange(); } return nsEventStatus_eConsumeNoDefault; }
void AsyncPanZoomController::DoFling() { if (mState != FLING) { return; } { ReentrantMonitorAutoEnter monitor(mReentrantMonitor); if (!mX.FlingApplyFrictionOrCancel() && !mY.FlingApplyFrictionOrCancel()) { ForceRepaint(); SendViewportChange(); mState = NOTHING; return; } float scale = mFrameMetrics.mResolution.width; ScrollBy(nsIntPoint( mX.UpdateAndGetDisplacement(scale), mY.UpdateAndGetDisplacement(scale) )); ForceRepaint(); SendViewportChange(); } }
void scContUnit::SetStyle( long offset1, long offset2, TypeSpec style, Bool retabulate, Bool forceRepaint ) { long tmp; long compOffset1, compOffset2; if ( offset1 >= offset2 ) { tmp = offset1; offset1 = offset2; offset2 = tmp; } compOffset1 = MAX( offset1, 0 ); compOffset2 = MIN( offset2, GetContentSize() ); // apply the spec only if it is an emopty para if ( compOffset1 == 0 && compOffset2 == 0 && GetContentSize() ) return; if ( compOffset1 == 0 || compOffset1 != compOffset2 ) { if ( compOffset2 == GetContentSize() ) fSpecRun.ApplySpec( style, compOffset1, LONG_MAX ); else fSpecRun.ApplySpec( style, compOffset1, compOffset2 ); #ifdef _RUBI_SUPPORT if ( fRubiArray ) fRubiArray->ApplyStyle( compOffset1, compOffset2, style ); #endif fSpecRun.SetContentSize( GetContentSize() ); if ( forceRepaint ) ForceRepaint( compOffset1, compOffset2 ); if ( retabulate ) fCharArray.Retabulate( fSpecRun, compOffset1, compOffset2, style, GetContentSize() ); else Mark( scRETABULATE ); Mark( scREBREAK ); } }
nsEventStatus AsyncPanZoomController::OnTouchStart(const MultiTouchEvent& event) { SingleTouchData& touch = GetTouchFromEvent(event); nsIntPoint point = touch.mScreenPoint; PRInt32 xPos = point.x, yPos = point.y; switch (mState) { case ANIMATED_ZOOM: { // We just interrupted a double-tap animation, so force a redraw in case // this touchstart is just a tap that doesn't end up triggering a redraw. ReentrantMonitorAutoEnter monitor(mReentrantMonitor); ForceRepaint(); SendViewportChange(); } // Fall through. case FLING: case BOUNCE: CancelAnimation(); // Fall through. case NOTHING: case WAITING_LISTENERS: mX.StartTouch(xPos); mY.StartTouch(yPos); mState = TOUCHING; break; case TOUCHING: case PANNING: case PANNING_LOCKED: case PANNING_HOLD: case PANNING_HOLD_LOCKED: case PINCHING: NS_WARNING("Received impossible touch in OnTouchStart"); break; default: NS_WARNING("Unhandled case in OnTouchStart"); break; } return nsEventStatus_eConsumeNoDefault; }
nsEventStatus AsyncPanZoomController::OnTouchEnd(const MultiTouchEvent& event) { switch (mState) { case FLING: case BOUNCE: case WAITING_LISTENERS: // Should never happen. NS_WARNING("Received impossible touch end in OnTouchEnd."); // Fall through. case ANIMATED_ZOOM: case NOTHING: // May happen if the user double-taps and drags without lifting after the // second tap. Ignore if this happens. return nsEventStatus_eIgnore; case TOUCHING: mState = NOTHING; return nsEventStatus_eIgnore; case PANNING: case PANNING_LOCKED: case PANNING_HOLD: case PANNING_HOLD_LOCKED: { ReentrantMonitorAutoEnter monitor(mReentrantMonitor); ForceRepaint(); SendViewportChange(); } mState = FLING; return nsEventStatus_eConsumeNoDefault; case PINCHING: mState = NOTHING; // Scale gesture listener should have handled this. NS_WARNING("Gesture listener should have handled pinching in OnTouchEnd."); return nsEventStatus_eIgnore; } return nsEventStatus_eConsumeNoDefault; }
void scContUnit::ApplyAnnotation( long start, long end, const scAnnotation& annot ) { eChTranType chTranType = eNormalTran; if ( !fRubiArray ) { AllocRubiArray(); } else if ( fRubiArray->IsRubiData( start, end ) ) { int nth; int index; scRubiData rd; fCharArray.Transform( start, end, eRemoveJapTran, end - start ); for ( nth = 1; fRubiArray->GetNthRubi( index, rd, nth, start, end ); ) fRubiArray->RemoveDataAt( index ); } if ( annot.fAnnotate ) { scRubiData rd( annot.fCharStr, start, end, SpecAtOffset( start + 1 ) ); fRubiArray->AddRubiData( rd ); chTranType = eRubiTran; } else { // i should have already removed any annotations if ( fRubiArray->GetNumItems() == 0 ) DeleteRubiArray(); chTranType = eRemoveJapTran; } Mark( scREBREAK ); ForceRepaint( start, end ); fCharArray.Transform( start, end, chTranType, end - start ); }
LONG AL_EXPORT CALLBACK gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) #endif { // // After the window has been created, the pointer to the ALGauge object // is kept in the windows long word. I get it here so everyone else // can have access to it. // #if defined ( AL_WATCOM ) || defined( AL_FLAT_MODEL ) ALGauge *pgauge = (ALGauge *) GetWindowLong( hwnd, 0 ); #else ALGauge _far *pgauge = (ALGauge _far *) GetWindowLong( hwnd, 0 ); #endif switch (uMsg) { // // When I get the WM_CREATE message, I create a new ALGauge object, then // put its address in the Windows long word. // case WM_CREATE: #if defined( AL_SYMANTEC ) || defined( AL_WATCOM ) || defined( AL_FLAT_MODEL ) // Not sure about this yet pgauge = new ALGauge; #else pgauge = new _far ALGauge; #endif if ( pgauge == 0 ) return (0L); SetWindowLong( hwnd, 0, (LONG) pgauge ); SendMessage( hwnd, WM_SETFONT, NULL, 0L ); break; case WM_DESTROY: if ( pgauge ) #if defined( AL_SYMANTEC ) && !defined( AL_LARGE_DATA ) delete (void _near *) pgauge; #else delete pgauge; #endif break; case ALGaugeGetPosition : return pgauge->iPosition; case ALGaugeGetRange : return pgauge->iRange; case ALGaugeGetOrientation : return pgauge->iOrientation; case ALGaugeGetForegroundColor : return pgauge->dwTextColor; case ALGaugeGetBackgroundColor: return pgauge->dwBackgroundColor; case ALGaugeSetBackgroundColor : pgauge->dwBackgroundColor = lParam; return 0L; case ALGaugeSetForegroundColor : pgauge->dwTextColor = lParam; return 0L; case ALGaugeSetPosition : pgauge->iPosition = wParam; return ForceRepaint( hwnd ); case ALGaugeSetRange : pgauge->iRange = wParam; return ForceRepaint( hwnd ); case ALGaugeSetOrientation : pgauge->iOrientation = (ALGaugeOrientation) wParam; return ForceRepaint ( hwnd ); case ALGaugeSetDeltaPosition : pgauge->iPosition += (signed) wParam; return ForceRepaint( hwnd ); case WM_PAINT : pgauge->gaugePaint( hwnd ); return (0L); case WM_GETFONT : if ( pgauge->hFont == GetStockObject(SYSTEM_FONT) ) return NULL; else return (WORD) pgauge->hFont; case WM_SETFONT : if ( wParam == 0 ) pgauge->hFont = (HFONT) GetStockObject( SYSTEM_FONT ); else pgauge->hFont = (HFONT) wParam; /* redraw if indicated in message */ if ( (BOOL) lParam ) { InvalidateRect( hwnd, NULL, TRUE ); UpdateWindow( hwnd ); } return (0L); } return ( DefWindowProc( hwnd, uMsg, wParam, lParam ) ); }
/*------------------------------------------------------------------------ Procedure: HandleCommand ID:1 Purpose: Handles all menu commands. Input: Output: Errors: -------------------------------------------------------------------------- Edit History: 06 Oct 2003 - Chris Watford [email protected] - Removed entries that crashed OCaml - Removed useless entries - Added Save ML and Save Transcript ------------------------------------------------------------------------*/ void HandleCommand(HWND hwnd, WPARAM wParam,LPARAM lParam) { char *fname; int r; switch(LOWORD(wParam)) { case IDM_OPEN: fname = SafeMalloc(512); if (OpenMlFile(fname,512)) { char *buf = SafeMalloc(512); char *p = strrchr(fname,'.'); if (p && !stricmp(p,".ml")) { wsprintf(buf, "#use \"%s\";;", fname); AddLineToControl(buf); } else if (p && !stricmp(p,".cmo")) { wsprintf(buf, "#load \"%s\";;", fname); AddLineToControl(buf); } free(buf); } free(fname); break; case IDM_GC: AddLineToControl("Gc.full_major();;"); break; case IDCTRLC: InterruptOcaml(); break; case IDM_EDITPASTE: Add_Clipboard_To_Queue(); break; case IDM_EDITCOPY: CopyToClipboard(hwnd); break; // updated to save a transcript case IDM_SAVEAS: fname = SafeMalloc(512); if (GetSaveName(fname,512)) { SaveText(fname); } free(fname); break; // updated to save an ML file case IDM_SAVE: fname = SafeMalloc(512); if (GetSaveMLName(fname,512)) { SaveML(fname); } free(fname); break; // updated to work with new history system case IDM_HISTORY: r = CallDlgProc(HistoryDlgProc,IDD_HISTORY); if (r) { AddLineToControl(GetHistoryLine(r-1)); } break; case IDM_PRINTSU: // Removed by Chris Watford // seems to die // CallPrintSetup(); break; case IDM_FONT: CallChangeFont(hwndMain); break; case IDM_COLORTEXT: ProgramParams.TextColor = CallChangeColor(ProgramParams.TextColor); ForceRepaint(); break; case IDM_BACKCOLOR: BackColor = CallChangeColor(BackColor); DeleteObject(BackgroundBrush); BackgroundBrush = CreateSolidBrush(BackColor); ForceRepaint(); break; case IDM_EDITUNDO: Undo(hwnd); break; /* Removed, really not very useful in this IDE case IDM_WINDOWTILE: SendMessage(hwndMDIClient,WM_MDITILE,0,0); break; case IDM_WINDOWCASCADE: SendMessage(hwndMDIClient,WM_MDICASCADE,0,0); break; case IDM_WINDOWICONS: SendMessage(hwndMDIClient,WM_MDIICONARRANGE,0,0); break; */ case IDM_EXIT: PostMessage(hwnd,WM_CLOSE,0,0); break; case IDM_ABOUT: CallDlgProc(AboutDlgProc,IDD_ABOUT); break; default: if (LOWORD(wParam) >= IDEDITCONTROL && LOWORD(wParam) < IDEDITCONTROL+5) { switch (HIWORD(wParam)) { case EN_ERRSPACE: ResetText(); break; } } break; } }
void iNWButton::OnMouseEnter(void) { m_BtnState = BtnFocused; ForceRepaint(); iNWControlTT::OnMouseEnter(); }
void iNWButton::OnMouseLeave(void) { m_BtnState = BtnUnpressed; ForceRepaint(); iNWControlTT::OnMouseLeave(); }
void iNWButton::OnLButtonUp(const iPoint &pos, uint32 vkey) { ForceRepaint(); iNWControlTT::OnLButtonUp(pos,vkey); }
void iNWSliderBar::SetCur(sint32 cur, bool refMsg ) { m_Cur = iCLAMP(m_Min,m_Max,cur); if (refMsg) GetOwner()->ControlMessage(iNWMessage((iNWElementI*)this, NWMSG_SLDPOS_CHANGED,0,&m_Cur)); ForceRepaint(); }
nsEventStatus AsyncPanZoomController::OnScale(const PinchEvent& event) { float prevSpan = event.mPreviousSpan; if (fabsf(prevSpan) <= EPSILON) { // We're still handling it; we've just decided to throw this event away. return nsEventStatus_eConsumeNoDefault; } float spanRatio = event.mCurrentSpan / event.mPreviousSpan; { ReentrantMonitorAutoEnter monitor(mReentrantMonitor); float scale = mFrameMetrics.mResolution.width; nsIntPoint focusPoint = event.mFocusPoint; PRInt32 xFocusChange = (mLastZoomFocus.x - focusPoint.x) / scale, yFocusChange = (mLastZoomFocus.y - focusPoint.y) / scale; // If displacing by the change in focus point will take us off page bounds, // then reduce the displacement such that it doesn't. if (mX.DisplacementWillOverscroll(xFocusChange) != Axis::OVERSCROLL_NONE) { xFocusChange -= mX.DisplacementWillOverscrollAmount(xFocusChange); } if (mY.DisplacementWillOverscroll(yFocusChange) != Axis::OVERSCROLL_NONE) { yFocusChange -= mY.DisplacementWillOverscrollAmount(yFocusChange); } ScrollBy(nsIntPoint(xFocusChange, yFocusChange)); // When we zoom in with focus, we can zoom too much towards the boundaries // that we actually go over them. These are the needed displacements along // either axis such that we don't overscroll the boundaries when zooming. PRInt32 neededDisplacementX = 0, neededDisplacementY = 0; // Only do the scaling if we won't go over 8x zoom in or out. bool doScale = (scale < 8.0f && spanRatio > 1.0f) || (scale > 0.125f && spanRatio < 1.0f); // If this zoom will take it over 8x zoom in either direction, but it's not // already there, then normalize it. if (scale * spanRatio > 8.0f) { spanRatio = scale / 8.0f; } else if (scale * spanRatio < 0.125f) { spanRatio = scale / 0.125f; } if (doScale) { switch (mX.ScaleWillOverscroll(spanRatio, focusPoint.x)) { case Axis::OVERSCROLL_NONE: break; case Axis::OVERSCROLL_MINUS: case Axis::OVERSCROLL_PLUS: neededDisplacementX = -mX.ScaleWillOverscrollAmount(spanRatio, focusPoint.x); break; case Axis::OVERSCROLL_BOTH: // If scaling this way will make us overscroll in both directions, then // we must already be at the maximum zoomed out amount. In this case, we // don't want to allow this scaling to go through and instead clamp it // here. doScale = false; break; } } if (doScale) { switch (mY.ScaleWillOverscroll(spanRatio, focusPoint.y)) { case Axis::OVERSCROLL_NONE: break; case Axis::OVERSCROLL_MINUS: case Axis::OVERSCROLL_PLUS: neededDisplacementY = -mY.ScaleWillOverscrollAmount(spanRatio, focusPoint.y); break; case Axis::OVERSCROLL_BOTH: doScale = false; break; } } if (doScale) { ScaleWithFocus(scale * spanRatio, focusPoint); if (neededDisplacementX != 0 || neededDisplacementY != 0) { ScrollBy(nsIntPoint(neededDisplacementX, neededDisplacementY)); } ForceRepaint(); // We don't want to redraw on every scale, so don't use SendViewportChange() } mLastZoomFocus = focusPoint; } return nsEventStatus_eConsumeNoDefault; }