Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

resizedlg.cpp

Go to the documentation of this file.
00001 // ResizeDlg.cpp: implementation of the CResizeDlg class. 00002 // 00004 00005 #include "pch.h" 00006 #include "ResizeDlg.h" 00007 #include "debug.h" 00008 #include "persctl.h" 00009 // #include "w32err.h" // #include "E:\nt\private\NTOS\w32\w32inc\w32err.h" 00010 // #include "usercli.h" // #include "e:\nt\private\ntos\w32\ntuser\client\usercli.h" 00011 // #include "resource.h" 00012 // #include "E:\nt\private\NTOS\w32\w32inc\w32err.h" 00013 00014 00015 #define MIN_COL_SPACE 4 00016 #define MIN_ROW_SPACE 4 00017 00018 void* __cdecl operator new(size_t n) 00019 { 00020 // return malloc(n); 00021 return GlobalAlloc( GPTR, n); 00022 } 00023 00024 void __cdecl operator delete(void* p) 00025 { 00026 // free(p); 00027 GlobalFree(p); 00028 } 00029 00030 extern "C" { 00031 00032 LPVOID __cdecl MakeAResizeDlg(int id,HANDLE h) 00033 { 00034 return new CResizeDlg(id, NULL, (HINSTANCE)h); 00035 } 00036 00037 LRESULT ResizeDlgMessage( LPVOID pObject, 00038 HWND hwnd, 00039 UINT message, 00040 WPARAM wParam, 00041 LPARAM lParam ) 00042 { 00043 return ((CResizeDlg*)pObject)->DlgProc( hwnd, message, wParam, lParam ); 00044 } 00045 00046 00047 }; 00048 00049 00050 00051 00053 // Construction/Destruction 00055 00056 CResizeDlg::CResizeDlg(int DlgID, HWND hWndParent, HINSTANCE hInst) 00057 : BASECLASS(DlgID, hWndParent, hInst) 00058 { 00059 SetAnnotate(FALSE); 00060 SetRowWeight(0); 00061 SetColWeight(0); 00062 m_hwndGripper=NULL; 00063 } 00064 00065 CResizeDlg::~CResizeDlg() 00066 { 00067 00068 } 00069 00071 // 00072 // 00073 // 00075 BOOL CALLBACK CResizeDlg::DlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam) 00076 { 00077 switch( uMessage ) 00078 { 00079 case WM_NCHITTEST: 00080 { 00081 // Because we always turn on the resize frame, we must always hit test. 00082 // if( (GetRowWeight() !=0 ) || (GetColWeight() != 0 ) ) 00083 { 00084 // call def window proc to see what he wants to do 00085 LONG lRes= HitTest( DefWindowProc( hDlg, uMessage, wParam, lParam ) ); 00086 if( lRes != (HTERROR-1) ) 00087 { 00088 SetWindowLong( hDlg, DWL_MSGRESULT, lRes ); 00089 return TRUE; 00090 } 00091 } 00092 } 00093 break; 00094 00095 case WM_WINDOWPOSCHANGING: 00096 if( (GetRowWeight() !=0 ) || (GetColWeight() != 0 ) ) 00097 DoChangePos( (WINDOWPOS*)lParam); 00098 break; 00099 00100 case WM_ERASEBKGND: 00101 /* 00102 if( (GetRowWeight() !=0 ) || (GetColWeight() != 0 ) ) 00103 { 00104 HDC hdc=(HDC)wParam; 00105 RECT rcWindow; 00106 GetClientRect(hDlg, &rcWindow); 00107 int g_cxGrip = GetSystemMetrics( SM_CXVSCROLL ); 00108 int g_cyGrip = GetSystemMetrics( SM_CYHSCROLL ); 00109 rcWindow.left = rcWindow.right - g_cxGrip; // pWState->x_VSBArrow; 00110 rcWindow.top = rcWindow.bottom - g_cyGrip; // pWState->y_HSBArrow; 00111 DrawFrameControl(hdc, &rcWindow, DFC_SCROLL, DFCS_SCROLLSIZEGRIP); 00112 } 00113 */ 00114 break; 00115 00116 case WM_INITDIALOG: 00117 SetWindow(hDlg); 00118 DoInitDialog(); 00119 // Re-adjusts the dialogs to what we think they should be 00120 // breaks some apps who are completely owner draw. 00121 if( (GetRowWeight() !=0 ) || (GetColWeight() != 0 ) ) 00122 { 00123 AddGripper(); // need to sit on the size meesage too. 00124 RECT r; 00125 GetWindowRect( hDlg, &r); 00126 SetWindowPos( 00127 NULL, NULL, 0,0, r.right - r.left, r.bottom - r.top, 00128 SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | 00129 SWP_NOREDRAW | SWP_NOZORDER ); 00130 } 00131 return TRUE; 00132 break; 00133 00134 case WM_SIZE: 00135 if( (GetRowWeight() !=0 ) || (GetColWeight() != 0 ) ) 00136 { 00137 // Don't try to re-adjust to the size when initially shown. 00138 if( wParam == SIZE_RESTORED ) 00139 { 00140 WINDOWPOS pos={NULL, NULL, 0,0, LOWORD(lParam), HIWORD(lParam), 00141 SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | 00142 SWP_NOREDRAW | SWP_NOSENDCHANGING | SWP_NOZORDER }; 00143 DoChangePos( &pos ); 00144 ResizeControls(LOWORD( lParam ) , HIWORD (lParam) ); 00145 } 00146 } 00147 break; 00148 00149 case WM_PAINT: 00150 Annotate(); 00151 break; 00152 } 00153 return FALSE; 00154 } 00155 00157 // 00158 // Walks all the controls, finds their edges, 00159 // attatches them to their edges/guides. 00160 // 00162 void CResizeDlg::WalkControls() 00163 { 00164 m_ParentInfo.Init( GetWindow() ); 00165 FindControls(); 00166 m_ParentInfo.DeterminBorders( &m_ControlList ); 00167 MakeAttatchments(); 00168 FindCommonGuides(); 00169 SpecialRowCol(); 00170 } 00171 00173 // 00174 // Walk the dialog 00175 // build structures of what we think the relationships of the controls is. 00176 // 00178 void CResizeDlg::FindControls() 00179 { 00180 HWND hCurrent; 00181 HWND hFirst; 00182 hCurrent=hFirst=::GetWindow(GetWindow(),GW_CHILD); 00183 TRACE(L"FindControls on 0x%0x\n", GetWindow() ); 00184 TRACE(L"Parent size is %d,%d by %d,%d\n", 00185 m_ParentInfo.GetLeft(), 00186 m_ParentInfo.GetTop(), 00187 m_ParentInfo.GetRight(), 00188 m_ParentInfo.GetBottom() ); 00189 00190 if( hFirst ) 00191 { 00192 do { 00193 CResizeControl * pC = new CResizeControl(hCurrent, m_ParentInfo); 00194 if( pC->Valid() ) 00195 { 00196 // 00197 // Make sure the control is wihin the bounds of our parent. 00198 // 00199 RECT r=pC->GetLocation(); 00200 TRACE(L"Control size is %d,%d by %d,%d\n", 00201 r.left, 00202 r.top, 00203 r.right, 00204 r.bottom); 00205 if( (r.right > m_ParentInfo.GetRight()) || 00206 (r.bottom > m_ParentInfo.GetBottom()) || 00207 (r.top < m_ParentInfo.GetTop()) || 00208 (r.left < m_ParentInfo.GetLeft()) ) 00209 { 00210 TRACE(L"Punting this control %s\n", pC->GetClassName() ); 00211 delete pC; // we don't play with these. 00212 } 00213 else 00214 m_ControlList.Append(pC); 00215 } 00216 else 00217 delete pC; 00218 } while (hCurrent=::GetWindow(hCurrent,GW_HWNDNEXT)); 00219 } 00220 } 00221 00223 // 00224 // We have data backing each control now. 00225 // walk it and have it initialize itself. 00226 // 00228 void CResizeDlg::FindBorders() 00229 { 00230 } 00231 00233 // 00234 // Now we have determined the borders on the dialog, see 00235 // if any controls can make assumptions about their individual 00236 // attatchments. 00237 // 00239 void CResizeDlg::MakeAttatchments() 00240 { 00241 CResizeControl * pC; 00242 int i=0; 00243 while( pC=m_ControlList.GetControl(i++) ) 00244 pC->DeterminLeftAttatchments(); 00245 00246 i=0; 00247 while( pC=m_ControlList.GetControl(i++) ) 00248 pC->DeterminTopAttatchments(); 00249 00250 i=0; 00251 while( pC=m_ControlList.GetControl(i++) ) 00252 pC->DeterminRightAttatchments(); 00253 00254 i=0; 00255 while( pC=m_ControlList.GetControl(i++) ) 00256 pC->DeterminBottomAttatchments(); 00257 00258 i=0; 00259 while( pC=m_ControlList.GetControl(i++) ) 00260 pC->SetControlAssociations(); 00261 } 00262 00264 // 00265 // 00266 // 00268 void CResizeDlg::ResizeControls(WORD width, WORD height) 00269 { 00270 int iSpecialRow = GetNumRows()-1; 00271 int iSpecialCol = GetNumCols()-1; 00272 00273 // 00274 // Add free space 00275 // 00276 if( GetColWeight()>0 ) 00277 { 00278 int FreeW = width - m_Cols[ GetNumCols() ].Pos - m_ParentInfo.GetRightBorder(); 00279 if( FreeW != 0 ) 00280 { 00281 int iPadding=0; 00282 int iPad=FreeW/GetColWeight(); 00283 for( int fi=0;fi<= GetNumCols(); fi++) 00284 { 00285 m_Cols[ fi ].Pos += iPadding; 00286 if( m_Cols[fi].iFixed>=0) 00287 iPadding+=iPad * m_Cols[fi].iWeight; 00288 } 00289 } 00290 } 00291 00292 // 00293 // Add free row. 00294 // 00295 if( GetRowWeight()>0 ) 00296 { 00297 int Free = height - m_Rows[ GetNumRows() ].Pos - m_ParentInfo.GetBottomBorder(); 00298 if( Free != 0 ) 00299 { 00300 int iPadding=0; 00301 int iPad=Free/GetRowWeight(); 00302 for( int fi=0;fi<= GetNumRows(); fi++) 00303 { 00304 m_Rows[ fi ].Pos += iPadding; 00305 if( m_Rows[fi].iFixed>=0) 00306 iPadding+=iPad * m_Rows[fi].iWeight; 00307 } 00308 } 00309 } 00310 00311 // 00312 // Now setup the information for all of the controls, as to which cell they are in. 00313 // 00314 HDWP hdwp = BeginDeferWindowPos( m_ControlList.GetControlCount() ); 00315 int i=0; 00316 CResizeControl * pC; 00317 CConstraint * pCons; 00318 while( pC=(CResizeControl *) m_ControlList.GetPointer(i++) ) 00319 { 00320 pCons=&(pC->m_Cons); 00321 int x=m_Cols[pCons->GetCol()].Pos + pCons->GetPadLeft(); 00322 int y=m_Rows[pCons->GetRow()].Pos + pCons->GetPadTop(); 00323 int w,h; 00324 00325 BOOL bMove=true; BOOL bSize=false; 00326 if( pC->IsGrowsWide() ) 00327 { 00328 w=m_Cols[pCons->GetCol()+pCons->GetColW()].Pos + pCons->GetPadRight() -x; 00329 bSize=true; 00330 } 00331 else 00332 w=pC->GetWidth(); 00333 00334 if( pC->IsGrowsHigh() ) 00335 { 00336 h=m_Rows[pCons->GetRow()+pCons->GetRowH()].Pos + pCons->GetPadBottom() -y; 00337 bSize=true; 00338 } 00339 else 00340 h=pC->GetHeight(); 00341 00342 // 00343 // Here we special case the ComboBox - yuck. 00344 // 00345 if( lstrcmp( pC->GetClassName(), L"Button") ==0) 00346 { 00347 // 00348 // Check box button is OK though. 00349 // 00350 int ibs=GetWindowStyle( pC->GetControl() ); 00351 if( (ibs & 0xf) == BS_GROUPBOX ) 00352 { 00353 // 00354 // Force the width / height. 00355 // 00356 w=m_Cols[pCons->GetCol()+pCons->GetColW()].Pos + pCons->GetPadRight() -x; 00357 h=m_Rows[pCons->GetRow()+pCons->GetRowH()].Pos + pCons->GetPadBottom() -y; 00358 bSize=true; 00359 } 00360 } 00361 00362 // 00363 // If they are in special row / columns we do something special to them. 00364 // 00365 if( m_SpecialCol.bSpecial && ( pCons->GetCol() == iSpecialCol ) ) 00366 { 00367 // alignment issues 00368 if(m_SpecialCol.iAlignment == -1 ) 00369 { 00370 y=pC->GetTopGap(); 00371 } 00372 else 00373 if(m_SpecialCol.iAlignment == 1 ) 00374 { 00375 // 00376 // Right aligned. 00377 // 00378 y=pC->GetTopGap() + height - m_SpecialCol.iMax - m_ParentInfo.GetTopBorder(); 00379 } 00380 else 00381 { 00382 // 00383 // Center aligned 00384 // 00385 y=pC->GetTopGap() + ((height - m_SpecialCol.iMax - m_ParentInfo.GetTopBorder())/2); 00386 } 00387 } 00388 00389 if( m_SpecialRow.bSpecial && ( pCons->GetRow() == iSpecialRow ) ) 00390 { 00391 // alignment issues 00392 if(m_SpecialRow.iAlignment == -1 ) 00393 { 00394 x=pC->GetLeftGap(); 00395 } 00396 else 00397 if(m_SpecialRow.iAlignment == 1 ) // right aligned. 00398 { 00399 x=pC->GetLeftGap() + width - m_SpecialRow.iMax - m_ParentInfo.GetRightBorder(); 00400 } 00401 else 00402 { 00403 x=pC->GetLeftGap() + ((width - m_SpecialRow.iMax - m_ParentInfo.GetRightBorder()) / 2); 00404 } 00405 } 00406 00407 hdwp = DeferWindowPos( hdwp, pC->GetControl(), NULL, 00408 x, y, w , h, 00409 (bMove ? 0: SWP_NOMOVE) | (bSize ? 0: SWP_NOSIZE) | SWP_NOZORDER ); 00410 00411 } 00412 00413 // 00414 // Move the gripper 00415 // 00416 SetGripperPos(hdwp); 00417 00418 EndDeferWindowPos( hdwp ); 00419 } 00420 00422 // 00423 // Tries to combine guides to be offsets from other guides. 00424 // 00426 void CResizeDlg::FindCommonGuides() 00427 { 00428 CEdge ** ppVert = m_ParentInfo.GetVerticalEdges(); 00429 CEdge ** ppHoriz = m_ParentInfo.GetHorizontalEdges(); 00430 00431 // 00432 // Work out which guides are used in columns. 00433 // 00434 int iCount,i; 00435 iCount=m_ParentInfo.GetNumVert(); 00436 Sort(ppVert, iCount ); 00437 #ifdef _DEBUG 00438 TRACE(L"Vertical edge information %d edges\n", iCount ); 00439 for(i=0;i<iCount;i++) 00440 { 00441 CEdge * pEdge=ppVert[i]; 00442 TRACE(L"Edge %02d: Edge@%02d times as 0x%02x, position %08d, Guide@%03d\n", 00443 i, pEdge->GetControlCount(), 00444 pEdge->GetGuide()->Attatchment(), 00445 pEdge->GetPosition(), 00446 pEdge->GetGuide()->NumAttatchments() 00447 ); 00448 } 00449 #endif 00450 00451 iCount=m_ParentInfo.GetNumHoriz(); 00452 Sort(ppHoriz, iCount ); 00453 #ifdef _DEBUG 00454 TRACE(L"Horiz edge information %d edges\n", iCount ); 00455 for(i=0;i<iCount;i++) 00456 { 00457 CEdge * pEdge=ppHoriz[i]; 00458 CGuide * pGuide=pEdge->GetGuide(); 00459 TRACE(L"Edge %02d: Edge@%02d times as 0x%02x, position %08d, Guide@%03d\n",i, 00460 pEdge->GetControlCount(), 00461 pEdge->Attatchment(), 00462 pGuide->GetPosition(), 00463 pEdge->GetGuide()->NumAttatchments() 00464 ); 00465 } 00466 #endif 00467 00468 // 00469 // Determin rows and columns 00470 // 00471 DeterminCols( ppVert, m_ParentInfo.GetNumVert() ); 00472 DeterminRows( ppHoriz, m_ParentInfo.GetNumHoriz() ); 00473 PlaceControls(); 00474 00475 delete [] ppVert; 00476 delete [] ppHoriz; 00477 00478 DeterminWeights(); 00479 } 00480 00482 // 00483 // Sorts an array of edges. 00484 // 00486 void CResizeDlg::Sort(CEdge * *ppEdges, int iCount) 00487 { 00488 // 00489 // Lame sort BB fix later. 00490 // 00491 int iInsert=0; 00492 while ( iInsert < iCount ) 00493 { 00494 int iSmallest=iInsert; 00495 for(int iMatch=iInsert; iMatch<iCount; iMatch++) 00496 { 00497 if( ppEdges[iMatch]->GetPosition() < ppEdges[iSmallest]->GetPosition() ) 00498 iSmallest=iMatch; 00499 } 00500 if( iSmallest > iInsert ) 00501 { 00502 CEdge * pTemp=ppEdges[iInsert]; 00503 ppEdges[iInsert]=ppEdges[iSmallest]; 00504 ppEdges[iSmallest]=pTemp; 00505 } 00506 // TRACE(L"%02d is %08d\n", iInsert, ppEdges[iInsert]->GetPosition() ); 00507 iInsert++; 00508 } 00509 } 00510 00511 00513 // 00514 // State table kinda used to determin when a new col. is needed 00515 // Prev This New Col? 00516 // L L Yes, on this edge 00517 // L R Yes, on this edge 00518 // R L Yes, between these two edges 00519 // R R Yes if last (no if on same guide)? 00520 // 00522 void CResizeDlg::DeterminCols(CEdge * * ppEdges, int iCount) 00523 { 00524 // 00525 // First pass is just to work out positions of edges, 00526 // and if those edges constitute Columns. 00527 // 00528 int i; 00529 int iCols=0; 00530 int iLastGuide; 00531 int iThisGuide; 00532 int * iPos = new int[iCount]; // where the edges are 00533 iPos[0]=ppEdges[0]->GetPosition(); // we always use the first edge. 00534 int iLastPos=0; 00535 for(i=1; i<iCount;i++) 00536 { 00537 iThisGuide=ppEdges[i]->Attatchment() ; 00538 iLastGuide=ppEdges[i-1]->Attatchment(); 00539 TRACE(L"Edge:%02d - Attatched as %02d\n", i, iThisGuide); 00540 00541 // 00542 // Column between these two controls 00543 // 00544 if( (iLastGuide & RIGHT_AT ) && ( iThisGuide & LEFT_AT ) ) 00545 { 00546 iCols++; 00547 iPos[iCols] = ppEdges[i-1]->GetPosition() + ((ppEdges[i]->GetPosition() - ppEdges[i-1]->GetPosition())/2); 00548 continue; 00549 } 00550 00551 // 00552 // If we're starting another left edge of a control, needs a new guide 00553 // 00554 if( (iThisGuide & LEFT_AT ) ) 00555 { 00556 iCols++; 00557 iPos[iCols]= ppEdges[i]->GetPosition(); 00558 continue; 00559 } 00560 00561 // 00562 // If this is the last right edge 00563 // 00564 if( (iThisGuide & RIGHT_AT ) && ((i+1)==iCount) ) 00565 { 00566 iCols++; 00567 iPos[iCols] = ppEdges[i]->GetPosition() ; 00568 continue; // just incase you add anytyhing below 00569 } 00570 } 00571 00572 00573 // 00574 // Second pass is to make up the column information 00575 // we don't allow narrow colums, that is columns who are <2 appart. 00576 // 00577 TRACE(L"Column Widths are ...\n"); 00578 SetNumCols( iCols ); // 0 through n are USED. Not n-1 00579 m_Cols = new CHANNEL[iCols+1]; 00580 m_Cols[0].Pos=iPos[0]; 00581 iLastPos=0; 00582 int iThisCol=1; 00583 for(int iThisPos=1;iThisPos<=iCols;iThisPos++) 00584 { 00585 int iWidth=iPos[iThisPos]-iPos[iLastPos]; 00586 if( iWidth >= MIN_COL_SPACE ) 00587 { 00588 m_Cols[iThisCol].Pos = iPos[iThisPos]; 00589 m_Cols[iThisCol-1].Size = iWidth; 00590 m_Cols[iThisCol-1].iWeight=0; 00591 m_Cols[iThisCol-1].iFixed=FALSE; 00592 /* 00593 TRACE(L"Col:%02d Width:%03d Pos:%03d\n", 00594 iThisCol-1, 00595 m_Cols[iThisCol-1].Size, 00596 m_Cols[iThisCol-1].Pos); 00597 */ 00598 iLastPos=iThisPos; 00599 iThisCol++; 00600 } 00601 else 00602 { 00603 // TRACE(L"Skipping col #%d as it's only %d wide\n",iThisPos,iWidth); 00604 } 00605 } 00606 #ifdef _DEBUG 00607 if( (iThisCol-1) != iCols ) 00608 TRACE(L"Skipped %d rows\n",iThisCol-1-iCols); 00609 #endif 00610 SetNumCols( iThisCol-1 ); 00611 00612 delete [] iPos; 00613 } 00614 00616 // 00617 // State table kinda used to determin when a new col. is needed 00618 // Prev This New Col? 00619 // L L Yes, on this edge 00620 // L R Yes, on this edge 00621 // R L Yes, between these two edges 00622 // R R Yes if last (no if on same guide)? 00623 // 00625 void CResizeDlg::DeterminRows(CEdge * * ppEdges, int iCount) 00626 { 00627 int i; 00628 int iRows=0; 00629 int iLastGuide; 00630 int iThisGuide; 00631 int * iPos = new int[iCount]; 00632 00633 // 00634 // brute force, each edge is a row. 00635 // 00636 iRows=0; 00637 iPos[0]=ppEdges[0]->GetPosition(); 00638 int iLastPos=0; 00639 for(i=1; i<iCount;i++) 00640 { 00641 iThisGuide=ppEdges[i]->Attatchment() ; 00642 iLastGuide=ppEdges[i-1]->Attatchment(); 00643 TRACE(L"Edge:%02d - Attatched as %02d pos:%03d\n", i, iThisGuide, ppEdges[i]->GetPosition() ); 00644 00645 // 00646 // row between these two controls 00647 // 00648 if( (iLastGuide & BOTTOM_AT ) && ( iThisGuide & TOP_AT ) ) 00649 { 00650 iRows++; 00651 iPos[iRows] = ppEdges[i-1]->GetPosition() + ((ppEdges[i]->GetPosition() - ppEdges[i-1]->GetPosition())/2); 00652 continue; 00653 } 00654 00655 // 00656 // If we're starting another left edge of a control, needs a new guide 00657 // 00658 if( (iThisGuide & TOP_AT ) ) 00659 { 00660 iRows++; 00661 iPos[iRows]= ppEdges[i]->GetPosition(); 00662 continue; 00663 } 00664 00665 // 00666 // If this is the last right edge 00667 // 00668 if( (iThisGuide & BOTTOM_AT ) && ((i+1)==iCount) ) 00669 { 00670 iRows++; 00671 iPos[iRows] = ppEdges[i]->GetPosition() ; 00672 continue; // just incase you add anytyhing below 00673 } 00674 } 00675 00676 // 00677 // Second pass is to make up the column information 00678 // we don't allow narrow colums, that is columns who are <2 appart. 00679 // 00680 TRACE(L"Rowumn Widths are ...\n"); 00681 SetNumRows( iRows ); // 0 through n are USED. Not n-1 00682 m_Rows = new CHANNEL[iRows+1]; 00683 m_Rows[0].Pos=iPos[0]; 00684 iLastPos=0; 00685 int iThisRow=1; 00686 for(int iThisPos=1;iThisPos<=iRows;iThisPos++) 00687 { 00688 int iWidth=iPos[iThisPos]-iPos[iLastPos]; 00689 if( iWidth >= MIN_ROW_SPACE ) 00690 { 00691 m_Rows[iThisRow].Pos = iPos[iThisPos]; 00692 m_Rows[iThisRow-1].Size = iWidth; 00693 m_Rows[iThisRow-1].iWeight=0; 00694 m_Rows[iThisRow-1].iFixed=FALSE; 00695 /* 00696 TRACE(L"Row:%02d Width:%03d Pos:%03d\n", 00697 iThisRow-1, 00698 m_Rows[iThisRow-1].Size, 00699 m_Rows[iThisRow-1].Pos); 00700 */ 00701 iLastPos=iThisPos; 00702 iThisRow++; 00703 } 00704 else 00705 { 00706 // TRACE(L"Skipping Row #%d as it's only %d wide\n",iThisPos,iWidth); 00707 } 00708 } 00709 #ifdef _DEBUG 00710 if( (iThisRow-1) != iRows ) 00711 TRACE(L"Skipped %d rows\n",iThisRow-1-iRows); 00712 #endif 00713 SetNumRows( iThisRow-1 ); 00714 00715 delete [] iPos; 00716 } 00717 00719 // 00720 // Draws the annotations on the dialog of where the column/rows are 00721 // 00723 void CResizeDlg::Annotate() 00724 { 00725 if(GetAnnotate()==false) 00726 return; 00727 00728 HDC hdc=GetDC( GetWindow() ); 00729 // 00730 // Draw all the control edges on the screen. 00731 // 00732 // m_ParentInfo.Annotate( hdc ); 00733 00734 // 00735 // Now show the cols/rows 00736 // 00737 int iCount=GetNumRows(); 00738 int i; 00739 RECT r; 00740 GetWindowRect( GetWindow(), &r); 00741 int iWidth=r.right - r.left; 00742 int iHeight=r.bottom - r.top; 00743 00744 HPEN hFixedPen = CreatePen( PS_SOLID, 2, RGB( 0x00,0x00,0xff) ); 00745 HPEN hSizePen = CreatePen( PS_SOLID, 2, RGB( 0x00,0xff,0x00) ); 00746 HGDIOBJ holdPen= SelectObject( hdc, hFixedPen); 00747 00748 // 00749 // Horizontal lines 00750 // 00751 for(i=0;i<=iCount;i++) 00752 { 00753 if(m_Rows[i].iFixed >= 0 ) 00754 SelectObject( hdc, hSizePen ); 00755 else 00756 SelectObject( hdc, hFixedPen ); 00757 MoveToEx( hdc, 0, m_Rows[i].Pos, NULL ); 00758 LineTo( hdc, iWidth , m_Rows[i].Pos ); 00759 } 00760 00761 // 00762 // Vertical lines 00763 // 00764 iCount = GetNumCols(); 00765 for(i=0;i<=iCount;i++) 00766 { 00767 if(m_Cols[i].iFixed >= 0 ) 00768 SelectObject( hdc, hSizePen ); 00769 else 00770 SelectObject( hdc, hFixedPen ); 00771 MoveToEx( hdc, m_Cols[i].Pos, 0, NULL ); 00772 LineTo( hdc, m_Cols[i].Pos, iHeight ); 00773 } 00774 00775 SelectObject(hdc, holdPen); 00776 DeleteObject(hFixedPen); 00777 DeleteObject(hSizePen); 00778 00779 ReleaseDC( GetWindow(), hdc ); 00780 } 00781 00783 // 00784 // 00785 // 00787 int CResizeDlg::FindRow(int pos) 00788 { 00789 int i=0; 00790 while( i<=GetNumRows() ) 00791 { 00792 if( m_Rows[i].Pos > pos ) 00793 return i-1; 00794 i++; 00795 } 00796 return GetNumRows(); 00797 } 00798 00800 // 00801 // 00802 // 00804 int CResizeDlg::FindCol(int pos) 00805 { 00806 int i=0; 00807 while( i<=GetNumCols() ) 00808 { 00809 if( m_Cols[i].Pos > pos ) 00810 return i-1; 00811 i++; 00812 } 00813 return GetNumCols(); 00814 } 00815 00817 // 00818 // Walks the rows/columns and determins if they are resizable. 00819 // 00821 void CResizeDlg::DeterminWeights() 00822 { 00823 int iColWeight=0; 00824 { 00825 for( int fi=0;fi<= GetNumCols(); fi++) 00826 m_Cols[ fi ].iFixed<0 ? 0: iColWeight+=m_Cols[fi].iWeight; 00827 } 00828 int iRowWeight=0; 00829 { 00830 for( int fi=0;fi<= GetNumRows(); fi++) 00831 m_Rows[ fi ].iFixed<0 ? 0: iRowWeight+=m_Rows[fi].iWeight; 00832 } 00833 SetColWeight(iColWeight); 00834 SetRowWeight(iRowWeight); 00835 } 00836 00838 // 00839 // Passed in the current hit test, allows you to override it. 00840 // return HTERROR -1 if we didn't deal with it. 00841 // 00843 LONG CResizeDlg::HitTest(LONG lCurrent) 00844 { 00845 #define WIDE 1 00846 #define HIGH 2 00847 int iThisDlg = (GetRowWeight() ? HIGH : 0 ) | ( GetColWeight() ? WIDE : 0 ); 00848 00849 // TRACE(L"NC Hit Test %d - dlg is %d\n",lCurrent, iThisDlg); 00850 switch( lCurrent ) 00851 { 00852 case HTLEFT: // In the left border of a window 00853 case HTRIGHT: // In the rigcase HT border of a window 00854 if( iThisDlg==0) 00855 return HTNOWHERE; 00856 if( iThisDlg & WIDE ) 00857 return lCurrent; // OK 00858 return HTNOWHERE; 00859 00860 case HTTOP: // In the upper horizontal border of a window 00861 case HTBOTTOM: // In the lower horizontal border of a window 00862 if( iThisDlg==0) 00863 return HTNOWHERE; 00864 if( iThisDlg & HIGH ) 00865 return lCurrent; // OK 00866 return HTNOWHERE; // Can't make taller 00867 00868 case HTTOPLEFT: // In the upper-left corner of a window border 00869 case HTTOPRIGHT: // In the upper rigcase HT corner of a window border 00870 if( iThisDlg==0) 00871 return HTNOWHERE; 00872 00873 if( (iThisDlg & (HIGH | WIDE)) == (HIGH | WIDE )) 00874 return lCurrent; 00875 if( iThisDlg & HIGH ) 00876 return HTTOP; 00877 if( lCurrent == HTTOPLEFT ) 00878 return HTLEFT; 00879 return HTRIGHT; 00880 00881 case HTGROWBOX: // In a size box (same as case HTSIZE) 00882 if( iThisDlg==0) 00883 return HTNOWHERE; 00884 if( (iThisDlg & (HIGH | WIDE)) == (HIGH | WIDE )) 00885 return lCurrent; 00886 if( iThisDlg & HIGH ) 00887 return HTBOTTOM; 00888 return HTRIGHT; 00889 00890 case HTBOTTOMLEFT: // In the lower-left corner of a window border 00891 case HTBOTTOMRIGHT: // In the lower-rigcase HT corner of a window border 00892 if( iThisDlg==0) 00893 return HTNOWHERE; 00894 if( (iThisDlg & (HIGH | WIDE)) == (HIGH | WIDE )) 00895 return lCurrent; 00896 if( iThisDlg & HIGH ) 00897 return HTBOTTOM; 00898 if(lCurrent == HTBOTTOMRIGHT) 00899 return HTRIGHT; 00900 return HTLEFT; 00901 } 00902 return HTERROR-1; 00903 } 00904 00906 // 00907 // Determins the location of the controls in the row/col space. 00908 // 00910 void CResizeDlg::PlaceControls() 00911 { 00912 // 00913 // Now setup the information for all of the controls, as to which cell they are in. 00914 // 00915 int i=0; 00916 CResizeControl * pC; 00917 CConstraint * pCons; 00918 while( pC=(CResizeControl *) m_ControlList.GetPointer(i++) ) 00919 { 00920 int Row, Col, RowH, ColW; 00921 00922 RECT r=pC->GetLocation(); 00923 pCons=&(pC->m_Cons); 00924 00925 Row = FindRow( r.top); 00926 RowH = FindRow( r.bottom ) - Row +1 ; 00927 if( RowH + Row > GetNumRows() ) 00928 RowH = GetNumRows() - Row; 00929 00930 Col = FindCol( r.left); 00931 ColW = FindCol( r.right ) - Col + 1; 00932 if( ColW + Col > GetNumCols() ) 00933 ColW = GetNumCols() - Col; 00934 00935 pCons->SetCol( Col ); 00936 pCons->SetRow( Row ); 00937 pCons->SetColW( ColW ); 00938 pCons->SetRowH( RowH ); 00939 00940 // 00941 // Now adjust the padding from the edges of the cell. 00942 // 00943 pCons->SetPadTop ( r.top - m_Rows[ Row ].Pos ); 00944 pCons->SetPadBottom( r.bottom - m_Rows[ Row + RowH ].Pos ); 00945 pCons->SetPadLeft ( r.left - m_Cols[ Col ].Pos ); 00946 pCons->SetPadRight ( r.right - m_Cols[ Col + ColW ].Pos ); 00947 00948 /* 00949 IF you're worried that you got the dimentions wrong 00950 TRACE(L"Component %03d [%06d] %s\n pos: l:%03d, r:%03d, t:%03d, b:%03d\nCell: l:%03d, r:%03d, t:%03d, b:%03d\n", 00951 i, GetDlgCtrlID( pC->GetControl()), pC->GetClassName(), r.left, r.right, r.top, r.bottom, 00952 m_Cols[pCons->GetCol()].Pos + pCons->GetPadLeft(), 00953 m_Cols[pCons->GetCol()+pCons->GetColW()].Pos + pCons->GetPadRight(), 00954 m_Rows[pCons->GetRow()].Pos + pCons->GetPadTop(), 00955 m_Rows[pCons->GetRow()+pCons->GetRowH()].Pos + pCons->GetPadBottom() ); 00956 */ 00957 00958 TRACE(L"Component %03d [%06d] %s\n pos: Cell: %03d,%03d by %03d x %03d\n Padding:l:%03d, r:%03d, t:%03d, b:%03d\n", 00959 i, GetDlgCtrlID( pC->GetControl()), pC->GetClassName(), 00960 pCons->GetCol(), pCons->GetRow(), pCons->GetColW(), pCons->GetRowH(), 00961 pCons->GetPadLeft(), pCons->GetPadRight(), pCons->GetPadTop(), pCons->GetPadBottom() ); 00962 00963 // 00964 // Mark each column this control spans as gets wider. 00965 // 00966 int iCol=pCons->GetCol(); 00967 int ic=pCons->GetColW(); 00968 while( ic-- ) 00969 { 00970 if( pC-> IsGrowsWide() == false ) 00971 m_Cols[ iCol+ic ].iFixed-=1; // can't make wider 00972 else 00973 { 00974 m_Cols[ iCol+ic ].iWeight++; 00975 m_Cols[ iCol+ic ].iFixed+=2; // can make wider 00976 } 00977 } 00978 00979 ic=pCons->GetRowH(); 00980 int iRow=pCons->GetRow(); 00981 while( ic-- ) 00982 { 00983 if( pC-> IsGrowsHigh() == false ) 00984 m_Rows[ iRow+ic ].iFixed-=1; // can't make wider 00985 else 00986 { 00987 m_Rows[ iRow+ic ].iWeight++; 00988 m_Rows[ iRow+ic ].iFixed+=2; // can make wider 00989 } 00990 } 00991 } 00992 } 00993 00995 // 00996 // Determins if we can actually change size to that asked for. 00997 // 00999 void CResizeDlg::DoChangePos(WINDOWPOS * lpwp) 01000 { 01001 if((lpwp->flags & SWP_NOSIZE) == FALSE) 01002 { 01003 // 01004 // We're being sized - size in screen area (ie. included title bar) 01005 // m_ParentInfo EXCLUDES title bar. 01006 // 01007 RECT r; 01008 GetWindowRect( GetWindow(), &r ); 01009 if( GetRowWeight() <= 0 ) 01010 lpwp->cy=r.bottom- r.top; 01011 if( GetColWeight() <= 0 ) 01012 lpwp->cx=r.right - r.left; 01013 DIMENSION dMin= m_ParentInfo.GetMinimumSize(); 01014 if( lpwp->cx < dMin.Width ) 01015 lpwp->cx=dMin.Width; 01016 if( lpwp->cy < dMin.Height ) 01017 lpwp->cy=dMin.Height; 01018 } 01019 } 01020 01022 // 01023 // 01024 // 01026 void CResizeDlg::DoInitDialog() 01027 { 01028 AddToSystemMenu(); 01029 WalkControls(); 01030 ResizeControls( (WORD)m_ParentInfo.GetWidth() , (WORD)m_ParentInfo.GetHeight() ); 01031 } 01032 01034 // 01035 // Adds an annotate option to the system menu. 01036 // 01038 void CResizeDlg::AddToSystemMenu() 01039 { 01040 /* 01041 // 01042 // Get the system menu - add an annotate option to it? 01043 // 01044 HMENU hm=GetSystemMenu(GetWindow(), false); 01045 TCHAR szAnnotate[128]; 01046 LoadString( GetInstance(), IDS_ANNOTATE, szAnnotate, 128); 01047 MENUITEMINFO minfo={ 01048 sizeof(MENUITEMINFO), 01049 MIIM_ID | MIIM_TYPE, 01050 MFT_STRING, 01051 0, 01052 IDS_ANNOTATE, // ID 01053 NULL, // SubMenu 01054 NULL, // Checked 01055 NULL, // Unchecked 01056 0, // Item data - app specific 01057 szAnnotate, // Content of the menu item 01058 lstrlen(szAnnotate)+1// Length of menu item data 01059 }; 01060 01061 InsertMenuItem( hm, -1, TRUE, &minfo); 01062 */ 01063 } 01064 01065 void CResizeDlg::AddGripper() 01066 { 01067 int g_cxGrip = GetSystemMetrics( SM_CXVSCROLL ); 01068 int g_cyGrip = GetSystemMetrics( SM_CYHSCROLL ); 01069 RECT rc; 01070 GetClientRect( GetWindow(), &rc); 01071 m_hwndGripper = CreateWindow( TEXT("Scrollbar"), 01072 NULL, 01073 WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | 01074 WS_CLIPCHILDREN | SBS_BOTTOMALIGN | SBS_SIZEGRIP | 01075 SBS_SIZEBOXBOTTOMRIGHTALIGN, 01076 rc.right - g_cxGrip, 01077 rc.bottom - g_cyGrip, 01078 g_cxGrip, 01079 g_cyGrip, 01080 GetWindow(), 01081 (HMENU)-1, 01082 (HINSTANCE)GetWindowLong( GetWindow(), GWL_HINSTANCE ) , // g_hinst, 01083 NULL ); 01084 } 01085 01086 HDWP CResizeDlg::SetGripperPos(HDWP hdwp) 01087 { 01088 if( m_hwndGripper != NULL ) 01089 { 01090 int g_cxGrip = GetSystemMetrics( SM_CXVSCROLL ); 01091 int g_cyGrip = GetSystemMetrics( SM_CYHSCROLL ); 01092 RECT rc; 01093 GetClientRect( GetWindow(), &rc); 01094 return DeferWindowPos( hdwp, m_hwndGripper, NULL, 01095 rc.right - g_cxGrip, 01096 rc.bottom - g_cyGrip, 01097 g_cxGrip, 01098 g_cyGrip, 01099 SWP_NOZORDER | SWP_NOSIZE ); 01100 } 01101 else 01102 return hdwp; 01103 } 01104 01106 // 01107 // 01108 // 01111 // Construction/Destruction 01113 01114 CScaleDlg::CScaleDlg(int DlgID, HWND hWndParent, HINSTANCE hInst) 01115 : BASECLASS(DlgID, hWndParent, hInst) 01116 { 01117 } 01118 01119 CScaleDlg::~CScaleDlg() 01120 { 01121 01122 } 01123 01124 // 01125 // Multiply the positions as a result of what they are now. 01126 // 01127 void CScaleDlg::ResizeControls(WORD width, WORD height) 01128 { 01129 // 01130 // Perhaps we just scale the fontsize information too? 01131 // 01132 int OrigW = m_ParentInfo.GetRightBorder(); 01133 OrigW = m_ParentInfo.GetWidth(); 01134 int OrigH = m_ParentInfo.GetBottomBorder(); 01135 OrigH = m_ParentInfo.GetHeight(); 01136 01137 // 01138 // SetDialogFont 01139 // 01140 HFONT hFont=(HFONT)SendMessage( GetWindow(), WM_GETFONT, 0,0 ); 01141 LOGFONT lf; 01142 GetObject( (HGDIOBJ)hFont, sizeof(lf), &lf); 01143 int scalew= width * 100 / OrigW; 01144 int scaleh=height * 100 / OrigH; 01145 int scale=scalew; 01146 01147 if( scalew < scaleh ) 01148 scale=scaleh; 01149 01150 lf.lfHeight = m_dwInitFontSize * scale / 100; 01151 HFONT hNewFont=CreateFontIndirect( &lf ); 01152 01153 HWND hCurrent; 01154 HWND hFirst; 01155 hCurrent=hFirst=::GetWindow(GetWindow(),GW_CHILD); 01156 if( hFirst ) 01157 { 01158 do { 01159 SendMessage( hCurrent, WM_SETFONT, (WPARAM)hNewFont, 1 ); 01160 } while (hCurrent=::GetWindow(hCurrent,GW_HWNDNEXT)); 01161 } 01162 01163 // newX=origX * width / origParentWidth 01164 // 01165 // Now setup the information for all of the controls, as to which cell they are in. 01166 // 01167 HDWP hdwp = BeginDeferWindowPos( m_ControlList.GetControlCount() +1 ); // 1 for the gripper 01168 int i=0; 01169 CResizeControl * pC; 01170 while( pC=(CResizeControl *) m_ControlList.GetPointer(i++) ) 01171 { 01172 int x=pC->GetLeftGap(); // GetLeftEdge()->GetPosition(); 01173 int y=pC->GetTopGap(); // GetTopEdge()->GetPosition(); 01174 int w=OrigW - pC->GetRightGap() - x; // GetRightEdge()-GetPosition() - x; 01175 int h=OrigH - pC->GetBottomGap() - y; // BottomEdge()-GetPosition() -y; 01176 01177 int newx=x * width / OrigW; 01178 int newy=y * height / OrigH; 01179 01180 int neww=w * width / OrigW; 01181 int newh=h * height / OrigH; 01182 01183 01184 BOOL bMove=false; 01185 if( (newx != x) || (newy != y)) 01186 bMove=true; 01187 01188 BOOL bSize=false; 01189 if( (newh != h) || (neww != w)) 01190 bSize=true; 01191 01192 hdwp = DeferWindowPos( hdwp, pC->GetControl(), NULL, 01193 newx, newy, neww , newh, 01194 (bMove ? 0: SWP_NOMOVE) | (bSize ? 0: SWP_NOSIZE) | SWP_NOZORDER ); 01195 01196 } 01197 01198 // 01199 // Move the gripper 01200 // 01201 SetGripperPos(hdwp); 01202 01203 EndDeferWindowPos( hdwp ); 01204 01205 } 01206 01207 void CScaleDlg::DeterminWeights() 01208 { 01209 SetRowWeight(1); 01210 SetColWeight(1); 01211 HFONT hFont=(HFONT)SendMessage( GetWindow(), WM_GETFONT, 0,0 ); 01212 LOGFONT lf; 01213 GetObject( hFont, sizeof(lf), &lf); 01214 m_dwInitFontSize = lf.lfHeight; 01215 } 01216 01217 void CScaleDlg::DoChangePos(WINDOWPOS * lpwp) 01218 { 01219 // Lock the apsect ratio. 01220 if((lpwp->flags & SWP_NOSIZE) == FALSE) 01221 { 01222 if( dwLastCX != lpwp->cx ) 01223 dwLastCY = lpwp->cy = (lpwp->cx * m_ParentInfo.GetHeight()) / m_ParentInfo.GetWidth(); 01224 01225 if( dwLastCY != lpwp->cy ) 01226 dwLastCX = lpwp->cx = (lpwp->cy * m_ParentInfo.GetWidth()) / m_ParentInfo.GetHeight(); 01227 } 01228 } 01229 01230 void CResizeDlg::DeterminNumberOfControls() 01231 { 01232 int iControlCount=0; 01233 HWND hCurrent; 01234 HWND hFirst; 01235 hCurrent=hFirst=::GetWindow(GetWindow(),GW_CHILD); 01236 if( hFirst ) 01237 { 01238 do { 01239 iControlCount++; 01240 } while (hCurrent=::GetWindow(hCurrent,GW_HWNDNEXT)); 01241 } 01242 m_ControlCount=iControlCount; 01243 } 01244 01246 // 01247 // Looks for the last row/col being full of buttons. 01248 // 01250 void CResizeDlg::SpecialRowCol() 01251 { 01252 TRACE("There are %d rows, and %d columns\n", GetNumRows(), GetNumCols() ); 01253 01254 // 01255 // Walk the controls, find the row/col they are in. 01256 // 01257 BOOL bSpecialRow=TRUE; 01258 BOOL bSpecialCol=TRUE; 01259 int iNumRows=GetNumRows()-1; 01260 int iNumCols=GetNumCols()-1; 01261 01262 // 01263 // It is a special row if all the heights are the same 01264 // it is a special col if all the widths are the same 01265 // 01266 int iRowHeight=0; 01267 int iColWidth=0; 01268 01269 // 01270 // It's a row/col if there is more than one control there 01271 // 01272 int iRowCount=0; 01273 int iColCount=0; 01274 01275 // 01276 // We remember the bounds of the rows/cols 01277 // left/right is the left of the left button, and the right of the right 01278 // top/bottom is the top of the topmost, and the bottom of the bottom most. 01279 // 01280 RECT bounds; // this is the 01281 bounds.left=m_ParentInfo.GetWidth(); 01282 bounds.right=0; 01283 bounds.top=m_ParentInfo.GetHeight(); 01284 bounds.bottom=0; 01285 01286 int i=0; 01287 CResizeControl * pC; 01288 CConstraint * pCons; 01289 while( pC=(CResizeControl *) m_ControlList.GetPointer(i++) ) 01290 { 01291 pCons=&(pC->m_Cons); 01292 01293 // 01294 // Column work (widths same) 01295 // 01296 if( bSpecialCol ) 01297 { 01298 if( ((pCons->GetCol() == iNumCols ) || (pCons->GetCol() + pCons->GetColW() > iNumCols) )) 01299 { 01300 if( iColWidth==0 ) 01301 iColWidth=pC->GetWidth(); 01302 if( pC->GetWidth() != iColWidth ) 01303 bSpecialCol=FALSE; 01304 iColCount++; 01305 } 01306 01307 // 01308 // If this item is wholy in this column 01309 // 01310 if( pCons->GetCol() == iNumCols ) 01311 { 01312 RECT r=pC->GetLocation(); 01313 if( r.top < bounds.top ) 01314 bounds.top = r.top; 01315 if( r.bottom > bounds.bottom ) 01316 bounds.bottom = r.bottom; 01317 } 01318 } 01319 01320 if( bSpecialRow ) 01321 { 01322 if( (pCons->GetRow() == iNumRows ) || (pCons->GetRow() + pCons->GetRowH() > iNumRows) ) 01323 { 01324 if( iRowHeight==0 ) 01325 iRowHeight=pC->GetHeight(); 01326 if( pC->GetHeight() != iRowHeight ) 01327 bSpecialRow=FALSE; 01328 iRowCount++; 01329 } 01330 01331 // 01332 // If this item is wholy in this row 01333 // 01334 if( pCons->GetRow() == iNumRows ) 01335 { 01336 RECT r=pC->GetLocation(); 01337 if( r.left < bounds.left ) 01338 bounds.left = r.left; 01339 if( r.right > bounds.right ) 01340 bounds.right = r.right; 01341 } 01342 } 01343 01344 if( (bSpecialCol==FALSE) && ( bSpecialRow==FALSE ) ) 01345 break; 01346 } 01347 01348 m_SpecialRow.bSpecial = iRowCount>1?bSpecialRow:FALSE; 01349 m_SpecialCol.bSpecial = iColCount>1?bSpecialCol:FALSE; 01350 01351 // 01352 // Check the row alignment. 01353 // 01354 if( m_SpecialRow.bSpecial ) 01355 { 01356 int lGap = bounds.left - m_ParentInfo.GetLeftBorder(); 01357 int rGap = m_ParentInfo.GetWidth() - m_ParentInfo.GetRightBorder() - bounds.right; 01358 TRACE("Constraits on the special row are: left %d, right %d\n",bounds.left, bounds.right ); 01359 TRACE("Parent info is: left %d, right %d\n", m_ParentInfo.GetLeftBorder(), m_ParentInfo.GetWidth() - m_ParentInfo.GetRightBorder() ); 01360 TRACE("Gaps are: left %d, right %d\n", lGap, rGap ); 01361 int GapDiff = lGap - rGap; 01362 m_SpecialRow.bSpecial = TRUE; 01363 m_SpecialRow.iMin = bounds.left; 01364 m_SpecialRow.iMax = bounds.right; 01365 if( GapDiff < -10 ) 01366 { 01367 TRACE("Probably a left aligned thing\n"); 01368 m_SpecialRow.iAlignment = -1; 01369 } 01370 else 01371 if( GapDiff > 10 ) 01372 { 01373 TRACE(" Probably a right aligned thing\n"); 01374 m_SpecialRow.iAlignment = 1; 01375 } 01376 else 01377 { 01378 TRACE(" Probably a centered thing\n"); 01379 m_SpecialRow.iAlignment = 0; 01380 } 01381 m_SpecialRow.iDiff=GapDiff; 01382 } 01383 01384 // 01385 // Check the Col alignment. 01386 // 01387 if( m_SpecialCol.bSpecial ) 01388 { 01389 int tGap = bounds.top - m_ParentInfo.GetTopBorder(); 01390 int bGap = m_ParentInfo.GetHeight() - m_ParentInfo.GetBottomBorder() - bounds.bottom; 01391 TRACE("Constraits on the special Col are: top %d, bottom %d\n",bounds.top, bounds.bottom); 01392 TRACE("Parent info is: top %d, bottom %d\n", m_ParentInfo.GetTopBorder(), m_ParentInfo.GetHeight() - m_ParentInfo.GetBottomBorder() ); 01393 TRACE("Gaps are: top %d, bottom %d\n", tGap, bGap ); 01394 int GapDiff = tGap - bGap; 01395 m_SpecialCol.iMin = bounds.top; 01396 m_SpecialCol.iMax = bounds.bottom; 01397 if( GapDiff < -10 ) 01398 { 01399 TRACE("Probably a left aligned thing\n"); 01400 m_SpecialCol.iAlignment = -1; 01401 } 01402 else 01403 if( GapDiff > 10 ) 01404 { 01405 TRACE(" Probably a right aligned thing\n"); 01406 m_SpecialCol.iAlignment = 1; 01407 } 01408 else 01409 { 01410 TRACE(" Probably a centered thing\n"); 01411 m_SpecialCol.iAlignment = 0; 01412 } 01413 m_SpecialCol.iDiff=GapDiff; 01414 } 01415 }

Generated on Sat May 15 19:41:39 2004 for test by doxygen 1.3.7