void CPWL_Wnd::Create(const PWL_CREATEPARAM& cp) { if (!IsValid()) { m_sPrivateParam = cp; OnCreate(m_sPrivateParam); m_sPrivateParam.rcRectWnd.Normalize(); m_rcWindow = m_sPrivateParam.rcRectWnd; m_rcClip = CPWL_Utils::InflateRect(m_rcWindow, 1.0f); CreateMsgControl(); if (m_sPrivateParam.pParentWnd) m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD); PWL_CREATEPARAM ccp = m_sPrivateParam; ccp.dwFlags &= 0xFFFF0000L; // remove sub styles ccp.mtChild = CFX_Matrix(1, 0, 0, 1, 0, 0); CreateScrollBar(ccp); CreateChildWnd(ccp); m_bVisible = HasFlag(PWS_VISIBLE); OnCreated(); RePosChildWnd(); m_bCreated = TRUE; } }
bool Dialog::CreateFromXML(const char* idd){ ScopedPointer<File> fh = gUiRender->OpenFile(idd); if(!fh) return false; char* xml = (char*)fh->ReadWholeFile(); int tmpInt; bool result = true; try { ticpp::Document doc; doc.Parse(xml); ticpp::Element* root = doc.FirstChildElement("Root_Element"); if(root->GetAttribute("ID", &tmpInt)) SetID(tmpInt); if(root->GetAttribute("X", &tmpInt)) SetPositionX(tmpInt); if(root->GetAttribute("Y", &tmpInt)) SetPositionY(tmpInt); if(root->GetAttribute("WIDTH", &tmpInt)) SetSizeX(tmpInt); if(root->GetAttribute("HEIGHT", &tmpInt)) SetSizeY(tmpInt); if(root->GetAttribute("MODAL", &tmpInt)) SetModal(tmpInt); if(root->GetAttribute("SHOWSID", &tmpInt)) SetShowSoundID(tmpInt); if(root->GetAttribute("HIDESID", &tmpInt)) SetHideSoundID(tmpInt); if(root->GetAttribute("EXTENT", &tmpInt)) SetExtent(tmpInt); if(root->GetAttribute("DEFAULT_X", &tmpInt)) SetDefaultPositionX(tmpInt); if(root->GetAttribute("DEFAULT_Y", &tmpInt)) SetDefaultPositionY(tmpInt); if(root->GetAttribute("ADJUST_X", &tmpInt)) SetDefaultAdjustPositionX(tmpInt); if(root->GetAttribute("ADJUST_Y", &tmpInt)) SetDefaultAdjustPositionY(tmpInt); if(root->GetAttribute("DEFAULT_VISIBLE", &tmpInt)) SetDefaultVisible(tmpInt); SetName(root->GetAttribute("NAME").c_str()); for(ticpp::Element* child = root->FirstChildElement(false); child; child = child->NextSiblingElement(false)){ if(child->Value() == "CAPTION"){ mCaption = (Caption*)CreateControlFromXML(child, this); }else if(child->Value() == "RADIOBUTTON"){ RadioButton* btn = (RadioButton*)CreateControlFromXML(child, this); if(int id = btn->RadioBoxID()){ RadioBox* box = (RadioBox*)GetControlByID(id); if(box && box->ControlType() == CT_RADIOBOX) box->AddButton(btn); } AddChild(btn); }else{ AddChild(CreateControlFromXML(child, this)); } } }catch(ticpp::Exception& ex){ LOG("TinyXML Exception %s", ex.what()); result = false; } OnCreated(); delete [] xml; return result; }
NS_IMETHODIMP nsPopupSetFrame::ShowPopup(nsIContent* aElementContent, nsIContent* aPopupContent, PRInt32 aXPos, PRInt32 aYPos, const nsString& aPopupType, const nsString& anAnchorAlignment, const nsString& aPopupAlignment) { NS_ASSERTION(aElementContent != aPopupContent, "self referential popup"); if (!MayOpenPopup(this)) return NS_OK; nsWeakFrame weakFrame(this); // First fire the popupshowing event. if (!OnCreate(aXPos, aYPos, aPopupContent) || !weakFrame.IsAlive()) return NS_OK; // See if we already have an entry in our list. We must create a new one on a miss. nsPopupFrameList* entry = nsnull; if (mPopupList) entry = mPopupList->GetEntry(aPopupContent); if (!entry) { entry = new nsPopupFrameList(aPopupContent, mPopupList); if (!entry) return NS_ERROR_OUT_OF_MEMORY; mPopupList = entry; } // Cache the element content we're supposed to sync to entry->mPopupType = aPopupType; entry->mElementContent = aElementContent; entry->mPopupAlign = aPopupAlignment; entry->mPopupAnchor = anAnchorAlignment; entry->mXPos = aXPos; entry->mYPos = aYPos; // If a frame exists already, go ahead and use it. mPresContext->PresShell()->GetPrimaryFrameFor(aPopupContent, &entry->mPopupFrame); #ifdef DEBUG_PINK printf("X Pos: %d\n", mXPos); printf("Y Pos: %d\n", mYPos); #endif // Generate the popup. entry->mCreateHandlerSucceeded = PR_TRUE; entry->mIsOpen = PR_TRUE; // This may destroy or change entry->mPopupFrame or remove the entry from // mPopupList. |this| may also get deleted. MarkAsGenerated(aPopupContent); if (!weakFrame.IsAlive()) { return NS_OK; } nsPopupFrameList* newEntry = mPopupList ? mPopupList->GetEntry(aPopupContent) : nsnull; if (!newEntry || newEntry != entry) { NS_WARNING("The popup entry for aPopupContent has changed!"); return NS_OK; } // determine if this menu is a context menu and flag it nsIMenuParent* childPopup = nsnull; if (entry->mPopupFrame) CallQueryInterface(entry->mPopupFrame, &childPopup); if ( childPopup && aPopupType.EqualsLiteral("context") ) childPopup->SetIsContextMenu(PR_TRUE); // Now open the popup. OpenPopup(entry, PR_TRUE); if (!weakFrame.IsAlive()) { return NS_OK; } // Now fire the popupshown event. OnCreated(aXPos, aYPos, aPopupContent); return NS_OK; }