| 2199 | } |
| 2200 | |
| 2201 | CSplitContainer * CSplitContainer::Create(CPanel * pPanelA, CPanel * pPanelB) |
| 2202 | { |
| 2203 | CSplitPanel * pSplitPanelA = dynamic_cast<CSplitPanel *>( pPanelA ); |
| 2204 | if (pSplitPanelA != NULL) |
| 2205 | { |
| 2206 | return NULL; // already a part of a CSplitContainer |
| 2207 | } |
| 2208 | |
| 2209 | CSplitPanel * pSplitPanelB = dynamic_cast<CSplitPanel *>( pPanelB ); |
| 2210 | if (pSplitPanelB != NULL) |
| 2211 | { |
| 2212 | return NULL; // already a part of a CSplitContainer |
| 2213 | } |
| 2214 | |
| 2215 | CRect rcDest(0, 0, 0, 0); |
| 2216 | SplitterOrientation orien = SPLIT_CONTAINER_H; |
| 2217 | |
| 2218 | if (::IntersectRect(&rcDest, pPanelA, pPanelB) == TRUE) // invalid spliter container, a spliter continer's two panel cannot intersect each other |
| 2219 | { |
| 2220 | return NULL; |
| 2221 | } |
| 2222 | |
| 2223 | |
| 2224 | if (pPanelA->right < pPanelB->left) |
| 2225 | { |
| 2226 | orien = SPLIT_CONTAINER_H; |
| 2227 | } |
| 2228 | else if (pPanelA->bottom < pPanelB->top) |
| 2229 | { |
| 2230 | orien = SPLIT_CONTAINER_V; |
| 2231 | } |
| 2232 | else |
| 2233 | { |
| 2234 | return NULL; |
| 2235 | } |
| 2236 | if (pPanelA->Parent != NULL) |
| 2237 | { |
| 2238 | if (pPanelA->Parent->RemoveChild( pPanelA ) == FALSE) |
| 2239 | { |
| 2240 | return NULL; |
| 2241 | } |
| 2242 | } |
| 2243 | if (pPanelB->Parent != NULL) |
| 2244 | { |
| 2245 | if (pPanelB->Parent->RemoveChild( pPanelB ) == FALSE) |
| 2246 | { |
| 2247 | return NULL; |
| 2248 | } |
| 2249 | } |
| 2250 | |
| 2251 | pSplitPanelA = new CSplitPanel( pPanelA ); |
| 2252 | pSplitPanelB = new CSplitPanel( pPanelB ); |
| 2253 | |
| 2254 | |
| 2255 | CSplitContainer * pSpliter = new CSplitContainer(pSplitPanelA, pSplitPanelB, orien); |
| 2256 | return pSpliter; |
| 2257 | |
| 2258 | } |
nothing calls this directly
no test coverage detected