当前位置: 首页>>代码示例>>C++>>正文


C++ Tab::getName方法代码示例

本文整理汇总了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());
}
开发者ID:drsounds,项目名称:BungalowCpp,代码行数:30,代码来源:TabBarElement.cpp

示例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();
}
开发者ID:drsounds,项目名称:BungalowCpp,代码行数:26,代码来源:TabBarElement.cpp

示例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();
}
开发者ID:drsounds,项目名称:BungalowCpp,代码行数:27,代码来源:TabBarElement.cpp


注:本文中的Tab::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。