dolphin-emulator/Externals/wxWidgets3/src/osx/scrolbar_osx.cpp
EmptyChaos 822326eea9 Update wxWidgets to 3.1.0
From wxWidgets master 81570ae070b35c9d52de47b1f14897f3ff1a66c7.

include/wx/defs.h -- __w64 warning disable patch by comex brought forward.

include/wx/msw/window.h -- added GetContentScaleFactor() which was not implemented on Windows but is necessary for wxBitmap scaling on Mac OS X so it needs to work to avoid #ifdef-ing the code.

src/gtk/window.cpp -- Modified DoSetClientSize() to direct call wxWindowGTK::DoSetSize() instead of using public wxWindowBase::SetSize() which now prevents derived classes (like wxAuiToolbar) intercepting the call and breaking it. This matches Windows which does NOT need to call DoSetSize internally. End result is this fixes Dolphin's debug tools toolbars on Linux.

src/osx/window_osx.cpp -- Same fix as for GTK since it has the same issue.

src/msw/radiobox.cpp -- Hacked to fix display in HiDPI (was clipping off end of text).

Updated CMakeLists for Linux and Mac OS X. Small code changes to Dolphin to fix debug error boxes, deprecation warnings, and retain previous UI behavior on Windows.
2016-06-26 15:25:29 +10:00

178 lines
4 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// Name: src/osx/scrolbar_osx.cpp
// Purpose: wxScrollBar
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#include "wx/scrolbar.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/settings.h"
#endif
#include "wx/osx/private.h"
#if wxUSE_SCROLLBAR
wxBEGIN_EVENT_TABLE(wxScrollBar, wxControl)
wxEND_EVENT_TABLE()
bool wxScrollBar::Create( wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name )
{
DontCreatePeer();
if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
return false;
SetPeer(wxWidgetImpl::CreateScrollBar( this, parent, id, pos, size, style, GetExtraStyle() ));
MacPostControlCreate( pos, size );
return true;
}
wxScrollBar::~wxScrollBar()
{
}
void wxScrollBar::SetThumbPosition( int viewStart )
{
GetPeer()->SetScrollThumb( viewStart, m_viewSize );
}
int wxScrollBar::GetThumbPosition() const
{
return GetPeer()->GetValue();
}
void wxScrollBar::SetScrollbar( int position,
int thumbSize,
int range,
int pageSize,
bool WXUNUSED(refresh) )
{
m_pageSize = pageSize;
m_viewSize = thumbSize;
m_objectSize = range;
int range1 = wxMax( (m_objectSize - m_viewSize), 0 );
GetPeer()->SetMaximum( range1 );
GetPeer()->SetScrollThumb( position, m_viewSize );
}
void wxScrollBar::Command( wxCommandEvent& event )
{
SetThumbPosition( event.GetInt() );
ProcessCommand( event );
}
bool wxScrollBar::OSXHandleClicked( double WXUNUSED(timestampsec) )
{
int new_pos = GetPeer()->GetValue();
wxScrollEvent event( wxEVT_SCROLL_THUMBRELEASE, m_windowId );
if ( m_windowStyle & wxHORIZONTAL )
event.SetOrientation( wxHORIZONTAL );
else
event.SetOrientation( wxVERTICAL );
event.SetPosition( new_pos );
event.SetEventObject( this );
wxWindow* window = GetParent();
if (window && window->MacIsWindowScrollbar( this ))
// this is hardcoded
window->MacOnScroll( event );
else
HandleWindowEvent( event );
return true;
}
wxSize wxScrollBar::DoGetBestSize() const
{
int w = 100;
int h = 100;
if ( IsVertical() )
{
w = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
}
else
{
h = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
}
wxSize best(w, h);
CacheBestSize(best);
return best;
}
void wxScrollBar::TriggerScrollEvent( wxEventType scrollEvent )
{
int position = GetPeer()->GetValue();
int minPos = 0 ;
int maxPos = GetPeer()->GetMaximum();
int nScrollInc = 0;
if ( scrollEvent == wxEVT_SCROLL_LINEUP )
{
nScrollInc = -1;
}
else if ( scrollEvent == wxEVT_SCROLL_LINEDOWN )
{
nScrollInc = 1;
}
else if ( scrollEvent == wxEVT_SCROLL_PAGEUP )
{
nScrollInc = -m_pageSize;
}
else if ( scrollEvent == wxEVT_SCROLL_PAGEDOWN )
{
nScrollInc = m_pageSize;
}
int new_pos = position + nScrollInc;
if (new_pos < minPos)
new_pos = minPos;
else if (new_pos > maxPos)
new_pos = maxPos;
if ( nScrollInc )
SetThumbPosition( new_pos );
wxScrollEvent event( scrollEvent, m_windowId );
if ( m_windowStyle & wxHORIZONTAL )
event.SetOrientation( wxHORIZONTAL );
else
event.SetOrientation( wxVERTICAL );
event.SetPosition( new_pos );
event.SetEventObject( this );
wxWindow* window = GetParent();
if (window && window->MacIsWindowScrollbar( this ))
// this is hardcoded
window->MacOnScroll( event );
else
HandleWindowEvent( event );
}
#endif