Beispiel #1
0
void ImageView::OnKeyboard(int key)
{
	// Treat all keys as lower case (note: isalpha wants 0 <= key <= 255)
	if (key >= 0 && key <= 255 && isalpha(key) && isupper(key))
		key = tolower(key);

	if (key == 'c')
	{
		m_showCoordinates = !m_showCoordinates;

		if (Fl::belowmouse() == this)
			OnMouseMove();
	}
	else if (key == '+' || key == '=')
	{
		OnZoom(-1);
	}
	else if (key == '-')
	{
		OnZoom(1);
	}
	else if (key == '0')
	{
		OnZoomAndDragReset();
	}
	else if (m_pPainter)
	{
		if (m_pPainter->UpdateDrawingState(m_painterInfo, key))
			redraw();
	}
}
void tui::LayoutCanvas::OnMouseMotion(wxMouseEvent& event) {
   ScrMARKold = ScrMARK;
   // get a current position
   ScrMARK = TP(event.GetX(),event.GetY()) * _LayCTM ;
   int4b stepDB = Properties->stepDB();
   ScrMARK.roundTO(stepDB);
   if (Properties->autopan() && mouse_input && !invalid_window) {
      CTM LayCTMR(_LayCTM.Reversed());
      TP sp_BL     =     lp_BL * LayCTMR;
      TP sp_TR     =     lp_TR * LayCTMR;
      TP s_ScrMARK = n_ScrMARK * LayCTMR;
      TP nsp;
      if      (abs(s_ScrMARK.x() - sp_BL.x()) < ap_trigger)  {
               wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
               eventZOOM.SetInt(ZOOM_LEFT);
               OnZoom(eventZOOM);
               nsp = ScrMARK * _LayCTM.Reversed();
               WarpPointer(nsp.x(),nsp.y());return;
            }
      else  if(abs(sp_TR.x() - s_ScrMARK.x()) < ap_trigger) {
               wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
               eventZOOM.SetInt(ZOOM_RIGHT);
               OnZoom(eventZOOM);
               nsp = ScrMARK * _LayCTM.Reversed();
               WarpPointer(nsp.x(),nsp.y());return;
            }   
      else  if(abs(sp_BL.y() - s_ScrMARK.y()) < ap_trigger) {
               wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
               eventZOOM.SetInt(ZOOM_UP);
               OnZoom(eventZOOM);
               nsp = ScrMARK * _LayCTM.Reversed();
               WarpPointer(nsp.x(),nsp.y());return;
            }   
      else  if(abs(s_ScrMARK.y() - sp_TR.y()) < ap_trigger) {
               wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
               eventZOOM.SetInt(ZOOM_DOWN);
               OnZoom(eventZOOM);
               nsp = ScrMARK * _LayCTM.Reversed();
               WarpPointer(nsp.x(),nsp.y());return;
            }   
   }   
   // update movement indicators
   static int deltaX = abs(ScrMARKold.x() - ScrMARK.x());
   static int deltaY = abs(ScrMARKold.y() - ScrMARK.y());
   if (!(deltaX || deltaY)) return;
   //
//   if (event.LeftIsDown() && !mouse_input) {
//      presspoint = ScrMARKold;
//      mouseIN(true);rubber_band = true;
//   }   
//   if (mouse_input && event.LeftIsDown() && !rubber_band)  rubber_band = true;
   //
   CursorControl(event.ShiftDown(), event.ControlDown());
   if (deltaX > 0) 
      UpdateCoordWin(ScrMARK.x(), POS_X, (n_ScrMARK.x() - releasepoint.x()), DEL_X);
   if (deltaY > 0) 
      UpdateCoordWin(ScrMARK.y(), POS_Y, (n_ScrMARK.y() - releasepoint.y()), DEL_Y);
   if ((tmp_wnd || mouse_input)) Refresh();//updateGL();
}   
void CEquationEditorWindow::Zoom(bool param)
{
    int height = presenter->GetRoot()->GetRect().GetHeight();
    float step = 10;
    float coef = 1 + (param ? 1 : -1) * step / height;
    OnZoom(coef);
}
void tui::LayoutCanvas::OnMouseWheel(wxMouseEvent& event)
{
   int delta    = event.GetWheelDelta();
   int fulldist = event.GetWheelRotation();
   double scroll = fulldist / delta;
   wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
   if (event.ShiftDown())
   {
      if      ( 1 <= scroll) eventZOOM.SetInt(ZOOM_UP);
      else if (-1 >= scroll) eventZOOM.SetInt(ZOOM_DOWN);
   }
   else if (event.ControlDown())
   {
      if      ( 1 <= scroll) eventZOOM.SetInt(ZOOM_RIGHT);
      else if (-1 >= scroll) eventZOOM.SetInt(ZOOM_LEFT);
   }
   else
   {
      const double scalefactor = event.AltDown() ? 0.8 : 0.5;
      CTM tmpmtrx;
      TP markerpos(event.GetX(), event.GetY());
      if      ( 1 <= scroll)
         tmpmtrx.Scale(scalefactor,scalefactor);
      else if (-1 >= scroll)
         tmpmtrx.Scale(1/scalefactor,1/scalefactor);
      tmpmtrx.Translate(markerpos * _LayCTM - markerpos * _LayCTM * tmpmtrx);
      DBbox* box = DEBUG_NEW DBbox( lp_BL, lp_TR );
      (*box) = (*box) * tmpmtrx;
      eventZOOM.SetInt(tui::ZOOM_WINDOW);
      eventZOOM.SetClientData(static_cast<void*>(box));
   }
   OnZoom(eventZOOM);
   PointUpdate(event.GetX(), event.GetY());
}
Beispiel #5
0
/*!
	When dealing with mouse coordinates, we need to convert them to
	image coordinates, and so must consider the following things:

	1) The mouse has the origin at top-left, but in all calculations we
	  assume an origin at bottom-left, so when reading the mouse, we do
	  mousePt.Set(Fl::event_x(), h() - Fl::event_y()).

    2) In general, the relation between the (bottom-left-origin) mouse point
	   $p_m$ and its corresponding image point $p_i$ is given by:
	   
	   \[ p_m = p_i * S + T \],

	   where S is the scaling and T is the translation. Then, given a mouse 
	   point we get the image point by

	   \[ p_i = (p_m - T) / S \]

	3) When zooming, we want to end up at the same image point,. Then, given a 
	   requested new scaling factor, $S'$, we must find find the appropriate 
	   translation $T'$ for it that will make the mouse point, $p_m$, correspond to
	   the same image point $p_i$.

	   \[ p_m = p_i * S' + T' \], which means that from (2), we can get

	   \[ T' = p_m - p_i * S' \]. We could replace $p_i$ and simplify things a bit, 
	   but that's not really necessary.

	4) In the case of the y coordinate, we have it reflexed (multiplied by -1) and 
	   translated by the window hight, h, to make it agree with the top-left origin 
	   of the displayed images. So, thes coordinate needs some special treatment. Then,
	   the image y-coordinate is given by

	   \[ p_i = (p_m - T - h) / -S \], and the new translation dy is given by

	   \[ dy = p_m - p_i * -S' - h \]. Agaim, some simplifycation could me made here,
	   but that's not necessary, and the point realtion are seen clearer this way.
*/
int ImageView::handle(int eventId)
{
	switch (eventId) 
	{
		// case FL_KEYDOWN: // does not work
		case FL_KEYUP:
			OnKeyboard(Fl::event_key());
			return 1;
		case FL_MOUSEWHEEL:
			OnZoom(Fl::event_dy());
			return 1;
		case FL_PUSH:
			OnMousePush();
			return 1;
		case FL_DRAG:
			OnMouseDrag();
			return 1;
		//case FL_ENTER:
		//	m_savedTitle = parent()->label();
		//	return 1;
		case FL_LEAVE:
			if (m_curImgInfo != parent()->label())
			{
				parent()->label(m_curImgInfo.c_str());
				parent()->redraw();
			}
			return 1;
		case FL_MOVE:
			OnMouseMove();
			return 1;
	}

	return BaseImageView::handle(eventId);
}
CTilePreviewPalette::CTilePreviewPalette(CDocumentWindow* owner, CImage32 image)
: CPaletteWindow(owner, "Tile Preview",
  Configuration::Get(KEY_TILE_PREVIEW_RECT),
  Configuration::Get(KEY_TILE_PREVIEW_VISIBLE))
