Esempio n. 1
0
EditorTab* MapTabbook::GetCurrentTab()
{
	if(GetTabCount() == 0 || GetSelection() == -1) {
		return nullptr;
	}
	return dynamic_cast<EditorTab*>(GetInternalTab(GetSelection()));
}
JBoolean
JXTabGroup::ScrollForWheel
	(
	const JXMouseButton		button,
	const JXKeyModifiers&	modifiers
	)
{
	if ((button == kJXButton4 || button == kJXButton6) &&
		itsCanScrollUpFlag && itsFirstDrawIndex > 1)
		{
		itsFirstDrawIndex--;
		Refresh();
		return kJTrue;
		}
	else if ((button == kJXButton5 || button == kJXButton7) &&
			 itsCanScrollDownFlag && itsFirstDrawIndex < GetTabCount())
		{
		itsFirstDrawIndex++;
		Refresh();
		return kJTrue;
		}
	else
		{
		return kJFalse;
		}
}
Esempio n. 3
0
wxWindow* MapTabbook::GetCurrentPage()
{
	if(GetTabCount() == 0) {
		return nullptr;
	}
	return GetCurrentTab()->GetWindow();
}
int CGraphicTabControl::TotalTabWidth(void) const {
	int w = 0;
		for( int i = 0; i < GetTabCount(); i++ ) {
			w += GetTab( i ).m_nWidth;
		}
	return w;
}
Esempio n. 5
0
unsigned
TabBarControl::AddTab(Widget *widget, const TCHAR *caption, const Bitmap *bmp)
{
  pager.Add(widget);
  tab_display->Add(caption, bmp);
  return GetTabCount() - 1;
}
Esempio n. 6
0
// Gets the height of the specified view.
// nTab and nView are zero-based, nHeight is in %
int BDataViews::GetViewHeight(int nTab, int nView)
{
	ASSERT(nTab < GetTabCount());
	ASSERT(nView < GetViewCount(nTab));
	int nIndex = GetTabIndex(nTab) + nView;
	return m_avi[nIndex].m_lngViewHeight;
}
Esempio n. 7
0
// Sets the height of the specified view.
// nTab and nView are zero-based, nHeight is in %
BOOL BDataViews::SetViewHeight(int nTab, int nView, int nHeight)
{
	ASSERT(nTab < GetTabCount());
	ASSERT(nView < GetViewCount(nTab));
	int nIndex = GetTabIndex(nTab) + nView;
	m_avi[nIndex].m_lngViewHeight = nHeight;
	return TRUE;
}
Esempio n. 8
0
void MapTabbook::OnSwitchEditorMode(EditorMode mode)
{
	for(int32_t i = 0; i < GetTabCount(); ++i) {
		EditorTab* editorTab = GetTab(i);
		if(editorTab) {
			editorTab->OnSwitchEditorMode(mode);
		}
	}
}
void
JXTabGroup::Activate()
{
	JXWidget::Activate();

	JIndex i;
	if (WouldBeActive() && GetTabCount() > 0 && !GetCurrentTabIndex(&i))
		{
		ShowTab(1);
		}
}
void
JXTabGroup::HandleMouseDrag
	(
	const JPoint&			pt,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	if (itsDragAction == kScrollUp)
		{
		const JBoolean newScrollUpPushedFlag = JI2B( itsScrollUpRect.Contains(pt) );
		if (itsScrollUpPushedFlag != newScrollUpPushedFlag)
			{
			itsScrollUpPushedFlag = newScrollUpPushedFlag;
			Redraw();
			}
		else if (itsScrollUpPushedFlag &&
				 itsCanScrollUpFlag && itsFirstDrawIndex > 1)
			{
			itsFirstDrawIndex--;
			Refresh();
			ScrollWait(kContinuousScrollDelay);
			}
		}
	else if (itsDragAction == kScrollDown)
		{
		const JBoolean newScrollDownPushedFlag = JI2B( itsScrollDownRect.Contains(pt) );
		if (itsScrollDownPushedFlag != newScrollDownPushedFlag)
			{
			itsScrollDownPushedFlag = newScrollDownPushedFlag;
			Redraw();
			}
		else if (itsScrollDownPushedFlag &&
				 itsCanScrollDownFlag && itsFirstDrawIndex < GetTabCount())
			{
			itsFirstDrawIndex++;
			Refresh();
			ScrollWait(kContinuousScrollDelay);
			}
		}
	else if (itsDragAction == kClose)
		{
		const JBoolean old = itsClosePushedFlag;
		itsClosePushedFlag = JI2B(itsMouseIndex > 0 && itsCloseRect.Contains(pt));
		if ((!old &&  itsClosePushedFlag) ||
			( old && !itsClosePushedFlag))
			{
			Redraw();
			}
		}
}
Esempio n. 11
0
void CContextControl::OnTabClosing_Deferred(wxCommandEvent& event)
{
	int tab = event.GetId();
	if (tab < 0)
	{
		tab++;
		int count = GetTabCount();
		for (int i = count - 1; i >= 0; i--)
		{
			if (i != -tab)
				CloseTab(i);
		}
	}
	else
		CloseTab(tab);
}
void
JXTabGroup::ShowPreviousTab()
{
	JIndex index;
	if (!GetCurrentTabIndex(&index))
		{
		index = 2;
		}

	index--;
	if (index == 0)
		{
		index = GetTabCount();
		}

	ShowTab(index);
}
void
JXTabGroup::ShowNextTab()
{
	JIndex index;
	if (!GetCurrentTabIndex(&index))
		{
		index = 0;
		}

	index++;
	if (index > GetTabCount())
		{
		index = 1;
		}

	ShowTab(index);
}
Esempio n. 14
0
int CDocking3DTab::ClickedOnTab()
{
CDocking3DTabControl *pTabCtrl = (CDocking3DTabControl *)GetTabControl();

	_ASSERTE(NULL != pTabCtrl);
	_ASSERTE(pTabCtrl -> IsKindOf(RUNTIME_CLASS(CDocking3DTabControl)));

CPoint ptMouse;

	GetCursorPos(&ptMouse);
	pTabCtrl -> ScreenToClient(&ptMouse);
	for (int i = 0; i < GetTabCount(); ++i) {
		if (pTabCtrl -> TabHit(i, ptMouse))
			return i;
	}
	return -1;
}
void CGraphicTabControl::ChangeTabClient( int iTab, CWnd* pClient )
{
	if( m_bChangingClient )
		return;
	ASSERT_RETURN( iTab >= 0 && iTab < GetTabCount() && pClient != NULL );

	if( TabExists( pClient ) ) {
		// make sure window is shown and update tab bar layout
		pClient->ShowWindow(SW_SHOW);
		RecalcLayout();
		UpdateWindow();
		return;  // nothing to do
	}

	SECTab* ptab = GetTabPtr(iTab);
	ASSERT_RETURN( ptab );
	CWnd* pOldClient = (CWnd*)ptab->m_pClient;
	// check to see if we really need to do anything
	if( pOldClient == pClient ) {
		pClient->ShowWindow( SW_SHOW );
		return;
	} 
	m_bChangingClient = true;
	// hide both windows
	pClient->ShowWindow(SW_HIDE);
	pOldClient->ShowWindow(SW_HIDE);
	CString tabName = ptab->m_csLabel;
	InsertTab( iTab, tabName, pClient, NULL, NULL );
	// remove old tab
	ActivateTab( iTab );
	DeleteTab( iTab + 1 );
	pClient->ShowWindow(SW_SHOW);
	RecalcLayout();
	UpdateWindow();
	m_bChangingClient = false;
	return;
}
JXWidgetSet*
JXTabGroup::RemoveTab
	(
	const JIndex index
	)
{
	JIndex selIndex;
	const JBoolean hasSelection = itsCardFile->GetCurrentCardIndex(&selIndex);
	if (hasSelection && index == selIndex &&
		itsPrevTabIndex > 0 && itsPrevTabIndex != index)
		{
		ShowTab(itsPrevTabIndex);
		}
	else if (hasSelection && index == selIndex && index > 1)
		{
		ShowTab(index-1);
		}
	else if (hasSelection && index == selIndex && index < GetTabCount())
		{
		ShowTab(index+1);
		}

	itsPrevTabIndex = 0;

	if (itsCanScrollUpFlag && !itsCanScrollDownFlag)
		{
		JXScrollTabsTask* task = new JXScrollTabsTask(this);
		assert( task != NULL );
		task->Go();
		}

	Refresh();
	itsTitles->DeleteElement(index);
	itsTabInfoList->RemoveElement(index);
	return itsCardFile->RemoveCard(index);
}
Esempio n. 17
0
LRESULT MultiTab_Editor::onMouseMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch (uMsg)
  {
    case WM_LBUTTONDBLCLK:
      if (CURSES_INSTANCE && CURSES_INSTANCE->m_font_w && CURSES_INSTANCE->m_font_h)
      {
        const int y = ((short)HIWORD(lParam)) / CURSES_INSTANCE->m_font_h - m_top_margin;
        const int x = ((short)LOWORD(lParam)) / CURSES_INSTANCE->m_font_w + m_offs_x;
        WDL_FastString *fs=m_text.Get(y + m_paneoffs_y[m_curpane]);
        if (fs && y >= 0)
        {
          const char *url=fs->Get();
          
          while (NULL != (url = strstr(url,"http://")))
          {
            if (url != fs->Get() && isalnum(url[-1]))
            {
              url+=7;
            }
            else
            {
              const int soffs = (int) (url - fs->Get());
              char tmp[512];
              char *p=tmp;
              while (p < (tmp+sizeof(tmp)-1) &&
                    *url && *url != ' ' && *url != ')' && *url != '\t' && *url != '"' && *url != '\'' )
              {
                *p++ = *url++;
              }
              *p=0;
              if (strlen(tmp) >= 10 && x >= soffs && x<(url-fs->Get()))
              {
                ShellExecute(hwnd,"open",tmp,"","",0);
                break;
              }
            }
          }
        }
      }

    break;
    case WM_LBUTTONDOWN:
      if (CURSES_INSTANCE && CURSES_INSTANCE->m_font_w && CURSES_INSTANCE->m_font_h)
      {
        int x = ((short)LOWORD(lParam)) / CURSES_INSTANCE->m_font_w;
        int y = ((short)HIWORD(lParam)) / CURSES_INSTANCE->m_font_h;
        const int tabcnt=GetTabCount();
        if (y==0 && tabcnt>1)
        {
          int tsz=COLS/tabcnt;
          // this is duplicated in draw_top_line
          if (tsz>128)tsz=128;
          if (tsz<12) tsz=12;
          SwitchTab(x/tsz,false);

          return 1;
        }
      }
    break;
  }
  return WDL_CursesEditor::onMouseMessage(hwnd,uMsg,wParam,lParam);
}
Esempio n. 18
0
int CShopEx::Buy(LPCHARACTER ch, BYTE pos)
{
	BYTE tabIdx = pos / SHOP_HOST_ITEM_MAX_NUM;
	BYTE slotPos = pos % SHOP_HOST_ITEM_MAX_NUM;
	if (tabIdx >= GetTabCount())
	{
		sys_log(0, "ShopEx::Buy : invalid position %d : %s", pos, ch->GetName());
		return SHOP_SUBHEADER_GC_INVALID_POS;
	}

	sys_log(0, "ShopEx::Buy : name %s pos %d", ch->GetName(), pos);

	GuestMapType::iterator it = m_map_guest.find(ch);

	if (it == m_map_guest.end())
		return SHOP_SUBHEADER_GC_END;

	TShopTableEx& shopTab = m_vec_shopTabs[tabIdx];
	TShopItemTable& r_item = shopTab.items[slotPos];

	if (r_item.price <= 0)
	{
		LogManager::instance().HackLog("SHOP_BUY_GOLD_OVERFLOW", ch);
		return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
	}

	DWORD dwPrice = r_item.price;

	switch (shopTab.coinType)
	{
	case SHOP_COIN_TYPE_GOLD:
		if (it->second)	// if other empire, price is triple
			dwPrice *= 3;

		if (ch->GetGold() < (int) dwPrice)
		{
			sys_log(1, "ShopEx::Buy : Not enough money : %s has %d, price %d", ch->GetName(), ch->GetGold(), dwPrice);
			return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
		}
		break;
	case SHOP_COIN_TYPE_SECONDARY_COIN:
		{
			int count = ch->CountSpecifyTypeItem(ITEM_SECONDARY_COIN);
			if (count < dwPrice)
			{
				sys_log(1, "ShopEx::Buy : Not enough myeongdojun : %s has %d, price %d", ch->GetName(), count, dwPrice);
				return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY_EX;
			}
		}
		break;
	}
	
	LPITEM item;

	item = ITEM_MANAGER::instance().CreateItem(r_item.vnum, r_item.count);

	if (!item)
		return SHOP_SUBHEADER_GC_SOLD_OUT;

	int iEmptyPos;
	if (item->IsDragonSoul())
	{
		iEmptyPos = ch->GetEmptyDragonSoulInventory(item);
	}
	else
	{
		iEmptyPos = ch->GetEmptyInventory(item->GetSize());
	}

	if (iEmptyPos < 0)
	{
		sys_log(1, "ShopEx::Buy : Inventory full : %s size %d", ch->GetName(), item->GetSize());
		M2_DESTROY_ITEM(item);
		return SHOP_SUBHEADER_GC_INVENTORY_FULL;
	}

	switch (shopTab.coinType)
	{
	case SHOP_COIN_TYPE_GOLD:
		ch->PointChange(POINT_GOLD, -dwPrice, false);
		break;
	case SHOP_COIN_TYPE_SECONDARY_COIN:
		ch->RemoveSpecifyTypeItem(ITEM_SECONDARY_COIN, dwPrice);
		break;
	}


	if (item->IsDragonSoul())
		item->AddToCharacter(ch, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyPos));
	else
		item->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyPos));

	ITEM_MANAGER::instance().FlushDelayedSave(item);
	LogManager::instance().ItemLog(ch, item, "BUY", item->GetName());

	if (item->GetVnum() >= 80003 && item->GetVnum() <= 80007)
	{
		LogManager::instance().GoldBarLog(ch->GetPlayerID(), item->GetID(), PERSONAL_SHOP_BUY, "");
	}

	DBManager::instance().SendMoneyLog(MONEY_LOG_SHOP, item->GetVnum(), -dwPrice);

	if (item)
		sys_log(0, "ShopEx: BUY: name %s %s(x %d):%u price %u", ch->GetName(), item->GetName(), item->GetCount(), item->GetID(), dwPrice);

	if (LC_IsBrazil())
	{
		ch->SaveReal();
		db_clientdesc->DBPacketHeader(HEADER_GD_FLUSH_CACHE, 0, sizeof(DWORD));
		DWORD pid = ch->GetPlayerID();
		db_clientdesc->Packet(&pid, sizeof(DWORD));
	}
	else
	{
		ch->Save();
	}

    return (SHOP_SUBHEADER_GC_OK);
}
Esempio n. 19
0
void MultiTab_Editor::OpenFileInTab(const char *fnp)
{
  // try to find file to open
  WDL_FastString s;        
  FILE *fp=NULL;
  {
    const char *ptr = fnp;
    while (!fp && *ptr)
    {          
      // first try same path as loading effect
      if (m_filename.Get()[0])
      {
        s.Set(m_filename.Get());
        const char *sp=s.Get()+s.GetLength();
        while (sp>=s.Get() && *sp != '\\' && *sp != '/') sp--;
        s.SetLen(sp + 1 - s.Get());
        if (s.GetLength())
        {
          s.Append(ptr);
          fp=fopenUTF8(s.Get(),"rb");
        }
      }

      // scan past any / or \\, and try again
      if (!fp)
      {
        while (*ptr && *ptr != '\\' && *ptr != '/') ptr++;
        if (*ptr) ptr++;
      }
    }
  }

  if (!fp) 
  {
    s.Set("");
    fp = tryToFindOrCreateFile(fnp,&s);
  }

  if (!fp && s.Get()[0])
  {
    m_newfn.Set(s.Get());

    if (COLS > 25)
    {
      int allowed = COLS-25;
      if (s.GetLength()>allowed)
      {
        s.DeleteSub(0,s.GetLength() - allowed + 3);
        s.Insert("...",0);
      }
      s.Insert("Create new file '",0);
      s.Append("' (Y/n)? ");
    }
    else
      s.Set("Create new file (Y/n)? ");

    m_state=UI_STATE_SAVE_AS_NEW;
    attrset(m_color_message);
    bkgdset(m_color_message);
    mvaddstr(LINES-1,0,s.Get());
    clrtoeol();
    attrset(0);
    bkgdset(0);
  }
  else if (fp)
  {
    fclose(fp);
    int x;
    for (x=0;x<GetTabCount();x++)
    {
      MultiTab_Editor *e = GetTab(x);
      if (e && !stricmp(e->GetFileName(),s.Get()))
      {
        SwitchTab(x,false);
        return;
      }
    }
    AddTab(s.Get());
  }
}
Esempio n. 20
0
void MultiTab_Editor::draw_top_line()
{
  int ypos=0;
  if (m_top_margin > 1)
  {
    int xpos=0;
    int x;
    move(ypos++,0);
    const int cnt= GetTabCount();
    int tsz=16;
    // this is duplicated in onMouseMessage
    if (cnt>0) tsz=COLS/cnt;
    if (tsz>128)tsz=128;
    if (tsz<12) tsz=12;

    for (x= 0; x < cnt && xpos < COLS; x ++)
    {
      MultiTab_Editor *ed = GetTab(x);
      if (ed)
      {
        char buf[128 + 8];
        memset(buf,' ',tsz);
        const char *p = WDL_get_filepart(ed->GetFileName());
        const int lp=strlen(p);
        int skip=0;        
        if (x<9) 
        { 
          if (tsz>16)
          {
#ifdef __APPLE__
            memcpy(buf,"<Cmd+",skip=5);
#else
            memcpy(buf,"<Ctrl+",skip=6);
#endif
          }
          buf[skip++]='F'; 
          buf[skip++] = '1'+x; 
          buf[skip++] = '>';
          skip++;
        }
        memcpy(buf+skip,p,min(tsz-1-skip,lp));
        buf[tsz]=0;
        int l = tsz;
        if (l > COLS-xpos) l = COLS-xpos;
        if (ed == this)
        {
          attrset(SYNTAX_HIGHLIGHT2|A_BOLD);
        }
        else
        {
          attrset(A_NORMAL);
        }
        addnstr(buf,l);
        xpos += l;
      }
    }
    if (xpos < COLS) clrtoeol();
  }
  attrset(COLOR_TOPLINE|A_BOLD);
  bkgdset(COLOR_TOPLINE);
  const char *p=GetFileName();
  move(ypos,0);
  if (COLS>4)
  {
    const int pl = (int) strlen(p);
    if (pl > COLS-1 && COLS > 4)
    {
      addstr("...");
      p+=pl - (COLS-1) + 4;
    }
    addstr(p);
  }
  clrtoeol();
}
void
JXTabGroup::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	itsDragAction = kInvalidClick;

	if (button == kJXLeftButton && itsScrollUpRect.Contains(pt))
		{
		if (itsCanScrollUpFlag && itsFirstDrawIndex > 1)	// avoid left click when arrow disabled
			{
			itsDragAction         = kScrollUp;
			itsScrollUpPushedFlag = kJTrue;
			itsFirstDrawIndex--;
			Refresh();
			ScrollWait(kInitialScrollDelay);
			itsScrollUpPushedFlag = kJFalse;		// ignore first HandleMouseDrag()
			}
		}
	else if (button == kJXLeftButton && itsScrollDownRect.Contains(pt))
		{
		if (itsCanScrollDownFlag && itsFirstDrawIndex < GetTabCount())	// avoid left click when arrow disabled
			{
			itsDragAction           = kScrollDown;
			itsScrollDownPushedFlag = kJTrue;
			itsFirstDrawIndex++;
			Refresh();
			ScrollWait(kInitialScrollDelay);
			itsScrollDownPushedFlag = kJFalse;		// ignore first HandleMouseDrag()
			}
		}
	else if (button == kJXLeftButton &&
			 itsMouseIndex > 0 && itsCloseRect.Contains(pt))
		{
		itsDragAction      = kClose;
		itsClosePushedFlag = kJTrue;
		Refresh();
		}
	else if (button == kJXLeftButton)
		{
		JIndex i;
		JRect r;
		if (FindTab(pt, &i, &r))
			{
			ShowTab(i);
			}
		}
	else if (button == kJXRightButton)
		{
		CreateContextMenu();
		itsContextMenu->PopUp(this, pt, buttonStates, modifiers);
		}
	else
		{
		ScrollForWheel(button, modifiers);
		}
}
Esempio n. 22
0
void MultiTab_Editor::draw(int lineidx)
{
  if (m_top_margin != 0) m_top_margin = GetTabCount()>1 ? 2 : 1;
  WDL_CursesEditor::draw(lineidx);
}
Esempio n. 23
0
void sTabBorderBase::OnPaint2D()
{
  // get total width

  sFont2D *font = sGui->PropFont;
  font->SetColor(sGC_TEXT,sGC_BACK);
  sInt max = GetTabCount();
  sInt space = (font->GetWidth(L" ")/2+1)*2;
  sInt kill = (Height/4)*2+1;
  if(max==1)
    kill = -2*space;
  Rects.Resize(max);
  sInt arrow = font->GetWidth(L"\x25c4  ");

  // layout rects

  sInt xs=0;
  for(sInt i=0;i<max;i++)
  {
    xs+=space;
    const sChar *text = GetTabName(i);
    sInt xw = font->GetWidth(text);

    Rects[i].Client.Init(Rect.x0+xs,Rect.y0+2,Rect.x0+xs+space*4+xw+kill,Rect.y1-1);
    xs+= space*4 + xw + kill;
    sRect r=Rects[i].Client;
    r.x0++;
    r.x1--;
    r.y0++;
    Rects[i].Kill.Init(r.x1-kill-space,r.CenterY()-kill/2,r.x1-space,r.CenterY()-kill/2+kill);
  }
  xs+=space;

  // prepare scrolling

  if(xs<=Client.SizeX())
  {
    ScrollWidth = 0;
  }
  else
  {
    ScrollWidth = xs - (Client.SizeX()-2*arrow);
    if(ScrollWidth<0)
      ScrollWidth = 0;

    if(ScrollTo>=0 && ScrollTo<max)
    {
      sInt over = 2*arrow;
      if(Rects[ScrollTo].Client.x0-Scroll < Client.x0+over)
        Scroll = (Rects[ScrollTo].Client.x0)-(Client.x0+over);
      if(Rects[ScrollTo].Client.x1-Scroll > Client.x1-2*arrow-over)
        Scroll = (Rects[ScrollTo].Client.x1)-(Client.x1-2*arrow-over);
      Scroll = sClamp(Scroll,0,ScrollWidth);
      ScrollTo = -1;
    }

    sInt xo = arrow-sMin(Scroll,ScrollWidth);

    Info *info;
    sFORALL(Rects,info)
    {
      info->Client.x0 += xo;
      info->Client.x1 += xo;
      info->Kill.x0 += xo;
      info->Kill.x1 += xo;
    }
  }