//=============================================================================
// Called when graphics device is reset
//=============================================================================
void MessageDialog::onResetDevice()
{
    if (!initialized)
        return;
    prepareVerts();
    dxFont.onResetDevice();
}
//=============================================================================
// Set text string, size dialog bottom to fit text and set visible = true
//=============================================================================
void MessageDialog::print(const std::string &str)         
{
    if (!initialized || visible)    // if not initialized or already in use
        return;
    text = str + "\n\n\n\n";        // leave some room for buttons

    // Set textRect to text area of dialog
    textRect.left   = (long)(x + messageDialogNS::MARGIN);
    textRect.right  = (long)(x + messageDialogNS::WIDTH - messageDialogNS::MARGIN);
    textRect.top    = (long)(y + messageDialogNS::MARGIN);
    textRect.bottom = (long)(y + messageDialogNS::HEIGHT - messageDialogNS::MARGIN);

    // Set textRect.bottom to precise height required for text
    // No text is printed with DT_CALDRECT option.
    dxFont.print(text,textRect,DT_CENTER|DT_WORDBREAK|DT_CALCRECT);
    height = textRect.bottom - (int)y + messageDialogNS::BORDER + messageDialogNS::MARGIN;

    prepareVerts();                 // prepare the vertex buffers
    buttonClicked = 0;              // clear buttonClicked
    visible = true;
}
//=============================================================================
// テキスト文字列を設定、ダイアログの下端をテキストが収まるサイズに変更、
// visible = trueを設定
//=============================================================================
void MessageDialog::print(const std::string &str)         
{
	// 初期化されていない、または既に使用中の場合
    if (!mInitialized || mVisible)
        return;
    mText = str + "\n\n\n\n";        // ボタン用に空間を空ける

	// textRectをダイアログのテキスト領域として設定
    mTextRect.left   = (long)(mX + messageDialogNS::MARGIN);
    mTextRect.right  = (long)(mX + messageDialogNS::WIDTH - messageDialogNS::MARGIN);
    mTextRect.top    = (long)(mY + messageDialogNS::MARGIN);
    mTextRect.bottom = (long)(mY + messageDialogNS::HEIGHT - messageDialogNS::MARGIN);

	// textRect.bottomをテキストに必要な高さに設定
	// DT_CALCERCTオプションの場合、テキストは出力されない
    mDxFont.print(mText,mTextRect,DT_CENTER|DT_WORDBREAK|DT_CALCRECT);
    mHeight = mTextRect.bottom - (int)mY + messageDialogNS::BORDER + messageDialogNS::MARGIN;

    prepareVerts();                 // 頂点バッファを準備
    mButtonClicked = 0;             // buttonClickedクリア
    mVisible = true;
}