7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-19 00:21:36 +00:00

Implement wxDC coordinate handling and wxGCDC.

* Implement code to allow wxDC to handle coordinate conversions between
  device and drawing units.
* Add build settings to enable wxGCDC for wxGraphicsContext testing.
* Remove wxAUI conditional build cruft as it is now required to build
  Kicad.
* Fix scroll increment size regression to prevent jumping around the
  zoom center position.
* Add find GDI+ cmake module for building on WXMSW when wxGraphicsContext
  is enabled.
This commit is contained in:
stambaughw 2010-02-08 18:15:42 +00:00
parent 3f0a7f8deb
commit 3066c70559
52 changed files with 632 additions and 583 deletions

View File

@ -78,7 +78,6 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent,
// Make a Pcb3D_GLCanvas
m_Canvas = new Pcb3D_GLCanvas( this );
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz;
@ -101,7 +100,6 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
m_auimgr.Update();
#endif
}

View File

@ -21,10 +21,6 @@ void WinEDA3D_DrawFrame::ReCreateHToolbar()
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
#if !defined(KICAD_AUIMANAGER)
SetToolBar( (wxToolBar*) m_HToolBar );
#endif
// Set up toolbar
m_HToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString,
wxBitmap( import3d_xpm ),

View File

@ -192,10 +192,8 @@ public:
wxPoint m_FramePos;
wxSize m_FrameSize;
#if defined(KICAD_AUIMANAGER)
wxAuiManager m_auimgr;
~WinEDA3D_DrawFrame() { m_auimgr.UnInit(); };
#endif
private:
wxString m_FrameName; // name used for writing and reading setup

View File

@ -18,10 +18,10 @@ option(KICAD_MINIZIP "enable/disable building minizip (default ON)" ON)
option(wxUSE_UNICODE "enable/disable building unicode (default OFF)")
option(KICAD_GOST "enable/disable building using GOST notation for multiple gates per package (default OFF)")
# these are now mandatorily set to ON, and now done so in CMakeModules/config.h.cmake
#option(KICAD_AUIMANAGER "Enable use of wxAuiManager (default ON)" ON)
#option(KICAD_AUITOOLBAR "Enable use of wxAuiToolBar (default ON)" ON)
option(USE_WX_ZOOM "Use wxDC to perform zooming (default OFF). Warning, this is experimental" )
option(USE_WX_GRAPHICS_CONTEXT
"Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental")
# Comment this out if you don't want to build with Python support.
# OPTION(KICAD_PYTHON "enable/disable building with Python support (default OFF)")
@ -50,6 +50,16 @@ if(KICAD_GOST)
add_definitions(-DKICAD_GOST)
endif(KICAD_GOST)
if(USE_WX_ZOOM)
add_definitions(-DUSE_WX_ZOOM)
endif(USE_WX_ZOOM)
if(USE_WX_GRAPHICS_CONTEXT)
set( USE_WX_ZOOM ON )
add_definitions(-DUSE_WX_ZOOM)
add_definitions(-DUSE_WX_GRAPHICS_CONTEXT)
endif(USE_WX_GRAPHICS_CONTEXT)
# Locations for install targets.
set(KICAD_BIN bin
CACHE PATH "Location of KiCad binaries.")
@ -124,7 +134,7 @@ check_find_package_result(OPENGL_FOUND "OpenGL")
if(APPLE)
find_package(wxWidgets COMPONENTS gl adv html core net base QUIET)
else(APPLE)
find_package(wxWidgets COMPONENTS gl aui adv html core net base QUIET)
find_package(wxWidgets COMPONENTS gl aui adv html core net base QUIET)
endif(APPLE)
check_find_package_result(wxWidgets_FOUND "wxWidgets")
@ -135,11 +145,16 @@ include(${wxWidgets_USE_FILE})
# Include MinGW resource compiler.
include(MinGWResourceCompiler)
# Generate build system specific header file.
include(PerformFeatureChecks)
perform_feature_checks()
# Find GDI+ on windows if wxGraphicsContext is available.
if(WIN32 AND USE_WX_GRAPHICS_CONTEXT)
find_package(GdiPlus)
check_find_package_result(GDI_PLUS_FOUND "GDI+")
endif(WIN32 AND USE_WX_GRAPHICS_CONTEXT)
# Automagically create version header file.
include(CreateSVNVersionHeader)
create_svn_version_header()

View File

@ -0,0 +1,22 @@
# - Try to find Microsoft GDI+ build files.
# Once done this will define
#
# GDI_PLUS_FOUND - system has GDI+
# GDI_PLUS_INCLUDE_DIR - the GDI+ include directory
# GDI_PLUS_LIBRARIES - Link these to use GDI+
if(GDI_PLUS_INCLUDE_DIR AND GDI_PLUS_LIBRARIES)
set(GDI_PLUS_FIND_QUIETLY TRUE)
endif(GDI_PLUS_INCLUDE_DIR AND GDI_PLUS_LIBRARIES)
find_path(GDI_PLUS_INCLUDE_DIR GdiPlus.h )
find_library(GDI_PLUS_LIBRARIES gdiplus )
# handle the QUIETLY and REQUIRED arguments and set GDI_PLUS_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GDI_PLUS DEFAULT_MSG GDI_PLUS_LIBRARIES GDI_PLUS_INCLUDE_DIR)
mark_as_advanced(GDI_PLUS_INCLUDE_DIR GDI_PLUS_LIBRARIES)

View File

@ -49,13 +49,10 @@
#define strnicmp _strnicmp
#endif
#if 1
// now mandatory, not configurable
#define KICAD_AUIMANAGER 1
#define KICAD_AUITOOLBAR 1
#else
#cmakedefine KICAD_AUIMANAGER 1
#cmakedefine KICAD_AUITOOLBAR 1
#endif
/* Warning!!! Using wxDC for zooming is experimental. */
#cmakedefine USE_WX_ZOOM 1
/* Warning!!! Using wxGraphicContext for rendering is experimental. */
#cmakedefine USE_WX_GRAPHICS_CONTEXT 1
#endif /* __CONFIG_H__ */

View File

@ -26,6 +26,11 @@ Common
* Integer/long/double input boxes should handle comma and dot separated values,
not only comma.
Wayne:
C1) Fix mouse wheel scrolling (ctrl + Mouse wheel) and (Shift + mouse wheel)
to move more than a single scroll increment.
CvPCB
-----
* Preview of the already assigned footprint.
@ -36,6 +41,11 @@ EESchema
* Use collector classes.
* Drag and drop between two EESchema windows.
Wayne:
E1) Relpace find dialog with wxFormBuilder version using a modeless dialog
and event driven design similar to wxFindReplaceDialog implementation.
GerbView
--------
* Need work as good as gerbv from gEDA
@ -119,3 +129,30 @@ L9) On board load, ReFill() is called, this should also update the Render
checkboxes and colors. Will need to extend the widget API.
L10)still thinking about background colors, easier now without wxformbuilder.
Use wxDC for coordinate scaling and offsetting fix. (Wayne)
------------------------------------------------------------
W1) Make wxAutoBufferedPaintDC function properly.
W2) Make bitmap grid drawing method function properly.
W3) Use one cursor position (preferrably logical (drawing) units) instead
of keeping track of both logical and device cursor positions at the same
time.
W4) Figure out why none of the apps render correctly using wxGCDC on Windows.
W5) Add instructions for building wxWidgets with GDI+ using MinGW/MSYS
on Windows so wxGraphicsContext is available without having to use
Visual Studio.
** After (if?) new code accepted as project default: **
W6) Remove all old coordinate scaling and offset code from Kicad.
W7) Remove conditional compilation pragmas and dead code paths.
W8) Remove redundant drawing helper functions from gr_basic.cpp.
W9) Remove all global variables used by old drawing code.