,  m_Image(image)
, m_BlitImage(NULL)
{
  OnZoom(1);
}
void tui::LayoutCanvas::OnPanCenter(wxCommandEvent&)
{
   CTM tmpmtrx;
   TP center((lp_TR.x() + lp_BL.x())/2, (lp_TR.y() + lp_BL.y())/2);
   tmpmtrx.Translate(ScrMARK - center);
   DBbox* box = DEBUG_NEW DBbox( lp_BL, lp_TR );
   (*box) = (*box) * tmpmtrx;
   wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
   eventZOOM.SetInt(tui::ZOOM_WINDOW);
   eventZOOM.SetClientData(static_cast<void*>(box));
   OnZoom(eventZOOM);
}
CFontPreviewPalette::CFontPreviewPalette(CDocumentWindow* owner, sFont* font)
: CPaletteWindow(owner, "Font Preview",
  Configuration::Get(KEY_FONT_PREVIEW_RECT),
  Configuration::Get(KEY_FONT_PREVIEW_VISIBLE))
,  m_Font(font)
//, m_ZoomFactor(1)
, m_RedrawAll(true)
, m_RedrawCharacter(-1)
, m_BlitImage(NULL)
{
  m_Text = "The quick brown fox jumped over the lazy dog";
  OnZoom(2);
}
void tui::LayoutCanvas::OnChar(wxKeyEvent& event)
{
   wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
   switch(event.GetKeyCode())
   {
      case WXK_LEFT : eventZOOM.SetInt(ZOOM_LEFT ); break;
      case WXK_RIGHT: eventZOOM.SetInt(ZOOM_RIGHT); break;
      case WXK_UP   : eventZOOM.SetInt(ZOOM_UP   ); break;
      case WXK_DOWN : eventZOOM.SetInt(ZOOM_DOWN ); break;
      case '+'      : eventZOOM.SetInt(ZOOM_IN   ); break;
      case '-'      : eventZOOM.SetInt(ZOOM_OUT  ); break;
            default : event.Skip(); return;
   }
   OnZoom(eventZOOM);
   PointUpdate(event.GetX(), event.GetY());
}
void
CTilePreviewPalette::OnImageChanged(CImage32 image)
{
  bool changed_size =
    (image.GetWidth()  != m_Image.GetWidth()
  || image.GetHeight() != m_Image.GetHeight());
	
  m_Image = image;

  if (changed_size) {
    OnZoom(m_ZoomFactor.GetZoomFactor());
  }
  else {
    Invalidate();
  }
}
tui::LayoutCanvas::LayoutCanvas(wxWindow *parent, int* attribList): wxGLCanvas(parent,
   ID_TPD_CANVAS, wxDefaultPosition, wxDefaultSize, 0,wxT("LayoutCanvas"), attribList){

   crossCur = MakeCursor(crosscursor,16, 16);
   //crossCur = new wxCursor((const char*)crosscursor,16, 16);
   SetCursor(*crossCur);
   tmp_wnd = false;
   mouse_input = false;
   rubber_band = false;
   restricted_move = false;
   invalid_window = false;
   initializeGL();
   wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
   eventZOOM.SetInt(ZOOM_EMPTY);
   OnZoom(eventZOOM);
   ap_trigger = 10;
}
Beispiel #12
0
void WinEDA_DrawFrame::Process_Zoom(wxCommandEvent& event)
/**********************************************************/
/* fonction de traitement des boutons de Zoom.
	Appelle simplement la fonction de traitement du Zoom de la
	fenetre active.
*/
{
int id = event.GetId();

	switch (id)
		{
		case ID_ZOOM_PLUS_BUTT:
		case ID_ZOOM_MOINS_BUTT:
		case ID_ZOOM_REDRAW_BUTT:
		case ID_ZOOM_PAGE_BUTT:
			OnZoom(id);
			break;

		default:
			DisplayError(this, wxT("WinEDA_DrawFrame::Process_Zoom id Error") );
			break;
		}
}
Beispiel #13
0
GMessage::Result GWindow::OnEvent(GMessage *Msg)
{
	int Status = 0;

	switch (MsgCode(Msg))
	{
		case M_SET_WINDOW_PLACEMENT:
		{
			/*	
				Apparently if you use SetWindowPlacement inside the WM_CREATE handler,
				then the restored rect doesn't "stick", it gets stomped on by windows.
				So this code... RESETS it to be what we set earlier. Windows sucks.
			*/
			if (d->Wp)
			{
				if (_View)
				{
					GRect r = d->Wp->rcNormalPosition;

					if (!GView::Visible())
					{
						d->Wp->showCmd = SW_HIDE;
					}

					#if DEBUG_WINDOW_PLACEMENT
					LgiTrace("%s:%i - SetWindowPlacement, pos=%s, show=%i\n", __FILE__, __LINE__, r.GetStr(), d->Wp->showCmd);
					#endif

					SetWindowPlacement(_View, d->Wp);
				}
				DeleteObj(d->Wp);
			}
			break;
		}
		case WM_SYSCOLORCHANGE:
		{
			LgiInitColours();
			break;
		}
		case WM_WINDOWPOSCHANGING:
		{
			bool Icon = IsIconic(Handle());
			bool Zoom = IsZoomed(Handle());

			if (!Icon && (_Dialog || !Zoom))
			{
				WINDOWPOS *Info = (LPWINDOWPOS) Msg->b;
				if (!Info)
				    break;
				    
				if (Info->flags == (SWP_NOSIZE | SWP_NOMOVE) && _Dialog)
				{
				    // Info->flags |= SWP_NOZORDER;
				    Info->hwndInsertAfter = _Dialog->Handle();
				}

				if (GetMinimumSize().x &&
					GetMinimumSize().x > Info->cx)
				{
					Info->cx = GetMinimumSize().x;
				}

				if (GetMinimumSize().y &&
					GetMinimumSize().y > Info->cy)
				{
					Info->cy = GetMinimumSize().y;
				}

				RECT Rc;
				if (d->SnapToEdge &&
					SystemParametersInfo(SPI_GETWORKAREA, 0, &Rc, SPIF_SENDCHANGE))
				{
					GRect r = Rc;
					GRect p(Info->x,
					        Info->y,
					        Info->x + Info->cx - 1,
					        Info->y + Info->cy - 1);
					
					if (r.Valid() && p.Valid())
					{
						int Snap = 12;

						if (abs(p.x1 - r.x1) <= Snap)
						{
							// Snap left edge
							Info->x = r.x1;
						}
						else if (abs(p.x2 - r.x2) <= Snap)
						{
							// Snap right edge
							Info->x = r.x2 - Info->cx + 1;
						}

						if (abs(p.y1 - r.y1) <= Snap)
						{
							// Snap top edge
							Info->y = r.y1;
						}
						else if (abs(p.y2 - r.y2) <= Snap)
						{
							// Snap bottom edge
							Info->y = r.y2 - Info->cy + 1;
						}
					}
				}
			}
			break;
		}
		case WM_SIZE:
		{
			if (Visible())
			{
				GWindowZoom z = d->Show;
				switch (Msg->a)
				{
					case SIZE_MINIMIZED:
					{
						z = GZoomMin;
						break;
					}
					case SIZE_MAXIMIZED:
					{
						z = GZoomMax;
						break;
					}
					case SIZE_RESTORED:
					{
						z = GZoomNormal;
						break;
					}
				}
				if (z != d->Show)
				{
					OnZoom(d->Show = z);
				}
			}

			Status = GView::OnEvent(Msg);
			break;
		}
		case WM_ACTIVATE:
		{
			// This is a hack to make Windows set the focus of a child
			// control when you Alt-Tab in and out of a top level window
			if (LOWORD(Msg->a) != WA_INACTIVE)
			{
				/*
				// gaining focus
				if (LastFocus)
				{
					if (In_SetWindowPos)
					{
						assert(0);
						LgiTrace("%s:%i - %s->SetFocus()\n", __FILE__, __LINE__, GetClass());
					}
					SetFocus(LastFocus);
					LastFocus = 0;
				}
				
				if (d->Focus && d->Focus->Handle())
				{
					if (In_SetWindowPos)
					{
						assert(0);
						LgiTrace("%s:%i - %s->SetFocus()\n", __FILE__, __LINE__, GetClass());
					}
					else
					{					
						::SetFocus(d->Focus->Handle());
					}
				}
				*/
			}
			/*
			else
			{
				// losing focus
				LastFocus = 0;
				HWND f = GetFocus();
				for (HWND p = ::GetParent(f); p; p = ::GetParent(p))
				{
					if (p == Handle())
					{
						LastFocus = f;
					}
				}
			}
			*/
			break;
		}
		case WM_CREATE:
		{
			Pour();
			OnCreate();

			if (!_Default)
			{
				_Default = FindControl(IDOK);
				if (_Default)
				{
					_Default->Invalidate();
				}
			}

			d->InCreate = false;
			if (d->Wp)
			{
				PostEvent(M_SET_WINDOW_PLACEMENT);
			}
			break;
		}
		case WM_WINDOWPOSCHANGED:
		{
			DeleteObj(d->Wp);
			Status = GView::OnEvent(Msg);
			break;
		}
		case WM_QUERYENDSESSION:
	 	case WM_CLOSE:
		{
			bool QuitApp;
			if (QuitApp = OnRequestClose(MsgCode(Msg) == WM_QUERYENDSESSION))
			{
				Quit();
			}

			if (MsgCode(Msg) == WM_CLOSE)
			{
				return 0;
			}
			else
			{
				return QuitApp;
			}
			break;
		}
		case WM_SYSCOMMAND:
		{
		    if (Msg->a == SC_CLOSE)
		    {
    			if (OnRequestClose(false))
    		    {
    		        Quit();
    		    }

   		        return 0;
		    }
		    else
		    {
			    Status = GView::OnEvent(Msg);
			}
		    break;
		}
		case WM_DROPFILES:
		{
			HDROP hDrop = (HDROP) Msg->a;
			if (hDrop)
			{
				GArray<char*> FileNames;
				int Count = 0;
				
				Count = DragQueryFileW(hDrop, -1, NULL, 0);

				for (int i=0; i<Count; i++)
				{
					char16 FileName[256];
					if (DragQueryFileW(hDrop, i, FileName, sizeof(FileName)-1) > 0)
					{
						FileNames.Add(LgiNewUtf16To8(FileName));
					}
				}

				OnReceiveFiles(FileNames);
				FileNames.DeleteArrays();
			}
			break;
		}
		case M_HANDLEMOUSEMOVE:
		{
			// This receives events fired from the GMouseHookPrivate class so that
			// non-LGI windows create mouse hook events as well.
			GTempView v((OsView)MsgB(Msg));
			GMouse m;
			m.x = LOWORD(MsgA(Msg));
			m.y = HIWORD(MsgA(Msg));
			HandleViewMouse(&v, m);
			break;
		}
		case M_COMMAND:
		{
			HWND OurWnd = Handle(); // copy onto the stack, because
									// we might lose the 'this' object in the
									// OnCommand handler which would delete
									// the memory containing the handle.

			Status = OnCommand(Msg->a, 0, (HWND) Msg->b);
			if (!IsWindow(OurWnd))
			{
				// The window was deleted so break out now
				break;
			}
			// otherwise fall thru to the GView handler
		}
		default:
		{
			Status = GView::OnEvent(Msg);
			break;
		}
	}

	return Status;
}
void tui::LayoutCanvas::OnMouseRightUp(wxMouseEvent& WXUNUSED(event)) {
   tmp_wnd = false;
   int4b stepDB = Properties->stepDB();
   if ((abs(presspoint.x() - ScrMARK.x())  > stepDB) ||
       (abs(presspoint.y() - ScrMARK.y())  > stepDB))   {
      // if dragging ...
      wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
      eventZOOM.SetInt(ZOOM_WINDOWM);
      OnZoom(eventZOOM);
   }
   else {
   // Context menu here
      wxMenu menu;
      if ( NULL != Console->puc) {
         switch (Properties->drawprop().currentop()) {
            case layprop::op_dbox:
               if (Console->numpoints() > 0) {
                  menu.Append(CM_CANCEL_LAST, wxT("Cancel first point"));
               }
               menu.Append(CM_CONTINUE, wxT("Continue"));
               menu.Append(   CM_ABORT, wxT("Abort"));
               break;
            case layprop::op_dpoly:
               if (Console->numpoints() >= 3) {
                  menu.Append(CM_CLOSE, wxT("Close polygon"));
               }
               if (Console->numpoints() > 1) {
                  menu.Append(CM_CANCEL_LAST, wxT("Cancel last point"));
               }
               else if (Console->numpoints() > 0) {
                  menu.Append(CM_CANCEL_LAST, wxT("Cancel first point"));
               }
               menu.Append(CM_CONTINUE, wxT("Continue"));
               menu.Append(   CM_ABORT, wxT("Abort"));
               break;
            case layprop::op_dwire:
               if (Console->numpoints() > 1) {
                  menu.Append(CM_CLOSE, wxT("Finish wire"));
               }
               if (Console->numpoints() > 1) {
                  menu.Append(CM_CANCEL_LAST, wxT("Cancel last point"));
               }
               else if (Console->numpoints() > 0) {
                  menu.Append(CM_CANCEL_LAST, wxT("Cancel first point"));
               }
               menu.Append(CM_CONTINUE, wxT("Continue"));
               menu.Append(   CM_ABORT, wxT("Abort"));
               break;
//            case layprop::op_move:
//            case layprop::op_copy:
            default:
               menu.Append(CM_CONTINUE, wxT("Continue"));
               menu.Append(   CM_ABORT, wxT("Abort"));
         }
      }
      else { // no user input expected
         menu.Append(   CM_AGAIN, wxString(Console->lastCommand(), wxConvUTF8));
         menu.Append(TMEDIT_UNDO, wxT("undo"));
         menu.AppendSeparator();
         if (DATC->numselected() > 0) {
            menu.Append(    TMEDIT_MOVE, wxT("move"  ));
            menu.Append(    TMEDIT_COPY, wxT("copy"  ));
            menu.Append(TMEDIT_ROTATE90, wxT("rotate"));
            menu.Append(   TMEDIT_FLIPX, wxT("flipX" ));
            menu.Append(   TMEDIT_FLIPY, wxT("flipY" ));
         }
         else {
            menu.Append(     TMDRAW_BOX, wxT("box"   ));
            menu.Append(    TMDRAW_POLY, wxT("poly"  ));
            menu.Append(    TMDRAW_WIRE, wxT("wire"  ));
            menu.Append(    TMDRAW_TEXT, wxT("text"  ));
         }
         menu.AppendSeparator();
         menu.Append( TMSEL_SELECT_IN, wxT("select"     ));
         menu.Append(TMSEL_PSELECT_IN, wxT("part select"));
         if (DATC->numselected() > 0) {
            menu.Append( TMSEL_UNSELECT_IN, wxT("unselect"     ));
            menu.Append(TMSEL_PUNSELECT_IN, wxT("part unselect"));
         }
      }
      TP s_ScrMARK = ScrMARK * _LayCTM.Reversed();
      PopupMenu(&menu, wxPoint(s_ScrMARK.x(), s_ScrMARK.y()));
   }
}
void CEquationEditorWindow::OnWmCommand( WPARAM wParam, LPARAM lParam )
{
	CCaret caret;
	if( HIWORD( wParam ) == 1 ) {
		switch( LOWORD( wParam ) ) {
			case ID_ACC_SQRBRAC:
				presenter->AddControlView( SQUAREBRACKETS );
				break;
			case ID_ACC_BRAC:
				presenter->AddControlView( BRACES );
				break;
			case ID_ACC_PAR:
				presenter->AddControlView( PARENTHESES );
				break;
			case ID_ACC_DEGR:
				presenter->AddControlView( DEGR );
				break;
			case ID_ACC_FRAC:
				presenter->AddControlView( FRAC );
				break;
			case ID_SHIFT_LEFT:
				caret = presenter->GetCaret();
				caret.GetCurEdit()->MoveCaretLeft( caret.GetCurEdit().get(), caret );
				presenter->SetSelection( caret.GetPointX(), caret.GetPointY() );
				break;
			case ID_SHIFT_RIGHT:
				caret = presenter->GetCaret();
				caret.GetCurEdit()->MoveCaretRight( caret.GetCurEdit().get(), caret );
				presenter->SetSelection( caret.GetPointX(), caret.GetPointY() );
				break;
			default:
				return;
		}
	} else if( HIWORD( wParam ) == 0 ) {
		switch( LOWORD( wParam ) ) {
			case ID_ADD_FRAC:
				presenter->AddControlView( FRAC );
				break;
			case ID_ADD_DEGR:
				presenter->AddControlView( DEGR );
				break;
			case ID_ADD_SUBSCRIPT:
				presenter->AddControlView( SUBSCRIPT );
				break;
			case ID_ADD_RADICAL:
				presenter->AddControlView( RADICAL );
				break;
			case ID_ADD_PARANTHESES:
				presenter->AddControlView( PARENTHESES );
				break;
			case ID_ADD_BRACES:
				presenter->AddControlView( BRACES );
				break;
			case ID_ADD_SQUAREBRACKETS:
				presenter->AddControlView( SQUAREBRACKETS );
				break;
			case ID_ADD_SUM:
				presenter->AddControlView( SUM );
				break;
			case ID_ADD_PRODUCT:
				presenter->AddControlView( PRODUCT );
				break;
            case ID_ZOOM_IN:
                Zoom( true );
                break;
            case ID_ZOOM_OUT:
                Zoom( false );
                break;
			case ID_ADD_SYSTEM:
				presenter->AddControlView( SYSTEM );
				break;
			case ID_ADD_Validator:
				CEquationEditorWindow::ValidateFormula();
				break;
            case ID_DRAW_GRAPH:
                DrawGraph();
                break;
		    case ID_ADD_SAVE:
			    SaveToFile();
			    break;
		}
        OnZoom();
	}
}
Beispiel #16
0
void WinEDA_BasePcbFrame::GeneralControle(wxDC *DC, wxPoint Mouse)
/****************************************************************/
/* traitement des touches de fonctions utilisees ds tous les menus
	Zoom
	Redessin d'ecran
	Cht Unites
	Cht couches
	Remise a 0 de l'origine des coordonnees relatives
*/
{
wxSize delta;
wxPoint curpos, oldpos;
int hotkey = 0;

	if( GetScreen()->IsRefreshReq() )
		{
		RedrawActiveWindow(DC, TRUE);
                // We must return here, instead of proceeding.
                // If we let the cursor move during a refresh request,
                // the cursor be displayed in the wrong place
                // during delayed repaint events that occur when
                // you move the mouse when a message dialog is on
                // the screen, and then you dismiss the dialog by
                // typing the Enter key.
                return;
		}

	curpos = DrawPanel->CursorRealPosition(Mouse);
	oldpos = GetScreen()->m_Curseur;

	delta.x = GetScreen()->GetGrid().x / GetScreen()->GetZoom();
	delta.y = GetScreen()->GetGrid().y / GetScreen()->GetZoom();
	if( delta.x == 0 ) delta.x = 1;
	if( delta.y == 0 ) delta.y = 1;

	switch(g_KeyPressed)
		{
		case WXK_NUMPAD_SUBTRACT :
		case WXK_SUBTRACT :
		case '-' :
			if(GetScreen()->m_Active_Layer > 0)
				GetScreen()->m_Active_Layer--;
			break ;

		case WXK_NUMPAD_ADD :
		case WXK_ADD :
		case '+' :
			if(GetScreen()->m_Active_Layer < 31)
				GetScreen()->m_Active_Layer ++;
			break ;

		case 'F' | GR_KB_CTRL :
		case 'f' | GR_KB_CTRL :
			DisplayOpt.DisplayPcbTrackFill ^= 1; DisplayOpt.DisplayPcbTrackFill &= 1 ;
			GetScreen()->SetRefreshReq();
			break ;

		case ' ' : /* Mise a jour de l'origine des coord relatives */
			GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
			break ;


		case 'U' | GR_KB_CTRL :
		case 'u' | GR_KB_CTRL :
			if (g_UnitMetric == INCHES ) g_UnitMetric = MILLIMETRE ;
			else 	g_UnitMetric = INCHES ;
			break ;

		case WXK_F1 :
			OnZoom(ID_ZOOM_PLUS_KEY);
			curpos = GetScreen()->m_Curseur;
			break;

		case WXK_F2 :
			OnZoom(ID_ZOOM_MOINS_KEY);
			curpos = GetScreen()->m_Curseur;
			break;

		case WXK_F3 :
			OnZoom(ID_ZOOM_REDRAW_KEY);
			break;

		case WXK_F4 :
			OnZoom(ID_ZOOM_CENTER_KEY);
			curpos = GetScreen()->m_Curseur;
			break;

		case WXK_NUMPAD8  :	/* Deplacement curseur vers le haut */
		case WXK_UP	:
			Mouse.y -= delta.y;
			DrawPanel->MouseTo(Mouse);
			break ;

		case WXK_NUMPAD2:	/* Deplacement curseur vers le bas */
		case WXK_DOWN:
			Mouse.y += delta.y;
			DrawPanel->MouseTo(Mouse);
			break ;

		case WXK_NUMPAD4:	/* Deplacement curseur vers la gauche */
		case WXK_LEFT :
			Mouse.x -= delta.x;
			DrawPanel->MouseTo(Mouse);
			break ;

		case WXK_NUMPAD6:  /* Deplacement curseur vers la droite */
		case WXK_RIGHT :
			Mouse.x += delta.x;
			DrawPanel->MouseTo(Mouse);
			break ;

		default: hotkey = g_KeyPressed;
			break;
		}

	/* Recalcul de la position du curseur schema */
	GetScreen()->m_Curseur = curpos;
	/* Placement sur la grille generale */
	PutOnGrid( & GetScreen()->m_Curseur);

	if ( (oldpos.x != GetScreen()->m_Curseur.x) ||
		 (oldpos.y != GetScreen()->m_Curseur.y) )
		{
		curpos = GetScreen()->m_Curseur;
		GetScreen()->m_Curseur = oldpos;
		GetScreen()->CursorOff(DrawPanel, DC);

		GetScreen()->m_Curseur = curpos;
		GetScreen()->CursorOn(DrawPanel, DC);

		if(GetScreen()->ManageCurseur)
			{
			GetScreen()->ManageCurseur(DrawPanel, DC, TRUE);
			}
		}

	SetToolbars();
	Affiche_Status_Box();	 /* Affichage des coord curseur */

	if ( hotkey )
	{
		OnHotKey(DC, hotkey, NULL);
	}
}
afx_msg void
CFontPreviewPalette::OnZoomOut()
{
  m_ZoomFactor.ZoomOut();
  OnZoom(m_ZoomFactor.GetZoomFactor());
}
Beispiel #18
0
void GWindow::Visible(bool v)
{
	if (v)
	{
		Pour();
	}
	else
	{
		int asd=0;
	}

	if (v)
	{
		SetStyle(GetStyle() | WS_VISIBLE);

		if (_View)
		{
			GWindowZoom z = d->Show;
			char *Cmd = 0;

			WINDOWPLACEMENT *Wp = new WINDOWPLACEMENT;
			if (Wp)
			{
				ZeroObj(*Wp);
				Wp->length = sizeof(*Wp);
				Wp->flags = 2;
				Wp->ptMaxPosition.x = -1;
				Wp->ptMaxPosition.y = -1;

				if (d->Show == GZoomMax)
				{
					Wp->showCmd = SW_MAXIMIZE;
					Cmd = "SW_MAXIMIZE";
				}
				else if (d->Show == GZoomMin)
				{
					Wp->showCmd = SW_MINIMIZE;
					Cmd = "SW_MINIMIZE";
				}
				else
				{
					Wp->showCmd = SW_NORMAL;
					Cmd = "SW_NORMAL";
				}

				Wp->rcNormalPosition = Pos;
				#if DEBUG_WINDOW_PLACEMENT
				LgiTrace("%s:%i - SetWindowPlacement, pos=%s, show=%i\n", __FILE__, __LINE__, Pos.GetStr(), Wp->showCmd);
				#endif
				SetWindowPlacement(_View, Wp);

				if (d->InCreate)
				{
					DeleteObj(d->Wp);
					d->Wp = Wp;
				}
				else
				{
					DeleteObj(Wp);
				}
			}
		}
	}
	else
	{
		#if DEBUG_WINDOW_PLACEMENT
		LgiTrace("%s:%i - Visible(%i)\n", __FILE__, __LINE__, v);
		#endif
		GView::Visible(v);
	}

	if (v)
	{
		OnZoom(d->Show);
	}
}