void GlowMessageWindow::Init( const GlowMessageWindowParams& params) { GLOW_DEBUGSCOPE("GlowMessageWindow::Init"); GlowWidgetWindowParams wparams; wparams.title = params.windowTitle; wparams.x = params.x; wparams.y = params.y; wparams.backColor = params.backColor; GlowFixedSizeWidgetWindow::Init(wparams); // Make buttons char* tempbuf = new char[GLOW_CSTD::strlen(params.buttonLabels)+1]; GLOW_CSTD::strcpy(tempbuf, params.buttonLabels); GlowPushButtonParams pbparams; pbparams.font = params.buttonFont; int buttonsWidth = -params.windowSpacing; while (true) { pbparams.text = GLOW_CSTD::strtok(buttons_.size()==0 ? tempbuf : 0, "\t"); if (pbparams.text == 0) break; buttons_.push_back(new Glow_MessageWindowButton(this, pbparams, buttons_.size())); buttons_.back()->AutoReshape(); buttonsWidth += buttons_.back()->Width() + params.windowSpacing; } int buttonHeight = buttons_.front()->Height(); GLOW_DEBUG(buttons_.size()==0, "No buttons specified in GlowMessageWindow"); GLOW_DEBUG(buttonsWidth>800, "Buttons too wide in GlowMessageWindow"); delete[] tempbuf; // Label GlowLabelParams lparams; lparams.text = params.text; lparams.font = params.textFont; lparams.textColor = lparams.disableTextColor = params.textColor; lparams.x = lparams.y = params.windowSpacing; GlowLabelWidget* label = new GlowLabelWidget(this, lparams); label->AutoReshape(); GLOW_DEBUG(label->Width()>800, "Text too wide"); GLOW_DEBUG(label->Height()>800, "Text too tall"); // Compute window width int windowWidth = buttonsWidth + params.windowSpacing*2; if (label->Width()+params.windowSpacing*2 > windowWidth) { windowWidth = label->Width()+params.windowSpacing*2; } // Arrange buttons int xbutton = (windowWidth - buttonsWidth)/2; for (GLOW_STD::vector<GlowPushButtonWidget*>::iterator iter = buttons_.begin(); iter != buttons_.end(); ++iter) { (*iter)->Move(xbutton, label->Height()+params.windowSpacing*2+10); xbutton += (*iter)->Width()+params.windowSpacing; } // Size window ForceReshape(windowWidth, label->Height()+buttonHeight+ params.windowSpacing*3+10); if (params.receiver != 0) { sender_.Bind(params.receiver); } // Enter and escape filters enterFilter_ = new GlowWidgetMapToPushButtonFilter( (params.enterButton<0 || params.enterButton>=int(buttons_.size())) ? 0 : buttons_[params.enterButton], Glow::enterKey, Glow::noModifier); escapeFilter_ = new GlowWidgetMapToPushButtonFilter( (params.escapeButton<0 || params.escapeButton>=int(buttons_.size())) ? 0 : buttons_[params.escapeButton], Glow::escapeKey, Glow::noModifier); RegisterFilter(enterFilter_); RegisterFilter(escapeFilter_); }
STDAPI DllRegisterServer() { RegisterFilter(); HRESULT hr=AMovieDllRegisterServer2( TRUE ); return hr; }