예제 #1
0
void wxTabView::SetTabSelection(int sel, bool activateTool)
{
  if ( sel==m_tabSelection )
    return;

  int oldSel = m_tabSelection;
  wxTabControl *control = FindTabControlForId(sel);
  if (sel == 0) sel=control->GetId();
  wxTabControl *oldControl = FindTabControlForId(m_tabSelection);

  if (!OnTabPreActivate(sel, oldSel))
    return;

  if (control)
    control->SetSelected((sel != -1)); // TODO ??
  else if (sel != -1)
  {
    wxFAIL_MSG(_("Could not find tab for id"));
    return;
  }

  if (oldControl)
    oldControl->SetSelected(false);

  m_tabSelection = sel;

  if (control)
    MoveSelectionTab(control);

  if (activateTool)
    OnTabActivate(sel, oldSel);
}
예제 #2
0
bool wxTabView::ChangeTab(wxTabControl *control)
{
  wxTabControl *currentTab = FindTabControlForId(m_tabSelection);
  int oldTab = -1;
  if (currentTab)
    oldTab = currentTab->GetId();

  if (control == currentTab)
    return true;

  if (m_layers.GetCount() == 0)
    return false;

  if (!OnTabPreActivate(control->GetId(), oldTab))
    return false;

  // Move the tab to the bottom
  MoveSelectionTab(control);

  if (currentTab)
    currentTab->SetSelected(false);

  control->SetSelected(true);
  m_tabSelection = control->GetId();

  OnTabActivate(control->GetId(), oldTab);

  // Leave window refresh for the implementing window

  return true;
}
예제 #3
0
wxString wxTabView::GetTabText(int id) const
{
    wxTabControl* control = FindTabControlForId(id);
    if (!control)
      return wxEmptyString;
    else
      return control->GetLabel();
}
예제 #4
0
bool wxTabView::SetTabText(int id, const wxString& label)
{
    wxTabControl* control = FindTabControlForId(id);
    if (!control)
      return false;
    control->SetLabel(label);
    return true;
}
예제 #5
0
// Process mouse event, return false if we didn't process it
bool wxTabView::OnEvent(wxMouseEvent& event)
{
  if (!event.LeftDown())
    return false;

  wxCoord x, y;
  event.GetPosition(&x, &y);

  wxTabControl *hitControl = NULL;

  wxTabLayerList::compatibility_iterator node = m_layers.GetFirst();
  while (node)
  {
    wxTabLayer *layer = (wxTabLayer *)node->GetData();
    wxList::compatibility_iterator node2 = layer->GetFirst();
    while (node2)
    {
      wxTabControl *control = (wxTabControl *)node2->GetData();
      if (control->HitTest((int)x, (int)y))
      {
        hitControl = control;
        node = wxTabLayerList::compatibility_iterator();
        node2 = wxList::compatibility_iterator();
      }
      else
        node2 = node2->GetNext();
    }

    if (node)
      node = node->GetNext();
  }

  if (!hitControl)
    return false;

  wxTabControl *currentTab = FindTabControlForId(m_tabSelection);

  if (hitControl == currentTab)
    return false;

  ChangeTab(hitControl);

  return true;
}
예제 #6
0
// Layout tabs (optional, e.g. if resizing window)
void wxTabView::LayoutTabs(void)
{
  // Make a list of the tab controls, deleting the wxTabLayers.
  wxList controls;

  wxTabLayerList::compatibility_iterator layerNode = m_layers.GetFirst();
  while (layerNode)
  {
    wxTabLayer *layer = (wxTabLayer *)layerNode->GetData();
    wxList::compatibility_iterator tabNode = layer->GetFirst();
    while (tabNode)
    {
      wxTabControl *tab = (wxTabControl *)tabNode->GetData();
      controls.Append(tab);
      wxList::compatibility_iterator next = tabNode->GetNext();
      layer->Erase(tabNode);
      tabNode = next;
    }
    wxTabLayerList::compatibility_iterator nextLayerNode = layerNode->GetNext();
    delete layer;
    m_layers.Erase(layerNode);
    layerNode = nextLayerNode;
  }

  wxTabControl *lastTab = NULL;

  wxTabLayer *currentLayer = new wxTabLayer;
  m_layers.Append(currentLayer);

  wxList::compatibility_iterator node = controls.GetFirst();
  while (node)
  {
    wxTabControl *tabControl = (wxTabControl *)node->GetData();
    if (lastTab)
    {
      // Start another layer (row).
      // Tricky choice: can't just check if will be overlapping the edge, because
      // this happens anyway for 2nd and subsequent rows.
      // Should check this for 1st row, and then subsequent rows should not exceed 1st
      // in length.
      if (((currentLayer == m_layers.GetFirst()->GetData()) && ((lastTab->GetX() + 2*lastTab->GetWidth() + GetHorizontalTabSpacing())
                > GetViewRect().width)) ||
          ((currentLayer != m_layers.GetFirst()->GetData()) && (currentLayer->GetCount() == ((wxTabLayer *)m_layers.GetFirst()->GetData())->GetCount())))
     {
       currentLayer = new wxTabLayer;
       m_layers.Append(currentLayer);
       lastTab = NULL;
     }
    }

    int layer = m_layers.GetCount() - 1;

    tabControl->SetRowPosition(currentLayer->GetCount());
    tabControl->SetColPosition(layer);

    // Top of new tab
    int verticalOffset = (- GetTopMargin()) - ((layer+1)*GetTabHeight());
    // Offset from view top-left
    int horizontalOffset = 0;
    if (!lastTab)
      horizontalOffset = layer*GetHorizontalTabOffset();
    else
      horizontalOffset = lastTab->GetX() + GetTabWidth() + GetHorizontalTabSpacing();

    tabControl->SetPosition(horizontalOffset, verticalOffset);
    tabControl->SetSize(GetTabWidth(), GetTabHeight());

    currentLayer->Append(tabControl);
    lastTab = tabControl;

    node = node->GetNext();
  }

  // Move the selected tab to the bottom
  wxTabControl *control = FindTabControlForId(m_tabSelection);
  if (control)
    MoveSelectionTab(control);

}
예제 #7
0
// Process mouse event, return false if we didn't process it
bool wxTabView::OnEvent(wxMouseEvent& event)
{
  if (!event.LeftDown())
    return false;

  wxCoord x, y;
  event.GetPosition(&x, &y);

  wxTabControl *hitControl = NULL;

  wxTabLayerList::compatibility_iterator node = m_layers.GetFirst();
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
  while (node)
  {
    wxTabLayer *layer = (wxTabLayer *)node->GetData();
    wxList::compatibility_iterator node2 = layer->GetFirst();
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    while (node2)
    {
      wxTabControl *control = (wxTabControl *)node2->GetData();
      if (control->HitTest((int)x, (int)y))
      {
        hitControl = control;
        node = wxTabLayerList::compatibility_iterator();
        node2 = wxList::compatibility_iterator();
      }
      else
        node2 = node2->GetNext();
    }

    if (node)
      node = node->GetNext();
  }

  if (!hitControl)
    return false;

  wxTabControl *currentTab = FindTabControlForId(m_tabSelection);

  if (hitControl == currentTab)
    return false;

  ChangeTab(hitControl);

  return true;
}