Exemplo n.º 1
0
void wxMenu::Attach(wxMenuBarBase *menubar)
{
    wxMenuBase::Attach(menubar);

    // inherit layout direction from menubar.
    SetLayoutDirection(menubar->GetLayoutDirection());
}
EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
                                const wxPoint& pos, const wxSize& size ) :
    wxScrolledWindow( parent, id, pos, size, drawPanelStyle )
{
    wxASSERT( parent );

    ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
    DisableKeyboardScrolling();

    m_scrollIncrementX = std::min( size.x / 8, 10 );
    m_scrollIncrementY = std::min( size.y / 8, 10 );

    SetLayoutDirection( wxLayout_LeftToRight );

    SetBackgroundColour( parent->GetDrawBgColor().ToColour() );

#if KICAD_USE_BUFFERED_DC || KICAD_USE_BUFFERED_PAINTDC
    SetBackgroundStyle( wxBG_STYLE_CUSTOM );
#endif

    m_ClipBox.SetSize( size );
    m_ClipBox.SetX( 0 );
    m_ClipBox.SetY( 0 );
    m_canStartBlock = -1;       // Command block can start if >= 0
    m_abortRequest = false;
    m_enableMousewheelPan = false;
    m_enableZoomNoCenter = false;
    m_enableAutoPan = true;
    m_ignoreMouseEvents = false;
    // Be sure a mouse release button event will be ignored when creating the canvas
    // if the mouse click was not made inside the canvas (can happen sometimes, when
    // launching a editor from a double click made in another frame)
    m_ignoreNextLeftButtonRelease = true;

    m_mouseCaptureCallback = NULL;
    m_endMouseCaptureCallback = NULL;

    Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &m_enableMousewheelPan, false );
    Pgm().CommonSettings()->Read( ENBL_ZOOM_NO_CENTER_KEY, &m_enableZoomNoCenter, false );
    Pgm().CommonSettings()->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true );

    m_requestAutoPan = false;
    m_enableBlockCommands = false;
    m_minDragEventCount = 0;

#ifdef __WXMAC__
    m_defaultCursor = m_currentCursor = wxCURSOR_CROSS;
    m_showCrossHair = false;
#else
    m_defaultCursor = m_currentCursor = wxCURSOR_ARROW;
    m_showCrossHair = true;
#endif

    m_cursorLevel = 0;
    m_PrintIsMirrored = false;

    m_ClickTimer = (wxTimer*) NULL;
    m_doubleClickInterval = 250;
}
EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
                                        const wxPoint& aPosition, const wxSize& aSize,
                                        GAL_TYPE aGalType ) :
    wxScrolledCanvas( aParentWindow, aWindowId, aPosition, aSize )
{
    m_parent     = aParentWindow;
    m_edaFrame   = dynamic_cast<EDA_DRAW_FRAME*>( aParentWindow );
    m_gal        = NULL;
    m_backend    = GAL_TYPE_NONE;
    m_view       = NULL;
    m_painter    = NULL;
    m_eventDispatcher = NULL;
    m_lostFocus  = false;

    SetLayoutDirection( wxLayout_LeftToRight );

    SwitchBackend( aGalType );
    SetBackgroundStyle( wxBG_STYLE_CUSTOM );
    
// Scrollbars broken in GAL on OSX
#ifdef __WXMAC__
    ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
#else
    ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
#endif
    EnableScrolling( false, false );    // otherwise Zoom Auto disables GAL canvas

    m_painter = new KIGFX::PCB_PAINTER( m_gal );

    m_view = new KIGFX::VIEW( true );
    m_view->SetPainter( m_painter );
    m_view->SetGAL( m_gal );

    Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
    Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
    Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), NULL, this );

    const wxEventType events[] =
    {
        wxEVT_LEFT_UP, wxEVT_LEFT_DOWN, wxEVT_LEFT_DCLICK,
        wxEVT_RIGHT_UP, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_DCLICK,
        wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_DCLICK,
        wxEVT_MOTION, wxEVT_MOUSEWHEEL, wxEVT_CHAR,
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
        wxEVT_MAGNIFY,
#endif
        KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE
    };

    BOOST_FOREACH( wxEventType eventType, events )
    {
        Connect( eventType, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ),
                 NULL, m_eventDispatcher );
    }
