本文整理汇总了C++中Tab::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Tab::getName方法的具体用法?C++ Tab::getName怎么用?C++ Tab::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tab
的用法示例。
在下文中一共展示了Tab::getName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void TabBarElement::Draw(int x, int y, GraphicsContext *g) {
if (this->absoluteBounds == NULL)
this->absoluteBounds = new rectangle;
this->absoluteBounds->x = x;
this->absoluteBounds->y = y;
this->absoluteBounds->width = this->getWidth();
this->absoluteBounds->height = this->getHeight();
g->fillRectangle(x, y, this->getWidth(), this->getHeight(), (Color *)this->getAttributeObj("bgcolor"));
int left = 0;
std::vector<Tab *>::iterator it = this->getTabs()->begin();
do {
Color *fgColor = (Color *)this->getAttributeObj("fgcolor");
Tab *tab = (Tab *)static_cast<Tab *>(*it);
string *title = tab->getName();
string *id = tab->getId();
rectangle strSize = g->measureString((char *)title->c_str(), font);
int width = 20 + 100 + 20;
if (this->activeTab == tab) {
fgColor = (Color *)this->getAttributeObj("active_tab_fgcolor");
Color *bgColor = (Color *)this->getAttributeObj("active_tab_bgcolor");
g->fillRectangle(x + left, y, width, this->getHeight(), bgColor);
}
g->drawString((char *)title->c_str(), font, fgColor, left + x + 20, y + (this->getHeight() / 2) - (strSize.height / 2), strSize.width, strSize.height);
left += width;
++it;
} while (it != this->getTabs()->end());
}
示例2: mousedown
void TabBarElement::mousedown(int mouseButton, int x, int y) {
TabBarElement *tabBar = this;
x = tabBar->getAbsoluteBounds() != NULL ? x - tabBar->getAbsoluteBounds()->x : x;
y = tabBar->getAbsoluteBounds() != NULL ? y - tabBar->getAbsoluteBounds()->y : y;
FontStyle *font = (FontStyle *)tabBar->getAttributeObj("font");
int left = 0;
for(std::vector<Tab *>::iterator it = tabBar->getTabs()->begin(); it != tabBar->getTabs()->end(); ++it) {
Tab *tab = (Tab *)static_cast<Tab *>(*it);
string *title = tab->getName();
string *id = tab->getId();
string *uri = tab->getUri();
GraphicsContext *g = tabBar->createGraphics();
rectangle strSize = g->measureString((char *)title->c_str(), font);
int width = 20 + 100 + 20;
if (x > left && x < left + width) {
tabBar->activeTab = tab;
TabBarEventArgs *args = new TabBarEventArgs(tab);
tabBar->notify(string("tabselected"), (SPType *)tabBar, (EventArgs *)args);
cout << title->c_str();
break;
}
left += width;
}
tabBar->invalidate();
}
示例3: tabbar_mousedown
int tabbar_mousedown(SPType *sender, EventArgs *e) {
TabBarElement *tabBar = (TabBarElement *)sender;
MouseEventArgs *me = (MouseEventArgs *)e;
int x = tabBar->getAbsoluteBounds() != NULL ? me->getX() - tabBar->getAbsoluteBounds()->y : me->getX();
int y = tabBar->getAbsoluteBounds() != NULL ? me->getY() - tabBar->getAbsoluteBounds()->y : me->getY();
int left = 0;
;
for(std::vector<Tab *>::iterator it = tabBar->tabs->begin(); it != tabBar->tabs->end(); ++it) {
Tab *tab = (Tab *)dynamic_cast<Tab *>(*it);
string *title = tab->getName();
string *id = tab->getId();
string *uri = tab->getUri();
FontStyle *font = (FontStyle *)tabBar->getAttributeObj("font");
GraphicsContext *g = tabBar->createGraphics();
rectangle strSize = g->measureString((char *)title->c_str(), font);
int width = 20 + strSize.width + 20;
if (x > left && x < left + width) {
tabBar->activeTab = tab;
TabBarEventArgs *args = new TabBarEventArgs(tab);
tabBar->notify(string("tabselected"), (SPType *)tabBar, (EventArgs *)args);
}
left += width;
}
tabBar->invalidate();
}