예제 #1
0
void CGUIDialog::Render()
{
  CGUIWindow::Render();
  // Check to see if we should close at this point
  // We check after the controls have finished rendering, as we may have to close due to
  // the controls rendering after the window has finished it's animation
  // we call the base class instead of this class so that we can find the change
  if (m_dialogClosing && !CGUIWindow::IsAnimating(ANIM_TYPE_WINDOW_CLOSE))
  {
    Close(true);
  }
    
  if (m_autoClosing && m_showStartTime + m_showDuration < timeGetTime() && !m_dialogClosing)
  {
    // Before we close the window, lets check to see if the visibility conditions allow us to close the window
    // if the visibilitiy conditions dictate that the window would be reopened, then lets just leave the
    // window open to begin with.

    // The following is an ugly hack to make the g_infoManager to believe that this dialog is already closed,
    // otherwise, it thinks that this dialog is always active and will never automatically close the dialog box
    m_dialogClosing = TRUE;
    if (g_infoManager.GetBool(GetVisibleCondition(), GetID()))
    {
      // Conditions dictate that this dialog stays visible...update the showStartTime so that we don't ask to
      // close it again
      m_showStartTime = timeGetTime();

      // Restore dialog state to not closing, as we only made it appear as if we were closing so that we could
      // check to see what the visibility conditions dictate
      m_dialogClosing = FALSE;
    }
    else
    {
      // Restore dialog state to not closing, otherwise, it won't animate the window closure
      m_dialogClosing = FALSE;
      Close();
    }
  }
}
// BuildAddRequest()
// Builds XML and checks for errors for DoAddRequest().
// Returns request XML if it could be created.
//
string CMenuSubscribeDlg::BuildAddRequest() {
	// Begin request.
	DOMXMLBuilder xmlBuilder;
	xmlBuilder.CreateSubscriptionXMLHeader();

	// Check initial xmlBuilder access for COM and other initialization errors.
	if( xmlBuilder.GetHasError() ) {
		DisplayXMLError( xmlBuilder );
		return "";
	}

	// Add UI Extension tags.
	xmlBuilder.AddAggregate( UIEXTSUBADDRQ_TAG );
	xmlBuilder.AddAggregate( UIEXTSUBADD_TAG );

	// Add subscriber id.
	xmlBuilder.AddElement( SUBSCRIBERID_TAG, SUBSCRIBER_ID );
	
	// Add callback info.
	xmlBuilder.AddAggregate( COMCALLBACKINFO_TAG );
	xmlBuilder.AddElement( APPNAME_TAG, HANDLER_APP_NAME );
	xmlBuilder.AddElement( CLSID_TAG, HANDLER_CLSID );
	xmlBuilder.AddEndAggregate( COMCALLBACKINFO_TAG );

	// Begin menu definition section.
	xmlBuilder.AddAggregate( MENUEXTSUB_TAG );
	string strAddToMenu = GetItemText( IDC_ADD_TO );
	xmlBuilder.AddElement( ADDTOMENU_TAG, strAddToMenu );

	// If more than one menu defined, create submenu of items.
	int iCount = GetMenuCount();
	if( iCount > 1 ) {
		xmlBuilder.AddAggregate( SUBMENU_TAG );
	}

	// Create XML for each defined menu item.
	for( int iMenu = 0; iMenu < 3; iMenu++ ) {
		// Menu text.
		string strMenuText = GetMenuText( iMenu );

		// If menu text defined, add menu item.
		if( strMenuText.length() > 0 ) {
			// Begin this menu item definition.
			xmlBuilder.AddAggregate( MENUITEM_TAG );
			xmlBuilder.AddElement( MENUTEXT_TAG, strMenuText );

			// Menu tag (menu_1,menu_2,etc.) This gets echoed back in
			// event XML when menu item is clicked by user.
			string strEventTag = "menu_";
			char lpszID[2];
			lpszID[0] = (char)('1'+iMenu);
			lpszID[1] = 0;
			strEventTag.append( lpszID );
			xmlBuilder.AddElement( EVENTTAG_TAG, strEventTag );

			// Display conditions.
			string strVisibleCondition = GetVisibleCondition( iMenu );
			string strEnabledCondition = GetEnabledCondition( iMenu );
			if( strVisibleCondition.length() > 0 || strEnabledCondition.length() > 0 ) {
				xmlBuilder.AddAggregate( DISPLAYCONDITION_TAG );
				// Visible condition.
				if( strVisibleCondition.length() > 0 ) {
					BOOL bVisibleIf = GetVisibleIf( iMenu );
					if( bVisibleIf ) {
						xmlBuilder.AddElement( VISIBLEIF_TAG, strVisibleCondition );
					}
					else {
						xmlBuilder.AddElement( VISIBLEIFNOT_TAG, strVisibleCondition );
					}
				}
				// Enabled condition.
				if( strEnabledCondition.length() > 0 ) {
					BOOL bEnabledIf = GetEnabledIf( iMenu );
					if( bEnabledIf ) {
						xmlBuilder.AddElement( ENABLEDIF_TAG, strEnabledCondition );
					}
					else {
						xmlBuilder.AddElement( ENABLEDIFNOT_TAG, strEnabledCondition );
					}
				}
				xmlBuilder.AddEndAggregate( DISPLAYCONDITION_TAG );
			}

			// End menu item aggregate.
			xmlBuilder.AddEndAggregate( MENUITEM_TAG );
		}
	}

	// If more than one menu defined, end submenu aggregate.
	if( iCount > 1 ) {
		xmlBuilder.AddEndAggregate( SUBMENU_TAG );
	}

	// Finish request.
	xmlBuilder.AddEndAggregate( MENUEXTSUB_TAG );

	xmlBuilder.AddEndAggregate( UIEXTSUBADD_TAG );
	xmlBuilder.AddEndAggregate( UIEXTSUBADDRQ_TAG );
	xmlBuilder.CreateSubscriptionXMLTrailer();

	// If any errors occurred, display error message.
	if( xmlBuilder.GetHasError() ) {
		DisplayXMLError( xmlBuilder );
		return "";
	}

	// If no errors, return request formatted with tabs and line breaks.
	return xmlBuilder.GetXML();
}