View File

@ -104,9 +104,9 @@ wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
wxPoint curpos = ScreenPos;
Unscale( curpos );
//#ifndef WX_ZOOM
#ifndef USE_WX_ZOOM
curpos += m_DrawOrg;
//#endif
#endif
return curpos;
}
@ -143,7 +143,7 @@ void BASE_SCREEN::SetScalingFactor(double aScale )
*/
int BASE_SCREEN::Scale( int coord )
{
#ifdef WX_ZOOM
#ifdef USE_WX_ZOOM
return coord;
#else
if( !m_ZoomScalar || !m_Zoom )
@ -156,7 +156,7 @@ int BASE_SCREEN::Scale( int coord )
double BASE_SCREEN::Scale( double coord )
{
#ifdef WX_ZOOM
#ifdef USE_WX_ZOOM
return coord;
#else
if( !m_Zoom )
@ -179,7 +179,7 @@ void BASE_SCREEN::Scale( wxPoint& pt )
void BASE_SCREEN::Scale( wxRealPoint& pt )
{
#ifdef WX_ZOOM
#ifdef USE_WX_ZOOM
// No change
#else
if( !m_ZoomScalar || !m_Zoom )
@ -206,7 +206,7 @@ void BASE_SCREEN::Scale( wxSize& sz )
*/
int BASE_SCREEN::Unscale( int coord )
{
#ifdef WX_ZOOM
#ifdef USE_WX_ZOOM
return coord;
#else
if( !m_Zoom || !m_ZoomScalar )

View File

@ -427,7 +427,13 @@ void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC,
/* Draw text anchor, if allowed */
if( aAnchor_color != UNSPECIFIED_COLOR )
{
#if USE_WX_ZOOM
int anchor_size = aDC->DeviceToLogicalXRel( 2 );
#else
int anchor_size = aPanel->GetScreen()->Unscale( 2 );
#endif
aAnchor_color = (EDA_Colors) ( aAnchor_color & MASKCOLOR );
int cX = aPos.x + aOffset.x;

View File

@ -101,6 +101,7 @@ void BLOCK_SELECTOR::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
int aDrawMode,
int aColor )
{
int w = aPanel->GetScreen()->Scale( GetWidth() );
int h = aPanel->GetScreen()->Scale( GetHeight() );

View File

@ -17,6 +17,7 @@
#include "class_base_screen.h"
#include "wxstruct.h"
#include "confirm.h"
#include "kicad_device_context.h"
#include <wx/fontdlg.h>
@ -114,9 +115,7 @@ WinEDA_DrawFrame::~WinEDA_DrawFrame()
if( m_CurrentScreen != NULL )
delete m_CurrentScreen;
#if defined(KICAD_AUIMANAGER)
m_auimgr.UnInit();
#endif
}
@ -299,10 +298,8 @@ void WinEDA_DrawFrame::SetToolbars()
{
DisplayUnitsMsg();
#if defined(KICAD_AUIMANAGER)
if( m_auimgr.GetManagedWindow() )
m_auimgr.Update();
#endif
}
@ -344,61 +341,6 @@ void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv )
{
m_FrameSize = GetClientSize( );
#if !defined(KICAD_AUIMANAGER)
wxSize clientSize = m_FrameSize;
wxPoint clientPosition;
int default_value = -1;
// Ugly fix for a problem found in recent linux version
// where default value is broken
#ifdef __WXGTK__
if( GetToolBar() ) // use main tool bar dimension as default value
default_value = GetToolBar()->GetSize().y;
#endif
clientSize.y -= m_MsgFrameHeight;
if( MsgPanel ) // Resize the message panel.
{
MsgPanel->SetSize( 0, clientSize.y, clientSize.x, m_MsgFrameHeight );
}
if( m_AuxiliaryToolBar && m_AuxiliaryToolBar->IsShown() ) // Resize the auxilary horizontal tool bar.
{
m_AuxiliaryToolBar->SetSize( clientSize.x, default_value);
m_AuxiliaryToolBar->Move( 0, 0 );
clientSize.y -= m_AuxiliaryToolBar->GetDimension();
clientPosition.y = m_AuxiliaryToolBar->GetDimension();
}
if( m_VToolBar && m_VToolBar->IsShown() ) // Resize the main right vertical tool bar.
{
m_VToolBar->SetSize(default_value, clientSize.y );
clientSize.x -= m_VToolBar->GetDimension();
m_VToolBar->Move( clientSize.x, clientPosition.y );
}
if( m_AuxVToolBar && m_AuxVToolBar->IsShown() ) // Resize the auxiliary right vertical toolbar.
{
m_AuxVToolBar->SetSize( default_value, clientSize.y );
clientSize.x -= m_AuxVToolBar->GetDimension();
m_AuxVToolBar->Move( clientSize.x, clientPosition.y );
}
if( m_OptionsToolBar && m_OptionsToolBar->IsShown() ) // Resize the main left vertical tool bar.
{
m_OptionsToolBar->SetSize( default_value, clientSize.y );
clientSize.x -= m_OptionsToolBar->GetDimension( );
m_OptionsToolBar->Move( 0, clientPosition.y );
clientPosition.x += m_OptionsToolBar->GetDimension( );
}
if( DrawPanel )
{
DrawPanel->SetSize( clientPosition.x, clientPosition.y,
clientSize.x, clientSize.y );
}
#endif
SizeEv.Skip();
}
@ -500,101 +442,97 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_DrawFrame::AdjustScrollBars()
{
int xUnit, yUnit;
wxSize draw_size, panel_size;
wxSize scrollbar_number;
wxPoint scrollbar_pos;
int pixelsPerUnitX, pixelsPerUnitY, unitsX, unitsY, posX, posY;
wxSize drawingSize, clientSize;
BASE_SCREEN* screen = GetBaseScreen();
if( screen == NULL || DrawPanel == NULL )
return;
// The drawing size is twice the current page size.
draw_size = screen->ReturnPageSize() * 2;
drawingSize = screen->ReturnPageSize() * 2;
// Calculate the portion of the drawing that can be displayed in the
// client area at the current zoom level.
panel_size = DrawPanel->GetClientSize();
screen->Unscale( panel_size );
clientSize = DrawPanel->GetClientSize();
#ifdef USE_WX_ZOOM
INSTALL_DC( dc, DrawPanel );
clientSize.x = dc.DeviceToLogicalXRel( clientSize.x );
clientSize.y = dc.DeviceToLogicalYRel( clientSize.y );
#else
screen->Unscale( clientSize );
#endif
/* Adjust drawing size when zooming way out to prevent centering around
* cursor problems. */
if( panel_size.x > draw_size.x || panel_size.y > draw_size.y )
draw_size = panel_size;
if( clientSize.x > drawingSize.x || clientSize.y > drawingSize.y )
drawingSize = clientSize;
draw_size += panel_size / 2;
drawingSize += clientSize / 2;
if( screen->m_Center )
{
screen->m_DrawOrg.x = -draw_size.x / 2;
screen->m_DrawOrg.y = -draw_size.y / 2;
screen->m_DrawOrg.x = -drawingSize.x / 2;
screen->m_DrawOrg.y = -drawingSize.y / 2;
}
else
{
screen->m_DrawOrg.x = -panel_size.x / 2;
screen->m_DrawOrg.y = -panel_size.y / 2;
screen->m_DrawOrg.x = -clientSize.x / 2;
screen->m_DrawOrg.y = -clientSize.y / 2;
}
#ifndef WX_ZOOM
/* Always set scrollbar pixels per unit to 1 unless you want the zoom
* around cursor to jump around. This reported problem occurs when the
* zoom point is not on a pixel per unit increment. If you set the
* pixels per unit to 10, you have potential for the zoom point to
* jump around +/-5 pixels from the nearest grid point.
*/
pixelsPerUnitX = pixelsPerUnitY = 1;
// Calculate the number of scroll bar units for the given zoom level. */
scrollbar_number.x =
wxRound( (double) draw_size.x /
(double) screen->Unscale( screen->m_ZoomScalar ) );
scrollbar_number.y =
wxRound( (double) draw_size.y /
(double) screen->Unscale( screen->m_ZoomScalar ) );
xUnit = yUnit = screen->m_ZoomScalar;
if( xUnit <= 1 )
xUnit = 1;
if( yUnit <= 1 )
yUnit = 1;
xUnit = screen->Unscale( xUnit );
yUnit = screen->Unscale( yUnit );
#ifdef USE_WX_ZOOM
unitsX = dc.LogicalToDeviceXRel( drawingSize.x );
unitsY = dc.LogicalToDeviceYRel( drawingSize.y );
#else
unitsX = screen->Scale( drawingSize.x );
unitsY = screen->Scale( drawingSize.y );
#endif
// Calculate the position, place the cursor at the center of screen.
scrollbar_pos = screen->m_Curseur - screen->m_DrawOrg;
posX = screen->m_Curseur.x - screen->m_DrawOrg.x;
posY = screen->m_Curseur.y - screen->m_DrawOrg.y;
scrollbar_pos.x -= panel_size.x / 2;
scrollbar_pos.y -= panel_size.y / 2;
posX -= clientSize.x / 2;
posY -= clientSize.y / 2;
if( scrollbar_pos.x <= 0 )
scrollbar_pos.x = 0;
if( scrollbar_pos.y <= 0 )
scrollbar_pos.y = 0;
if( posX <= 0 )
posX = 0;
if( posY <= 0 )
posY = 0;
scrollbar_pos.x = wxRound( (double) scrollbar_pos.x / (double) xUnit );
scrollbar_pos.y = wxRound( (double) scrollbar_pos.y / (double) yUnit );
screen->m_ScrollbarPos = scrollbar_pos;
screen->m_ScrollbarNumber = scrollbar_number;
#ifdef USE_WX_ZOOM
posX = dc.LogicalToDeviceXRel( posX );
posY = dc.LogicalToDeviceYRel( posY );
#else
posX = screen->Scale( posX );
posY = screen->Scale( posY );
#endif
DrawPanel->SetScrollbars( screen->m_ZoomScalar,
screen->m_ZoomScalar,
screen->m_ScrollbarPos = wxPoint( posX, posY );
screen->m_ScrollbarNumber = wxSize( unitsX, unitsY );
#if 0
wxLogDebug( wxT( "SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
pixelsPerUnitX, pixelsPerUnitY, unitsX, unitsY, posX, posY );
#endif
DrawPanel->SetScrollbars( pixelsPerUnitX,
pixelsPerUnitY,
screen->m_ScrollbarNumber.x,
screen->m_ScrollbarNumber.y,
screen->m_ScrollbarPos.x,
screen->m_ScrollbarPos.y, TRUE );
#else
int x, y, scroll_x, scroll_y;
double scale_x, scale_y;
DrawPanel DC( this );
x = DC.LogicalToDeviceXRel( draw_size.GetWidth() );
y = DC.LogicalToDeviceYRel( draw_size.GetHeight() );
scrollbar_pos = screen->m_Curseur - screen->m_DrawOrg;
scrollbar_pos.x -= panel_size.x / 2;
scrollbar_pos.y -= panel_size.y / 2;
scroll_x = DC.LogicalToDeviceXRel( scrollbar_pos.x );
scroll_y = DC.LogicalToDeviceYRel( scrollbar_pos.y );
wxLogDebug( wxT( "SetScrollbars(1, 1, %d, %d, %d, %d)" ),
x, y, scroll_x, scroll_y );
DrawPanel->SetScrollbars( 1, 1, x, y, scroll_x, scroll_y );
#endif
}

View File

@ -24,13 +24,20 @@ KicadGraphicContext::KicadGraphicContext( WinEDA_DrawPanel* aDrawPanel ) :
{
GRResetPenAndBrush( this );
SetBackgroundMode( wxTRANSPARENT );
#ifdef WX_ZOOM
double scale = aDrawPanel->GetScreen()->GetScalingFactor();
SetUserScale( scale, scale );
wxPoint origin = aDrawPanel->GetScreen()->m_DrawOrg;
SetLogicalOrigin( origin.x, origin.y );
#ifdef USE_WX_ZOOM
if( aDrawPanel->GetScreen() != NULL )
{
double scale = aDrawPanel->GetScreen()->GetScalingFactor();
aDrawPanel->SetScale( scale, scale );
aDrawPanel->DoPrepareDC( *this );
wxPoint origin = aDrawPanel->GetScreen()->m_DrawOrg;
SetLogicalOrigin( origin.x, origin.y );
}
#endif
aDrawPanel->SetBoundaryBox();
aDrawPanel->SetBoundaryBox( this );
}
@ -49,16 +56,16 @@ static bool s_IgnoreNextLeftButtonRelease = false;
// Events used by WinEDA_DrawPanel
BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow )
EVT_LEAVE_WINDOW( WinEDA_DrawPanel::OnMouseLeaving )
EVT_MOUSEWHEEL( WinEDA_DrawPanel::OnMouseWheel )
EVT_MOUSE_EVENTS( WinEDA_DrawPanel::OnMouseEvent )
EVT_CHAR( WinEDA_DrawPanel::OnKeyEvent )
EVT_CHAR_HOOK( WinEDA_DrawPanel::OnKeyEvent )
EVT_PAINT( WinEDA_DrawPanel::OnPaint )
EVT_SIZE( WinEDA_DrawPanel::OnSize )
EVT_SCROLLWIN( WinEDA_DrawPanel::OnScroll )
EVT_ACTIVATE( WinEDA_DrawPanel::OnActivate )
EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, WinEDA_DrawPanel::OnPan )
EVT_LEAVE_WINDOW( WinEDA_DrawPanel::OnMouseLeaving )
EVT_MOUSEWHEEL( WinEDA_DrawPanel::OnMouseWheel )
EVT_MOUSE_EVENTS( WinEDA_DrawPanel::OnMouseEvent )
EVT_CHAR( WinEDA_DrawPanel::OnKeyEvent )
EVT_CHAR_HOOK( WinEDA_DrawPanel::OnKeyEvent )
EVT_PAINT( WinEDA_DrawPanel::OnPaint )
EVT_SIZE( WinEDA_DrawPanel::OnSize )
EVT_SCROLLWIN( WinEDA_DrawPanel::OnScroll )
EVT_ACTIVATE( WinEDA_DrawPanel::OnActivate )
EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, WinEDA_DrawPanel::OnPan )
END_EVENT_TABLE()
/***********************************************************************/
@ -72,7 +79,9 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id,
{
m_Parent = parent;
wxASSERT( m_Parent );
m_ScrollButt_unit = 40;
m_scrollIncrementX = MIN( size.x / 8, 10 );
m_scrollIncrementY = MIN( size.y / 8, 10 );
SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red,
ColorRefs[g_DrawBgColor].m_Green,
@ -131,9 +140,13 @@ void WinEDA_DrawPanel::DrawCursor( wxDC* aDC, int aColor )
GRSetDrawMode( aDC, GR_XOR );
if( m_Parent->m_CursorShape == 1 ) /* Draws a crosshair. */
{
#ifdef USE_WX_ZOOM
int dx = m_ClipBox.GetWidth();
int dy = m_ClipBox.GetHeight();
#else
int dx = GetScreen()->Unscale( m_ClipBox.GetWidth() );
int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() );
#endif
GRLine( &m_ClipBox, aDC, Cursor.x - dx, Cursor.y,
Cursor.x + dx, Cursor.y, 0, aColor ); // Y axis
GRLine( &m_ClipBox, aDC, Cursor.x, Cursor.y - dx,
@ -141,7 +154,11 @@ void WinEDA_DrawPanel::DrawCursor( wxDC* aDC, int aColor )
}
else
{
#ifdef USE_WX_ZOOM
int len = aDC->DeviceToLogicalXRel( CURSOR_SIZE );
#else
int len = GetScreen()->Unscale( CURSOR_SIZE );
#endif
GRLine( &m_ClipBox, aDC, Cursor.x - len, Cursor.y,
Cursor.x + len, Cursor.y, 0, aColor );
@ -197,17 +214,17 @@ wxRealPoint WinEDA_DrawPanel::GetGrid()
* @return position (in internal units)
* @param ScreenPos = absolute position in pixels
*/
wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos )
wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& aPosition )
{
#ifdef WX_ZOOM
#ifdef USE_WX_ZOOM
wxCoord x, y;
INSTALL_DC( DC, this );
x = DC.DeviceToLogicalX( ScreenPos.x );
y = DC.DeviceToLogicalY( ScreenPos.y );
x = DC.DeviceToLogicalX( aPosition.x );
y = DC.DeviceToLogicalY( aPosition.y );
return wxPoint( x, y );
#else
return GetScreen()->CursorRealPosition( ScreenPos );
return GetScreen()->CursorRealPosition( aPosition );
#endif
}
@ -222,7 +239,8 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
wxPoint pos;
EDA_Rect display_rect;
SetBoundaryBox();
INSTALL_DC( dc, this ); // Refresh the boundary box.
display_rect = m_ClipBox;
// Slightly decreased the size of the useful screen area to avoid drawing
@ -230,6 +248,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
#define PIXEL_MARGIN 8
display_rect.Inflate( -PIXEL_MARGIN );
#ifndef USE_WX_ZOOM
// Convert physical coordinates.
pos = CalcUnscrolledPosition( display_rect.GetPosition() );
@ -237,6 +256,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
pos += GetScreen()->m_DrawOrg;
display_rect.m_Pos = pos;
GetScreen()->Unscale( display_rect.m_Size );
#endif
return display_rect.Inside( ref_pos );
}
@ -263,6 +283,13 @@ void WinEDA_DrawPanel::PostDirtyRect( EDA_Rect aRect )
}
/**
* Scale and offset a rectangle in drawing units to device units.
*
* This is the equivalent of wxDC::LogicalToDevice.
*
* @param aRect - Rectangle to scale.
*/
void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect )
{
// Calculate the draw area origin in internal units:
@ -270,13 +297,18 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect )
ConvertPcbUnitsToPixelsUnits( &pos );
aRect->SetOrigin( pos ); // rect origin in pixel units
#if USE_WX_ZOOM
double scale = GetScreen()->GetScalingFactor();
aRect->m_Size.x = wxRound( (double) aRect->m_Size.x * scale );
aRect->m_Size.y = wxRound( (double) aRect->m_Size.y * scale );
#else
GetScreen()->Scale( aRect->m_Size );
#endif
}
/***************************************************************************/
void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
/***************************************************************************/
{
// Calculate the draw area origin in internal units:
wxPoint drwOrig;
@ -290,6 +322,15 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
drwOrig.x *= x_axis_scale;
drwOrig.y *= y_axis_scale;
#if USE_WX_ZOOM
INSTALL_DC( dc, this );
drwOrig.x = dc.DeviceToLogicalX( drwOrig.x );
drwOrig.y = dc.DeviceToLogicalY( drwOrig.y );
*aPosition -= drwOrig;
aPosition->x = dc.LogicalToDeviceX( aPosition->x );
aPosition->y = dc.LogicalToDeviceY( aPosition->y );
#else
// Origin in internal units
GetScreen()->Unscale( drwOrig );
@ -301,6 +342,7 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
// position in pixels, relative to the visible draw area origin
GetScreen()->Scale( *aPosition );
#endif
}
@ -309,18 +351,18 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
*/
wxPoint WinEDA_DrawPanel::CursorScreenPosition()
{
#ifdef WX_ZOOM
wxCoord x, y;
wxPoint pos = GetScreen()->m_Curseur - GetScreen()->m_DrawOrg;
#ifdef USE_WX_ZOOM
INSTALL_DC( DC, this );
x = DC.LogicalToDeviceX( GetScreen()->m_Curseur.x );
y = DC.LogicalToDeviceY( GetScreen()->m_Curseur.y );
return wxPoint( x, y );
pos.x = DC.LogicalToDeviceXRel( pos.x );
pos.y = DC.LogicalToDeviceYRel( pos.y );
#else
wxPoint pos = GetScreen()->m_Curseur - GetScreen()->m_DrawOrg;
GetScreen()->Scale( pos );
return pos;
#endif
return pos;
}
@ -333,19 +375,19 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void )
wxSize size;
wxPoint realpos;
size = GetClientSize() / 2;
realpos = CalcUnscrolledPosition( wxPoint( size.x, size.y ) );
size = GetClientSize() / 2;
GetScreen()->Unscale( realpos );
#ifdef WX_ZOOM
#ifdef USE_WX_ZOOM
INSTALL_DC( DC, this );
// wxCoord x, y;
// INSTALL_DC( DC, this );
// realpos.x = DC.DeviceToLogicalX( realpos.x );
// realpos.y = DC.DeviceToLogicalY( realpos.y );
realpos.x = DC.DeviceToLogicalX( size.x );
realpos.y = DC.DeviceToLogicalY( size.y );
#else
realpos = CalcUnscrolledPosition( wxPoint( size.x, size.y ) );
GetScreen()->Unscale( realpos );
realpos += GetScreen()->m_DrawOrg;
#endif
return realpos;
}
@ -369,7 +411,7 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse )
wxPoint screenPos, drawingPos;
wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() );
#ifdef WX_ZOOM
#ifdef USE_WX_ZOOM
CalcScrolledPosition( Mouse.x, Mouse.y, &screenPos.x, &screenPos.y );
#else
screenPos = Mouse - GetScreen()->m_StartVisu;
@ -390,13 +432,13 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse )
clientRect.width, clientRect.height, x, y );
if( screenPos.y < clientRect.GetTop() )
y -= m_ScrollButt_unit * yPpu;
y -= m_scrollIncrementY * yPpu;
else if( screenPos.y > clientRect.GetBottom() )
y += m_ScrollButt_unit * yPpu;
y += m_scrollIncrementY * yPpu;
else if( clientRect.GetRight() < screenPos.x )
x += m_ScrollButt_unit * xPpu;
x += m_scrollIncrementX * xPpu;
else
x -= m_ScrollButt_unit * xPpu;
x -= m_scrollIncrementX * xPpu;
Scroll( x, y );
CalcScrolledPosition( drawingPos.x, drawingPos.y,
@ -434,10 +476,10 @@ void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event )
dir = event.GetOrientation(); // wxHORIZONTAL or wxVERTICAL
if( id == wxEVT_SCROLLWIN_LINEUP )
value = -m_ScrollButt_unit;
value = -m_scrollIncrementY;
else if( id == wxEVT_SCROLLWIN_LINEDOWN )
value = m_ScrollButt_unit;
value = m_scrollIncrementY;
else if( id == wxEVT_SCROLLWIN_THUMBTRACK )
{
@ -468,7 +510,9 @@ void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event )
void WinEDA_DrawPanel::OnSize( wxSizeEvent& event )
{
SetBoundaryBox();
#if !defined( USE_WX_GRAPHICS_CONTEXT ) // Crashes Cairo on initial size event.
INSTALL_DC( dc, this ); // Update boundary box.
#endif
event.Skip();
}
@ -476,35 +520,41 @@ void WinEDA_DrawPanel::OnSize( wxSizeEvent& event )
/** Function SetBoundaryBox()
* set the m_ClipBox member to the current displayed rectangle dimensions
*/
void WinEDA_DrawPanel::SetBoundaryBox()
void WinEDA_DrawPanel::SetBoundaryBox( wxDC* dc )
{
wxASSERT( dc != NULL );
BASE_SCREEN* Screen = GetScreen();;
if( !Screen )
return;
wxPoint org;
int ii, jj;
GetViewStart( &org.x, &org.y );
GetScrollPixelsPerUnit( &ii, &jj );
org.x *= ii;
org.y *= jj;
Screen->m_StartVisu = org;
m_ClipBox.SetOrigin( org );
Screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
m_ClipBox.SetSize( GetClientSize() );
#ifdef WX_ZOOM
CalcUnscrolledPosition( m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y,
&m_ClipBox.m_Pos.x, &m_ClipBox.m_Pos.y );
int scrollX, scrollY;
#ifdef USE_WX_ZOOM
scrollX = dc->LogicalToDeviceXRel( wxRound( Screen->GetGridSize().x ) );
scrollY = dc->LogicalToDeviceYRel( wxRound( Screen->GetGridSize().y ) );
#else
m_ClipBox.m_Pos -= GetScreen()->m_StartVisu;
scrollX = wxRound( Screen->Scale( Screen->GetGridSize().x ) );
scrollY = wxRound( Screen->Scale( Screen->GetGridSize().y ) );
#endif
m_ScrollButt_unit = MIN( Screen->m_SizeVisu.x, Screen->m_SizeVisu.y ) / 4;
if( m_ScrollButt_unit < 2 )
m_ScrollButt_unit = 2;
m_scrollIncrementX = MAX( GetClientSize().x / 8, scrollX );
m_scrollIncrementY = MAX( GetClientSize().y / 8, scrollY );
#ifdef USE_WX_ZOOM
/* Using wxDC scaling requires clipping in drawing (logical) units. */
m_ClipBox.m_Pos.x = dc->DeviceToLogicalX( 0 );
m_ClipBox.m_Pos.y = dc->DeviceToLogicalY( 0 );
m_ClipBox.m_Size.x = dc->DeviceToLogicalXRel( m_ClipBox.m_Size.x );
m_ClipBox.m_Size.y = dc->DeviceToLogicalYRel( m_ClipBox.m_Size.y );
#endif
Screen->m_ScrollbarPos.x = GetScrollPos( wxHORIZONTAL );
Screen->m_ScrollbarPos.y = GetScrollPos( wxVERTICAL );
@ -515,38 +565,31 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC )
{
GRSetDrawMode( DC, GR_COPY );
#ifndef WX_ZOOM
GRSFilledRect( &m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
0, g_DrawBgColor, g_DrawBgColor );
#else
EDA_Rect tmp = m_ClipBox;
m_ClipBox.m_Pos.x = DC->DeviceToLogicalX( m_ClipBox.m_Pos.x );
m_ClipBox.m_Pos.y = DC->DeviceToLogicalY( m_ClipBox.m_Pos.y );
m_ClipBox.m_Size.SetWidth(
DC->DeviceToLogicalXRel( m_ClipBox.m_Size.GetWidth() ) );
m_ClipBox.m_Size.SetHeight(
DC->DeviceToLogicalYRel( m_ClipBox.m_Size.GetHeight() ) );
GRSFilledRect( &m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
0, g_DrawBgColor, g_DrawBgColor );
m_ClipBox = tmp;
#endif
}
#if wxUSE_GRAPHICS_CONTEXT
void WinEDA_DrawPanel::DoPrepareDC(wxDC& dc)
{
#ifdef USE_WX_ZOOM
if( GetScreen() != NULL )
{
double scale = GetScreen()->GetScalingFactor();
// note: wxUSE_GRAPHICS_CONTEXT must be set to 1 in wxWidgets
// see setup.h in wx Widgets.
// wxWidgets configure can need option --enable-graphics_ctx
// Currently, **only for tests**
//#define USE_GCDC_IN_KICAD // uncomment it to use wxGCDC
SetScale( scale, scale );
wxScrolledWindow::DoPrepareDC( dc );
wxPoint origin = GetScreen()->m_DrawOrg;
dc.SetLogicalOrigin( origin.x, origin.y );
}
#endif
GRResetPenAndBrush( &dc );
dc.SetBackgroundMode( wxTRANSPARENT );
SetBoundaryBox( &dc );
}
void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
{
@ -556,64 +599,45 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
return;
}
#ifdef USE_GCDC_IN_KICAD
wxPaintDC pDC( this );
// Following line should be disabled on MSW and OS X
wxGCDC paintDC( pDC );
// Fix for pixel offset bug http://trac.wxwidgets.org/ticket/4187
paintDC.GetGraphicsContext()->Translate( 0.5, 0.5 );
#else
INSTALL_PAINTDC( paintDC, this );
#endif
/* wxAutoBufferedPaintDC does not work correctly by setting the user scale and
* logcial offset. The bitmap coordinates and scaling are not effected by the
* code below. It appears that the wxBufferPaintDC needs to be created with the
* wxBUFFER_VIRTUAL_AREA set and the wirtual method wxWindow::PrepareDC() needs
* to be overridden to set up the buffered paint DC properly. The bitmap grid
* draw code ( see DrawGrid() below ) will have to be fixed before this can be
* implemented.
*/
EDA_Rect tmp;
wxRect PaintClipBox;
wxPoint org;
SetBoundaryBox();
tmp = m_ClipBox;
org = m_ClipBox.GetOrigin();
wxRegion upd = GetUpdateRegion(); // get the update rect list
// get the union of all rectangles in the update region, 'upd'
PaintClipBox = upd.GetBox();
#if 0 && defined(DEBUG)
printf( "1) PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) m_ClipBox=(%d, %d, %d, %d)\n",
PaintClipBox.x,
PaintClipBox.y,
PaintClipBox.width,
PaintClipBox.height,
org.x, org.y,
m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y,
m_ClipBox.m_Size.x, m_ClipBox.m_Size.y
);
#if 0
wxLogDebug( wxT( "1) PaintClipBox=(%d, %d, %d, %d), m_ClipBox=(%d, %d, %d, %d)" ),
PaintClipBox.x, PaintClipBox.y, PaintClipBox.width, PaintClipBox.height,
m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y, m_ClipBox.m_Size.x, m_ClipBox.m_Size.y );
#endif
#ifdef WX_ZOOM
wxLogDebug( wxT( "1) PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) " \
"m_ClipBox=(%d, %d, %d, %d)\n" ), PaintClipBox.x,
PaintClipBox.y, PaintClipBox.width, PaintClipBox.height,
org.x, org.y, m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y,
m_ClipBox.m_Size.x, m_ClipBox.m_Size.y );
wxSize drawing_size = GetScreen()->ReturnPageSize() * 2;
m_ClipBox.m_Pos.x = 0;
m_ClipBox.m_Pos.y = 0;
m_ClipBox.SetWidth( drawing_size.x );
m_ClipBox.SetHeight( drawing_size.y );
wxLogDebug( wxT( "2) PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) " \
"m_ClipBox=(%d, %d, %d, %d)\n" ), PaintClipBox.x,
PaintClipBox.y, PaintClipBox.width, PaintClipBox.height,
org.x, org.y, m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y,
m_ClipBox.m_Size.x, m_ClipBox.m_Size.y );
#if defined( USE_WX_ZOOM )
/* When using wxDC scaling the clipping region coordinates are in drawing
* (logical) units.
*/
m_ClipBox.m_Pos.x = paintDC.DeviceToLogicalX( PaintClipBox.x );
m_ClipBox.m_Pos.y = paintDC.DeviceToLogicalY( PaintClipBox.y );
m_ClipBox.m_Size.x = paintDC.DeviceToLogicalXRel( PaintClipBox.width );
m_ClipBox.m_Size.y = paintDC.DeviceToLogicalYRel( PaintClipBox.height );
#else
PaintClipBox.Offset( org );
/* When using Kicads scaling the clipping region coordinates are in screen
* (device) units.
*/
m_ClipBox.SetX( PaintClipBox.GetX() );
m_ClipBox.SetY( PaintClipBox.GetY() );
m_ClipBox.SetWidth( PaintClipBox.GetWidth() );
@ -623,31 +647,19 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
// Be sure the drawpanel clipbox is bigger than the region to repair:
m_ClipBox.Inflate( 1 ); // Give it one pixel more in each direction
#if 0 && defined(DEBUG)
printf( "2) PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) m_ClipBox=(%d, %d, %d, %d)\n",
PaintClipBox.x,
PaintClipBox.y,
PaintClipBox.width,
PaintClipBox.height,
org.x, org.y,
m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y,
m_ClipBox.m_Size.x, m_ClipBox.m_Size.y
);
#if 0
wxLogDebug( wxT( "2) PaintClipBox=(%d, %d, %d, %d), m_ClipBox=(%d, %d, %d, %d)" ),
PaintClipBox.x, PaintClipBox.y, PaintClipBox.width, PaintClipBox.height,
m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y, m_ClipBox.m_Size.x, m_ClipBox.m_Size.y );
#endif
#if defined( USE_WX_ZOOM ) && defined( KICAD_USE_BUFFERED_PAINTDC )
PaintClipBox = m_ClipBox;
#endif
// call ~wxDCClipper() before ~wxPaintDC()
{
#ifndef WX_ZOOM
wxDCClipper dcclip( paintDC, PaintClipBox );
#endif
ReDraw( &paintDC, true );
#ifdef WX_ZOOM
paintDC.SetUserScale( 1.0, 1.0 );
#endif
}
m_ClipBox = tmp;
@ -743,12 +755,25 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
* and zoom value are sufficient
*/
screen_grid_size = screen->GetGridSize();
org = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
screen->m_StartVisu = org;
size = GetClientSize();
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( wxRound( screen_grid_size.x ) ) < 5
|| DC->LogicalToDeviceXRel( wxRound( screen_grid_size.y ) ) < 5 )
return;
org.x = DC->DeviceToLogicalX( 0 );
org.y = DC->DeviceToLogicalY( 0 );
size.SetWidth( DC->DeviceToLogicalXRel( size.GetWidth() ) );
size.SetHeight( DC->DeviceToLogicalYRel( size.GetHeight() ) );
#else
wxRealPoint dgrid = screen_grid_size;
screen->Scale( dgrid ); // dgrid = grid size in pixels
// if the grid size is small ( < 5 pixels) do not display all points
if( dgrid.x < 5 )
if( dgrid.x < 5 )
{
screen_grid_size.x *= 2;
dgrid.x *= 2;
@ -765,29 +790,9 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
return; // The grid is too small
GetViewStart( &org.x, &org.y );
GetScrollPixelsPerUnit( &ii, &jj );
org.x *= ii;
org.y *= jj;
screen->m_StartVisu = org;
screen->Unscale( org );
org += screen->m_DrawOrg;
size = GetClientSize();
screen->Unscale( size );
#ifdef WX_ZOOM
screen_grid_size = screen->GetGridSize();
if( DC->LogicalToDeviceXRel( (int) screen_grid_size.x ) < 5
|| DC->LogicalToDeviceYRel( (int) screen_grid_size.y ) < 5 )
drawgrid = false;
org.x = DC->DeviceToLogicalX( org.x );
org.y = DC->DeviceToLogicalY( org.y );
size.SetWidth( DC->DeviceToLogicalXRel( size.GetWidth() ) );
size.SetHeight( DC->DeviceToLogicalYRel( size.GetHeight() ) );
screen->Unscale( org );
org += screen->m_DrawOrg;
#endif
m_Parent->PutOnGrid( &org );
@ -805,7 +810,12 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
wxWindowUpdateLocker( this ); // under macOSX: drawings are faster with this
#endif
#if defined( __WXMAC__ )
/* The bitmap grid drawing code below cannot be used when wxDC scaling is used
* as it does not scale the grid bitmap properly. This needs to be fixed.
*/
#if defined( __WXMAC__ ) || defined( USE_WX_ZOOM )
// Use a pixel based draw to display grid
// There is a lot of calls, so the cost is hight
// and grid is slowly drawn on some platforms
@ -840,7 +850,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
wxSize screenSize = GetClientSize();
wxMemoryDC tmpDC;
wxBitmap tmpBM(1, screenSize.y);
wxBitmap tmpBM( 1, screenSize.y );
tmpDC.SelectObject( tmpBM );
GRSetColorPen( &tmpDC, g_DrawBgColor );
tmpDC.DrawLine( 0, 0, 0, screenSize.y-1 ); // init background
@ -978,8 +988,12 @@ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event )
return;
}
#ifdef USE_WX_ZOOM
GetScreen()->m_Curseur = CursorRealPosition( event.GetPosition() );
#else
GetScreen()->m_Curseur =
CursorRealPosition( CalcUnscrolledPosition( event.GetPosition() ) );
#endif
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
@ -1078,13 +1092,20 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
localrealbutt |= localbutt; /* compensation default wxGTK */
/* Compute absolute m_MousePosition in pixel units: */
screen->m_MousePositionInPixels =
CalcUnscrolledPosition( event.GetPosition() );
#ifdef USE_WX_ZOOM
/* Compute the cursor position in screen (device) units. */
screen->m_MousePositionInPixels = event.GetPosition();
/* Compute absolute m_MousePosition in user units: */
/* Compute the cursor position in drawing (logical) units. */
screen->m_MousePosition = CursorRealPosition( event.GetPosition() );
#else
/* Compute the cursor position in screen (device) units. */
screen->m_MousePositionInPixels = CalcUnscrolledPosition( event.GetPosition() );
/* Compute the cursor position in drawing (logical) units. */
screen->m_MousePosition =
CursorRealPosition( screen->m_MousePositionInPixels );
CursorRealPosition( CalcUnscrolledPosition( event.GetPosition() ) );
#endif
INSTALL_DC( DC, this );
@ -1347,7 +1368,6 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
BASE_SCREEN* Screen = GetScreen();
g_KeyPressed = localkey;
if( escape )
@ -1366,17 +1386,18 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
}
/* Some key commands use the current mouse position: refresh it */
#ifdef WX_ZOOM
pos = CalcUnscrolledPosition( wxGetMousePosition() );
#ifdef USE_WX_ZOOM
pos = wxGetMousePosition() - GetScreenPosition();
#else
pos = CalcUnscrolledPosition( wxGetMousePosition() - GetScreenPosition() );
#endif
/* Compute absolute mouse position in pixel units (i.e. considering the
* current scroll) : */
/* Compute cursor position in screen units (pixel) including the
* current scroll bar position. Also known as device units to wxDC. */
Screen->m_MousePositionInPixels = pos;
/* Compute absolute mouse position in user units: */
/* Compute the cursor position in drawing units. Also known as logical units
* to wxDC. */
Screen->m_MousePosition = CursorRealPosition( pos );
m_Parent->GeneralControle( &DC, pos );
@ -1396,19 +1417,19 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event )
switch( event.GetId() )
{
case ID_PAN_UP:
y -= m_ScrollButt_unit;
y -= m_scrollIncrementY;
break;
case ID_PAN_DOWN:
y += m_ScrollButt_unit;
y += m_scrollIncrementY;
break;
case ID_PAN_LEFT:
x -= m_ScrollButt_unit;
x -= m_scrollIncrementX;
break;
case ID_PAN_RIGHT:
x += m_ScrollButt_unit;
x += m_scrollIncrementX;
break;
default:

View File

@ -89,7 +89,7 @@ static void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
static inline int USCALE( us arg, us num, us den )
{
#ifndef WX_ZOOM
#ifndef USE_WX_ZOOM
int ii;
ii = (int) ( ( (float) arg * num ) / den );
return ii;
@ -110,7 +110,7 @@ static int inline ZoomValue( int val )
/****************************************/
int GRMapX( int x )
{
#ifndef WX_ZOOM
#ifndef USE_WX_ZOOM
int coord = x - ActiveScreen->m_DrawOrg.x;
coord = ZoomValue( coord );
coord -= ActiveScreen->m_StartVisu.x;
@ -123,7 +123,7 @@ int GRMapX( int x )
int GRMapY( int y )
{
#ifndef WX_ZOOM
#ifndef USE_WX_ZOOM
int coord = y - ActiveScreen->m_DrawOrg.y;
coord = ZoomValue( coord );
coord -= ActiveScreen->m_StartVisu.y;
@ -373,28 +373,24 @@ void GRSetDrawMode( wxDC* DC, int draw_mode )
{
if( draw_mode & GR_OR )
#if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
DC->SetLogicalFunction( wxCOPY );
#elif defined( USE_WX_GRAPHICS_CONTEXT )
DC->SetLogicalFunction( wxCOPY );
#else
DC->SetLogicalFunction( wxOR );
#endif
else if( draw_mode & GR_XOR )
#if defined( USE_WX_GRAPHICS_CONTEXT )
DC->SetLogicalFunction( wxCOPY );
#else
DC->SetLogicalFunction( wxXOR );
#endif
else if( draw_mode & GR_NXOR )
#if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
DC->SetLogicalFunction( wxXOR );
#elif defined( USE_WX_GRAPHICS_CONTEXT )
DC->SetLogicalFunction( wxCOPY );
#else
DC->SetLogicalFunction( wxEQUIV );
#endif
else

View File

@ -12,15 +12,10 @@
WinEDA_Toolbar::WinEDA_Toolbar( id_toolbar type, wxWindow * parent,
wxWindowID id, bool horizontal ):
#if defined(KICAD_AUITOOLBAR)
wxAuiToolBar( parent, id, wxDefaultPosition, wxDefaultSize,
wxAUI_TB_DEFAULT_STYLE | ( ( horizontal ) ?
wxAUI_TB_HORZ_LAYOUT :
wxAUI_TB_VERTICAL ) )
#else
wxToolBar( parent, id, wxPoint( -1,-1 ), wxSize( -1,-1 ),
horizontal ? wxTB_HORIZONTAL : wxTB_VERTICAL )
#endif
{
m_Parent = parent;
m_Ident = type;

View File

@ -35,7 +35,7 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
* TODO: see exactly how the mouse creates problems when moving during refresh
* use Refresh() and update() do not change problems
*/
INSTALL_DC(dc,DrawPanel);
INSTALL_DC( dc, DrawPanel );
DrawPanel->ReDraw( &dc );
/* Move the mouse cursor to the on grid graphic cursor position */

View File

@ -72,7 +72,8 @@ if(APPLE)
set_target_properties(${CVPCB_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
endif(APPLE)
target_link_libraries(${CVPCB_NAME} 3d-viewer common pcbcommon polygon bitmaps kbool ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES})
target_link_libraries(${CVPCB_NAME} 3d-viewer common pcbcommon polygon bitmaps kbool
${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} ${GDI_PLUS_LIBRARIES})
install(TARGETS ${CVPCB_NAME}
DESTINATION ${KICAD_BIN}

View File

@ -74,7 +74,6 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( WinEDA_CvpcbFrame* father,
ReCreateHToolbar();
ReCreateVToolbar();
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz;
@ -105,7 +104,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( WinEDA_CvpcbFrame* father,
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update();
#endif
Show( TRUE );
}
@ -219,7 +218,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize();
#ifdef USE_WX_ZOOM
delta.x = DC->LogicalToDeviceXRel( wxRound( delta.x ) );
delta.y = DC->LogicalToDeviceYRel( wxRound( delta.y ) );
Mouse = DrawPanel->CalcUnscrolledPosition( Mouse );
#else
GetScreen()->Scale( delta );
#endif
if( delta.x <= 0 )
delta.x = 1;

View File

@ -157,27 +157,6 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title,
BuildCmpListBox();
BuildFOOTPRINTS_LISTBOX();
#if !defined(KICAD_AUIMANAGER)
/* Create size constraints of the component list window display. */
wxLayoutConstraints* linkpos = new wxLayoutConstraints;
linkpos->top.SameAs( this, wxTop );
linkpos->bottom.SameAs( this, wxBottom );
linkpos->left.SameAs( this, wxLeft );
linkpos->width.PercentOf( this, wxWidth, 66 );
if( m_ListCmp )
m_ListCmp->SetConstraints( linkpos );
/* Create size constraints for the footprint display window. */
linkpos = new wxLayoutConstraints;
linkpos->top.SameAs( m_ListCmp, wxTop );
linkpos->bottom.SameAs( m_ListCmp, wxBottom );
linkpos->right.SameAs( this, wxRight );
linkpos->left.SameAs( m_ListCmp, wxRight );
if( m_FootprintList )
m_FootprintList->SetConstraints( linkpos );
#endif
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz;
@ -204,7 +183,6 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title,
Right().BestSize( (int) ( m_FrameSize.x * 0.36 ), m_FrameSize.y ) );
m_auimgr.Update();
#endif
}
@ -219,9 +197,7 @@ WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame()
config->Write( wxT( FILTERFOOTPRINTKEY ), state );
}
#if defined(KICAD_AUIMANAGER)
m_auimgr.UnInit();
#endif
}

View File

@ -22,10 +22,6 @@ void WinEDA_CvpcbFrame::ReCreateHToolbar()
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
#if !defined(KICAD_AUIMANAGER)
SetToolBar( (wxToolBar *)m_HToolBar );
#endif
m_HToolBar->AddTool( ID_CVPCB_READ_INPUT_NETLIST, wxEmptyString,
wxBitmap( open_xpm ),
_( "Open a net list file" ) );

View File

@ -154,7 +154,7 @@ if(APPLE)
set_target_properties(eeschema PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
endif(APPLE)
target_link_libraries(eeschema common bitmaps ${wxWidgets_LIBRARIES})
target_link_libraries(eeschema common bitmaps ${wxWidgets_LIBRARIES} ${GDI_PLUS_LIBRARIES})
install(TARGETS eeschema
DESTINATION ${KICAD_BIN}

View File

@ -267,7 +267,11 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDc,
/* Enable this to draw the anchor of the component. */
#if 0
#ifdef USE_WX_ZOOM
int len = aDc->DeviceToLogicalXRel( 3 );
#else
int len = aPanel->GetScreen()->Unscale( 3 );
#endif
GRLine( &aPanel->m_ClipBox, aDc, aOffset.x, aOffset.y - len, aOffset.x,
aOffset.y + len, 0, aColor );
GRLine( &aPanel->m_ClipBox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len,

View File

@ -230,7 +230,14 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
oldpos = screen->m_Curseur;
delta = screen->GetGridSize();
#ifdef USE_WX_ZOOM
delta.x = DC->LogicalToDeviceXRel( wxRound( delta.x ) );
delta.y = DC->LogicalToDeviceYRel( wxRound( delta.y ) );
MousePositionInPixels = DrawPanel->CalcUnscrolledPosition( MousePositionInPixels );
#else
screen->Scale( delta );
#endif
if( delta.x <= 0 )
delta.x = 1;
@ -324,7 +331,14 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
oldpos = screen->m_Curseur;
delta = screen->GetGridSize();
#ifdef USE_WX_ZOOM
delta.x = DC->LogicalToDeviceXRel( wxRound( delta.x ) );
delta.y = DC->LogicalToDeviceYRel( wxRound( delta.y ) );
MousePositionInPixels = DrawPanel->CalcUnscrolledPosition( MousePositionInPixels );
#else
screen->Scale( delta );
#endif
if( delta.x <= 0 )
delta.x = 1;
@ -417,7 +431,14 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
oldpos = screen->m_Curseur;
delta = screen->GetGridSize();
#ifdef USE_WX_ZOOM
delta.x = DC->LogicalToDeviceXRel( wxRound( delta.x ) );
delta.y = DC->LogicalToDeviceYRel( wxRound( delta.y ) );
MousePositionInPixels = DrawPanel->CalcUnscrolledPosition( MousePositionInPixels );
#else
screen->Scale( delta );
#endif
if( delta.x <= 0 )
delta.x = 1;

View File

@ -192,10 +192,15 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
DisplayCmpDoc();
UpdateAliasSelectList();
UpdatePartSelectList();
#ifdef USE_WX_GRAPHICS_CONTEXT
GetScreen()->SetZoom( BestZoom() );
#else
Zoom_Automatique( false );
#endif
Show( true );
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz;
@ -224,7 +229,6 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
m_auimgr.AddPane( MsgPanel,
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update();
#endif
}

View File

@ -194,7 +194,6 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_HIGH );
m_pageSetupData.GetPrintData().SetOrientation( wxLANDSCAPE );
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz;
@ -231,7 +230,6 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update();
#endif
}
@ -409,7 +407,7 @@ int WinEDA_SchematicFrame::BestZoom()
size = DrawPanel->GetClientSize();
zoom = MAX( (double) dx / (double) size.x,
(double) dy / (double) size.y );
(double) dy / (double) size.y );
GetScreen()->m_Curseur.x = dx / 2;
GetScreen()->m_Curseur.y = dy / 2;

View File

@ -94,9 +94,7 @@ void WinEDA_LibeditFrame::ReCreateHToolbar()
return;
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true );
#if !defined(KICAD_AUIMANAGER)
SetToolBar( (wxToolBar*)m_HToolBar );
#endif
// Set up toolbar
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_LIB, wxEmptyString,
wxBitmap( save_library_xpm ),

Some files were not shown because too many files have changed in this diff Show More