Esempio n. 1
0
//----------
// Tool::Bar
//----------
Bar::Bar (Win::Dow::Handle winParent,
		  int toolbarId,
		  int bitmapId,
		  int buttonWidth,
		  Cmd::Vector const & cmdVector,
		  Tool::Item const * buttonItems,
		  Win::Style const & barStyle)
	: _buttonImages (winParent.GetInstance (), bitmapId, buttonWidth),
	  _cmdVector (cmdVector),
	  _buttonItems (buttonItems)
{
	Tool::Maker maker (winParent, toolbarId);
	maker.Style () << barStyle;
	Reset (maker.Create ());
	int width, height;
	_buttonImages.GetImageSize (width, height);
	SetButtonSize (width, height);
	SetImageList (_buttonImages);

	// Map button id to command id and cmd id to button item index
	for (unsigned i = 0; _buttonItems [i].buttonId != Item::idEnd; ++i)
	{
		int buttonId = _buttonItems [i].buttonId;
		if (buttonId != Item::idSeparator)
		{
			int cmdId = _cmdVector.Cmd2Id (_buttonItems [i].cmdName);
			Assert (cmdId != -1);
			_buttonId2CmdId [buttonId] = cmdId;
			_cmdId2ButtonIdx [cmdId] = i;
		}
	}
}
Esempio n. 2
0
bool TopCtrl::OnCreate (Win::CreateData const * create, bool & success) 
{
	Win::Dow::Handle win = GetWindow ();
	ResString caption (win.GetInstance (), ID_CAPTION);
	try
	{
		TheOutput.Init (caption);
		win.SetText (caption);
		_commander.reset (new Commander (win));
		_commander->SetModelessManager (&_modelessMan);
		_cmdVector.reset (new CmdVector (Cmd::Table, _commander.get ()));
		Accel::Maker accelMaker (Accel::Keys, *_cmdVector);
		_kbdAccel.reset (new Accel::Handler (win, accelMaker.Create ()));
		_msgPrepro.SetKbdAccelerator (_kbdAccel.get ());
		_menu.reset (new Menu::DropDown (Menu::barItems, *_cmdVector));
		_menu->AttachToWindow (win);
		_view.reset (new View (win));
		RegisterAsDropTarget(win);

		win.PostMsg (_initMsg);
		success = true;
	}
	catch (Win::Exception e)
	{
		TheOutput.Display (e);
		success = false;
	}
	catch (...)
	{
		Win::ClearError ();
		TheOutput.Display ("Initialization -- Unknown Error", Out::Error);
		success = false;
	}
	TheOutput.SetParent (win);
	_ready = true;
	return true;
}