20 EventSplitPaneMoved evt(
this);
41 if (iPane < 0 || iPane >=
m_lstPane.GetCount())
51 if (iPane < 0 || iPane >=
m_lstPane.GetCount())
81 HCURSOR hCursor = GETRESPROVIDER->LoadCursor((
m_orintation == Vertical) ? IDC_SIZEWE : IDC_SIZENS);
94 CRect rcSep = rcClient;
96 rcSep.right = rcClient.left;
98 rcSep.bottom = rcSep.top;
100 LONG &RB = (
m_orintation == Vertical) ? rcSep.right : rcSep.bottom;
101 LONG < = (
m_orintation == Vertical) ? rcSep.left : rcSep.top;
103 for (
int i = 0; i < (int)
m_lstPane.GetCount() - 1; i++)
107 CRect rcPane =
m_lstPane[i]->GetWindowRect();
108 RB += (
m_orintation == Vertical) ? rcPane.Width() : rcPane.Height();
117 __baseCls::OnLButtonDown(nFlags, pt);
125 for (
int i = 0; i < (int)
m_lstPane.GetCount(); i++)
136 for (
int i = 0; i < (int)
m_lstPane.GetCount(); i++)
149 __baseCls::OnLButtonUp(nFlags, pt);
159 SplitPaneList lstPane1, lstPane2;
160 SplitPaneList lstPriority1, lstPriority2;
162 for (
int i = 0; i < (int)
m_lstPane.GetCount(); i++)
176 lstPriority1.Add(pane);
178 lstPriority2.Add(pane);
184 int diff =
m_orintation == Vertical ? diffPoint.x : diffPoint.y;
186 PANESIZELIST lstPaneSize1, lstPaneSize2;
192 int maxShrink = 0, maxExtent = 0;
193 for (
int i = 0; i < (int)lstPaneSize1.GetCount(); i++)
195 maxExtent += lstPaneSize1[i].maximum - lstPaneSize1[i].actural;
197 for (
int i = 0; i < (int)lstPaneSize2.GetCount(); i++)
199 maxShrink += lstPaneSize2[i].actural - lstPaneSize2[i].minimum;
201 diff = smin(diff, smin(maxShrink, maxExtent));
206 int idxPrev = lstPriority1.Find(lstPane1.GetAt(lstPane1.GetCount() - 1));
207 SASSERT(idxPrev != -1);
208 PANESIZE &paneSize1 = lstPaneSize1[idxPrev];
210 int max_digest = paneSize1.maximum - paneSize1.actural;
211 if (max_digest > diff)
213 paneSize1.actural += diff;
217 paneSize1.actural += max_digest;
218 PANESIZE szBackup = paneSize1;
219 lstPaneSize1.RemoveAt(idxPrev);
220 int remain = diff - max_digest;
222 lstPaneSize1.InsertAt(idxPrev, szBackup);
226 int idxNext = lstPriority2.Find(lstPane2[0]);
227 SASSERT(idxNext != -1);
228 PANESIZE &paneSize2 = lstPaneSize2[idxNext];
230 max_digest = paneSize2.actural - paneSize2.minimum;
231 if (max_digest > diff)
233 paneSize2.actural -= diff;
237 paneSize2.actural -= max_digest;
238 PANESIZE szBackup = paneSize2;
239 lstPaneSize2.RemoveAt(idxNext);
240 int remain = max_digest - diff;
242 lstPaneSize2.InsertAt(idxNext, szBackup);
247 int maxShrink = 0, maxExtent = 0;
248 for (
int i = 0; i < (int)lstPaneSize2.GetCount(); i++)
250 maxExtent += lstPaneSize2[i].maximum - lstPaneSize2[i].actural;
252 for (
int i = 0; i < (int)lstPaneSize1.GetCount(); i++)
254 maxShrink += lstPaneSize1[i].actural - lstPaneSize1[i].minimum;
258 diff = smin(diff, smin(maxShrink, maxExtent));
263 int idxPrev = lstPriority1.Find(lstPane1.GetAt(lstPane1.GetCount() - 1));
264 SASSERT(idxPrev != -1);
265 PANESIZE &paneSize1 = lstPaneSize1[idxPrev];
267 int max_digest = paneSize1.actural - paneSize1.minimum;
268 if (max_digest > diff)
270 paneSize1.actural -= diff;
274 paneSize1.actural -= max_digest;
275 PANESIZE szBackup = paneSize1;
276 lstPaneSize1.RemoveAt(idxPrev);
277 int remain = max_digest - diff;
279 lstPaneSize1.InsertAt(idxPrev, szBackup);
283 int idxNext = lstPriority2.Find(lstPane2[0]);
284 SASSERT(idxNext != -1);
285 PANESIZE &paneSize2 = lstPaneSize2[idxNext];
287 max_digest = paneSize2.maximum - paneSize2.actural;
288 if (max_digest > diff)
290 paneSize2.actural += diff;
294 paneSize2.actural += max_digest;
295 PANESIZE szBackup = paneSize2;
296 lstPaneSize2.RemoveAt(idxNext);
297 int remain = diff - max_digest;
299 lstPaneSize2.InsertAt(idxNext, szBackup);
306 int nOffset =
m_orintation == Vertical ? rcClient.left : rcClient.top;
315 for (UINT i = 0; i <
m_lstPane.GetCount(); i++)
354 rc.DeflateRect(
GetStyle().GetPadding());
379 if (!rcContainer.IsRectEmpty())
381 PANESIZELIST lstPaneSize;
385 lstPaneSize[index].actural = lstPaneSize[index].preferred;
394 if (lstPaneSize.IsEmpty())
399 for (
int i = 0; i < (int)lstPaneSize.GetCount(); i++)
400 actural += lstPaneSize[i].actural;
402 int nVisiblePanelCount = 0;
406 ++nVisiblePanelCount;
409 int remain = ((Vertical ==
m_orintation) ? rc.Width() : rc.Height()) - actural - (nVisiblePanelCount - 1) *
m_spliterSize;
411 int nOffset = (Vertical ==
m_orintation) ? rc.left : rc.top;
418 for (
int i = 0; i < (int)lstPriority.GetCount(); i++)
420 PANESIZE &pane = lstPriority[i];
423 if (pane.preferred < pane.actural)
426 int max_digest = pane.preferred - pane.actural;
427 if (max_digest >= remain)
429 pane.actural += remain;
435 pane.actural += max_digest;
436 remain -= max_digest;
441 if (pane.preferred > pane.actural)
444 int max_digest = pane.actural - pane.preferred;
445 if (max_digest > -remain)
447 pane.actural += remain;
453 pane.actural -= max_digest;
454 remain += max_digest;
461 for (
int i = (
int)lstPriority.GetCount() - 1; i >= 0; i--)
463 PANESIZE &pane = lstPriority[i];
466 int max_digest = pane.maximum - pane.actural;
467 if (max_digest >= remain)
469 pane.actural += remain;
475 pane.actural += max_digest;
476 remain -= max_digest;
481 int max_digest = pane.actural - pane.minimum;
482 if (max_digest > -remain)
484 pane.actural += remain;
490 pane.actural -= max_digest;
491 remain += max_digest;
503 for (
int i = 0; i < (int)lstPane.GetCount(); i++)
505 int idx = lstPanePriority.Find(lstPane[i]);
510 rc.right = (offset + lstPaneSize[idx].actural);
515 rc.bottom = (offset + lstPaneSize[idx].actural);
519 lstPane[i]->Move(rc);
524 offset += lstPaneSize[idx].actural;
532 lstPaneSize.SetCount(lstPane.GetCount());
534 for (
int i = 0; i < (int)lstPane.GetCount(); i++)
538 lstPaneSize[i].actural = 0;
539 lstPaneSize[i].preferred = 0;
540 lstPaneSize[i].minimum = 0;
541 lstPaneSize[i].maximum = 0;
545 lstPaneSize[i].preferred = lstPane[i]->m_nSizeIdeal.toPixelSize(
GetScale());
546 lstPaneSize[i].minimum = lstPane[i]->m_nSizeMin.toPixelSize(
GetScale());
547 lstPaneSize[i].maximum = lstPane[i]->m_nSizeMax.toPixelSize(
GetScale());
550 lstPane[i]->GetWindowRect(&rcItem);
553 lstPaneSize[i].actural = rcItem.Width();
557 lstPaneSize[i].actural = rcItem.Height();
559 if (lstPaneSize[i].actural == 0)
560 lstPaneSize[i].actural = lstPane[i]->m_nSizeMin.toPixelSize(
GetScale());
Definition of the SSplitWnd and related classes.
BOOL addEvent(DWORD dwEventID, LPCWSTR pszEventHandlerName)
添加一个新事件到事件集
LPCWSTR GetName() SCONST OVERRIDE
static LPCWSTR GetClassName()
A pane within a split window.
SSplitPane()
Constructor for SSplitPane.
void Move(CRect rc)
Moves the pane to a new position.
void Relayout(const CRect &rc, PANESIZELIST lstPaneSize=PANESIZELIST())
Relayouts the panes within the window.
static int FunComp(const void *p1, const void *p2)
Comparison function for qsort.
virtual BOOL CreateChildren(SXmlNode xmlNode)
Creates child windows from an XML node.
void OnLButtonUp(UINT nFlags, CPoint pt)
Handles left mouse button up events.
SAutoRefPtr< ISkinObj > m_pSkinSep
SSplitWnd(void)
Constructor for SSplitWnd.
void UpdateChildrenPosition() OVERRIDE
Updates the positions of child windows.
void OnLButtonDown(UINT nFlags, CPoint pt)
Handles left mouse button down events.
int InsertItem(SSplitPane *pane, int index=-1)
Inserts a new pane.
void OnMouseMove(UINT nFlags, CPoint pt)
Handles mouse move events.
void RemoveItem(SSplitPane *pane)
Removes a pane.
void GetChildrenLayoutRect(RECT *prc) SCONST OVERRIDE
Retrieves the layout rectangle for child windows.
BOOL HidePane(UINT iPane)
Hides a pane.
int ResetPanesPostion(SplitPaneList &lstPane, SplitPaneList &lstPanePriority, PANESIZELIST &lstPaneSize, int offset)
Resets the positions of the panes based on size information.
SSplitPane * GetPane(UINT iPane)
Retrieves a pane by index.
void FatchPaneSizeInfo(const SplitPaneList &lstPane, PANESIZELIST &lstPaneSize)
Fetches size information for the panes.
virtual BOOL OnSetCursor(const CPoint &pt)
Sets the cursor.
int AdjustPanesSize(PANESIZELIST &lstPriority, int remain)
Adjusts the sizes of the panes.
int PaneIndex(const SStringW &strName) const
Retrieves the index of a pane by its name.
virtual ~SSplitWnd(void)
Destructor for SSplitWnd.
void SortPriorityList(SplitPaneList &lstPane)
Sorts the pane list by priority.
SplitPaneList m_lstPriority
BOOL ShowPane(UINT iPane)
Shows a pane.
void OnPaint(IRenderTarget *pRT)
Paints the window.
A class representing an ASCII string.
BOOL FireEvent(IEvtArgs *evt) OVERRIDE
Fires an event.
int GetScale() SCONST OVERRIDE
Retrieves the scale factor of the window.
BOOL IsVisible(BOOL bCheckParent=FALSE) SCONST OVERRIDE
Checks if the window is visible.
virtual CRect GetClientRect() const
Retrieves the client rectangle of the window.
void InsertChild(SWindow *pNewChild, SWindow *pInsertAfter=NULL)
Inserts a child window into the window tree.
SEventSet * GetEventSet()
Retrieves the event set associated with the window.
void Invalidate() OVERRIDE
Invalidates the entire window.
BOOL InitFromXml(IXmlNode *pNode) OVERRIDE
Initializes the window from an XML node.
void Update(BOOL bForce=FALSE) OVERRIDE
Updates the window.
const SwndStyle & GetStyle() const
Retrieves the style of the window.
void Move(LPCRECT prect) OVERRIDE
Moves the window to a new position and size.
Class representing an XML node.
SXmlNode next_sibling() const
Gets the next sibling node in the children list of the parent node.
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
Interface for rendering target objects.