AutoPtr<ArrayOf<Int32> > RelativeLayoutLayoutParams::GetRules(
    /* [in] */ Int32 layoutDirection)
{
    if (HasRelativeRules() &&
            (mRulesChanged || layoutDirection != GetLayoutDirection())) {
        ResolveRules(layoutDirection);
        if (layoutDirection != GetLayoutDirection()) {
            SetLayoutDirection(layoutDirection);
        }
    }
    return mRules;
}
Exemplo n.º 5
0
void wxMenuBar::Attach(wxFrame *frame)
{
    wxMenuBarBase::Attach(frame);

    wxMenuList::compatibility_iterator node = m_menus.GetFirst();
    while (node)
    {
        wxMenu *menu = node->GetData();
        AttachToFrame( menu, frame );
        node = node->GetNext();
    }

    SetLayoutDirection(wxLayout_Default);
}
Exemplo n.º 6
0
VideoDisplay::VideoDisplay(wxToolBar *toolbar, bool freeSize, wxComboBox *zoomBox, wxWindow *parent, agi::Context *c)
: wxGLCanvas(parent, -1, attribList)
, autohideTools(OPT_GET("Tool/Visual/Autohide"))
, con(c)
, zoomValue(OPT_GET("Video/Default Zoom")->GetInt() * .125 + .125)
, toolBar(toolbar)
, zoomBox(zoomBox)
, freeSize(freeSize)
, retina_helper(agi::make_unique<RetinaHelper>(this))
, scale_factor(retina_helper->GetScaleFactor())
, scale_factor_connection(retina_helper->AddScaleFactorListener([=](int new_scale_factor) {
	double new_zoom = zoomValue * new_scale_factor / scale_factor;
	scale_factor = new_scale_factor;
	SetZoom(new_zoom);
}))
{
	zoomBox->SetValue(fmt_wx("%g%%", zoomValue * 100.));
	zoomBox->Bind(wxEVT_COMBOBOX, &VideoDisplay::SetZoomFromBox, this);
	zoomBox->Bind(wxEVT_TEXT_ENTER, &VideoDisplay::SetZoomFromBoxText, this);

	con->videoController->Bind(EVT_FRAME_READY, &VideoDisplay::UploadFrameData, this);
	connections = agi::signal::make_vector({
		con->project->AddVideoProviderListener(&VideoDisplay::UpdateSize, this),
		con->videoController->AddARChangeListener(&VideoDisplay::UpdateSize, this),
	});

	Bind(wxEVT_PAINT, std::bind(&VideoDisplay::Render, this));
	Bind(wxEVT_SIZE, &VideoDisplay::OnSizeEvent, this);
	Bind(wxEVT_CONTEXT_MENU, &VideoDisplay::OnContextMenu, this);
	Bind(wxEVT_ENTER_WINDOW, &VideoDisplay::OnMouseEvent, this);
	Bind(wxEVT_CHAR_HOOK, &VideoDisplay::OnKeyDown, this);
	Bind(wxEVT_LEAVE_WINDOW, &VideoDisplay::OnMouseLeave, this);
	Bind(wxEVT_LEFT_DCLICK, &VideoDisplay::OnMouseEvent, this);
	Bind(wxEVT_LEFT_DOWN, &VideoDisplay::OnMouseEvent, this);
	Bind(wxEVT_LEFT_UP, &VideoDisplay::OnMouseEvent, this);
	Bind(wxEVT_MOTION, &VideoDisplay::OnMouseEvent, this);
	Bind(wxEVT_MOUSEWHEEL, &VideoDisplay::OnMouseWheel, this);

	SetCursor(wxNullCursor);

	c->videoDisplay = this;

	con->videoController->JumpToFrame(con->videoController->GetFrameN());

	SetLayoutDirection(wxLayout_LeftToRight);
}
Exemplo n.º 7
0
bool wxStaticBox::Create(wxWindow *parent,
                         wxWindowID id,
                         const wxString& label,
                         const wxPoint& pos,
                         const wxSize& size,
                         long style,
                         const wxString& name)
{
    if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
        return false;

    if ( !MSWCreateControl(wxT("BUTTON"), label, pos, size) )
        return false;

    // Always use LTR layout. Otherwise, the label would be mirrored.
    SetLayoutDirection(wxLayout_LeftToRight);

#ifndef __WXWINCE__
    if (!wxSystemOptions::IsFalse(wxT("msw.staticbox.optimized-paint")))
        Connect(wxEVT_PAINT, wxPaintEventHandler(wxStaticBox::OnPaint));
#endif // !__WXWINCE__

    return true;
}
EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
                                        const wxPoint& aPosition, const wxSize& aSize,
                                        GAL_TYPE aGalType ) :
    wxScrolledCanvas( aParentWindow, aWindowId, aPosition, aSize )
{
    m_parent     = aParentWindow;
    m_edaFrame   = dynamic_cast<EDA_DRAW_FRAME*>( aParentWindow );
    m_gal        = NULL;
    m_backend    = GAL_TYPE_NONE;
    m_view       = NULL;
    m_painter    = NULL;
    m_eventDispatcher = NULL;
    m_lostFocus  = false;

    SetLayoutDirection( wxLayout_LeftToRight );

    SwitchBackend( aGalType );
    SetBackgroundStyle( wxBG_STYLE_CUSTOM );

// Scrollbars broken in GAL on OSX
#ifdef __WXMAC__
    ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
#else
    ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
#endif
    EnableScrolling( false, false );    // otherwise Zoom Auto disables GAL canvas

    m_painter = new KIGFX::PCB_PAINTER( m_gal );

    m_view = new KIGFX::VIEW( true );
    m_view->SetPainter( m_painter );
    m_view->SetGAL( m_gal );

    Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
    Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
    Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), NULL, this );

    const wxEventType events[] =
    {
        wxEVT_LEFT_UP, wxEVT_LEFT_DOWN, wxEVT_LEFT_DCLICK,
        wxEVT_RIGHT_UP, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_DCLICK,
        wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_DCLICK,
        wxEVT_MOTION, wxEVT_MOUSEWHEEL, wxEVT_CHAR,
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
        wxEVT_MAGNIFY,
#endif
        KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE
    };

    for( wxEventType eventType : events )
    {
        Connect( eventType, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ),
                 NULL, m_eventDispatcher );
    }

    // View controls is the first in the event handler chain, so the Tool Framework operates
    // on updated viewport data.
    m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );

    m_pendingRefresh = false;
    m_drawing = false;
    m_drawingEnabled = false;

    // Set up timer that prevents too frequent redraw commands
    m_refreshTimer.SetOwner( this );
    Connect( m_refreshTimer.GetId(), wxEVT_TIMER,
            wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this );

    // Set up timer to execute OnShow() method when the window appears on the screen
    m_onShowTimer.SetOwner( this );
    Connect( m_onShowTimer.GetId(), wxEVT_TIMER,
            wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onShowTimer ), NULL, this );
    m_onShowTimer.Start( 10 );

    LoadGalSettings();
}
Exemplo n.º 9
0
ruiLinearLayout::ruiLinearLayout(ruiLayoutDirection layoutDirection, const rString& id, ruiIDocument* document, rEngine* engine) 
	:ruiLayout(id,document, engine){
	SetLayoutDirection(layoutDirection);
}
Exemplo n.º 10
0
HRESULT ui::UIListBox::Initialize(graphics::D3DInteropHelper *pD3DInteropHelper) {
#ifdef DEBUG_UILISTBOX
  LOG_ENTER(SEVERITY_LEVEL_DEBUG);
#endif
  assert(GetWidth() > 0.0f);
  assert(GetHeight() > 0.0f);

  ui::UIListBoxItem::LAYOUT_DIRECTION layoutDirection = ui::UIListBoxItem::LAYOUT_DIRECTION_VERTICAL;

  switch (m_scrollDirection) {
  case ui::UIListBox::SCROLL_DIRECTION_HORIZONTAL:
    layoutDirection = ui::UIListBoxItem::LAYOUT_DIRECTION_VERTICAL;
    m_itemHeight = GetHeight();
    if (m_preferredTextAreaSize.height == 0.0f) {
      m_preferredTextAreaSize.height = GetHeight() - m_preferredBitmapSize.height - m_marginBetweenBitmapAndText;
    }
    if (m_preferredTextAreaSize.width == 0.0f) {
      m_preferredTextAreaSize.width = m_preferredBitmapSize.width * 3.0f;
    }
    m_itemWidth = m_preferredTextAreaSize.width;
    break;
  case ui::UIListBox::SCROLL_DIRECTION_VERTICAL:
    layoutDirection = ui::UIListBoxItem::LAYOUT_DIRECTION_HORIZONTAL;
    m_itemWidth = GetWidth();
    if (m_preferredTextAreaSize.width == 0.0f) {
      m_preferredTextAreaSize.width = GetWidth() - m_preferredBitmapSize.width - m_marginBetweenBitmapAndText;
    }
    if (m_preferredTextAreaSize.height == 0.0f) {
      m_preferredTextAreaSize.height = m_preferredBitmapSize.height;
    }
    m_itemHeight = m_preferredTextAreaSize.height;
    break;
  }
  for (size_t i = 0; i < GetNumberOfElements(); ++i) {
    auto element = GetElement(i);
    auto listBoxItem = std::dynamic_pointer_cast<UIListBoxItem>(element);
    if (listBoxItem.get() != nullptr) {
      listBoxItem->SetLayoutDirection(layoutDirection);
      listBoxItem->SetPreferredBitmapSize(m_preferredBitmapSize);
      listBoxItem->SetPreferredTextAreaSize(m_preferredTextAreaSize);
      listBoxItem->SetBounds(0.0f, 0.0f, m_itemWidth, m_itemHeight);
    }
  }
  CHK_WARN_HRESULT(UIContainer::Initialize(pD3DInteropHelper));

  auto frameDecorator = std::make_shared<graphics::decorator::FrameDecorator>();
  frameDecorator->SetColorSet(m_colorSet);
  for (size_t i = 0; i < m_colorSet->GetNumberOfColors(); ++i) {
    frameDecorator->AddFrame(graphics::decorator::Frame(i));
  }
  m_rectFigure->AddDecorator(frameDecorator);

  m_rectFigure->SetX(0.0f);
  m_rectFigure->SetY(0.0f);
  m_rectFigure->SetWidth(GetWidth());
  m_rectFigure->SetHeight(GetHeight());
  m_rectFigure->SetColor(graphics::color::ColorValue(graphics::color::ColorValue::COLOR_TYPE_RGBA, 0x222222, 1.0f),
                         graphics::color::COLOR_PATTERN_FLAT);
  CHK_WARN_HRESULT(m_rectFigure->Initialize(pD3DInteropHelper));

  m_scrollBar->SetParentContainer(shared_from_this());
  m_scrollBar->SetMinValue(0.0f);
  m_scrollBar->SetMaxValue(GetNumberOfElements() - 1.0f);
  m_scrollBar->SetPageSize(1.0f);
  if (m_scrollBar->GetCurrentValue() < m_scrollBar->GetMinValue()
      || m_scrollBar->GetCurrentValue() > m_scrollBar->GetMaxValue() - m_scrollBar->GetPageSize()) {
    m_scrollBar->SetCurrentValue(0.0f);
  }
  FLOAT frameThick = static_cast<FLOAT>(m_colorSet->GetNumberOfColors());
  if (m_scrollDirection == ui::UIListBox::SCROLL_DIRECTION_HORIZONTAL) {
    m_scrollBar->SetDirection(ui::UIScrollBar::SCROLLBAR_DIRECTION_HORIZONTAL);
    m_scrollBar->SetBounds(frameThick + m_scrollBarMarginFromSide,
                           GetHeight() - m_scrollBarThick - frameThick - m_scrollBarMarginFromSide,
                           GetWidth() - (frameThick + m_scrollBarMarginFromSide) * 2, m_scrollBarThick);
  } else {
    m_scrollBar->SetDirection(ui::UIScrollBar::SCROLLBAR_DIRECTION_VERTICAL);
    m_scrollBar->SetBounds(GetWidth() - m_scrollBarThick - frameThick - m_scrollBarMarginFromSide,
                           frameThick + m_scrollBarMarginFromSide, m_scrollBarThick,
                           GetHeight() - (frameThick + m_scrollBarMarginFromSide) * 2);
  }
  m_scrollBar->AddPositionChangedCallback([&](FLOAT position) { NotifyScrollPositionChanged(position); });
  CHK_FATAL_HRESULT(m_scrollBar->Initialize(pD3DInteropHelper));

#ifdef DEBUG_UILISTBOX
  LOG_LEAVE(SEVERITY_LEVEL_DEBUG);
#endif
  return S_OK;
}