Esempio n. 1
0
WeatherPlugin::WeatherPlugin(unsigned base, bool bInit, const char *config)
        : Plugin(base)
{
    load_data(weatherData, &data, config);
    memset(&m_handler, 0, sizeof(m_handler));
    m_handler.startElement = p_element_start;
    m_handler.endElement   = p_element_end;
    m_handler.characters   = p_char_data;
    BarWeather = registerType();
    CmdWeather = registerType();
    EventWeather = registerType();
    Event eBar(EventToolbarCreate, (void*)BarWeather);
    eBar.process();
    IconDef icon;
    icon.name = "weather";
    icon.xpm  = na;
    Event eIcon(EventAddIcon, &icon);
    eIcon.process();
    Command cmd;
    cmd->id = CmdWeather;
    cmd->text = I18N_NOOP("Not connected");
    cmd->icon = "weather";
    cmd->bar_id = BarWeather;
    cmd->bar_grp = 0x1000;
    cmd->flags = BTN_PICT | BTN_DIV;
    Event eCmd(EventCommandCreate, cmd);
    eCmd.process();
    m_bar = NULL;
    if (!bInit){
        showBar();
        if (m_bar)
            m_bar->show();
    }
}
Esempio n. 2
0
WeatherPlugin::WeatherPlugin(unsigned base, bool bInit, Buffer *config)
        : Plugin(base)
{
    load_data(weatherData, &data, config);
    BarWeather = registerType();
    CmdWeather = registerType();
    EventWeather = registerType();
    m_icons = getIcons()->addIconSet("icons/weather.jisp", true);
    Event eBar(EventToolbarCreate, (void*)BarWeather);
    eBar.process();
    Command cmd;
    cmd->id = CmdWeather;
    cmd->text = I18N_NOOP("Not connected");
    cmd->icon = "weather";
    cmd->bar_id = BarWeather;
    cmd->bar_grp = 0x1000;
    cmd->flags = BTN_PICT | BTN_DIV;
    Event eCmd(EventCommandCreate, cmd);
    eCmd.process();
    m_bar = NULL;
    if (!bInit){
        showBar();
        if (m_bar)
            m_bar->show();
    }
}
Esempio n. 3
0
WeatherPlugin::WeatherPlugin(unsigned base, bool bInit, const char *config)
        : Plugin(base)
{
    load_data(weatherData, &data, config);
    BarWeather = registerType();
    CmdWeather = registerType();
    EventWeather = registerType();
    Event eBar(EventToolbarCreate, (void*)BarWeather);
    eBar.process();
    IconDef icon;
    icon.name = "weather";
    icon.xpm  = overcast;
    Event eIcon(EventAddIcon, &icon);
    eIcon.process();
    Command cmd;
    cmd->id = CmdWeather;
    cmd->text = I18N_NOOP("Not connected");
    cmd->icon = "weather";
    cmd->bar_id = BarWeather;
    cmd->bar_grp = 0x1000;
    cmd->flags = BTN_PICT;
    Event eCmd(EventCommandCreate, cmd);
    eCmd.process();
    m_bar = NULL;
    m_fetch_id = 0;
    if (!bInit){
        showBar();
        if (m_bar)
            m_bar->show();
    }
}
Esempio n. 4
0
WeatherPlugin::~WeatherPlugin()
{
    if (m_bar)
        delete m_bar;
    Event eCmd(EventCommandRemove, (void*)CmdWeather);
    Event eBar(EventToolbarRemove, (void*)BarWeather);
    free_data(weatherData, &data);
}
void iNWSliderBar::DrawElement(iMemoryDC &ddc) const
{
    iRect elrc = GetElementRect();
    iSize bsiz(m_dibBack.GetWidth()/3,m_dibBack.GetHeight()/2);

    // Draw Background
    sint32 ypos = (m_IsEnabled?0:bsiz.h);
    m_dibBack.CopyRectToDibXY(&ddc.m_Dib, iRect(0,ypos,bsiz.w,bsiz.h),iPoint(elrc.x,elrc.y),BLEND_ALPHABLEND);
    m_dibBack.TileRectToDibRect(iRect(bsiz.w,ypos,bsiz.w,bsiz.h),ddc.m_Dib,iRect(elrc.x+bsiz.w,elrc.y,elrc.w-bsiz.w*2,bsiz.h),BLEND_ALPHABLEND);
    m_dibBack.CopyRectToDibXY(&ddc.m_Dib, iRect(bsiz.w*2,ypos,bsiz.w,bsiz.h),iPoint(elrc.x+elrc.w-bsiz.w,elrc.y),BLEND_ALPHABLEND);

    // Create Bar (fake impl)
    iSize belsiz(m_dibBar.GetWidth()/3,m_dibBar.GetHeight()/2);
    iSize barsiz(elrc.w - bsiz.w*2,belsiz.h);

    iDib eBar(barsiz);
    iDib fBar(barsiz);
    m_dibBar.CopyRectToDibXY(&eBar, iRect(0,0,belsiz.w,belsiz.h),iPoint(0,0),BLEND_SRCCOPY);
    m_dibBar.TileRectToDibRect(iRect(belsiz.w,0,belsiz.w,belsiz.h),eBar,iRect(belsiz.w,0,barsiz.w-belsiz.w*2,barsiz.h),BLEND_SRCCOPY);
    m_dibBar.CopyRectToDibXY(&eBar, iRect(belsiz.w*2,0,belsiz.w,belsiz.h),iPoint(barsiz.w-belsiz.w,0),BLEND_SRCCOPY);

    m_dibBar.CopyRectToDibXY(&fBar, iRect(0,belsiz.h,belsiz.w,belsiz.h),iPoint(0,0),BLEND_SRCCOPY);
    m_dibBar.TileRectToDibRect(iRect(belsiz.w,belsiz.h,belsiz.w,belsiz.h),fBar,iRect(belsiz.w,0,barsiz.w-belsiz.w*2,barsiz.h),BLEND_SRCCOPY);
    m_dibBar.CopyRectToDibXY(&fBar, iRect(belsiz.w*2,belsiz.h,belsiz.w,belsiz.h),iPoint(barsiz.w-belsiz.w,0),BLEND_SRCCOPY);

    // Compose
    iPoint bar_pos(elrc.x+bsiz.w,elrc.y+(bsiz.h/2 - barsiz.h/2));
    sint32 hpos;
    sint32 cpos = m_bTracking?m_TrackPos:m_Cur;
    if (!m_IsEnabled || cpos == m_Min || m_Min == m_Max) {
        hpos = 0;
        eBar.CopyToDibXY(&ddc.m_Dib,bar_pos,BLEND_ALPHABLEND);
    } else if (cpos == m_Max) {
        hpos = barsiz.w;
        fBar.CopyToDibXY(&ddc.m_Dib,bar_pos,BLEND_ALPHABLEND);
    } else {
        hpos = iCLAMP<sint32>((sint32)0,(sint32)barsiz.w,(sint32)barsiz.w * (cpos-m_Min) / (m_Max-m_Min));
        fBar.CopyRectToDibXY(&ddc.m_Dib,iRect(0,0,hpos,barsiz.h),iPoint(bar_pos.x,bar_pos.y),BLEND_ALPHABLEND);
        eBar.CopyRectToDibXY(&ddc.m_Dib,iRect(hpos,0,barsiz.w-hpos,barsiz.h),iPoint(bar_pos.x+hpos,bar_pos.y),BLEND_ALPHABLEND);
    }

    // Draw Handle
    if (m_IsEnabled) {
        iSize hndsiz(m_dibHandle.GetWidth()/2,m_dibHandle.GetHeight());
        m_dibHandle.CopyRectToDibXY(&ddc.m_Dib, iRect(m_bTracking?hndsiz.w:0,0,hndsiz.w,hndsiz.h),iPoint(bar_pos.x+hpos-(sint32)(hndsiz.w/2),bar_pos.y+barsiz.h/2-hndsiz.h/2),BLEND_ALPHABLEND);
    }
}