Commit 3066c705 authored by stambaughw's avatar stambaughw

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.
parent 3f0a7f8d
...@@ -78,7 +78,6 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent, ...@@ -78,7 +78,6 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent,
// Make a Pcb3D_GLCanvas // Make a Pcb3D_GLCanvas
m_Canvas = new Pcb3D_GLCanvas( this ); m_Canvas = new Pcb3D_GLCanvas( this );
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz; wxAuiPaneInfo horiz;
...@@ -101,7 +100,6 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent, ...@@ -101,7 +100,6 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
m_auimgr.Update(); m_auimgr.Update();
#endif
} }
......
...@@ -21,10 +21,6 @@ void WinEDA3D_DrawFrame::ReCreateHToolbar() ...@@ -21,10 +21,6 @@ void WinEDA3D_DrawFrame::ReCreateHToolbar()
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE ); m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
#if !defined(KICAD_AUIMANAGER)
SetToolBar( (wxToolBar*) m_HToolBar );
#endif
// Set up toolbar // Set up toolbar
m_HToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString, m_HToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString,
wxBitmap( import3d_xpm ), wxBitmap( import3d_xpm ),
......
...@@ -192,10 +192,8 @@ public: ...@@ -192,10 +192,8 @@ public:
wxPoint m_FramePos; wxPoint m_FramePos;
wxSize m_FrameSize; wxSize m_FrameSize;
#if defined(KICAD_AUIMANAGER)
wxAuiManager m_auimgr; wxAuiManager m_auimgr;
~WinEDA3D_DrawFrame() { m_auimgr.UnInit(); }; ~WinEDA3D_DrawFrame() { m_auimgr.UnInit(); };
#endif
private: private:
wxString m_FrameName; // name used for writing and reading setup wxString m_FrameName; // name used for writing and reading setup
......
...@@ -18,10 +18,10 @@ option(KICAD_MINIZIP "enable/disable building minizip (default ON)" ON) ...@@ -18,10 +18,10 @@ option(KICAD_MINIZIP "enable/disable building minizip (default ON)" ON)
option(wxUSE_UNICODE "enable/disable building unicode (default OFF)") 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)") 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(USE_WX_ZOOM "Use wxDC to perform zooming (default OFF). Warning, this is experimental" )
#option(KICAD_AUIMANAGER "Enable use of wxAuiManager (default ON)" ON)
#option(KICAD_AUITOOLBAR "Enable use of wxAuiToolBar (default ON)" ON)
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. # Comment this out if you don't want to build with Python support.
# OPTION(KICAD_PYTHON "enable/disable building with Python support (default OFF)") # OPTION(KICAD_PYTHON "enable/disable building with Python support (default OFF)")
...@@ -50,6 +50,16 @@ if(KICAD_GOST) ...@@ -50,6 +50,16 @@ if(KICAD_GOST)
add_definitions(-DKICAD_GOST) add_definitions(-DKICAD_GOST)
endif(KICAD_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. # Locations for install targets.
set(KICAD_BIN bin set(KICAD_BIN bin
CACHE PATH "Location of KiCad binaries.") CACHE PATH "Location of KiCad binaries.")
...@@ -124,7 +134,7 @@ check_find_package_result(OPENGL_FOUND "OpenGL") ...@@ -124,7 +134,7 @@ check_find_package_result(OPENGL_FOUND "OpenGL")
if(APPLE) if(APPLE)
find_package(wxWidgets COMPONENTS gl adv html core net base QUIET) find_package(wxWidgets COMPONENTS gl adv html core net base QUIET)
else(APPLE) 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) endif(APPLE)
check_find_package_result(wxWidgets_FOUND "wxWidgets") check_find_package_result(wxWidgets_FOUND "wxWidgets")
...@@ -135,11 +145,16 @@ include(${wxWidgets_USE_FILE}) ...@@ -135,11 +145,16 @@ include(${wxWidgets_USE_FILE})
# Include MinGW resource compiler. # Include MinGW resource compiler.
include(MinGWResourceCompiler) include(MinGWResourceCompiler)
# Generate build system specific header file. # Generate build system specific header file.
include(PerformFeatureChecks) include(PerformFeatureChecks)
perform_feature_checks() 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. # Automagically create version header file.
include(CreateSVNVersionHeader) include(CreateSVNVersionHeader)
create_svn_version_header() create_svn_version_header()
......
# - 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)
...@@ -49,13 +49,10 @@ ...@@ -49,13 +49,10 @@
#define strnicmp _strnicmp #define strnicmp _strnicmp
#endif #endif
#if 1 /* Warning!!! Using wxDC for zooming is experimental. */
// now mandatory, not configurable #cmakedefine USE_WX_ZOOM 1
#define KICAD_AUIMANAGER 1
#define KICAD_AUITOOLBAR 1 /* Warning!!! Using wxGraphicContext for rendering is experimental. */
#else #cmakedefine USE_WX_GRAPHICS_CONTEXT 1
#cmakedefine KICAD_AUIMANAGER 1
#cmakedefine KICAD_AUITOOLBAR 1
#endif
#endif /* __CONFIG_H__ */ #endif /* __CONFIG_H__ */
...@@ -26,6 +26,11 @@ Common ...@@ -26,6 +26,11 @@ Common
* Integer/long/double input boxes should handle comma and dot separated values, * Integer/long/double input boxes should handle comma and dot separated values,
not only comma. 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 CvPCB
----- -----
* Preview of the already assigned footprint. * Preview of the already assigned footprint.
...@@ -36,6 +41,11 @@ EESchema ...@@ -36,6 +41,11 @@ EESchema
* Use collector classes. * Use collector classes.
* Drag and drop between two EESchema windows. * 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 GerbView
-------- --------
* Need work as good as gerbv from gEDA * 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 ...@@ -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. checkboxes and colors. Will need to extend the widget API.
L10)still thinking about background colors, easier now without wxformbuilder. 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.
...@@ -104,9 +104,9 @@ wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos ) ...@@ -104,9 +104,9 @@ wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
wxPoint curpos = ScreenPos; wxPoint curpos = ScreenPos;
Unscale( curpos ); Unscale( curpos );
//#ifndef WX_ZOOM #ifndef USE_WX_ZOOM
curpos += m_DrawOrg; curpos += m_DrawOrg;
//#endif #endif
return curpos; return curpos;
} }
...@@ -143,7 +143,7 @@ void BASE_SCREEN::SetScalingFactor(double aScale ) ...@@ -143,7 +143,7 @@ void BASE_SCREEN::SetScalingFactor(double aScale )
*/ */
int BASE_SCREEN::Scale( int coord ) int BASE_SCREEN::Scale( int coord )
{ {
#ifdef WX_ZOOM #ifdef USE_WX_ZOOM
return coord; return coord;
#else #else
if( !m_ZoomScalar || !m_Zoom ) if( !m_ZoomScalar || !m_Zoom )
...@@ -156,7 +156,7 @@ int BASE_SCREEN::Scale( int coord ) ...@@ -156,7 +156,7 @@ int BASE_SCREEN::Scale( int coord )
double BASE_SCREEN::Scale( double coord ) double BASE_SCREEN::Scale( double coord )
{ {
#ifdef WX_ZOOM #ifdef USE_WX_ZOOM
return coord; return coord;
#else #else
if( !m_Zoom ) if( !m_Zoom )
...@@ -179,7 +179,7 @@ void BASE_SCREEN::Scale( wxPoint& pt ) ...@@ -179,7 +179,7 @@ void BASE_SCREEN::Scale( wxPoint& pt )
void BASE_SCREEN::Scale( wxRealPoint& pt ) void BASE_SCREEN::Scale( wxRealPoint& pt )
{ {
#ifdef WX_ZOOM #ifdef USE_WX_ZOOM
// No change // No change
#else #else
if( !m_ZoomScalar || !m_Zoom ) if( !m_ZoomScalar || !m_Zoom )
...@@ -206,7 +206,7 @@ void BASE_SCREEN::Scale( wxSize& sz ) ...@@ -206,7 +206,7 @@ void BASE_SCREEN::Scale( wxSize& sz )
*/ */
int BASE_SCREEN::Unscale( int coord ) int BASE_SCREEN::Unscale( int coord )
{ {
#ifdef WX_ZOOM #ifdef USE_WX_ZOOM
return coord; return coord;
#else #else
if( !m_Zoom || !m_ZoomScalar ) if( !m_Zoom || !m_ZoomScalar )
......
...@@ -427,7 +427,13 @@ void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -427,7 +427,13 @@ void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC,
/* Draw text anchor, if allowed */ /* Draw text anchor, if allowed */
if( aAnchor_color != UNSPECIFIED_COLOR ) if( aAnchor_color != UNSPECIFIED_COLOR )
{ {
#if USE_WX_ZOOM
int anchor_size = aDC->DeviceToLogicalXRel( 2 );
#else
int anchor_size = aPanel->GetScreen()->Unscale( 2 ); int anchor_size = aPanel->GetScreen()->Unscale( 2 );
#endif
aAnchor_color = (EDA_Colors) ( aAnchor_color & MASKCOLOR ); aAnchor_color = (EDA_Colors) ( aAnchor_color & MASKCOLOR );
int cX = aPos.x + aOffset.x; int cX = aPos.x + aOffset.x;
......
...@@ -101,6 +101,7 @@ void BLOCK_SELECTOR::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -101,6 +101,7 @@ void BLOCK_SELECTOR::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
int aDrawMode, int aDrawMode,
int aColor ) int aColor )
{ {
int w = aPanel->GetScreen()->Scale( GetWidth() ); int w = aPanel->GetScreen()->Scale( GetWidth() );
int h = aPanel->GetScreen()->Scale( GetHeight() ); int h = aPanel->GetScreen()->Scale( GetHeight() );
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "class_base_screen.h" #include "class_base_screen.h"
#include "wxstruct.h" #include "wxstruct.h"
#include "confirm.h" #include "confirm.h"
#include "kicad_device_context.h"
#include <wx/fontdlg.h> #include <wx/fontdlg.h>
...@@ -114,9 +115,7 @@ WinEDA_DrawFrame::~WinEDA_DrawFrame() ...@@ -114,9 +115,7 @@ WinEDA_DrawFrame::~WinEDA_DrawFrame()
if( m_CurrentScreen != NULL ) if( m_CurrentScreen != NULL )
delete m_CurrentScreen; delete m_CurrentScreen;
#if defined(KICAD_AUIMANAGER)
m_auimgr.UnInit(); m_auimgr.UnInit();
#endif
} }
...@@ -299,10 +298,8 @@ void WinEDA_DrawFrame::SetToolbars() ...@@ -299,10 +298,8 @@ void WinEDA_DrawFrame::SetToolbars()
{ {
DisplayUnitsMsg(); DisplayUnitsMsg();
#if defined(KICAD_AUIMANAGER)
if( m_auimgr.GetManagedWindow() ) if( m_auimgr.GetManagedWindow() )
m_auimgr.Update(); m_auimgr.Update();
#endif
} }
...@@ -344,61 +341,6 @@ void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv ) ...@@ -344,61 +341,6 @@ void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv )
{ {
m_FrameSize = GetClientSize( ); 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(); SizeEv.Skip();
} }
...@@ -500,101 +442,97 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC ) ...@@ -500,101 +442,97 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_DrawFrame::AdjustScrollBars() void WinEDA_DrawFrame::AdjustScrollBars()
{ {
int xUnit, yUnit; int pixelsPerUnitX, pixelsPerUnitY, unitsX, unitsY, posX, posY;
wxSize draw_size, panel_size; wxSize drawingSize, clientSize;
wxSize scrollbar_number;
wxPoint scrollbar_pos;
BASE_SCREEN* screen = GetBaseScreen(); BASE_SCREEN* screen = GetBaseScreen();
if( screen == NULL || DrawPanel == NULL ) if( screen == NULL || DrawPanel == NULL )
return; return;
// The drawing size is twice the current page size. // 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 // Calculate the portion of the drawing that can be displayed in the
// client area at the current zoom level. // client area at the current zoom level.
panel_size = DrawPanel->GetClientSize(); clientSize = DrawPanel->GetClientSize();
screen->Unscale( panel_size );
#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 /* Adjust drawing size when zooming way out to prevent centering around
* cursor problems. */ * cursor problems. */
if( panel_size.x > draw_size.x || panel_size.y > draw_size.y ) if( clientSize.x > drawingSize.x || clientSize.y > drawingSize.y )
draw_size = panel_size; drawingSize = clientSize;
draw_size += panel_size / 2; drawingSize += clientSize / 2;
if( screen->m_Center ) if( screen->m_Center )
{ {
screen->m_DrawOrg.x = -draw_size.x / 2; screen->m_DrawOrg.x = -drawingSize.x / 2;
screen->m_DrawOrg.y = -draw_size.y / 2; screen->m_DrawOrg.y = -drawingSize.y / 2;
} }
else else
{ {
screen->m_DrawOrg.x = -panel_size.x / 2; screen->m_DrawOrg.x = -clientSize.x / 2;
screen->m_DrawOrg.y = -panel_size.y / 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. */ // Calculate the number of scroll bar units for the given zoom level. */
scrollbar_number.x = #ifdef USE_WX_ZOOM
wxRound( (double) draw_size.x / unitsX = dc.LogicalToDeviceXRel( drawingSize.x );
(double) screen->Unscale( screen->m_ZoomScalar ) ); unitsY = dc.LogicalToDeviceYRel( drawingSize.y );
scrollbar_number.y = #else
wxRound( (double) draw_size.y / unitsX = screen->Scale( drawingSize.x );
(double) screen->Unscale( screen->m_ZoomScalar ) ); unitsY = screen->Scale( drawingSize.y );
#endif
xUnit = yUnit = screen->m_ZoomScalar;
if( xUnit <= 1 )
xUnit = 1;
if( yUnit <= 1 )
yUnit = 1;
xUnit = screen->Unscale( xUnit );
yUnit = screen->Unscale( yUnit );
// Calculate the position, place the cursor at the center of screen. // 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;
posX -= clientSize.x / 2;
posY -= clientSize.y / 2;
scrollbar_pos.x -= panel_size.x / 2; if( posX <= 0 )
scrollbar_pos.y -= panel_size.y / 2; posX = 0;
if( posY <= 0 )
posY = 0;
if( scrollbar_pos.x <= 0 ) #ifdef USE_WX_ZOOM
scrollbar_pos.x = 0; posX = dc.LogicalToDeviceXRel( posX );
if( scrollbar_pos.y <= 0 ) posY = dc.LogicalToDeviceYRel( posY );
scrollbar_pos.y = 0; #else
posX = screen->Scale( posX );
posY = screen->Scale( posY );
#endif
screen->m_ScrollbarPos = wxPoint( posX, posY );
screen->m_ScrollbarNumber = wxSize( unitsX, unitsY );
scrollbar_pos.x = wxRound( (double) scrollbar_pos.x / (double) xUnit ); #if 0
scrollbar_pos.y = wxRound( (double) scrollbar_pos.y / (double) yUnit ); wxLogDebug( wxT( "SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
screen->m_ScrollbarPos = scrollbar_pos; pixelsPerUnitX, pixelsPerUnitY, unitsX, unitsY, posX, posY );
screen->m_ScrollbarNumber = scrollbar_number; #endif
DrawPanel->SetScrollbars( screen->m_ZoomScalar, DrawPanel->SetScrollbars( pixelsPerUnitX,
screen->m_ZoomScalar, pixelsPerUnitY,
screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.x,
screen->m_ScrollbarNumber.y, screen->m_ScrollbarNumber.y,
screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.x,
screen->m_ScrollbarPos.y, TRUE ); 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
} }
......
...@@ -24,13 +24,20 @@ KicadGraphicContext::KicadGraphicContext( WinEDA_DrawPanel* aDrawPanel ) : ...@@ -24,13 +24,20 @@ KicadGraphicContext::KicadGraphicContext( WinEDA_DrawPanel* aDrawPanel ) :
{ {
GRResetPenAndBrush( this ); GRResetPenAndBrush( this );
SetBackgroundMode( wxTRANSPARENT ); SetBackgroundMode( wxTRANSPARENT );
#ifdef WX_ZOOM
#ifdef USE_WX_ZOOM
if( aDrawPanel->GetScreen() != NULL )
{
double scale = aDrawPanel->GetScreen()->GetScalingFactor(); double scale = aDrawPanel->GetScreen()->GetScalingFactor();
SetUserScale( scale, scale );
aDrawPanel->SetScale( scale, scale );
aDrawPanel->DoPrepareDC( *this );
wxPoint origin = aDrawPanel->GetScreen()->m_DrawOrg; wxPoint origin = aDrawPanel->GetScreen()->m_DrawOrg;
SetLogicalOrigin( origin.x, origin.y ); SetLogicalOrigin( origin.x, origin.y );
}
#endif #endif
aDrawPanel->SetBoundaryBox();
aDrawPanel->SetBoundaryBox( this );
} }
...@@ -49,16 +56,16 @@ static bool s_IgnoreNextLeftButtonRelease = false; ...@@ -49,16 +56,16 @@ static bool s_IgnoreNextLeftButtonRelease = false;
// Events used by WinEDA_DrawPanel // Events used by WinEDA_DrawPanel
BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow ) BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow )
EVT_LEAVE_WINDOW( WinEDA_DrawPanel::OnMouseLeaving ) EVT_LEAVE_WINDOW( WinEDA_DrawPanel::OnMouseLeaving )
EVT_MOUSEWHEEL( WinEDA_DrawPanel::OnMouseWheel ) EVT_MOUSEWHEEL( WinEDA_DrawPanel::OnMouseWheel )
EVT_MOUSE_EVENTS( WinEDA_DrawPanel::OnMouseEvent ) EVT_MOUSE_EVENTS( WinEDA_DrawPanel::OnMouseEvent )
EVT_CHAR( WinEDA_DrawPanel::OnKeyEvent ) EVT_CHAR( WinEDA_DrawPanel::OnKeyEvent )
EVT_CHAR_HOOK( WinEDA_DrawPanel::OnKeyEvent ) EVT_CHAR_HOOK( WinEDA_DrawPanel::OnKeyEvent )
EVT_PAINT( WinEDA_DrawPanel::OnPaint ) EVT_PAINT( WinEDA_DrawPanel::OnPaint )
EVT_SIZE( WinEDA_DrawPanel::OnSize ) EVT_SIZE( WinEDA_DrawPanel::OnSize )
EVT_SCROLLWIN( WinEDA_DrawPanel::OnScroll ) EVT_SCROLLWIN( WinEDA_DrawPanel::OnScroll )
EVT_ACTIVATE( WinEDA_DrawPanel::OnActivate ) EVT_ACTIVATE( WinEDA_DrawPanel::OnActivate )
EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, WinEDA_DrawPanel::OnPan ) EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, WinEDA_DrawPanel::OnPan )
END_EVENT_TABLE() END_EVENT_TABLE()
/***********************************************************************/ /***********************************************************************/
...@@ -72,7 +79,9 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id, ...@@ -72,7 +79,9 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id,
{ {
m_Parent = parent; m_Parent = parent;
wxASSERT( m_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, SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red,
ColorRefs[g_DrawBgColor].m_Green, ColorRefs[g_DrawBgColor].m_Green,
...@@ -131,9 +140,13 @@ void WinEDA_DrawPanel::DrawCursor( wxDC* aDC, int aColor ) ...@@ -131,9 +140,13 @@ void WinEDA_DrawPanel::DrawCursor( wxDC* aDC, int aColor )
GRSetDrawMode( aDC, GR_XOR ); GRSetDrawMode( aDC, GR_XOR );
if( m_Parent->m_CursorShape == 1 ) /* Draws a crosshair. */ 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 dx = GetScreen()->Unscale( m_ClipBox.GetWidth() );
int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() ); int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() );
#endif
GRLine( &m_ClipBox, aDC, Cursor.x - dx, Cursor.y, GRLine( &m_ClipBox, aDC, Cursor.x - dx, Cursor.y,
Cursor.x + dx, Cursor.y, 0, aColor ); // Y axis Cursor.x + dx, Cursor.y, 0, aColor ); // Y axis
GRLine( &m_ClipBox, aDC, Cursor.x, Cursor.y - dx, GRLine( &m_ClipBox, aDC, Cursor.x, Cursor.y - dx,
...@@ -141,7 +154,11 @@ void WinEDA_DrawPanel::DrawCursor( wxDC* aDC, int aColor ) ...@@ -141,7 +154,11 @@ void WinEDA_DrawPanel::DrawCursor( wxDC* aDC, int aColor )
} }
else else
{ {
#ifdef USE_WX_ZOOM
int len = aDC->DeviceToLogicalXRel( CURSOR_SIZE );
#else
int len = GetScreen()->Unscale( CURSOR_SIZE ); int len = GetScreen()->Unscale( CURSOR_SIZE );
#endif
GRLine( &m_ClipBox, aDC, Cursor.x - len, Cursor.y, GRLine( &m_ClipBox, aDC, Cursor.x - len, Cursor.y,
Cursor.x + len, Cursor.y, 0, aColor ); Cursor.x + len, Cursor.y, 0, aColor );
...@@ -197,17 +214,17 @@ wxRealPoint WinEDA_DrawPanel::GetGrid() ...@@ -197,17 +214,17 @@ wxRealPoint WinEDA_DrawPanel::GetGrid()
* @return position (in internal units) * @return position (in internal units)
* @param ScreenPos = absolute position in pixels * @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; wxCoord x, y;
INSTALL_DC( DC, this ); INSTALL_DC( DC, this );
x = DC.DeviceToLogicalX( ScreenPos.x ); x = DC.DeviceToLogicalX( aPosition.x );
y = DC.DeviceToLogicalY( ScreenPos.y ); y = DC.DeviceToLogicalY( aPosition.y );
return wxPoint( x, y ); return wxPoint( x, y );
#else #else
return GetScreen()->CursorRealPosition( ScreenPos ); return GetScreen()->CursorRealPosition( aPosition );
#endif #endif
} }
...@@ -222,7 +239,8 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) ...@@ -222,7 +239,8 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
wxPoint pos; wxPoint pos;
EDA_Rect display_rect; EDA_Rect display_rect;
SetBoundaryBox(); INSTALL_DC( dc, this ); // Refresh the boundary box.
display_rect = m_ClipBox; display_rect = m_ClipBox;
// Slightly decreased the size of the useful screen area to avoid drawing // Slightly decreased the size of the useful screen area to avoid drawing
...@@ -230,6 +248,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) ...@@ -230,6 +248,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
#define PIXEL_MARGIN 8 #define PIXEL_MARGIN 8
display_rect.Inflate( -PIXEL_MARGIN ); display_rect.Inflate( -PIXEL_MARGIN );
#ifndef USE_WX_ZOOM
// Convert physical coordinates. // Convert physical coordinates.
pos = CalcUnscrolledPosition( display_rect.GetPosition() ); pos = CalcUnscrolledPosition( display_rect.GetPosition() );
...@@ -237,6 +256,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) ...@@ -237,6 +256,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
pos += GetScreen()->m_DrawOrg; pos += GetScreen()->m_DrawOrg;
display_rect.m_Pos = pos; display_rect.m_Pos = pos;
GetScreen()->Unscale( display_rect.m_Size ); GetScreen()->Unscale( display_rect.m_Size );
#endif
return display_rect.Inside( ref_pos ); return display_rect.Inside( ref_pos );
} }
...@@ -263,6 +283,13 @@ void WinEDA_DrawPanel::PostDirtyRect( EDA_Rect aRect ) ...@@ -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 ) void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect )
{ {
// Calculate the draw area origin in internal units: // Calculate the draw area origin in internal units:
...@@ -270,13 +297,18 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect ) ...@@ -270,13 +297,18 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect )
ConvertPcbUnitsToPixelsUnits( &pos ); ConvertPcbUnitsToPixelsUnits( &pos );
aRect->SetOrigin( pos ); // rect origin in pixel units 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 ); GetScreen()->Scale( aRect->m_Size );
#endif
} }
/***************************************************************************/
void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition ) void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
/***************************************************************************/
{ {
// Calculate the draw area origin in internal units: // Calculate the draw area origin in internal units:
wxPoint drwOrig; wxPoint drwOrig;
...@@ -290,6 +322,15 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition ) ...@@ -290,6 +322,15 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
drwOrig.x *= x_axis_scale; drwOrig.x *= x_axis_scale;
drwOrig.y *= y_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 // Origin in internal units
GetScreen()->Unscale( drwOrig ); GetScreen()->Unscale( drwOrig );
...@@ -301,6 +342,7 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition ) ...@@ -301,6 +342,7 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
// position in pixels, relative to the visible draw area origin // position in pixels, relative to the visible draw area origin
GetScreen()->Scale( *aPosition ); GetScreen()->Scale( *aPosition );
#endif
} }
...@@ -309,18 +351,18 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition ) ...@@ -309,18 +351,18 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
*/ */
wxPoint WinEDA_DrawPanel::CursorScreenPosition() wxPoint WinEDA_DrawPanel::CursorScreenPosition()
{ {
#ifdef WX_ZOOM wxPoint pos = GetScreen()->m_Curseur - GetScreen()->m_DrawOrg;
wxCoord x, y;
#ifdef USE_WX_ZOOM
INSTALL_DC( DC, this ); INSTALL_DC( DC, this );
x = DC.LogicalToDeviceX( GetScreen()->m_Curseur.x ); pos.x = DC.LogicalToDeviceXRel( pos.x );
y = DC.LogicalToDeviceY( GetScreen()->m_Curseur.y ); pos.y = DC.LogicalToDeviceYRel( pos.y );
return wxPoint( x, y );
#else #else
wxPoint pos = GetScreen()->m_Curseur - GetScreen()->m_DrawOrg;
GetScreen()->Scale( pos ); GetScreen()->Scale( pos );
return pos;
#endif #endif
return pos;
} }
...@@ -334,18 +376,18 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void ) ...@@ -334,18 +376,18 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void )
wxPoint realpos; wxPoint realpos;
size = GetClientSize() / 2; size = GetClientSize() / 2;
realpos = CalcUnscrolledPosition( wxPoint( size.x, size.y ) );
GetScreen()->Unscale( realpos ); #ifdef USE_WX_ZOOM
#ifdef WX_ZOOM INSTALL_DC( DC, this );
// wxCoord x, y; realpos.x = DC.DeviceToLogicalX( size.x );
// INSTALL_DC( DC, this ); realpos.y = DC.DeviceToLogicalY( size.y );
// realpos.x = DC.DeviceToLogicalX( realpos.x );
// realpos.y = DC.DeviceToLogicalY( realpos.y );
#else #else
realpos = CalcUnscrolledPosition( wxPoint( size.x, size.y ) );
GetScreen()->Unscale( realpos );
realpos += GetScreen()->m_DrawOrg; realpos += GetScreen()->m_DrawOrg;
#endif #endif
return realpos; return realpos;
} }
...@@ -369,7 +411,7 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse ) ...@@ -369,7 +411,7 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse )
wxPoint screenPos, drawingPos; wxPoint screenPos, drawingPos;
wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() ); wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() );
#ifdef WX_ZOOM #ifdef USE_WX_ZOOM
CalcScrolledPosition( Mouse.x, Mouse.y, &screenPos.x, &screenPos.y ); CalcScrolledPosition( Mouse.x, Mouse.y, &screenPos.x, &screenPos.y );
#else #else
screenPos = Mouse - GetScreen()->m_StartVisu; screenPos = Mouse - GetScreen()->m_StartVisu;
...@@ -390,13 +432,13 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse ) ...@@ -390,13 +432,13 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse )
clientRect.width, clientRect.height, x, y ); clientRect.width, clientRect.height, x, y );
if( screenPos.y < clientRect.GetTop() ) if( screenPos.y < clientRect.GetTop() )
y -= m_ScrollButt_unit * yPpu; y -= m_scrollIncrementY * yPpu;
else if( screenPos.y > clientRect.GetBottom() ) else if( screenPos.y > clientRect.GetBottom() )
y += m_ScrollButt_unit * yPpu; y += m_scrollIncrementY * yPpu;
else if( clientRect.GetRight() < screenPos.x ) else if( clientRect.GetRight() < screenPos.x )
x += m_ScrollButt_unit * xPpu; x += m_scrollIncrementX * xPpu;
else else
x -= m_ScrollButt_unit * xPpu; x -= m_scrollIncrementX * xPpu;
Scroll( x, y ); Scroll( x, y );
CalcScrolledPosition( drawingPos.x, drawingPos.y, CalcScrolledPosition( drawingPos.x, drawingPos.y,
...@@ -434,10 +476,10 @@ void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event ) ...@@ -434,10 +476,10 @@ void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event )
dir = event.GetOrientation(); // wxHORIZONTAL or wxVERTICAL dir = event.GetOrientation(); // wxHORIZONTAL or wxVERTICAL
if( id == wxEVT_SCROLLWIN_LINEUP ) if( id == wxEVT_SCROLLWIN_LINEUP )
value = -m_ScrollButt_unit; value = -m_scrollIncrementY;
else if( id == wxEVT_SCROLLWIN_LINEDOWN ) else if( id == wxEVT_SCROLLWIN_LINEDOWN )
value = m_ScrollButt_unit; value = m_scrollIncrementY;
else if( id == wxEVT_SCROLLWIN_THUMBTRACK ) else if( id == wxEVT_SCROLLWIN_THUMBTRACK )
{ {
...@@ -468,7 +510,9 @@ void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event ) ...@@ -468,7 +510,9 @@ void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event )
void WinEDA_DrawPanel::OnSize( wxSizeEvent& 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(); event.Skip();
} }
...@@ -476,35 +520,41 @@ void WinEDA_DrawPanel::OnSize( wxSizeEvent& event ) ...@@ -476,35 +520,41 @@ void WinEDA_DrawPanel::OnSize( wxSizeEvent& event )
/** Function SetBoundaryBox() /** Function SetBoundaryBox()
* set the m_ClipBox member to the current displayed rectangle dimensions * 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();; BASE_SCREEN* Screen = GetScreen();;
if( !Screen ) if( !Screen )
return; return;
wxPoint org;
int ii, jj;
GetViewStart( &org.x, &org.y ); Screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
GetScrollPixelsPerUnit( &ii, &jj ); m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
org.x *= ii;
org.y *= jj;
Screen->m_StartVisu = org;
m_ClipBox.SetOrigin( org );
m_ClipBox.SetSize( GetClientSize() ); m_ClipBox.SetSize( GetClientSize() );
#ifdef WX_ZOOM int scrollX, scrollY;
CalcUnscrolledPosition( m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y,
&m_ClipBox.m_Pos.x, &m_ClipBox.m_Pos.y ); #ifdef USE_WX_ZOOM
scrollX = dc->LogicalToDeviceXRel( wxRound( Screen->GetGridSize().x ) );
scrollY = dc->LogicalToDeviceYRel( wxRound( Screen->GetGridSize().y ) );
#else #else
m_ClipBox.m_Pos -= GetScreen()->m_StartVisu; scrollX = wxRound( Screen->Scale( Screen->GetGridSize().x ) );
scrollY = wxRound( Screen->Scale( Screen->GetGridSize().y ) );
#endif #endif
m_ScrollButt_unit = MIN( Screen->m_SizeVisu.x, Screen->m_SizeVisu.y ) / 4; m_scrollIncrementX = MAX( GetClientSize().x / 8, scrollX );
if( m_ScrollButt_unit < 2 ) m_scrollIncrementY = MAX( GetClientSize().y / 8, scrollY );
m_ScrollButt_unit = 2;
#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.x = GetScrollPos( wxHORIZONTAL );
Screen->m_ScrollbarPos.y = GetScrollPos( wxVERTICAL ); Screen->m_ScrollbarPos.y = GetScrollPos( wxVERTICAL );
...@@ -515,38 +565,31 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC ) ...@@ -515,38 +565,31 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC )
{ {
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
#ifndef WX_ZOOM
GRSFilledRect( &m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(), GRSFilledRect( &m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
m_ClipBox.GetRight(), m_ClipBox.GetBottom(), m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
0, g_DrawBgColor, g_DrawBgColor ); 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 SetScale( scale, scale );
// see setup.h in wx Widgets. wxScrolledWindow::DoPrepareDC( dc );
// wxWidgets configure can need option --enable-graphics_ctx wxPoint origin = GetScreen()->m_DrawOrg;
// Currently, **only for tests** dc.SetLogicalOrigin( origin.x, origin.y );
//#define USE_GCDC_IN_KICAD // uncomment it to use wxGCDC }
#endif #endif
GRResetPenAndBrush( &dc );
dc.SetBackgroundMode( wxTRANSPARENT );
SetBoundaryBox( &dc );
}
void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
{ {
...@@ -556,64 +599,45 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -556,64 +599,45 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
return; return;
} }
#ifdef USE_GCDC_IN_KICAD INSTALL_PAINTDC( paintDC, this );
wxPaintDC pDC( this );
// Following line should be disabled on MSW and OS X /* wxAutoBufferedPaintDC does not work correctly by setting the user scale and
wxGCDC paintDC( pDC ); * 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.
*/
// Fix for pixel offset bug http://trac.wxwidgets.org/ticket/4187
paintDC.GetGraphicsContext()->Translate( 0.5, 0.5 );
#else
INSTALL_PAINTDC( paintDC, this );
#endif
EDA_Rect tmp; EDA_Rect tmp;
wxRect PaintClipBox; wxRect PaintClipBox;
wxPoint org;
SetBoundaryBox();
tmp = m_ClipBox; tmp = m_ClipBox;
org = m_ClipBox.GetOrigin();
wxRegion upd = GetUpdateRegion(); // get the update rect list wxRegion upd = GetUpdateRegion(); // get the update rect list
// get the union of all rectangles in the update region, 'upd' // get the union of all rectangles in the update region, 'upd'
PaintClipBox = upd.GetBox(); PaintClipBox = upd.GetBox();
#if 0 && defined(DEBUG) #if 0
printf( "1) PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) m_ClipBox=(%d, %d, %d, %d)\n", wxLogDebug( wxT( "1) PaintClipBox=(%d, %d, %d, %d), m_ClipBox=(%d, %d, %d, %d)" ),
PaintClipBox.x, PaintClipBox.x, PaintClipBox.y, PaintClipBox.width, PaintClipBox.height,
PaintClipBox.y, m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y, m_ClipBox.m_Size.x, m_ClipBox.m_Size.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
);
#endif #endif
#ifdef WX_ZOOM #if defined( USE_WX_ZOOM )
wxLogDebug( wxT( "1) PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) " \ /* When using wxDC scaling the clipping region coordinates are in drawing
"m_ClipBox=(%d, %d, %d, %d)\n" ), PaintClipBox.x, * (logical) units.
PaintClipBox.y, PaintClipBox.width, PaintClipBox.height, */
org.x, org.y, m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y, m_ClipBox.m_Pos.x = paintDC.DeviceToLogicalX( PaintClipBox.x );
m_ClipBox.m_Size.x, m_ClipBox.m_Size.y ); m_ClipBox.m_Pos.y = paintDC.DeviceToLogicalY( PaintClipBox.y );
m_ClipBox.m_Size.x = paintDC.DeviceToLogicalXRel( PaintClipBox.width );
wxSize drawing_size = GetScreen()->ReturnPageSize() * 2; m_ClipBox.m_Size.y = paintDC.DeviceToLogicalYRel( PaintClipBox.height );
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 );
#else #else
PaintClipBox.Offset( org ); /* When using Kicads scaling the clipping region coordinates are in screen
* (device) units.
*/
m_ClipBox.SetX( PaintClipBox.GetX() ); m_ClipBox.SetX( PaintClipBox.GetX() );
m_ClipBox.SetY( PaintClipBox.GetY() ); m_ClipBox.SetY( PaintClipBox.GetY() );
m_ClipBox.SetWidth( PaintClipBox.GetWidth() ); m_ClipBox.SetWidth( PaintClipBox.GetWidth() );
...@@ -623,31 +647,19 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -623,31 +647,19 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
// Be sure the drawpanel clipbox is bigger than the region to repair: // Be sure the drawpanel clipbox is bigger than the region to repair:
m_ClipBox.Inflate( 1 ); // Give it one pixel more in each direction m_ClipBox.Inflate( 1 ); // Give it one pixel more in each direction
#if 0 && defined(DEBUG) #if 0
printf( "2) PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) m_ClipBox=(%d, %d, %d, %d)\n", wxLogDebug( wxT( "2) PaintClipBox=(%d, %d, %d, %d), m_ClipBox=(%d, %d, %d, %d)" ),
PaintClipBox.x, PaintClipBox.x, PaintClipBox.y, PaintClipBox.width, PaintClipBox.height,
PaintClipBox.y, m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y, m_ClipBox.m_Size.x, m_ClipBox.m_Size.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
);
#endif #endif
#if defined( USE_WX_ZOOM ) && defined( KICAD_USE_BUFFERED_PAINTDC )
PaintClipBox = m_ClipBox; PaintClipBox = m_ClipBox;
#endif
// call ~wxDCClipper() before ~wxPaintDC() // call ~wxDCClipper() before ~wxPaintDC()
{ {
#ifndef WX_ZOOM
wxDCClipper dcclip( paintDC, PaintClipBox ); wxDCClipper dcclip( paintDC, PaintClipBox );
#endif
ReDraw( &paintDC, true ); ReDraw( &paintDC, true );
#ifdef WX_ZOOM
paintDC.SetUserScale( 1.0, 1.0 );
#endif
} }
m_ClipBox = tmp; m_ClipBox = tmp;
...@@ -743,7 +755,20 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC ) ...@@ -743,7 +755,20 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
* and zoom value are sufficient * and zoom value are sufficient
*/ */
screen_grid_size = screen->GetGridSize(); 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; wxRealPoint dgrid = screen_grid_size;
screen->Scale( dgrid ); // dgrid = grid size in pixels screen->Scale( dgrid ); // dgrid = grid size in pixels
...@@ -765,29 +790,9 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC ) ...@@ -765,29 +790,9 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
return; // The grid is too small return; // The grid is too small
GetViewStart( &org.x, &org.y ); screen->Unscale( size );
GetScrollPixelsPerUnit( &ii, &jj );
org.x *= ii;
org.y *= jj;
screen->m_StartVisu = org;
screen->Unscale( org ); screen->Unscale( org );
org += screen->m_DrawOrg; 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() ) );
#endif #endif
m_Parent->PutOnGrid( &org ); m_Parent->PutOnGrid( &org );
...@@ -805,7 +810,12 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC ) ...@@ -805,7 +810,12 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
wxWindowUpdateLocker( this ); // under macOSX: drawings are faster with this wxWindowUpdateLocker( this ); // under macOSX: drawings are faster with this
#endif #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 // Use a pixel based draw to display grid
// There is a lot of calls, so the cost is hight // There is a lot of calls, so the cost is hight
// and grid is slowly drawn on some platforms // and grid is slowly drawn on some platforms
...@@ -840,7 +850,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC ) ...@@ -840,7 +850,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
wxSize screenSize = GetClientSize(); wxSize screenSize = GetClientSize();
wxMemoryDC tmpDC; wxMemoryDC tmpDC;
wxBitmap tmpBM(1, screenSize.y); wxBitmap tmpBM( 1, screenSize.y );
tmpDC.SelectObject( tmpBM ); tmpDC.SelectObject( tmpBM );
GRSetColorPen( &tmpDC, g_DrawBgColor ); GRSetColorPen( &tmpDC, g_DrawBgColor );
tmpDC.DrawLine( 0, 0, 0, screenSize.y-1 ); // init background tmpDC.DrawLine( 0, 0, 0, screenSize.y-1 ); // init background
...@@ -978,8 +988,12 @@ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event ) ...@@ -978,8 +988,12 @@ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event )
return; return;
} }
#ifdef USE_WX_ZOOM
GetScreen()->m_Curseur = CursorRealPosition( event.GetPosition() );
#else
GetScreen()->m_Curseur = GetScreen()->m_Curseur =
CursorRealPosition( CalcUnscrolledPosition( event.GetPosition() ) ); CursorRealPosition( CalcUnscrolledPosition( event.GetPosition() ) );
#endif
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this ); cmd.SetEventObject( this );
...@@ -1078,13 +1092,20 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1078,13 +1092,20 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
localrealbutt |= localbutt; /* compensation default wxGTK */ localrealbutt |= localbutt; /* compensation default wxGTK */
/* Compute absolute m_MousePosition in pixel units: */ #ifdef USE_WX_ZOOM
screen->m_MousePositionInPixels = /* Compute the cursor position in screen (device) units. */
CalcUnscrolledPosition( event.GetPosition() ); screen->m_MousePositionInPixels = event.GetPosition();
/* 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 absolute m_MousePosition in user units: */ /* Compute the cursor position in drawing (logical) units. */
screen->m_MousePosition = screen->m_MousePosition =
CursorRealPosition( screen->m_MousePositionInPixels ); CursorRealPosition( CalcUnscrolledPosition( event.GetPosition() ) );
#endif
INSTALL_DC( DC, this ); INSTALL_DC( DC, this );
...@@ -1347,7 +1368,6 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) ...@@ -1347,7 +1368,6 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
BASE_SCREEN* Screen = GetScreen(); BASE_SCREEN* Screen = GetScreen();
g_KeyPressed = localkey; g_KeyPressed = localkey;
if( escape ) if( escape )
...@@ -1366,17 +1386,18 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) ...@@ -1366,17 +1386,18 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
} }
/* Some key commands use the current mouse position: refresh it */ /* Some key commands use the current mouse position: refresh it */
#ifdef WX_ZOOM #ifdef USE_WX_ZOOM
pos = CalcUnscrolledPosition( wxGetMousePosition() ); pos = wxGetMousePosition() - GetScreenPosition();
#else #else
pos = CalcUnscrolledPosition( wxGetMousePosition() - GetScreenPosition() ); pos = CalcUnscrolledPosition( wxGetMousePosition() - GetScreenPosition() );
#endif #endif
/* Compute absolute mouse position in pixel units (i.e. considering the /* Compute cursor position in screen units (pixel) including the
* current scroll) : */ * current scroll bar position. Also known as device units to wxDC. */
Screen->m_MousePositionInPixels = pos; 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 ); Screen->m_MousePosition = CursorRealPosition( pos );
m_Parent->GeneralControle( &DC, pos ); m_Parent->GeneralControle( &DC, pos );
...@@ -1396,19 +1417,19 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event ) ...@@ -1396,19 +1417,19 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event )
switch( event.GetId() ) switch( event.GetId() )
{ {
case ID_PAN_UP: case ID_PAN_UP:
y -= m_ScrollButt_unit; y -= m_scrollIncrementY;
break; break;
case ID_PAN_DOWN: case ID_PAN_DOWN:
y += m_ScrollButt_unit; y += m_scrollIncrementY;
break; break;
case ID_PAN_LEFT: case ID_PAN_LEFT:
x -= m_ScrollButt_unit; x -= m_scrollIncrementX;
break; break;
case ID_PAN_RIGHT: case ID_PAN_RIGHT:
x += m_ScrollButt_unit; x += m_scrollIncrementX;
break; break;
default: default:
......
...@@ -89,7 +89,7 @@ static void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, ...@@ -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 ) static inline int USCALE( us arg, us num, us den )
{ {
#ifndef WX_ZOOM #ifndef USE_WX_ZOOM
int ii; int ii;
ii = (int) ( ( (float) arg * num ) / den ); ii = (int) ( ( (float) arg * num ) / den );
return ii; return ii;
...@@ -110,7 +110,7 @@ static int inline ZoomValue( int val ) ...@@ -110,7 +110,7 @@ static int inline ZoomValue( int val )
/****************************************/ /****************************************/
int GRMapX( int x ) int GRMapX( int x )
{ {
#ifndef WX_ZOOM #ifndef USE_WX_ZOOM
int coord = x - ActiveScreen->m_DrawOrg.x; int coord = x - ActiveScreen->m_DrawOrg.x;
coord = ZoomValue( coord ); coord = ZoomValue( coord );
coord -= ActiveScreen->m_StartVisu.x; coord -= ActiveScreen->m_StartVisu.x;
...@@ -123,7 +123,7 @@ int GRMapX( int x ) ...@@ -123,7 +123,7 @@ int GRMapX( int x )
int GRMapY( int y ) int GRMapY( int y )
{ {
#ifndef WX_ZOOM #ifndef USE_WX_ZOOM
int coord = y - ActiveScreen->m_DrawOrg.y; int coord = y - ActiveScreen->m_DrawOrg.y;
coord = ZoomValue( coord ); coord = ZoomValue( coord );
coord -= ActiveScreen->m_StartVisu.y; coord -= ActiveScreen->m_StartVisu.y;
...@@ -373,28 +373,24 @@ void GRSetDrawMode( wxDC* DC, int draw_mode ) ...@@ -373,28 +373,24 @@ void GRSetDrawMode( wxDC* DC, int draw_mode )
{ {
if( draw_mode & GR_OR ) if( draw_mode & GR_OR )
#if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) ) #if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
DC->SetLogicalFunction( wxCOPY );
#elif defined( USE_WX_GRAPHICS_CONTEXT )
DC->SetLogicalFunction( wxCOPY ); DC->SetLogicalFunction( wxCOPY );
#else #else
DC->SetLogicalFunction( wxOR ); DC->SetLogicalFunction( wxOR );
#endif #endif
else if( draw_mode & GR_XOR ) else if( draw_mode & GR_XOR )
#if defined( USE_WX_GRAPHICS_CONTEXT )
DC->SetLogicalFunction( wxCOPY );
#else
DC->SetLogicalFunction( wxXOR ); DC->SetLogicalFunction( wxXOR );
#endif
else if( draw_mode & GR_NXOR ) else if( draw_mode & GR_NXOR )
#if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) ) #if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
DC->SetLogicalFunction( wxXOR ); DC->SetLogicalFunction( wxXOR );
#elif defined( USE_WX_GRAPHICS_CONTEXT )
DC->SetLogicalFunction( wxCOPY );
#else #else
DC->SetLogicalFunction( wxEQUIV ); DC->SetLogicalFunction( wxEQUIV );
#endif #endif
else else
......
...@@ -12,15 +12,10 @@ ...@@ -12,15 +12,10 @@
WinEDA_Toolbar::WinEDA_Toolbar( id_toolbar type, wxWindow * parent, WinEDA_Toolbar::WinEDA_Toolbar( id_toolbar type, wxWindow * parent,
wxWindowID id, bool horizontal ): wxWindowID id, bool horizontal ):
#if defined(KICAD_AUITOOLBAR)
wxAuiToolBar( parent, id, wxDefaultPosition, wxDefaultSize, wxAuiToolBar( parent, id, wxDefaultPosition, wxDefaultSize,
wxAUI_TB_DEFAULT_STYLE | ( ( horizontal ) ? wxAUI_TB_DEFAULT_STYLE | ( ( horizontal ) ?
wxAUI_TB_HORZ_LAYOUT : wxAUI_TB_HORZ_LAYOUT :
wxAUI_TB_VERTICAL ) ) wxAUI_TB_VERTICAL ) )
#else
wxToolBar( parent, id, wxPoint( -1,-1 ), wxSize( -1,-1 ),
horizontal ? wxTB_HORIZONTAL : wxTB_VERTICAL )
#endif
{ {
m_Parent = parent; m_Parent = parent;
m_Ident = type; m_Ident = type;
......
...@@ -35,7 +35,7 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse ) ...@@ -35,7 +35,7 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
* TODO: see exactly how the mouse creates problems when moving during refresh * TODO: see exactly how the mouse creates problems when moving during refresh
* use Refresh() and update() do not change problems * use Refresh() and update() do not change problems
*/ */
INSTALL_DC(dc,DrawPanel); INSTALL_DC( dc, DrawPanel );
DrawPanel->ReDraw( &dc ); DrawPanel->ReDraw( &dc );
/* Move the mouse cursor to the on grid graphic cursor position */ /* Move the mouse cursor to the on grid graphic cursor position */
......
...@@ -72,7 +72,8 @@ if(APPLE) ...@@ -72,7 +72,8 @@ if(APPLE)
set_target_properties(${CVPCB_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) set_target_properties(${CVPCB_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
endif(APPLE) 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} install(TARGETS ${CVPCB_NAME}
DESTINATION ${KICAD_BIN} DESTINATION ${KICAD_BIN}
......
...@@ -74,7 +74,6 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( WinEDA_CvpcbFrame* father, ...@@ -74,7 +74,6 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( WinEDA_CvpcbFrame* father,
ReCreateHToolbar(); ReCreateHToolbar();
ReCreateVToolbar(); ReCreateVToolbar();
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz; wxAuiPaneInfo horiz;
...@@ -105,7 +104,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( WinEDA_CvpcbFrame* father, ...@@ -105,7 +104,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( WinEDA_CvpcbFrame* father,
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() ); wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update(); m_auimgr.Update();
#endif
Show( TRUE ); Show( TRUE );
} }
...@@ -219,7 +218,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -219,7 +218,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize(); 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 ); GetScreen()->Scale( delta );
#endif
if( delta.x <= 0 ) if( delta.x <= 0 )
delta.x = 1; delta.x = 1;
......
...@@ -157,27 +157,6 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, ...@@ -157,27 +157,6 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title,
BuildCmpListBox(); BuildCmpListBox();
BuildFOOTPRINTS_LISTBOX(); 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 ); m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz; wxAuiPaneInfo horiz;
...@@ -204,7 +183,6 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, ...@@ -204,7 +183,6 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title,
Right().BestSize( (int) ( m_FrameSize.x * 0.36 ), m_FrameSize.y ) ); Right().BestSize( (int) ( m_FrameSize.x * 0.36 ), m_FrameSize.y ) );
m_auimgr.Update(); m_auimgr.Update();
#endif
} }
...@@ -219,9 +197,7 @@ WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame() ...@@ -219,9 +197,7 @@ WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame()
config->Write( wxT( FILTERFOOTPRINTKEY ), state ); config->Write( wxT( FILTERFOOTPRINTKEY ), state );
} }
#if defined(KICAD_AUIMANAGER)
m_auimgr.UnInit(); m_auimgr.UnInit();
#endif
} }
......
...@@ -22,10 +22,6 @@ void WinEDA_CvpcbFrame::ReCreateHToolbar() ...@@ -22,10 +22,6 @@ void WinEDA_CvpcbFrame::ReCreateHToolbar()
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE ); 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, m_HToolBar->AddTool( ID_CVPCB_READ_INPUT_NETLIST, wxEmptyString,
wxBitmap( open_xpm ), wxBitmap( open_xpm ),
_( "Open a net list file" ) ); _( "Open a net list file" ) );
......
...@@ -154,7 +154,7 @@ if(APPLE) ...@@ -154,7 +154,7 @@ if(APPLE)
set_target_properties(eeschema PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) set_target_properties(eeschema PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
endif(APPLE) endif(APPLE)
target_link_libraries(eeschema common bitmaps ${wxWidgets_LIBRARIES}) target_link_libraries(eeschema common bitmaps ${wxWidgets_LIBRARIES} ${GDI_PLUS_LIBRARIES})
install(TARGETS eeschema install(TARGETS eeschema
DESTINATION ${KICAD_BIN} DESTINATION ${KICAD_BIN}
......
...@@ -267,7 +267,11 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDc, ...@@ -267,7 +267,11 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDc,
/* Enable this to draw the anchor of the component. */ /* Enable this to draw the anchor of the component. */
#if 0 #if 0
#ifdef USE_WX_ZOOM
int len = aDc->DeviceToLogicalXRel( 3 );
#else
int len = aPanel->GetScreen()->Unscale( 3 ); int len = aPanel->GetScreen()->Unscale( 3 );
#endif
GRLine( &aPanel->m_ClipBox, aDc, aOffset.x, aOffset.y - len, aOffset.x, GRLine( &aPanel->m_ClipBox, aDc, aOffset.x, aOffset.y - len, aOffset.x,
aOffset.y + len, 0, aColor ); aOffset.y + len, 0, aColor );
GRLine( &aPanel->m_ClipBox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len, GRLine( &aPanel->m_ClipBox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len,
......
...@@ -230,7 +230,14 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, ...@@ -230,7 +230,14 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
oldpos = screen->m_Curseur; oldpos = screen->m_Curseur;
delta = screen->GetGridSize(); 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 ); screen->Scale( delta );
#endif
if( delta.x <= 0 ) if( delta.x <= 0 )
delta.x = 1; delta.x = 1;
...@@ -324,7 +331,14 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, ...@@ -324,7 +331,14 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
oldpos = screen->m_Curseur; oldpos = screen->m_Curseur;
delta = screen->GetGridSize(); 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 ); screen->Scale( delta );
#endif
if( delta.x <= 0 ) if( delta.x <= 0 )
delta.x = 1; delta.x = 1;
...@@ -417,7 +431,14 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, ...@@ -417,7 +431,14 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
oldpos = screen->m_Curseur; oldpos = screen->m_Curseur;
delta = screen->GetGridSize(); 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 ); screen->Scale( delta );
#endif
if( delta.x <= 0 ) if( delta.x <= 0 )
delta.x = 1; delta.x = 1;
......
...@@ -192,10 +192,15 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father, ...@@ -192,10 +192,15 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
DisplayCmpDoc(); DisplayCmpDoc();
UpdateAliasSelectList(); UpdateAliasSelectList();
UpdatePartSelectList(); UpdatePartSelectList();
#ifdef USE_WX_GRAPHICS_CONTEXT
GetScreen()->SetZoom( BestZoom() );
#else
Zoom_Automatique( false ); Zoom_Automatique( false );
#endif
Show( true ); Show( true );
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz; wxAuiPaneInfo horiz;
...@@ -224,7 +229,6 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father, ...@@ -224,7 +229,6 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
m_auimgr.AddPane( MsgPanel, m_auimgr.AddPane( MsgPanel,
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() ); wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update(); m_auimgr.Update();
#endif
} }
......
...@@ -194,7 +194,6 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father, ...@@ -194,7 +194,6 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_HIGH ); m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_HIGH );
m_pageSetupData.GetPrintData().SetOrientation( wxLANDSCAPE ); m_pageSetupData.GetPrintData().SetOrientation( wxLANDSCAPE );
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz; wxAuiPaneInfo horiz;
...@@ -231,7 +230,6 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father, ...@@ -231,7 +230,6 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() ); wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update(); m_auimgr.Update();
#endif
} }
......
...@@ -94,9 +94,7 @@ void WinEDA_LibeditFrame::ReCreateHToolbar() ...@@ -94,9 +94,7 @@ void WinEDA_LibeditFrame::ReCreateHToolbar()
return; return;
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true ); m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true );
#if !defined(KICAD_AUIMANAGER)
SetToolBar( (wxToolBar*)m_HToolBar );
#endif
// Set up toolbar // Set up toolbar
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_LIB, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_LIB, wxEmptyString,
wxBitmap( save_library_xpm ), wxBitmap( save_library_xpm ),
......
...@@ -25,10 +25,6 @@ void WinEDA_SchematicFrame::ReCreateHToolbar() ...@@ -25,10 +25,6 @@ void WinEDA_SchematicFrame::ReCreateHToolbar()
wxString msg; wxString msg;
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE ); m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
#if !defined(KICAD_AUIMANAGER)
SetToolBar( (wxToolBar*)m_HToolBar );
#endif
// Set up toolbar // Set up toolbar
m_HToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString, wxBitmap( new_xpm ), m_HToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString, wxBitmap( new_xpm ),
_( "New schematic project" ) ); _( "New schematic project" ) );
......
...@@ -28,10 +28,6 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar() ...@@ -28,10 +28,6 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR,
true ); true );
#if !defined(KICAD_AUIMANAGER)
SetToolBar( (wxToolBar*)m_HToolBar );
#endif
// Set up toolbar // Set up toolbar
m_HToolBar->AddTool( ID_LIBVIEW_SELECT_LIB, wxEmptyString, m_HToolBar->AddTool( ID_LIBVIEW_SELECT_LIB, wxEmptyString,
wxBitmap( library_xpm ), wxBitmap( library_xpm ),
......
...@@ -170,10 +170,15 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, ...@@ -170,10 +170,15 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
if( DrawPanel ) if( DrawPanel )
DrawPanel->SetAcceleratorTable( table ); DrawPanel->SetAcceleratorTable( table );
#ifdef USE_WX_GRAPHICS_CONTEXT
GetScreen()->SetZoom( BestZoom() );
#else
Zoom_Automatique( false ); Zoom_Automatique( false );
#endif
Show( TRUE ); Show( TRUE );
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz; wxAuiPaneInfo horiz;
...@@ -225,12 +230,6 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, ...@@ -225,12 +230,6 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
pane.MinSize(wxSize(m_CmpListSize.x, -1)); pane.MinSize(wxSize(m_CmpListSize.x, -1));
m_auimgr.Update(); m_auimgr.Update();
#else
m_CmpListWindow->SetSize(m_CmpListSize);
if( m_LibListWindow )
m_LibListWindow->SetSize(m_LibListSize);
#endif
} }
...@@ -262,29 +261,6 @@ void WinEDA_ViewlibFrame::OnSashDrag( wxSashEvent& event ) ...@@ -262,29 +261,6 @@ void WinEDA_ViewlibFrame::OnSashDrag( wxSashEvent& event )
m_LibListSize.y = GetClientSize().y - m_MsgFrameHeight; m_LibListSize.y = GetClientSize().y - m_MsgFrameHeight;
m_CmpListSize.y = m_LibListSize.y; m_CmpListSize.y = m_LibListSize.y;
#ifndef KICAD_AUIMANAGER
switch( event.GetId() )
{
case ID_LIBVIEW_LIBWINDOW:
if( m_LibListWindow )
{
m_LibListSize.x = event.GetDragRect().width;
m_LibListWindow->SetSize( m_LibListSize );
m_CmpListWindow->SetPosition( wxPoint( m_LibListSize.x, 0 ) );
m_CmpListWindow->SetSize( m_CmpListSize );
}
break;
case ID_LIBVIEW_CMPWINDOW:
m_CmpListSize.x = event.GetDragRect().width;
m_CmpListWindow->SetSize( m_CmpListSize );
break;
}
// Now, we must recalculate the position and size of subwindows
wxSizeEvent SizeEv;
OnSize( SizeEv );
#else
switch( event.GetId() ) switch( event.GetId() )
{ {
case ID_LIBVIEW_LIBWINDOW: case ID_LIBVIEW_LIBWINDOW:
...@@ -306,57 +282,15 @@ void WinEDA_ViewlibFrame::OnSashDrag( wxSashEvent& event ) ...@@ -306,57 +282,15 @@ void WinEDA_ViewlibFrame::OnSashDrag( wxSashEvent& event )
} }
break; break;
} }
#endif
} }
void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv ) void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
{ {
#ifndef KICAD_AUIMANAGER
wxSize clientsize = GetClientSize();
m_FrameSize = clientsize;
clientsize.y -= m_MsgFrameHeight;
if( MsgPanel )
{
MsgPanel->SetSize( 0, clientsize.y, clientsize.x, m_MsgFrameHeight );
}
if( DrawPanel )
{
int xpos = m_LibListSize.x + m_CmpListSize.x;
DrawPanel->SetSize( xpos, 0,
clientsize.x - xpos, clientsize.y );
}
if( m_LibList && m_LibListWindow )
{
m_LibListSize.y = clientsize.y - 2;
m_LibListWindow->SetSize( m_LibListSize );
m_LibList->SetSize( m_LibListWindow->GetClientSize() -
wxSize( EXTRA_BORDER_SIZE * 2, 0 ) );
}
if( m_CmpList && m_CmpListWindow )
{
m_CmpListSize.y = clientsize.y - 2;
m_CmpListWindow->SetSize( m_CmpListSize );
m_CmpListWindow->SetPosition( wxPoint( m_LibListSize.x, 0 ) );
m_CmpList->SetSize( m_CmpListWindow->GetClientSize() -
wxSize( EXTRA_BORDER_SIZE * 2, 0 ) );
}
SizeEv.Skip();
// Ensure the panel is always redrawn (sometimes some garbage remains):
DrawPanel->Refresh();
#else
if( m_auimgr.GetManagedWindow() ) if( m_auimgr.GetManagedWindow() )
m_auimgr.Update(); m_auimgr.Update();
SizeEv.Skip(); SizeEv.Skip();
#endif
} }
......
...@@ -79,7 +79,8 @@ if(APPLE) ...@@ -79,7 +79,8 @@ if(APPLE)
set_target_properties(${GERBVIEW_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) set_target_properties(${GERBVIEW_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
endif(APPLE) endif(APPLE)
target_link_libraries(${GERBVIEW_NAME} common pcbcommon 3d-viewer polygon bitmaps kbool ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES}) target_link_libraries(${GERBVIEW_NAME} common pcbcommon 3d-viewer polygon bitmaps kbool
${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} ${GDI_PLUS_LIBRARIES})
install(TARGETS ${GERBVIEW_NAME} install(TARGETS ${GERBVIEW_NAME}
DESTINATION ${KICAD_BIN} DESTINATION ${KICAD_BIN}
......
...@@ -42,7 +42,14 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -42,7 +42,14 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize(); delta = GetScreen()->GetGridSize();
#ifdef USE_WX_ZOOM
delta.x = DC->LogicalToDeviceXRel( delta.x );
delta.y = DC->LogicalToDeviceYRel( delta.y );
Mouse = DrawPanel->CalcUnscrolledPosition( Mouse );
#else
GetScreen()->Scale( delta ); GetScreen()->Scale( delta );
#endif
if( delta.x == 0 ) if( delta.x == 0 )
delta.x = 1; delta.x = 1;
......
...@@ -283,7 +283,12 @@ void Trace_Segment( BOARD* aBrd, WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track ...@@ -283,7 +283,12 @@ void Trace_Segment( BOARD* aBrd, WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track
(double) (track->m_End.y - track->m_Start.y) ); (double) (track->m_End.y - track->m_Start.y) );
halfPenWidth = track->m_Width >> 1; halfPenWidth = track->m_Width >> 1;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( halfPenWidth ) < L_MIN_DESSIN )
#else
if( panel->GetScreen()->Scale( halfPenWidth ) < L_MIN_DESSIN ) if( panel->GetScreen()->Scale( halfPenWidth ) < L_MIN_DESSIN )
#endif
{ {
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, GRCircle( &panel->m_ClipBox, DC, track->m_Start.x,
track->m_Start.y, radius, 0, color ); track->m_Start.y, radius, 0, color );
...@@ -324,7 +329,12 @@ void Trace_Segment( BOARD* aBrd, WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track ...@@ -324,7 +329,12 @@ void Trace_Segment( BOARD* aBrd, WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track
radius = track->m_Width >> 1; radius = track->m_Width >> 1;
fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( radius ) < L_MIN_DESSIN )
#else
if( panel->GetScreen()->Scale( radius ) < L_MIN_DESSIN ) if( panel->GetScreen()->Scale( radius ) < L_MIN_DESSIN )
#endif
{ {
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, GRCircle( &panel->m_ClipBox, DC, track->m_Start.x,
track->m_Start.y, radius, 0, color ); track->m_Start.y, radius, 0, color );
...@@ -347,7 +357,12 @@ void Trace_Segment( BOARD* aBrd, WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track ...@@ -347,7 +357,12 @@ void Trace_Segment( BOARD* aBrd, WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track
l_piste = track->m_Width >> 1; l_piste = track->m_Width >> 1;
fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( l_piste ) < L_MIN_DESSIN )
#else
if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN ) if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN )
#endif
{ {
GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
track->m_End.x, track->m_End.y, 0, color ); track->m_End.x, track->m_End.y, 0, color );
...@@ -378,7 +393,11 @@ void Trace_Segment( BOARD* aBrd, WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track ...@@ -378,7 +393,11 @@ void Trace_Segment( BOARD* aBrd, WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track
case S_SEGMENT: case S_SEGMENT:
l_piste = track->m_Width >> 1; l_piste = track->m_Width >> 1;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( l_piste ) < L_MIN_DESSIN )
#else
if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN ) if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN )
#endif
{ {
GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
track->m_End.x, track->m_End.y, 0, color ); track->m_End.x, track->m_End.y, 0, color );
......
...@@ -26,7 +26,8 @@ public: ...@@ -26,7 +26,8 @@ public:
wxPoint m_CursorStartPos; // useful in testing the cursor wxPoint m_CursorStartPos; // useful in testing the cursor
// movement // movement
int m_ScrollButt_unit; // scroll bar pixels per unit value int m_scrollIncrementX; // X axis scroll increment in pixels per unit.
int m_scrollIncrementY; // Y axis scroll increment in pixels per unit.
bool m_AbortRequest; // Flag to abort long commands bool m_AbortRequest; // Flag to abort long commands
...@@ -59,7 +60,6 @@ public: ...@@ -59,7 +60,6 @@ public:
int m_CursorLevel; // Index for cursor redraw in XOR int m_CursorLevel; // Index for cursor redraw in XOR
// mode // mode
/* Cursor management (used in editing functions) */ /* Cursor management (used in editing functions) */
/* Mouse capture move callback function prototype. */ /* Mouse capture move callback function prototype. */
...@@ -124,6 +124,24 @@ public: ...@@ -124,6 +124,24 @@ public:
void OnActivate( wxActivateEvent& event ); void OnActivate( wxActivateEvent& event );
/**
* Prepare the device context for drawing.
*
* This overrides wxScrolledWindow::DoPrepareDC() for drawing depending
* on the render mode selected a build time. If the old kicad coordinate
* scaling code is used then this code doesn't do any thing other than
* update the boundary box. If wxDC coordinate manipulation is used, then
* the scale factor and drawing logical offset is set. Then the base
* method is called to set the DC device origin and user scale. This
* connects everything together to acheive the appropiate coordinate
* manipulation using wxDC LogicalToDeviceXXX and DeviceToLogixalXXX
* methods. This gets called automatically for a paint event. If you do
* any drawing outside the paint event, you must call DoPrepareDC manually.
*
* @param dc - The device context to prepare.
*/
virtual void DoPrepareDC(wxDC& dc);
/* Mouse and keys events */ /* Mouse and keys events */
void OnMouseWheel( wxMouseEvent& event ); void OnMouseWheel( wxMouseEvent& event );
void OnMouseEvent( wxMouseEvent& event ); void OnMouseEvent( wxMouseEvent& event );
...@@ -146,7 +164,7 @@ public: ...@@ -146,7 +164,7 @@ public:
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
bool IsPointOnDisplay( wxPoint ref_pos ); bool IsPointOnDisplay( wxPoint ref_pos );
void SetBoundaryBox(); void SetBoundaryBox( wxDC* dc );
void ReDraw( wxDC* DC, bool erasebg = TRUE ); void ReDraw( wxDC* DC, bool erasebg = TRUE );
/** Function CursorRealPosition /** Function CursorRealPosition
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
#include <wx/dcbuffer.h> #include <wx/dcbuffer.h>
#endif #endif
#if USE_WX_GRAPHICS_CONTEXT && USE_WX_ZOOM
#include <wx/dcgraph.h>
#endif
// Helper class to handle the client Device Context // Helper class to handle the client Device Context
class KicadGraphicContext : public wxClientDC class KicadGraphicContext : public wxClientDC
{ {
...@@ -31,19 +35,39 @@ public: ...@@ -31,19 +35,39 @@ public:
// Macro used to declare a device context in kicad: // Macro used to declare a device context in kicad:
#if USE_WX_GRAPHICS_CONTEXT && USE_WX_ZOOM
#define INSTALL_DC(name,parent) \
wxClientDC _cDC( parent ); \
wxGCDC name(_cDC); \
parent->DoPrepareDC( name ); \
name.GetGraphicsContext()->Translate( 0.5, 0.5 );
#else
#ifdef KICAD_USE_BUFFERED_DC #ifdef KICAD_USE_BUFFERED_DC
#define INSTALL_DC(name,parent) \ #define INSTALL_DC(name,parent) \
KicadGraphicContext _cDC( parent );\ wxClientDC _cDC( parent ); \
wxBufferedDC name(&_cDC, _cDC.GetSize() ); wxBufferedDC name(&_cDC, _cDC.GetSize() ); \
parent->DoPrepareDC( name );
#else #else
#define INSTALL_DC(name,parent) KicadGraphicContext name( parent ) #define INSTALL_DC(name,parent) \
wxClientDC name( parent ); \
parent->DoPrepareDC( name );
#endif
#endif #endif
#ifdef KICAD_USE_BUFFERED_PAINTDC #if USE_WX_GRAPHICS_CONTEXT
#define INSTALL_PAINTDC(name,parent) wxAutoBufferedPaintDC name(parent ) #define INSTALL_PAINTDC(name,parent) \
wxPaintDC _pDC(parent); \
wxGCDC name(_pDC); \
parent->DoPrepareDC( name ); \
name.GetGraphicsContext()->Translate( 0.5, 0.5);
#elif !defined( USE_WX_ZOOM ) && defined( KICAD_USE_BUFFERED_PAINTDC )
#define INSTALL_PAINTDC(name,parent) \
wxAutoBufferedPaintDC name(parent ); \
parent->DoPrepareDC( name );
#else #else
#define INSTALL_PAINTDC(name,parent) wxPaintDC name( parent ) #define INSTALL_PAINTDC(name,parent) \
wxPaintDC name( parent ); \
parent->DoPrepareDC( name );
#endif #endif
#endif // __KICAD_DEVICE_CONTEXT_H__ #endif // __KICAD_DEVICE_CONTEXT_H__
...@@ -13,10 +13,7 @@ ...@@ -13,10 +13,7 @@
#include "wx/config.h" #include "wx/config.h"
#include <wx/wxhtml.h> #include <wx/wxhtml.h>
#include <wx/laywin.h> #include <wx/laywin.h>
#if defined(KICAD_AUIMANAGER) || defined(KICAD_AUITOOLBAR)
#include <wx/aui/aui.h> #include <wx/aui/aui.h>
#endif
#include "colors.h" #include "colors.h"
...@@ -103,9 +100,7 @@ public: ...@@ -103,9 +100,7 @@ public:
// It is "SchematicFrame", "PcbFrame" .... // It is "SchematicFrame", "PcbFrame" ....
wxString m_AboutTitle; // Name of program displayed in About. wxString m_AboutTitle; // Name of program displayed in About.
#ifdef KICAD_AUIMANAGER
wxAuiManager m_auimgr; wxAuiManager m_auimgr;
#endif
public: public:
WinEDA_BasicFrame( wxWindow* father, int idtype, WinEDA_BasicFrame( wxWindow* father, int idtype,
...@@ -689,11 +684,7 @@ public: ...@@ -689,11 +684,7 @@ public:
/* class WinEDA_Toolbar */ /* class WinEDA_Toolbar */
/*************************/ /*************************/
#if defined(KICAD_AUITOOLBAR)
class WinEDA_Toolbar : public wxAuiToolBar class WinEDA_Toolbar : public wxAuiToolBar
#else
class WinEDA_Toolbar : public wxToolBar
#endif
{ {
public: public:
wxWindow* m_Parent; wxWindow* m_Parent;
...@@ -704,7 +695,6 @@ public: ...@@ -704,7 +695,6 @@ public:
WinEDA_Toolbar( id_toolbar type, wxWindow* parent, WinEDA_Toolbar( id_toolbar type, wxWindow* parent,
wxWindowID id, bool horizontal ); wxWindowID id, bool horizontal );
#if defined(KICAD_AUITOOLBAR)
bool GetToolState( int toolId ) { return GetToolToggled(toolId); }; bool GetToolState( int toolId ) { return GetToolToggled(toolId); };
void AddRadioTool( int toolid, void AddRadioTool( int toolid,
...@@ -721,7 +711,6 @@ public: ...@@ -721,7 +711,6 @@ public:
void SetToolNormalBitmap( int id, const wxBitmap& bitmap ) {}; void SetToolNormalBitmap( int id, const wxBitmap& bitmap ) {};
void SetRows( int nRows ) {}; void SetRows( int nRows ) {};
#endif
/** Function GetDimension /** Function GetDimension
* @return the dimension of this toolbar (Height if horizontal, Width if vertical. * @return the dimension of this toolbar (Height if horizontal, Width if vertical.
......
...@@ -49,7 +49,7 @@ install(TARGETS KiCad ...@@ -49,7 +49,7 @@ install(TARGETS KiCad
DESTINATION ${KICAD_BIN} DESTINATION ${KICAD_BIN}
COMPONENT binary) COMPONENT binary)
else(APPLE) else(APPLE)
target_link_libraries(kicad common bitmaps ${wxWidgets_LIBRARIES}) target_link_libraries(kicad common bitmaps ${wxWidgets_LIBRARIES} ${GDI_PLUS_LIBRARIES})
install(TARGETS kicad install(TARGETS kicad
DESTINATION ${KICAD_BIN} DESTINATION ${KICAD_BIN}
COMPONENT binary) COMPONENT binary)
......
...@@ -259,9 +259,7 @@ void WinEDA_MainFrame::RecreateBaseHToolbar() ...@@ -259,9 +259,7 @@ void WinEDA_MainFrame::RecreateBaseHToolbar()
// Allocate memory for m_HToolBar // Allocate memory for m_HToolBar
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE ); m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
#if !defined(KICAD_AUIMANAGER)
SetToolBar( (wxToolBar*)m_HToolBar );
#endif
// Set up toolbar // Set up toolbar
m_HToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString, m_HToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString,
wxBitmap( new_project_xpm ), wxBitmap( new_project_xpm ),
......
...@@ -67,23 +67,6 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, ...@@ -67,23 +67,6 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
// Bottom Window: box to display messages // Bottom Window: box to display messages
m_RightWin = new RIGHT_KM_FRAME( this ); m_RightWin = new RIGHT_KM_FRAME( this );
/* Setting the sash control interferes with wxAUIManager and prevents the
* right and left window panes from being resized.
*/
#ifndef KICAD_AUIMANAGER
m_LeftWin->SetDefaultSize( wxSize( m_LeftWin_Width, clientsize.y ) );
m_LeftWin->SetOrientation( wxLAYOUT_VERTICAL );
m_LeftWin->SetAlignment( wxLAYOUT_LEFT );
m_LeftWin->SetSashVisible( wxSASH_RIGHT, TRUE );
m_LeftWin->SetExtraBorderSize( 2 );
int rightWinWidth = clientsize.x - m_LeftWin_Width;
m_RightWin->SetDefaultSize( wxSize( rightWinWidth, clientsize.y ) );
m_RightWin->SetOrientation( wxLAYOUT_VERTICAL );
m_RightWin->SetAlignment( wxLAYOUT_RIGHT );
m_RightWin->SetExtraBorderSize( 2 );
#endif
msg = wxGetCwd(); msg = wxGetCwd();
line.Printf( _( "Ready\nWorking dir: %s\n" ), msg.GetData() ); line.Printf( _( "Ready\nWorking dir: %s\n" ), msg.GetData() );
PrintMsg( line ); PrintMsg( line );
...@@ -92,7 +75,6 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, ...@@ -92,7 +75,6 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::LoadProject" ) ); PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::LoadProject" ) );
#endif #endif
#if defined(KICAD_AUIMANAGER)
RecreateBaseHToolbar(); RecreateBaseHToolbar();
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
...@@ -121,15 +103,12 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, ...@@ -121,15 +103,12 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
CloseButton( false ).Left().BestSize( m_LeftWin_Width, clientsize.y ). CloseButton( false ).Left().BestSize( m_LeftWin_Width, clientsize.y ).
Layer( 1 ).CaptionVisible( false ) ); Layer( 1 ).CaptionVisible( false ) );
m_auimgr.Update(); m_auimgr.Update();
#endif
} }
WinEDA_MainFrame::~WinEDA_MainFrame() WinEDA_MainFrame::~WinEDA_MainFrame()
{ {
#if defined(KICAD_AUIMANAGER)
m_auimgr.UnInit(); m_auimgr.UnInit();
#endif
} }
...@@ -146,34 +125,15 @@ void WinEDA_MainFrame::PrintMsg( const wxString& text ) ...@@ -146,34 +125,15 @@ void WinEDA_MainFrame::PrintMsg( const wxString& text )
*/ */
void WinEDA_MainFrame::OnSashDrag( wxSashEvent& event ) void WinEDA_MainFrame::OnSashDrag( wxSashEvent& event )
{ {
#if defined(KICAD_AUIMANAGER)
#else
if( event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE )
return;
m_LeftWin_Width = event.GetDragRect().width;
m_LeftWin->SetDefaultSize( wxSize( m_LeftWin_Width, -1 ) );
wxLayoutAlgorithm layout;
layout.LayoutFrame( this );
#endif
event.Skip(); event.Skip();
} }
void WinEDA_MainFrame::OnSize( wxSizeEvent& event ) void WinEDA_MainFrame::OnSize( wxSizeEvent& event )
{ {
#if defined(KICAD_AUIMANAGER)
if( m_auimgr.GetManagedWindow() ) if( m_auimgr.GetManagedWindow() )
m_auimgr.Update(); m_auimgr.Update();
#else
wxLayoutAlgorithm layout;
layout.LayoutFrame( this );
#endif
event.Skip(); event.Skip();
} }
......
...@@ -222,7 +222,8 @@ if(APPLE) ...@@ -222,7 +222,8 @@ if(APPLE)
set_target_properties(${PCBNEW_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) set_target_properties(${PCBNEW_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
endif(APPLE) endif(APPLE)
target_link_libraries(${PCBNEW_NAME} 3d-viewer common pcbcommon polygon bitmaps kbool ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES}) target_link_libraries(${PCBNEW_NAME} 3d-viewer common pcbcommon polygon bitmaps kbool
${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} ${GDI_PLUS_LIBRARIES})
install(TARGETS ${PCBNEW_NAME} install(TARGETS ${PCBNEW_NAME}
DESTINATION ${KICAD_BIN} DESTINATION ${KICAD_BIN}
......
...@@ -431,7 +431,11 @@ void COTATION::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -431,7 +431,11 @@ void COTATION::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
typeaff = DisplayOpt.DisplayDrawItems; typeaff = DisplayOpt.DisplayDrawItems;
width = m_Width; width = m_Width;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( width ) < 2 )
#else
if( panel->GetScreen()->Scale( width ) < 2 ) if( panel->GetScreen()->Scale( width ) < 2 )
#endif
typeaff = FILAIRE; typeaff = FILAIRE;
switch( typeaff ) switch( typeaff )
......
...@@ -254,7 +254,12 @@ void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -254,7 +254,12 @@ void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
mode = DisplayOpt.DisplayDrawItems; mode = DisplayOpt.DisplayDrawItems;
if( m_Flags & FORCE_SKETCH ) if( m_Flags & FORCE_SKETCH )
mode = SKETCH; mode = SKETCH;
#ifdef USE_WX_ZOOM
if( l_piste < DC->DeviceToLogicalXRel( L_MIN_DESSIN ) )
#else
if( l_piste < panel->GetScreen()->Unscale( L_MIN_DESSIN ) ) if( l_piste < panel->GetScreen()->Unscale( L_MIN_DESSIN ) )
#endif
mode = FILAIRE; mode = FILAIRE;
switch( m_Shape ) switch( m_Shape )
......
...@@ -191,7 +191,12 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -191,7 +191,12 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if( !typeaff ) if( !typeaff )
typeaff = SKETCH; typeaff = SKETCH;
} }
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( m_Width ) < L_MIN_DESSIN )
#else
if( screen->Scale( m_Width ) < L_MIN_DESSIN ) if( screen->Scale( m_Width ) < L_MIN_DESSIN )
#endif
typeaff = FILAIRE; typeaff = FILAIRE;
switch( type_trace ) switch( type_trace )
......
...@@ -116,7 +116,12 @@ void MIREPCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -116,7 +116,12 @@ void MIREPCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
GRSetDrawMode( DC, mode_color ); GRSetDrawMode( DC, mode_color );
typeaff = DisplayOpt.DisplayDrawItems; typeaff = DisplayOpt.DisplayDrawItems;
width = m_Width; width = m_Width;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( width ) < 2 )
#else
if( panel->GetScreen()->Scale( width ) < 2 ) if( panel->GetScreen()->Scale( width ) < 2 )
#endif
typeaff = FILAIRE; typeaff = FILAIRE;
rayon = m_Size / 4; rayon = m_Size / 4;
......
...@@ -66,7 +66,11 @@ MODULE::~MODULE() ...@@ -66,7 +66,11 @@ MODULE::~MODULE()
void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int dim_ancre, int draw_mode ) int dim_ancre, int draw_mode )
{ {
#ifdef USE_WX_ZOOM
int anchor_size = DC->DeviceToLogicalXRel( dim_ancre );
#else
int anchor_size = panel->GetScreen()->Unscale( dim_ancre ); int anchor_size = panel->GetScreen()->Unscale( dim_ancre );
#endif
GRSetDrawMode( DC, draw_mode ); GRSetDrawMode( DC, draw_mode );
......
...@@ -432,8 +432,12 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, ...@@ -432,8 +432,12 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
switch( m_DrillShape ) switch( m_DrillShape )
{ {
case PAD_CIRCLE: case PAD_CIRCLE:
if( screen->Scale( hole ) > 1 ) /* draw hole if its size is enought
*/ #ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( hole ) > 1 )
#else
if( screen->Scale( hole ) > 1 ) /* draw hole if its size is enough */
#endif
GRFilledCircle( &panel->m_ClipBox, DC, cx0, cy0, hole, 0, GRFilledCircle( &panel->m_ClipBox, DC, cx0, cy0, hole, 0,
color, color ); color, color );
break; break;
...@@ -548,8 +552,12 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, ...@@ -548,8 +552,12 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
tsize = min( AreaSize.y, AreaSize.x / numpad_len ); tsize = min( AreaSize.y, AreaSize.x / numpad_len );
#define CHAR_SIZE_MIN 5 #define CHAR_SIZE_MIN 5
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when
// size too small. #ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
#else
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
#endif
{ {
tsize = (int) ( tsize * 0.8 ); // reserve room for tsize = (int) ( tsize * 0.8 ); // reserve room for
// marges and segments // marges and segments
...@@ -569,8 +577,11 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, ...@@ -569,8 +577,11 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
shortname_len = MAX( shortname_len, MIN_CHAR_COUNT ); shortname_len = MAX( shortname_len, MIN_CHAR_COUNT );
tsize = min( AreaSize.y, AreaSize.x / shortname_len ); tsize = min( AreaSize.y, AreaSize.x / shortname_len );
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too #ifdef USE_WX_ZOOM
// small. if( DC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
#else
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
#endif
{ {
if( !( !IsOnLayer( screen->m_Active_Layer ) if( !( !IsOnLayer( screen->m_Active_Layer )
&& DisplayOpt.ContrastModeDisplay ) ) && DisplayOpt.ContrastModeDisplay ) )
......
...@@ -356,7 +356,12 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, ...@@ -356,7 +356,12 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
width = m_Width; width = m_Width;
if( ( frame->m_DisplayModText == FILAIRE ) if( ( frame->m_DisplayModText == FILAIRE )
#ifdef USE_WX_ZOOM
|| ( DC->LogicalToDeviceXRel( width ) < L_MIN_DESSIN ) )
#else
|| ( screen->Scale( width ) < L_MIN_DESSIN ) ) || ( screen->Scale( width ) < L_MIN_DESSIN ) )
#endif
width = 0; width = 0;
else if( frame->m_DisplayModText == SKETCH ) else if( frame->m_DisplayModText == SKETCH )
width = -width; width = -width;
...@@ -367,7 +372,12 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, ...@@ -367,7 +372,12 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
if( brd->IsElementVisible( ANCHOR_VISIBLE ) ) if( brd->IsElementVisible( ANCHOR_VISIBLE ) )
{ {
color = brd->GetVisibleElementColor(ANCHOR_VISIBLE); color = brd->GetVisibleElementColor(ANCHOR_VISIBLE);
#ifdef USE_WX_ZOOM
int anchor_size = DC->DeviceToLogicalXRel( 2 );
#else
int anchor_size = screen->Unscale( 2 ); int anchor_size = screen->Unscale( 2 );
#endif
GRLine( &panel->m_ClipBox, DC, GRLine( &panel->m_ClipBox, DC,
pos.x - anchor_size, pos.y, pos.x - anchor_size, pos.y,
pos.x + anchor_size, pos.y, 0, color ); pos.x + anchor_size, pos.y, 0, color );
......
...@@ -597,13 +597,23 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin ...@@ -597,13 +597,23 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
{ {
rayon = (int) hypot( (double) ( m_End.x - m_Start.x ), rayon = (int) hypot( (double) ( m_End.x - m_Start.x ),
(double) ( m_End.y - m_Start.y ) ); (double) ( m_End.y - m_Start.y ) );
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( l_piste ) < L_MIN_DESSIN )
#else
if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN ) if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN )
#endif
{ {
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color ); GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color );
} }
else else
{ {
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( l_piste ) <= 1 ) /* Sketch mode if l_piste/zoom <= 1 */
#else
if( panel->GetScreen()->Scale( l_piste ) <= 1 ) /* Sketch mode if l_piste/zoom <= 1 */ if( panel->GetScreen()->Scale( l_piste ) <= 1 ) /* Sketch mode if l_piste/zoom <= 1 */
#endif
{ {
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color ); GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color );
} }
...@@ -621,7 +631,11 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin ...@@ -621,7 +631,11 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
return; return;
} }
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( l_piste ) < L_MIN_DESSIN )
#else
if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN ) if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN )
#endif
{ {
GRLine( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, GRLine( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
m_End.x, m_End.y, 0, color ); m_End.x, m_End.y, 0, color );
...@@ -671,7 +685,11 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin ...@@ -671,7 +685,11 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
if( len < THRESHOLD * m_Width ) if( len < THRESHOLD * m_Width )
return; return;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( m_Width ) < 6 ) // no room to display a text inside track
#else
if( panel->GetScreen()->Scale( m_Width ) < 6 ) // no room to display a text inside track if( panel->GetScreen()->Scale( m_Width ) < 6 ) // no room to display a text inside track
#endif
return; return;
if( GetNet() == 0 ) if( GetNet() == 0 )
...@@ -693,7 +711,12 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin ...@@ -693,7 +711,12 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
int angle = 0; int angle = 0;
if( (m_End.x - m_Start.x) == 0 ) // Vertical segment if( (m_End.x - m_Start.x) == 0 ) // Vertical segment
angle = 900; // angle is in 0.1 degree angle = 900; // angle is in 0.1 degree
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( tsize ) >= 6 )
#else
if( panel->GetScreen()->Scale( tsize ) >= 6 ) if( panel->GetScreen()->Scale( tsize ) >= 6 )
#endif
{ {
if( !(!IsOnLayer( curr_layer )&& DisplayOpt.ContrastModeDisplay) ) if( !(!IsOnLayer( curr_layer )&& DisplayOpt.ContrastModeDisplay) )
{ {
...@@ -757,12 +780,24 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi ...@@ -757,12 +780,24 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
rayon = m_Width >> 1; rayon = m_Width >> 1;
// for small via size on screen (rayon < 4 pixels) draw a simplified shape // for small via size on screen (rayon < 4 pixels) draw a simplified shape
#ifdef USE_WX_ZOOM
int radius_in_pixels = DC->LogicalToDeviceXRel( rayon );
#else
int radius_in_pixels = panel->GetScreen()->Scale( rayon ); int radius_in_pixels = panel->GetScreen()->Scale( rayon );
#endif
bool fast_draw = false; bool fast_draw = false;
// Vias are drawn as a filled circle or a double circle. The hole will be drawn later // Vias are drawn as a filled circle or a double circle. The hole will be drawn later
int drill_rayon = GetDrillValue() / 2; int drill_rayon = GetDrillValue() / 2;
#ifdef USE_WX_ZOOM
int inner_rayon = rayon - DC->DeviceToLogicalXRel( 2 );
#else
int inner_rayon = rayon - panel->GetScreen()->Unscale( 2 ); int inner_rayon = rayon - panel->GetScreen()->Unscale( 2 );
#endif
if( radius_in_pixels < 3 ) if( radius_in_pixels < 3 )
{ {
fast_draw = true; fast_draw = true;
...@@ -804,7 +839,11 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi ...@@ -804,7 +839,11 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
else else
GRSetDrawMode( DC, GR_XOR ); GRSetDrawMode( DC, GR_XOR );
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( drill_rayon ) > 1 ) /* draw hole if its size is enought */
#else
if( screen->Scale( drill_rayon ) > 1 ) /* draw hole if its size is enought */ if( screen->Scale( drill_rayon ) > 1 ) /* draw hole if its size is enought */
#endif
GRFilledCircle( &panel->m_ClipBox, DC, m_Start.x, GRFilledCircle( &panel->m_ClipBox, DC, m_Start.x,
m_Start.y, drill_rayon, 0, color, color ); m_Start.y, drill_rayon, 0, color, color );
...@@ -893,7 +932,12 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi ...@@ -893,7 +932,12 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
{ {
// calculate a good size for the text // calculate a good size for the text
int tsize = m_Width / len; int tsize = m_Width / len;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( tsize ) >= 6 )
#else
if( panel->GetScreen()->Scale( tsize ) >= 6 ) if( panel->GetScreen()->Scale( tsize ) >= 6 )
#endif
{ {
tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via
DrawGraphicText( panel, DC, m_Start, DrawGraphicText( panel, DC, m_Start,
......
...@@ -262,7 +262,14 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -262,7 +262,14 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize(); delta = GetScreen()->GetGridSize();
#ifdef USE_WX_ZOOM
delta.x = DC->LogicalToDeviceXRel( delta.x );
delta.y = DC->LogicalToDeviceYRel( delta.y );
Mouse = DrawPanel->CalcUnscrolledPosition( Mouse );
#else
GetScreen()->Scale( delta ); GetScreen()->Scale( delta );
#endif
if( delta.x <= 0 ) if( delta.x <= 0 )
delta.x = 1; delta.x = 1;
......
...@@ -188,7 +188,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, ...@@ -188,7 +188,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
if( DrawPanel ) if( DrawPanel )
DrawPanel->m_Block_Enable = TRUE; DrawPanel->m_Block_Enable = TRUE;
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz; wxAuiPaneInfo horiz;
...@@ -226,7 +226,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, ...@@ -226,7 +226,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() ); wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update(); m_auimgr.Update();
#endif
} }
...@@ -408,10 +407,9 @@ void WinEDA_ModuleEditFrame::SetToolbars() ...@@ -408,10 +407,9 @@ void WinEDA_ModuleEditFrame::SetToolbars()
} }
DisplayUnitsMsg(); DisplayUnitsMsg();
#if defined(KICAD_AUIMANAGER)
if( m_auimgr.GetManagedWindow() ) if( m_auimgr.GetManagedWindow() )
m_auimgr.Update(); m_auimgr.Update();
#endif
} }
...@@ -455,7 +453,14 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -455,7 +453,14 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize(); 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 ); GetScreen()->Scale( delta );
#endif
if( delta.x == 0 ) if( delta.x == 0 )
delta.x = 1; delta.x = 1;
......
...@@ -311,7 +311,6 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, ...@@ -311,7 +311,6 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
ReCreateAuxVToolbar(); ReCreateAuxVToolbar();
#if defined(KICAD_AUIMANAGER)
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz; wxAuiPaneInfo horiz;
...@@ -372,11 +371,6 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, ...@@ -372,11 +371,6 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() ); wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update(); m_auimgr.Update();
#else
if( m_AuxVToolBar )
m_AuxVToolBar->Show(m_show_microwave_tools);
#endif
SetToolbars(); SetToolbars();
ReFillLayerWidget(); // this is near end because contents establish size ReFillLayerWidget(); // this is near end because contents establish size
...@@ -617,5 +611,3 @@ void WinEDA_PcbFrame::SetVisibleAlls( ) ...@@ -617,5 +611,3 @@ void WinEDA_PcbFrame::SetVisibleAlls( )
for( int ii = 0; ii < PCB_VISIBLE(END_PCB_VISIBLE_LIST); ii++ ) for( int ii = 0; ii < PCB_VISIBLE(END_PCB_VISIBLE_LIST); ii++ )
m_Layers->SetRenderState( ii, true ); m_Layers->SetRenderState( ii, true );
} }
...@@ -32,9 +32,7 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar() ...@@ -32,9 +32,7 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar()
wxString msg; wxString msg;
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE ); m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
#if !defined(KICAD_AUIMANAGER)
SetToolBar( (wxToolBar*) m_HToolBar );
#endif
// Set up toolbar // Set up toolbar
m_HToolBar->AddTool( ID_MODEDIT_SELECT_CURRENT_LIB, wxEmptyString, m_HToolBar->AddTool( ID_MODEDIT_SELECT_CURRENT_LIB, wxEmptyString,
wxBitmap( open_library_xpm ), wxBitmap( open_library_xpm ),
......
...@@ -192,9 +192,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar() ...@@ -192,9 +192,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true ); m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true );
m_HToolBar->SetRows( 1 ); m_HToolBar->SetRows( 1 );
#if !defined(KICAD_AUIMANAGER)
SetToolBar( (wxToolBar*)m_HToolBar );
#endif
// Set up toolbar // Set up toolbar
m_HToolBar->AddTool( ID_NEW_BOARD, wxEmptyString, wxBitmap( new_xpm ), m_HToolBar->AddTool( ID_NEW_BOARD, wxEmptyString, wxBitmap( new_xpm ),
_( "New board" ) ); _( "New board" ) );
......
...@@ -265,13 +265,8 @@ void WinEDA_PcbFrame::SetToolbars() ...@@ -265,13 +265,8 @@ void WinEDA_PcbFrame::SetToolbars()
_( "Normal contrast display mode" ) : _( "Normal contrast display mode" ) :
_( "High contrast display mode" ) ); _( "High contrast display mode" ) );
#if !defined(KICAD_AUIMANAGER)
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1,
(m_AuxVToolBar && m_AuxVToolBar->IsShown()) ? true : false );
#else
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1,
m_auimgr.GetPane(wxT("m_AuxVToolBar")).IsShown() ); m_auimgr.GetPane(wxT("m_AuxVToolBar")).IsShown() );
#endif
} }
if( m_AuxiliaryToolBar ) if( m_AuxiliaryToolBar )
...@@ -281,8 +276,7 @@ void WinEDA_PcbFrame::SetToolbars() ...@@ -281,8 +276,7 @@ void WinEDA_PcbFrame::SetToolbars()
PrepareLayerIndicator(); PrepareLayerIndicator();
DisplayUnitsMsg(); DisplayUnitsMsg();
#if defined(KICAD_AUIMANAGER)
if(m_auimgr.GetManagedWindow()) if(m_auimgr.GetManagedWindow())
m_auimgr.Update(); m_auimgr.Update();
#endif
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment