void
JXDockDragData::AddTypes
	(
	const Atom selectionName
	)
{
	AddType((JXGetDockManager())->GetDNDMinSizeAtom());
	AddType((JXGetDockManager())->GetDNDWindowAtom());
}
JXMenuBar::JXMenuBar
	(
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXWidget(enclosure, hSizing, vSizing, x,y, w,h),
	itsOverflowMenu(NULL),
	itsIgnoreWidthChangedCount(0)
{
	itsMenus = new JPtrArray<JXMenu>(JPtrArrayT::kForgetAll);
	assert( itsMenus != NULL );

	SetBorderWidth(kJXDefaultBorderWidth);

	JXDockManager* dockMgr;
	if (JXGetDockManager(&dockMgr))
		{
		Move(JXDocktab::kWidth, 0);
		AdjustSize(-JXDocktab::kWidth, 0);

		JXDocktab* tab =
			new JXDocktab(enclosure,
						  hSizing == kFixedRight ? kFixedRight : kFixedLeft,
						  vSizing, x, y, JXDocktab::kWidth, h);
		assert( tab != NULL );
		}
}
JXDockDirector::JXDockDirector
	(
	std::istream&			input,
	const JFileVersion	vers,
	const JCharacter*	title
	)
	:
	JXWindowDirector(JXGetDockManager()),
	itsHorizPartition(NULL),
	itsVertPartition(NULL),
	itsFocusWindow(NULL)
{
	JBoolean splitHoriz;
	input >> splitHoriz;

	BuildWindow(title, splitHoriz);
	GetWindow()->ReadGeometry(input);

	if (itsHorizPartition != NULL)
		{
		itsHorizPartition->ReadSetup(input, vers);
		}
	else
		{
		itsVertPartition->ReadSetup(input, vers);
		}
}
Пример #4
0
JXDockWidget::~JXDockWidget()
{
	const JXDockManager::CloseDockMode mode = (JXGetDockManager())->GetCloseDockMode();
	if (itsWindowList != NULL && mode == JXDockManager::kUndockWindows)
		{
		// can't call UndockAll() because that calls UpdateMinSize()

		const JSize count = itsWindowList->GetElementCount();
		for (JIndex i=1; i<=count; i++)
			{
			JXWindow* w = itsWindowList->NthElement(i);
			StopListening(w);
			w->Undock();
			}

		delete itsWindowList;
		}
	else if (itsWindowList != NULL)
		{
		assert( mode == JXDockManager::kCloseWindows );

		const JSize count = itsWindowList->GetElementCount();
		for (JIndex i=1; i<=count; i++)
			{
			JXWindow* w = itsWindowList->NthElement(i);
			StopListening(w);
			w->Close();
			}

		delete itsWindowList;
		}
}
JBoolean
JXDockDragData::ConvertData
	(
	const Atom		requestType,
	Atom*			returnType,
	unsigned char**	data,
	JSize*			dataLength,
	JSize*			bitsPerBlock
	)
	const
{
	if (requestType == (JXGetDockManager())->GetDNDMinSizeAtom())
		{
		*returnType   = XA_POINT;
		*bitsPerBlock = 16;
		*dataLength   = sizeof(XPoint);
		*data         = new unsigned char[ *dataLength ];
		if (*data != NULL)
			{
			const JPoint minSize = itsWindow->GetMinSize();
			XPoint* xpt          = (XPoint*) *data;
			xpt->x               = JMin(minSize.x, (JCoordinate) SHRT_MAX);
			xpt->y               = JMin(minSize.y, (JCoordinate) SHRT_MAX);
			return kJTrue;
			}
		}

	else if (requestType == (JXGetDockManager())->GetDNDWindowAtom())
		{
		*returnType   = XA_WINDOW;
		*bitsPerBlock = 32;
		*dataLength   = sizeof(Window);
		*data         = new unsigned char[ *dataLength ];
		if (*data != NULL)
			{
			*((Window*) *data) = itsWindow->GetXWindow();
			return kJTrue;
			}
		}

	*bitsPerBlock = 8;
	*data         = NULL;
	*dataLength   = 0;
	*returnType   = None;
	return kJFalse;
}
void
TestjxDeleteGlobals()
{
	ofstream output(kDockSetupFileName);
	(JXGetDockManager())->WriteSetup(output);

	theApplication = NULL;
	theMDIServer   = NULL;
}
Пример #7
0
void
JXDockWidget::SetID
	(
	const JIndex id
	)
{
	itsID = id;
	(JXGetDockManager())->IDUsed(id);
}
JXDockDirector::JXDockDirector
	(
	const JCharacter*	title,
	const JBoolean		splitHoriz
	)
	:
	JXWindowDirector(JXGetDockManager()),
	itsHorizPartition(NULL),
	itsVertPartition(NULL),
	itsFocusWindow(NULL)
{
	BuildWindow(title, splitHoriz);
}
Пример #9
0
JXDockWidget::JXDockWidget
	(
	JXDockDirector*		director,
	JXPartition*		partition,
	const JBoolean		isHorizPartition,
	JXTabGroup*			tabGroup,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXWidgetSet(enclosure, hSizing, vSizing, x,y, w,h),
	itsDirector(director),
	itsPartition(partition),
	itsIsHorizFlag(isHorizPartition),
	itsTabGroup(tabGroup),
	itsID((JXGetDockManager())->GetUniqueDockID()),
	itsWindowList(NULL),
	itsMinSize(kDefaultMinSize, kDefaultMinSize),
	itsChildPartition(NULL)
{
	assert( itsDirector != NULL );
	assert( itsPartition != NULL );
	assert( itsTabGroup != NULL );

	if (!(JXGetDockManager())->IsReadingSetup())
		{
		(JXGetDockManager())->IDUsed(itsID);
		}

	ListenTo(itsTabGroup);
	ListenTo(itsTabGroup->GetCardEnclosure());
}
void
JXDockDirector::BuildWindow
	(
	const JCharacter*	title,
	const JBoolean		splitHoriz
	)
{
	const JCoordinate kSize = 300;

	JArray<JCoordinate> sizes;
	sizes.AppendElement(kSize);
	sizes.AppendElement(kSize);

	JArray<JCoordinate> minSizes;
	minSizes.AppendElement(JXDockWidget::kDefaultMinSize);
	minSizes.AppendElement(JXDockWidget::kDefaultMinSize);

	const JCoordinate w = 2*kSize + (splitHoriz ? JPartition::kDragRegionSize : 0);
	const JCoordinate h = 2*kSize + (splitHoriz ? 0 : JPartition::kDragRegionSize);

	JXWindow* window = jnew JXWindow(this, w, h, title);
	assert( window != NULL );

	JXImage* icon;
	if ((JXGetDockManager())->CreateIcon(&icon))
		{
		window->SetIcon(icon);
		}

	if (splitHoriz)
		{
		itsHorizPartition =
			jnew JXHorizDockPartition(this, NULL, sizes, 0, minSizes,
									 window, JXWidget::kHElastic, JXWidget::kVElastic,
									 0,0, w,h);
		assert( itsHorizPartition != NULL );
		}
	else
		{
		itsVertPartition =
			jnew JXVertDockPartition(this, NULL, sizes, 0, minSizes,
									window, JXWidget::kHElastic, JXWidget::kVElastic,
									0,0, w,h);
		assert( itsVertPartition != NULL );
		}

	window->SetMinSize(100,100);
	window->SetWMClass("Dock", JXGetDockWindowClass());
}
JBoolean
JXDockDirector::Close()
{
	JXApplication* app = JXGetApplication();
	JXDockManager* mgr = JXGetDockManager();
	if (mgr->IsLastDock(this) && !app->IsQuitting() && HasWindows())
		{
		app->Quit();
		return kJFalse;
		}
	else
		{
		// We must close all windows before closing ourselves because
		// otherwise, we will get a Draw event after partially destructing
		// if a document needs to ask the user whether or not to close.

		return JI2B( CloseAllWindows() && JXWindowDirector::Close() );
		}
}
Пример #12
0
void
JXDocktab::UpdateActionMenu()
{
	JXDockManager* dockMgr;
	if (!JXGetDockManager(&dockMgr))
		{
		itsActionMenu->RemoveAllItems();
		return;
		}

	while (itsActionMenu->GetItemCount() >= kShowFirstDockCmd)
		{
		itsActionMenu->RemoveItem(itsActionMenu->GetItemCount());
		}

	JPtrArray<JXDockDirector>* dockList = dockMgr->GetDockList();

	const JSize dockCount = dockList->GetElementCount();
	for (JIndex i=1; i<=dockCount; i++)
		{
		JString itemText = ((dockList->NthElement(i))->GetWindow())->GetTitle();
		itemText.Prepend(JGetString(kShowDockPrefixID));
		itsActionMenu->AppendItem(itemText);
		}

	const JBoolean isDocked = (GetWindow())->IsDocked();
	itsActionMenu->SetItemEnable(kUndockCmd, isDocked);
	itsActionMenu->SetItemEnable(kUndockAllCompartmentCmd, isDocked);
	itsActionMenu->SetItemEnable(kUndockAllDockCmd, isDocked);
	itsActionMenu->SetItemEnable(kUndockAllCmd, JI2B(dockCount > 0));
	itsActionMenu->SetItemEnable(kDockAllDefConfigCmd, dockMgr->CanDockAll());

	itsActionMenu->SetItemEnable(kUpdateWindowTypeMapCmd, (GetWindow())->HasWindowType());
	if (isDocked)
		{
		itsActionMenu->SetItemText(kUpdateWindowTypeMapCmd, JGetString(kAddToWindowTypeMapID));
		}
	else
		{
		itsActionMenu->SetItemText(kUpdateWindowTypeMapCmd, JGetString(kRemoveFromWindowTypeMapID));
		}
}
Пример #13
0
void
CBDeleteGlobals()
{
	theDocManager->JPrefObject::WritePrefs();

	JXDockManager* dockMgr;
	if (JXGetDockManager(&dockMgr))
		{
		dockMgr->JPrefObject::WritePrefs();
		}

	if (theMDIServer != NULL)
		{
		theMDIServer->JPrefObject::WritePrefs();
		}

	CBDeleteIcons();

	theApplication = NULL;
	theDocManager  = NULL;
	theMDIServer   = NULL;

	theCmdManager->JPrefObject::WritePrefs();
	delete theCmdManager;
	theCmdManager = NULL;

	delete theFnMenuUpdater;
	theFnMenuUpdater = NULL;

	delete theSymbolTypeList;
	theSymbolTypeList = NULL;

	// printers

	delete thePTTextPrinter;
	thePTTextPrinter = NULL;

	delete thePSTextPrinter;
	thePSTextPrinter = NULL;

	CBShutdownCompleters();
	CBShutdownStylers();

	// windows closed by JXGetPersistentWindowOwner()

	theSearchTextDialog->JPrefObject::WritePrefs();
	theRunTEScriptDialog->JPrefObject::WritePrefs();
	theViewManPageDialog->JPrefObject::WritePrefs();
	theFindFileDialog->JPrefObject::WritePrefs();
	theDiffFileDialog->JPrefObject::WritePrefs();

	theSearchTextDialog  = NULL;
	theRunTEScriptDialog = NULL;
	theViewManPageDialog = NULL;
	theFindFileDialog    = NULL;
	theDiffFileDialog    = NULL;

	// this must be last so everybody else can use it to save their setup

	delete thePrefsManager;
	thePrefsManager = NULL;
}
Пример #14
0
void
JXDocktab::HandleActionMenu
	(
	const JIndex index
	)
{
	JXDockManager* dockMgr;
	if (!JXGetDockManager(&dockMgr))
		{
		return;
		}

	if (index == kUndockCmd)
		{
		(GetWindow())->Undock();
		}
	else if (index == kUndockAllCompartmentCmd)
		{
		JXDockWidget* dock;
		if ((GetWindow())->GetDockWidget(&dock))
			{
			dock->UndockAll();
			}
		}
	else if (index == kUndockAllDockCmd)
		{
		JXWindow* w;
		if ((GetWindow())->GetDockWindow(&w))
			{
			w->UndockAllChildWindows();
			}
		}
	else if (index == kUndockAllCmd)
		{
		(GetDisplay())->UndockAllWindows();
		}

	else if (index == kUpdateWindowTypeMapCmd)
		{
		JXWindow* w = GetWindow();
		const JCharacter* type;
		if (w->GetWindowType(&type))
			{
			JXDockWidget* dock;
			w->GetDockWidget(&dock);
			(JXGetDockManager())->SetDefaultDock(type, w->IsDocked() ? dock : NULL);
			}
		}

	else if (index == kCreateDockHorizCmd)
		{
		dockMgr->CreateDock(kJTrue);
		}
	else if (index == kCreateDockVertCmd)
		{
		dockMgr->CreateDock(kJFalse);
		}
	else if (index == kDockAllDefConfigCmd)
		{
		dockMgr->DockAll();
		}

	else if (index >= kShowFirstDockCmd)
		{
		JPtrArray<JXDockDirector>* dockList = dockMgr->GetDockList();
		const JIndex i                      = index - kShowFirstDockCmd + 1;
		if (dockList->IndexValid(i))		// paranoia
			{
			(dockList->NthElement(i))->Activate();
			}
		}
}