Beispiel #1
0
void ToolbarDlg::ShowToolbarSizes()
{
	CMainFrame* pFrame = GetMainFrame();
	ENSURE(pFrame,"Can't find Main Frame in ShowToolBarSizes");

	// Only attempt to redisplay things if the toolbars dlg exists...
	if (WindowID)
	{
		// Fetch the states of all the docking bars...
		SetLongGadgetValue(_R(IDC_BIGTOP),		(INT32) pFrame->GetDockBar(DOCKBAR_TOP)->IsBigControls());
		SetLongGadgetValue(_R(IDC_BIGLEFT),		(INT32) pFrame->GetDockBar(DOCKBAR_LEFT)->IsBigControls());
		SetLongGadgetValue(_R(IDC_BIGRIGHT),	(INT32) pFrame->GetDockBar(DOCKBAR_RIGHT)->IsBigControls());
		SetLongGadgetValue(_R(IDC_BIGBOTTOM),	(INT32) pFrame->GetDockBar(DOCKBAR_BOTTOM)->IsBigControls());
		SetLongGadgetValue(_R(IDC_BIGFLOAT),	(INT32) pFrame->GetDockBar(DOCKBAR_FLOAT)->IsBigControls());
	}
}
Beispiel #2
0
void ToolbarDlg::TakeToolbarDetails()
{
	EnableGadget(_R(IDC_DELETEBAR), CanDeleteSelection());

	CMainFrame* pFrame = GetMainFrame();

	BOOL	check;
	BOOL	VV;

	check = (BOOL)GetLongGadgetValue(_R(IDC_BIGTOP),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
	pFrame->GetDockBar(DOCKBAR_TOP)->SetBigControlState(check);

	check = (BOOL)GetLongGadgetValue(_R(IDC_BIGLEFT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
	pFrame->GetDockBar(DOCKBAR_LEFT)->SetBigControlState(check);

	check = (BOOL)GetLongGadgetValue(_R(IDC_BIGRIGHT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
	pFrame->GetDockBar(DOCKBAR_RIGHT)->SetBigControlState(check);

	check = (BOOL)GetLongGadgetValue(_R(IDC_BIGBOTTOM),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
	pFrame->GetDockBar(DOCKBAR_BOTTOM)->SetBigControlState(check);

	check = (BOOL)GetLongGadgetValue(_R(IDC_BIGFLOAT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
	pFrame->GetDockBar(DOCKBAR_FLOAT)->SetBigControlState(check);


	CCustomList* pListGadget = CCustomList::GetGadget(GetReadWriteWindowID(), _R(IDC_BARLIST));
	if (pListGadget == NULL)
		return;
	
	// Adjust the visibility of the bars...
	INT32 listitem = 0;
	INT32 listcount = pListGadget->GetItemCount();
	String_32 BarName;
		
	// variables control the dynamic relocation of the 'floating' toolbar ....
//	INT32 ToolbarIndex = -1;
//	BOOL BeenHidden = FALSE;
//	BOOL ToolbarCurrentState = FALSE;
	
	while (listitem < listcount)
	{
		// Find bar by name...
		pListGadget->GetItemString(BarName, listitem, 1);

		// If name is "Infobar" deal with it specially...
		if (BarName == InfoBarName)
			InformationBarOp::SetVisibility(pListGadget->GetSwitchState(listitem, 0));
		else if (BarName == String_32 (TEXT ("Toolbar")))
		{
			// do special stuff now ....

			DialogBarOp* pBar = DialogBarOp::FindDialogBarOp(BarName);
			ERROR3IF(pBar == NULL, "Cannot find named bar in TakeToolbarDetails");

			// If bar is of correct type then adjust its visibility according to the
			// check mark...
			if (!pBar->IsKindOf(CC_RUNTIME_CLASS(SystemBarOp)) ||
				!pBar->IsKindOf(CC_RUNTIME_CLASS(InformationBarOp)) )
			{
				//ToolbarIndex = listitem;
				
				BOOL CurrentState = pBar->IsVisible ();
				//ToolbarCurrentState = CurrentState;
				pBar->SetVisibility(pListGadget->GetSwitchState(listitem, 0));

				if (pListGadget->GetSwitchState(listitem, 0) != CurrentState)
				{	
					if (pListGadget->GetSwitchState(listitem, 0))
					{
						GetMainFrame ()->SetToolbarCreated (TRUE);
						GetMainFrame ()->RelocateToolbar ();
					}
					else
					{
						// so that we can lock out the toolbar 'onmove' and 'onsize' code
						// from being executed when there is no toolbar
						GetMainFrame ()->SetToolbarCreated (FALSE);
					}
				}
			//	else
			//	{
			//		BeenHidden = TRUE;
			//	}
			}
		}
		else
		{
			// Look for the named bar in the barops list...
			DialogBarOp* pBar = DialogBarOp::FindDialogBarOp(BarName);
			ERROR3IF(pBar == NULL, "Cannot find named bar in TakeToolbarDetails");

			// If bar is of correct type then adjust its visibility according to the
			// check mark...
			if (!pBar->IsKindOf(CC_RUNTIME_CLASS(SystemBarOp)) ||
				!pBar->IsKindOf(CC_RUNTIME_CLASS(InformationBarOp)) )
			{
				pBar->SetVisibility(pListGadget->GetSwitchState(listitem, 0));
			}
		}

		listitem++;
	}

	// dynamically reposition the toolbar when the above options are changed ....
	
/*	if ((ToolbarIndex != -1) && (!BeenHidden))
	{
		if (pListGadget->GetSwitchState(ToolbarIndex, 0) != ToolbarCurrentState)
		if (pListGadget->GetSwitchState(ToolbarIndex, 0))
		{
			GetMainFrame ()->SetToolbarCreated (TRUE);
			GetMainFrame ()->RelocateToolbar ();
		}
	}*/
}
Beispiel #3
0
MsgResult ToolbarDlg::Message(Msg* Message)
{
	if (IS_OUR_DIALOG_MSG(Message))
	{
		DialogMsg* Msg = (DialogMsg*)Message;
		BOOL EndDialog = FALSE;

		switch (Msg->DlgMsg)
		{
			case DIM_CANCEL:
			case DIM_COMMIT:
 				// Cancel all changes the user wants to make to toolbars...
 				EndDialog = TRUE;
 			break;
	
 		 	case DIM_SELECTION_CHANGED:
 		 	case DIM_SELECTION_CHANGED_COMMIT:
				TakeToolbarDetails();
				break;
	
			case DIM_LFT_BN_CLICKED:
			{	// A control in the Toolbars... dialog has been clicked...
			 	CMainFrame* pFrame = GetMainFrame();
				BOOL	check;
				BOOL	VV;
				switch (Msg->GadgetID)
				{
					case _R(IDC_BIGALL):
						// Select all the large buttons...
						SetLongGadgetValue(_R(IDC_BIGTOP),1);
						SetLongGadgetValue(_R(IDC_BIGLEFT),1);
						SetLongGadgetValue(_R(IDC_BIGRIGHT),1);
						SetLongGadgetValue(_R(IDC_BIGBOTTOM),1);
						SetLongGadgetValue(_R(IDC_BIGFLOAT),1);
						TakeToolbarDetails();
					break;

					case _R(IDC_BIGNONE):
						// Deselect all the large buttons...
						SetLongGadgetValue(_R(IDC_BIGTOP),0);
						SetLongGadgetValue(_R(IDC_BIGLEFT),0);
						SetLongGadgetValue(_R(IDC_BIGRIGHT),0);
						SetLongGadgetValue(_R(IDC_BIGBOTTOM),0);
						SetLongGadgetValue(_R(IDC_BIGFLOAT),0);
						TakeToolbarDetails();
					break;

					case _R(IDC_NEWBAR):
						NewToolbar();
						break;

					case _R(IDC_BIGTOP):
						check = (BOOL)GetLongGadgetValue(_R(IDC_BIGTOP),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
						pFrame->GetDockBar(DOCKBAR_TOP)->SetBigControlState(check);
						break;
					case _R(IDC_BIGLEFT):
						check = (BOOL)GetLongGadgetValue(_R(IDC_BIGLEFT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
						pFrame->GetDockBar(DOCKBAR_LEFT)->SetBigControlState(check);
						break;
					case _R(IDC_BIGRIGHT):
						check = (BOOL)GetLongGadgetValue(_R(IDC_BIGRIGHT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
						pFrame->GetDockBar(DOCKBAR_RIGHT)->SetBigControlState(check);
						break;
					case _R(IDC_BIGBOTTOM):
						check = (BOOL)GetLongGadgetValue(_R(IDC_BIGBOTTOM),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
						pFrame->GetDockBar(DOCKBAR_BOTTOM)->SetBigControlState(check);
						break;
					case _R(IDC_BIGFLOAT):	
						check = (BOOL)GetLongGadgetValue(_R(IDC_BIGFLOAT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
						pFrame->GetDockBar(DOCKBAR_FLOAT)->SetBigControlState(check);
						break;
					
				
					case _R(IDC_DELETEBAR):		
					{	
						String_32 BarName;
						GetSelectedBarName(&BarName);

						if (BarName != String_8(TEXT("")))
						{
		 					// we can't delete the infoobar
							if(BarName == String_32(TEXT("Infobar")))
							{
								InformWarning(_R(IDS_CANTDELETEINFOBAR),_R(IDS_OK));
								break;
							}

							INT32 ButtonPressed = 1;
							ButtonPressed = InformWarning(_R(IDS_WARNDELETEBAR), _R(IDS_OK),_R(IDS_CANCEL));
							Error::ClearError();
							if (ButtonPressed ==  1)
								DeleteSelectedBar();
						}
						break;	
					}

					case _R(IDC_RESETBARS):		
					{	
						INT32 ButtonPressed = 1;						
						ButtonPressed = InformWarning(_R(IDS_WARNRESETBARS), _R(IDS_OK),_R(IDS_CANCEL));
						Error::ClearError();

						if(ButtonPressed ==  1)
						{
					  		Progress::Start(FALSE);
							// lock the window to avoid untidy layout recalcs
							::LockWindowUpdate(GetMainFrame()->GetSafeHwnd());

							// tell the mainframe we are changing modes - this prevents
							// some unnecessary work
							GetMainFrame()->SetChangingMode(TRUE);

							// kill all bars ( except infobar at the mo..)
							BROADCAST_TO_CLASS(DialogMsg(NULL, DIM_BAR_DEATH, NULL ),DialogBarOp);
							// hide the info bar
							InformationBarOp::SetVisibility(FALSE,TRUE);

							DialogBarOp::WipeBarFiles();

							DialogBarOp::LoadDefaultBars();
							
							// force the info bar to the correct visible state
							InformationBarOp::SetVisibility(InformationBarOp::IsVisible(),TRUE);
							// All clear to Mainframe
							GetMainFrame()->SetChangingMode(FALSE);

							// Make sure everything is positioned correctly
							GetMainFrame()->RecalcLayout();

							// Now handle the toolbar ....
							GetMainFrame ()->SetToolbarCreated (TRUE);
							GetMainFrame ()->RelocateToolbar ();

							// and unlock and show the window
							::LockWindowUpdate(NULL);
							ShowToolbarList();
							ShowToolbarSizes();
							Progress::Stop();
						}
						break;			
					}
				}
				break;
			}
		}

		if (EndDialog)	// Dialog communication over
		{

			Close();	// Close the dialog
			End();		// Destroy dialog
			return(OK);	// After destroying this object, it's very dangerous to call base class!
	   	}
	}
	else if ( MESSAGE_IS_A(Message,BarMsg) )
	{
		switch ( ((BarMsg*)Message)->Reason )
		{
			case BAR_CHANGESTATE:
				// A bar simply became horizontal, vertical or floating and we don't care
				// about that so do nothing.
				break;

			default:
				// In most cases of BarMsg we want to show the user what happened...
				ShowToolbarList();		// Show changes in bars to user
										// Note: it would be more optimal to use the pointer
										// to the bar that comes with this message to just
										// alter that item in the list.
				break;
		}
	}

	return DialogOp::Message(Message);
}