示例#1
0
void write_rebar(Profile& pr, tomato::window_ref rebar)
{
    WTL::CReBarCtrl rebars(rebar);

    for (UINT uIndex = 0, uCount = rebars.GetBandCount(); uIndex < uCount; ++uIndex) {
        REBARBANDINFO info; {
            info|tomato::size_initialized;
            info.fMask = RBBIM_SIZE | RBBIM_STYLE | RBBIM_CHILD;
            PSTADE_REQUIRE(rebars.GetBandInfo(uIndex, &info));
        }

        tomato::tstring buf; {
            tomato::tstringstream os;
            int id = ::GetDlgCtrlID(info.hwndChild);
            PSTADE_REQUIRE(id != 0);
            os << _T("rebar.band#") << id;
            buf = os.str();
        }

        candy::mask(info.fStyle, tomato::rebar_band_runtime_styles::value);

        pizza::set_integer(pr, buf + _T(".index"),  uIndex);
        pizza::set_integer(pr, buf + _T(".fStyle"), info.fStyle);
        pizza::set_integer(pr, buf + _T(".cx"),     info.cx);
    }
}
示例#2
0
void add_rebar_band(window_ref rebar, window_ref child, UINT fStyle, CStringizable const& str, UINT cx)
{
    BOOST_ASSERT("child window id must be valid." && ::GetDlgCtrlID(child) != 0);


    // info.lpText is not 'const'. 'const_cast' is dangerous,
    // so that, copy it.
    std::vector<TCHAR> text; {
        text = str|c_str|oven::as_c_str
            |oven::jointed(oven::single(_T('\0')))|oven::copied;
        BOOST_ASSERT(oven::contains_zero(text));
    }

    bool hasTitle = !boost::empty(text|oven::as_c_str);


    REBARBANDINFO info; {
        info|size_initialized;

#if (_WIN32_IE >= 0x0400)
        info.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_ID | RBBIM_SIZE | RBBIM_IDEALSIZE;
#else
        info.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_ID | RBBIM_SIZE;
#endif
        
        if (hasTitle)
            candy::set(info.fMask, RBBIM_TEXT);
        
        info.fStyle = fStyle;
        info.lpText = text|oven::pointed|oven::begin;
        info.hwndChild = child;
        info.wID = ::GetDlgCtrlID(child); // how's that

        info.cxMinChild = tomato::get_rebar_band_info_cxMinChild(child, hasTitle);
        info.cyMinChild = tomato::get_rebar_band_info_cyMinChild(child);
        
        // cx is the "current" width.
        if (cx == 0)
            info.cx = tomato::get_rebar_band_info_cxIdeal(child);
        else
            info.cx = cx;

#if (_WIN32_IE >= 0x0400)
        // Note: cxIdeal is used for CHEVRON. If MDI, cxIdeal is changed dynamically.
        info.cxIdeal = tomato::get_rebar_band_info_cxIdeal(child); // info.cx is not good.
#endif
    } // info


    PSTADE_REQUIRE(WTL::CReBarCtrl(rebar).InsertBand(-1, &info));


/* should be?
#if (_WIN32_IE >= 0x0501)
        DWORD dwExStyle = (DWORD)::SendMessage(child, TB_GETEXTENDEDSTYLE, 0, 0L);
        ::SendMessage(child, TB_SETEXTENDEDSTYLE, 0, dwExStyle | TBSTYLE_EX_HIDECLIPPEDBUTTONS);
#endif // (_WIN32_IE >= 0x0501)
*/

}
示例#3
0
void write_placement(Profile& pr, gravy::window_ref wnd)
{
    WINDOWPLACEMENT wndpl;
    gravy::size_initialize(wndpl);
    PSTADE_REQUIRE(::GetWindowPlacement(wnd, &wndpl));

    pizza::write_window_placement(pr, wndpl);
}
示例#4
0
template< class CStringizable > inline
void set_menu_text(menu_ref menu, UINT uIndex, CStringizable const& text)
{
    // get current menu_ref state so it doesn't change
    UINT uState = tomato::get_menu_state(menu, uIndex, MF_BYPOSITION);
    candy::remove(uState, mf_bitmap::value | MF_OWNERDRAW | MF_SEPARATOR);

    // set menu_ref text
    MENUITEMINFO mii = { 0 }; {
        mii|size_initialized;
        mii.fMask = MIIM_ID;
        PSTADE_REQUIRE(::GetMenuItemInfo(menu, uIndex, TRUE, &mii));
    }

    PSTADE_REQUIRE(tomato::modify_menu(menu, uIndex, MF_BYPOSITION |
        MF_STRING | uState, mii.wID, tomato::c_str(text))
    );
}
        inline
        bool get_last_item_rect(gravy::window_ref wnd, RECT& rc)
        {
            int nBtnCount = get_rebar_band_info_detail::get_button_count(wnd);
            if (nBtnCount > 0) {
                PSTADE_REQUIRE(::SendMessage(wnd, TB_GETITEMRECT, nBtnCount-1, reinterpret_cast<LPARAM>(&rc)));
                return true;
            }

            return false;
        }
inline
bool is_rebar_band_visible(HWND hWndReBar, UINT uBandID)
{
    BOOST_ASSERT(diet::valid(hWndReBar));

    WTL::CReBarCtrl rebar(hWndReBar);
    int index = rebar.IdToIndex(uBandID);
    BOOST_ASSERT("invalid band id" && index != -1);

    REBARBANDINFO info; {
        info|size_initialized;
        info.fMask = RBBIM_STYLE;
        PSTADE_REQUIRE(rebar.GetBandInfo(index, &info));
    }

    return !candy::test(info.fStyle, RBBS_HIDDEN);
}
inline
HWND get_rebar_band_hwnd(HWND hWndReBar, UINT uBandID)
{
    BOOST_ASSERT(diet::valid(hWndReBar));
    
    WTL::CReBarCtrl rebar(hWndReBar);
    int index = rebar.IdToIndex(uBandID);
    // Note: RB_IDTOINDEX doesn't use GetLastError().
    BOOST_ASSERT("invalid band id" && index != -1);

    REBARBANDINFO info; {
        info|size_initialized;
        info.fMask = RBBIM_CHILD;
        PSTADE_REQUIRE(rebar.GetBandInfo(index, &info));
    }

    return info.hwndChild;
}
示例#8
0
 impl(WTL::CIdleHandler *pIdleHandler, DWORD dwThreadID) :
     m_pIdleHandler(pIdleHandler), m_dwThreadID(dwThreadID)
 {
     WTL::CMessageLoop *pLoop = _Module.GetMessageLoop(m_dwThreadID);
     PSTADE_REQUIRE( pLoop && pLoop->AddIdleHandler(m_pIdleHandler) );
 }
示例#9
0
 explicit module_init(HINSTANCE hInstance)
 {
     PSTADE_REQUIRE(tomato::succeeded(_Module.Init(NULL, hInstance)));
     module_init_detail::resolve_thunking_problem();
 }
示例#10
0
void get_placement(Profile& pr, gravy::window_ref wnd)
{
    WINDOWPLACEMENT wndpl = pizza::get_window_placement(pr);
    PSTADE_REQUIRE(::SetWindowPlacement(wnd, &wndpl));
}