galbar.cpp

Go to the documentation of this file.
00001 // $Id: galbar.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // Implementation of the GalleryBar class
00099 
00100 /*
00101 */
00102  
00103 #include "camtypes.h"
00104 #include "galbar.h"
00105 #include "gallery.h"
00106 //#include "sgallery.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "ensure.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 #include "mainfrm.h"
00109 #include "oilmods.h"
00110 #include "dlgmgr.h"
00111 #include "bitbutn.h"
00112 //#include "resource.h" // temp
00113 #include "childbar.h"
00114 #include "bbutdef.h"
00115 #include "ctrlhelp.h"
00116 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00117 #include "camelot.h"
00118 #include "ctl3d.h"
00119 #include "fonts.h"
00120 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00121 //#include "ed.h"
00122 
00123 #define MIN(a,b)    (((a)>(b)) ? (b) : (a))
00124 #define MAX(a,b)    (((a)>(b)) ? (a) : (b))
00125 
00126 // The gallery should be large enough for the row of buttons and a bit of the listbox
00127 // The default also minimises the chance of making the listbox too small for the scrollbar
00128 // to fit inside it.
00129 #define MINIMUM_GALLERY_HEIGHT 40
00130 
00131 void Ctl3dSubClassCtl(HWND Hwnd); // for some reason not in an .h file
00132 
00133 
00134 IMPLEMENT_DYNCREATE( GalleryBar,BaseBar )
00135 
00136 
00137 /********************************************************************************************
00138 >   void PatB(CDC* hDC, INT32 x, INT32 y, INT32 dx, INT32 dy, COLORREF rgb)
00139 
00140     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> (Some MFC dude, actually)
00141     Created:    14/3/94
00142     Inputs:     hDC - destination DC
00143                 x,y,dx,dy - rectangle to fill
00144                 rgb - colour to fill with
00145     Purpose:    Paints a rectangle in the given (dithered) colour
00146                 It looks pretty hideous, but this is how the MFC buttonbar does it...
00147                 The conclusions that this leads to are left as an exercise for the reader.
00148                 (OK, so they're not. It suggest that either MFC sux, or plotting text is
00149                 easier/faster than creating a brush, in which case Windoze sux)
00150 ********************************************************************************************/
00151 
00152 static void NEAR PASCAL PatB(CDC* cDC, INT32 x, INT32 y, INT32 dx, INT32 dy, COLORREF rgb)
00153 {
00154     RECT rect;
00155     rect.left   = x;
00156     rect.top    = y;
00157     rect.right  = x + dx;
00158     rect.bottom = y + dy;
00159 
00160     cDC->SetBkColor(rgb);
00161     cDC->ExtTextOut(0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
00162 }
00163 
00164 
00165 // -----------------------------------------------------------------------------------------
00166 // Message map - maintained by Class Wizard.
00167 
00168 BEGIN_MESSAGE_MAP(GalleryBar, BaseBar)
00169     //{{AFX_MSG_MAP(GalleryBar)
00170     ON_WM_NCCALCSIZE()
00171     ON_WM_NCPAINT()
00172 //  ON_WM_NCACTIVATE()
00173 //  ON_WM_PAINT()
00174     ON_WM_NCHITTEST()
00175     ON_WM_MOUSEMOVE()
00176     ON_WM_NCLBUTTONDOWN()
00177 //  ON_WM_LBUTTONDOWN()
00178 //  ON_WM_LBUTTONDBLCLK()   
00179 //  ON_WM_LBUTTONUP()
00180 //  ON_WM_NCRBUTTONDOWN()
00181 //  ON_MESSAGE( WM_RESIZECONTROLS,DoResize )
00182 //  ON_MESSAGE(WM_CTL_SETFOCUS, SetControlFocus)
00183 //  ON_WM_DESTROY( )
00184 //  ON_WM_MOUSEACTIVATE( )
00185 //  ON_WM_ACTIVATE( )
00186 //  ON_WM_ACTIVATEAPP( )
00187 //  ON_WM_PARENTNOTIFY( )
00188     ON_WM_MOUSEWHEEL()
00189 //  ON_WM_SIZE()
00190     ON_MESSAGE(WM_GETBARSIZE,GetBarSize)
00191     ON_MESSAGE(WM_SETGALLERYSIZE,SetGallerySize)
00192     //}}AFX_MSG_MAP
00193 END_MESSAGE_MAP()
00194 
00195 
00196 /********************************************************************************************
00197 
00198 >   void GalleryBar::GalleryBar() 
00199      
00200     Author:     Alex
00201     Created:    1/7/94        
00202     Inputs:     -
00203     Outputs:    -
00204     Returns:    -
00205     Purpose:    
00206     Errors:     -
00207     SeeAlso:    -
00208 
00209 ********************************************************************************************/
00210 GalleryBar::GalleryBar() : BaseBar()
00211 {
00212     
00213     GallerySize.cx = 1; // This will make it appear at the minimum width for now
00214     GallerySize.cy = 256;
00215     ListBoxHWND = NULL;
00216     ListFont = FontFactory::GetCFont(STOCKFONT_GALLERYLIST);
00217 }
00218 
00219 
00220 
00221 LRESULT GalleryBar::SetGallerySize(WPARAM cx, LPARAM cy)
00222 {
00223     // Set this gallery to be the new size
00224     GallerySize.cx = cx;
00225     GallerySize.cy = cy - TitleBarHeight;
00226 
00227     FormatLineFeeds(cx);
00228     PositionControls();
00229 
00230     return(0);
00231 }
00232 
00233 
00234 /********************************************************************************************
00235 
00236 >   void GalleryBar::OnMouseMove(UINT32 Flags, CPoint Point)
00237      
00238     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00239     Created:    5/4/94        
00240     Inputs:     -
00241     Outputs:    -
00242     Returns:    -
00243     Purpose:    
00244     Errors:     -
00245     SeeAlso:    -
00246 
00247 ********************************************************************************************/
00248 void GalleryBar::OnMouseMove(UINT32 Flags, CPoint Point)
00249 {
00250 
00251     static INT32 LastFormatWidth=0;
00252     
00253     // always use screen co-ords 
00254     ClientToScreen(&Point); 
00255 
00256     // We are trying to start a drag
00257     if (DragType == TRYING)
00258     {
00259         if (CanStartDrag(Point))// Ok we have moved the mouse far enough from the start drag 
00260         {
00261             // release the mouse this will be captured again in StartDrag
00262             ReleaseCapture();
00263             // XOR the initial drag rectangle 
00264             PaintXORDragRect(OldDragRect,ParentDockBarType);
00265             //start the drag for real from the original point
00266             StartDrag(StartDragPoint,MOVE);
00267         }        
00268     }
00269     if (DragType != NONE && DragType != TRYING)
00270     {
00271         // A drag is taking place                       
00272         // Calculate the new drag rect
00273 //      TRACEUSER( "Gerry", _T("DragPoint     = (%d, %d)\n"), Point.x, Point.y);
00274 //      TRACEUSER( "Gerry", _T("GallerySize   = (%d, %d)\n"), GallerySize.cx, GallerySize.cy);
00275          
00276         CRect NewDragRect = OldDragRect;
00277 
00278         switch (DragType)
00279         {
00280             case MOVE:
00281             {
00282                 // Try out the shapes of horz and vert bars to see if the touch a
00283                 // docking bar...
00284                 DockBarType TempDockBarType = BarCloseToDock(Point);
00285                 if ( TempDockBarType != DOCKBAR_INVALID )
00286                 {
00287                     // Bar is close enough to dock to change shape...
00288                     DragDockBarType = TempDockBarType;              // Set new shape type
00289                     CalcDragOffsetDirection(DragDockBarType, Point);// Alter offset directions
00290                     DragOffset = CalcDragOffset(GetFormatRect(DragDockBarType),
00291                                                 Point,
00292                                                 DragOffsetFromLeft,
00293                                                 DragOffsetFromTop); // Calc new offsets
00294                 }
00295                 else /* bar floats either inside or outside */
00296                 {
00297                     // Don't change directions of offset into floating shape!
00298                     DragDockBarType = DOCKBAR_FLOAT;
00299                     DragOffset = CalcDragOffset(GetFormatRect(DragDockBarType),
00300                                                 Point,
00301                                                 DragOffsetFromLeft,
00302                                                 DragOffsetFromTop); // Calc new offsets
00303                 }
00304                 // Set the new bar outline rect according to whatever was computed above
00305                 // and position it on screen according to the cursor position and the
00306                 // offsets computed above...
00307                 NewDragRect = GetFormatRect(DragDockBarType);
00308                 NewDragRect.OffsetRect(Point.x-DragOffset.x,Point.y - DragOffset.y); 
00309 
00310 //              DragDockBarType = DOCKBAR_FLOAT;
00311 //              NewDragRect = GetFormatRect(DragDockBarType);
00312 //              NewDragRect.OffsetRect(Point.x-DragOffset.x,Point.y - DragOffset.y); 
00313                 break;
00314             }
00315 
00316             case GROW_NORTH:
00317             {
00318                 INT32 NewWidth;
00319 
00320                 GallerySize.cx = MAX(0,DragStartRect.right-DragStartRect.left);
00321 //              GallerySize.cy = MAX(0,DragStartRect.bottom-Point.y-TITLE_BAR_HEIGHT+BorderOffset.y);
00322                 GallerySize.cy = MAX(0,DragStartRect.bottom-Point.y-TITLE_BAR_HEIGHT);
00323                 NewWidth = GallerySize.cx ;// -((BAR_BORDERSIZE*2)+(BorderWidth*2));
00324                 FormatLineFeeds(NewWidth);
00325                 FormatBar(FALSE,USE_BAR);  
00326 
00327                 CRect Temp = GetFormatRect(DragDockBarType);
00328                 CRect TempNew(DragStartRect.left,
00329                               DragStartRect.bottom - Temp.Height(),
00330                               DragStartRect.left + Temp.Width(),
00331                               DragStartRect.bottom);
00332 
00333                 NewDragRect = TempNew; 
00334                 LastFormatWidth = NewWidth;
00335                 break;
00336             }
00337             case GROW_NORTHWEST:
00338             {
00339                 INT32 NewWidth;
00340 
00341                 GallerySize.cx = MAX(0,DragStartRect.right-Point.x+BorderOffset.x);
00342                 GallerySize.cy = MAX(0,DragStartRect.bottom-Point.y-TITLE_BAR_HEIGHT+BorderOffset.y);
00343                 NewWidth = GallerySize.cx ;//-((BAR_BORDERSIZE*2)+(BorderWidth*2));
00344                 FormatLineFeeds(NewWidth);
00345                 FormatBar(FALSE,USE_BAR);  
00346 
00347                 CRect Temp = GetFormatRect(DragDockBarType);
00348                 CRect TempNew(DragStartRect.right - Temp.Width(),
00349                               DragStartRect.bottom - Temp.Height(),
00350                               DragStartRect.right,
00351                               DragStartRect.bottom);
00352 
00353                 NewDragRect = TempNew; 
00354                 LastFormatWidth = NewWidth;
00355                 break;
00356             }
00357             case GROW_NORTHEAST:
00358             {
00359                 INT32 NewWidth;
00360 
00361                 
00362                 GallerySize.cx = MAX(0,Point.x-DragStartRect.left+BorderOffset.x);
00363                 GallerySize.cy = MAX(0,DragStartRect.bottom-Point.y-TITLE_BAR_HEIGHT+BorderOffset.y);
00364                 NewWidth = GallerySize.cx ;//-((BAR_BORDERSIZE*2)+(BorderWidth*2));
00365                 FormatLineFeeds(NewWidth);
00366                 FormatBar(FALSE,USE_BAR);  
00367 
00368                 CRect Temp = GetFormatRect(DragDockBarType);
00369                 CRect TempNew(DragStartRect.left,
00370                               DragStartRect.bottom - Temp.Height(),
00371                               DragStartRect.left + Temp.Width(),
00372                               DragStartRect.bottom);
00373 
00374 
00375                 NewDragRect = TempNew; 
00376                 LastFormatWidth = NewWidth;
00377                 break;
00378             }
00379             case GROW_SOUTH:
00380             {
00381                 INT32 NewWidth;
00382 
00383                 GallerySize.cx = MAX(0,DragStartRect.right-DragStartRect.left);
00384                 GallerySize.cy = MAX(0,Point.y-DragStartRect.top-TITLE_BAR_HEIGHT+BorderOffset.y);
00385                 NewWidth = GallerySize.cx ;//-((BAR_BORDERSIZE*2)+(BorderWidth*2));
00386 
00387                 FormatLineFeeds(NewWidth);
00388                 FormatBar(FALSE,USE_BAR);  
00389                 CRect Temp = GetFormatRect(DragDockBarType);
00390                 Temp.OffsetRect(DragStartRect.left,DragStartRect.top); 
00391                 NewDragRect = Temp; 
00392                 LastFormatWidth = NewWidth;
00393                 break;
00394 
00395             }
00396             case GROW_SOUTHEAST:
00397             {
00398                 INT32 NewWidth;
00399 
00400                 GallerySize.cx = MAX(0,Point.x-DragStartRect.left+BorderOffset.x);
00401                 GallerySize.cy = MAX(0,Point.y-DragStartRect.top-TITLE_BAR_HEIGHT+BorderOffset.y);
00402         
00403                 NewWidth = GallerySize.cx ;//-((BAR_BORDERSIZE*2)+(BorderWidth*2));
00404 
00405                 FormatLineFeeds(NewWidth);
00406                 FormatBar(FALSE,USE_BAR);  
00407                 CRect Temp = GetFormatRect(DragDockBarType);
00408                 Temp.OffsetRect(DragStartRect.left,DragStartRect.top); 
00409                 NewDragRect = Temp; 
00410                 LastFormatWidth = NewWidth;
00411                 break;
00412 
00413             }
00414     
00415             case GROW_SOUTHWEST:
00416             {
00417                 INT32 NewWidth;
00418 
00419                 GallerySize.cx = MAX(0,DragStartRect.right-Point.x+BorderOffset.x);
00420                 GallerySize.cy = MAX(0,Point.y-DragStartRect.top-TITLE_BAR_HEIGHT+BorderOffset.y);
00421         
00422                 NewWidth = GallerySize.cx ;//-((BAR_BORDERSIZE*2)+(BorderWidth*2));
00423 
00424                 FormatLineFeeds(NewWidth);
00425                 FormatBar(FALSE,USE_BAR);  
00426                 
00427                 CRect Temp = GetFormatRect(DragDockBarType); 
00428                 CRect TempNew(DragStartRect.right - Temp.Width(),
00429                               DragStartRect.top,
00430                               DragStartRect.right,
00431                               DragStartRect.top + Temp.Height());
00432         
00433                 NewDragRect = TempNew; 
00434                 LastFormatWidth = NewWidth;
00435                 break; 
00436             }
00437                         
00438             case GROW_EAST:
00439             {
00440                 INT32 NewWidth;
00441 
00442                 GallerySize.cx = MAX(0,Point.x-DragStartRect.left+BorderOffset.x);
00443 //              GallerySize.cy = MAX(0,DragStartRect.bottom-DragStartRect.top-TITLE_BAR_HEIGHT);
00444                 NewWidth = GallerySize.cx; //-((BAR_BORDERSIZE*2)+(BorderWidth*2));
00445 
00446                 FormatLineFeeds(NewWidth);
00447                 FormatBar(FALSE,USE_BAR);
00448                   
00449                 CRect Temp = GetFormatRect(DragDockBarType);
00450                 Temp.OffsetRect(DragStartRect.left,DragStartRect.top); 
00451                 NewDragRect = Temp; 
00452                 LastFormatWidth = NewWidth;
00453                 break; 
00454             }
00455 
00456             case GROW_WEST:
00457             {
00458                 INT32 NewWidth;
00459 
00460                 GallerySize.cx = MAX(0,DragStartRect.right-Point.x+BorderOffset.x);
00461 //              GallerySize.cy = MAX(0,DragStartRect.bottom-DragStartRect.top-TITLE_BAR_HEIGHT);
00462                 NewWidth = GallerySize.cx;  //-((BAR_BORDERSIZE*2)+(BorderWidth*2));
00463 
00464                 FormatLineFeeds(NewWidth);
00465                 FormatBar(FALSE,USE_BAR);  
00466                 
00467                 CRect Temp = GetFormatRect(DragDockBarType); 
00468                 CRect TempNew(DragStartRect.right - Temp.Width(),
00469                               DragStartRect.top,
00470                               DragStartRect.right,
00471                               DragStartRect.top + Temp.Height());
00472         
00473                 NewDragRect = TempNew; 
00474                 LastFormatWidth = NewWidth;
00475                 break; 
00476             }
00477 
00478         }
00479 
00480         if(NewDragRect!=OldDragRect)
00481         {
00482 //          TRACEUSER( "Gerry", _T("NewDragRect   = (%d, %d) - (%d, %d)\n"), NewDragRect.left, NewDragRect.top, NewDragRect.Width(), NewDragRect.Height());
00483 //          PaintDragRect(NewDragRect,OldDragRect,DOCKBAR_FLOAT,DOCKBAR_FLOAT);
00484             PaintDragRect(NewDragRect,OldDragRect,DragDockBarType,OldDragBarType);
00485             OldDragBarType=DragDockBarType;
00486             OldDragRect = NewDragRect; 
00487         }
00488     }
00489                                                       
00490 }
00491 
00492 
00493 
00494 /****************************************************************************
00495 
00496 >   UINT32 GalleryBar::OnNcHitTest(CPoint point)
00497 
00498     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00499     Created:    16/11/2004
00500 
00501     Inputs:     point       - Screen coordinate of point to test
00502     Returns:    
00503     Purpose:    Determines the part of window the point is over.
00504 
00505 ****************************************************************************/
00506 
00507 UINT32 GalleryBar::OnNcHitTest(CPoint point)
00508 {
00509     if (DragType != NONE)
00510         return HTCLIENT; 
00511 
00512     if (CurrentDlgBarMode == DIALOG)
00513     {
00514         return(BaseBar::OnNcHitTest(point));
00515     }
00516     else
00517     {
00518         // Get the window dimensions
00519         CRect rect;
00520         GetWindowRect(&rect);
00521         CRect InsideBorderRect = rect;
00522         InsideBorderRect.InflateRect(-BorderWidth,-BorderWidth);
00523         CPoint NonClientPoint (point.x - rect.left, point.y - rect.top); 
00524 
00525 //      TRACE( _T("NcHitTest (%d, %d)\n"), NonClientPoint.x, NonClientPoint.y);
00526 
00527         // Determine what active area the cursor is over
00528         if (SysMenuRect.PtInRect(NonClientPoint))
00529         {
00530             return HTSYSMENU; 
00531         }
00532         else if (TopBorderRect.PtInRect(NonClientPoint))
00533         {
00534             return HTTOP; 
00535         }
00536         else if (BottomBorderRect.PtInRect(NonClientPoint))
00537         {
00538             return HTBOTTOM; 
00539         }
00540         else if (LeftBorderRect.PtInRect(NonClientPoint))
00541         {
00542             return HTLEFT; 
00543         }
00544         else if (RightBorderRect.PtInRect(NonClientPoint))
00545         {
00546             return HTRIGHT; 
00547         }
00548         else if (CaptionBarRect.PtInRect(NonClientPoint))
00549         {
00550             return HTCAPTION; 
00551         }
00552     }
00553 
00554     // Normal client area hit 
00555     return HTCLIENT; 
00556 }
00557 
00558 /********************************************************************************************
00559 
00560 >   void GalleryBar::OnNcLButtonDown(UINT32 nHitTest, CPoint point)
00561 
00562     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00563     Created:    5/4/94
00564     Inputs:     -
00565     Outputs:    -
00566     Returns:    -
00567     Purpose:    
00568     Errors:     -
00569     SeeAlso:    -
00570 
00571 ********************************************************************************************/
00572 
00573 void GalleryBar::OnNcLButtonDown(UINT32 nHitTest, CPoint point)
00574 {
00575 
00576     ENSURE(DragType == NONE, "There should not be a drag going on"); 
00577     //SetFocus();
00578 //  if (CurrentDlgBarMode == DIALOG)
00579 //  {
00580         switch (nHitTest)
00581         {
00582             case HTCLIENT:
00583             {
00584                 CWnd::OnNcLButtonDown(nHitTest, point);
00585                 break;  
00586             }
00587         
00588             case HTSYSMENU:
00589             {
00590                 // Send a message to the GalleryBarOp to inform it that cancel has been selected
00591                 DialogMsg tmp(this->GetSafeHwnd(), DIM_CANCEL, NULL);
00592                 pOp->Message(&tmp); 
00593                 break;      
00594             }
00595 
00596             // The following hit test values all start a drag
00597 
00598             case HTCAPTION:
00599             {
00600                 StartDrag(point,MOVE); 
00601                 break; 
00602             }
00603 
00604             case HTTOP:
00605             {
00606                 StartDrag(point, GROW_NORTH); 
00607                 break; 
00608             }
00609 
00610             case HTBOTTOM:
00611             {
00612                 StartDrag(point, GROW_SOUTH); 
00613                 break; 
00614             }
00615 
00616             case HTLEFT:
00617             {
00618                 StartDrag(point, GROW_WEST); 
00619                 break; 
00620             }
00621 
00622             case HTRIGHT:
00623             {
00624                 StartDrag(point, GROW_EAST); 
00625                 break; 
00626             }
00627 
00628             
00629             case HTTOPLEFT:
00630             {
00631                 StartDrag(point, GROW_NORTHWEST); 
00632                 break; 
00633             }
00634 
00635             case HTBOTTOMLEFT:
00636             {
00637                 StartDrag(point, GROW_SOUTHWEST); 
00638                 break; 
00639             }
00640 
00641             case HTTOPRIGHT:
00642             {
00643                 StartDrag(point, GROW_NORTHEAST); 
00644                 break; 
00645             }
00646 
00647             case HTBOTTOMRIGHT:
00648             {
00649                 StartDrag(point, GROW_SOUTHEAST); 
00650                 break; 
00651             }
00652             default:
00653             {
00654                 ENSURE(FALSE,"Unknown Hit test value"); 
00655                 break;  
00656             }
00657 
00658         }
00659 //  }
00660 //  else 
00661 //  {
00662 //      // Don't do anything special with bar non client messages
00663 //      CWnd::OnNcLButtonDown(nHitTest, point);
00664 //  }
00665          
00666     return;     
00667 
00668 }
00669 
00670 
00671 /********************************************************************************************
00672 
00673 >   void GalleryBar::AdjustFormattedBarSize(CSize* pBarSize)
00674 
00675     Author:     Alex
00676     Created:    1/7/94
00677     Inputs:     Pointer to the bar size record to adjust 
00678     Outputs:    -
00679     Returns:    None
00680     Purpose:    Adjusts the proposed new size of a bar once formatting has taken place   
00681     Errors:     -
00682     SeeAlso:    GalleryBar::AdjustFormattedBarSize
00683 
00684 This function adjust the size of a bar after the formatting has taken place.
00685 
00686 The size of the formatted rectangle is in BarSize. We output the new bar size.
00687 
00688 ********************************************************************************************/
00689 
00690 void GalleryBar::AdjustFormattedBarSize(CSize* pBarSize)
00691 {
00692 //  TRACE( _T("AFBS BarSize (%d, %d)\n"), pBarSize->cx, pBarSize->cy);
00693 //  TRACE( _T("AFBS GalSize (%d, %d)\n"), GallerySize.cx, GallerySize.cy);
00694     GallerySize.cy = pBarSize->cy = MAX((pBarSize->cy + MINIMUM_GALLERY_HEIGHT), GallerySize.cy); 
00695 //  GallerySize.cy = pBarSize->cy = MAX(pBarSize->cy, GallerySize.cy); 
00696     GallerySize.cx = pBarSize->cx = MAX(pBarSize->cx, GallerySize.cx);
00697 //  INT32 Newx =  MAX(pBarSize->cx, GallerySize.cx);
00698 //  CRect Temp = GetFormatRect(DOCKBAR_BOTTOM);
00699 //  if(Newx >=Temp.Width())
00700 //        GallerySize.cx = pBarSize->cx =Newx;
00701     
00702     if (pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
00703         ((SuperGallery * )pOp)->SetGallerySize(GallerySize);
00704 #ifdef _DEBUG
00705     else
00706         ERROR3("GalleryBar::AdjustFormattedBarSize - I'm not a SuperGallery!?!");
00707 #endif
00708 
00709 //  TRACE( _T("AFBS NewSize (%d, %d)\n"), pBarSize->cx, pBarSize->cy);
00710 }
00711 
00712 
00713 
00714 /********************************************************************************************
00715 
00716 >   void GalleryBar::PositionExtraControls(CSize BarSize, INT32 xpos, INT32 ypos)
00717 
00718     Author:     Alex
00719     Created:    1/7/94
00720     Inputs:     Bar size record, x & y coord of current format position. 
00721     Outputs:    -
00722     Returns:    None
00723     Purpose:    Moves extra controls about once they have been created   
00724     Errors:     -
00725     SeeAlso:    BaseBar::PositionExtraControls, GalleryBar::CreateExtraControls
00726 
00727 This function does nothing in the base class, but may be overridden, for instance by Gallery
00728 Bars.
00729 
00730 ********************************************************************************************/
00731 
00732 void GalleryBar::PositionExtraControls(CSize BarSize, INT32 xpos, INT32 ypos)
00733 {
00734     ::SetWindowPos(ListBoxHWND,NULL,
00735                     BAR_BORDERSIZE,
00736                     ypos + BAR_BORDERSIZE,
00737                     BarSize.cx - 2 * BAR_BORDERSIZE -  (BorderWidth * 2),
00738                     BarSize.cy-ypos - 2 * BAR_BORDERSIZE - (BorderWidth * 2),   // Move the control 
00739                     SWP_NOZORDER);
00740 }
00741 
00742 /********************************************************************************************
00743 
00744 >   INT32 GalleryBar::CreateExtraControls()
00745 
00746     Author:     Alex
00747     Created:    1/7/94
00748     Inputs:     None 
00749     Outputs:    TRUE if successful, else FALSE
00750     Returns:    None
00751     Purpose:    Allows subclasses to create additional bar controls   
00752     Errors:     -
00753     SeeAlso:    BaseBar::CreateExtraControls, GalleryBar::PositionExtraControls
00754 
00755 This function does nothing in the base class, but may be overridden, for instance by Gallery
00756 Bars.
00757 
00758 ********************************************************************************************/
00759 
00760 INT32 GalleryBar::CreateExtraControls()
00761 {
00762     OILDockingBar * ThisDock =GetMainFrame()->GetDockBar(ParentDockBarType);
00763 
00764     DWORD ExtraStyleFlags = 0;
00765     // Ask op if the list box can have multiple selections or not.
00766     if (pOp->AllowMulSelInListBox())
00767         ExtraStyleFlags = LBS_EXTENDEDSEL | LBS_MULTIPLESEL;
00768 
00769     HWND CreatedWindow = NULL;
00770     if (pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
00771     {
00772         // Create a kernel-redrawn control for the list box of a SuperGallery
00773         CreatedWindow = ::CreateWindowEx(
00774                             //#if WIN32
00775                             //  pCurrentControl->dwExtendedStyle,
00776                             //#else
00777                                 0,
00778                             //#endif
00779                                "cc_DialogDraw",     // Class name
00780                                0,           // Window title
00781                                WS_BORDER | WS_CHILD |WS_VISIBLE,
00782                                0,
00783                                0,
00784                                10,
00785                                10, // Control gets resized anyway, but should be cleared up
00786                                GetSafeHwnd(),               // this window is its parent 
00787                                (HMENU)_R(IDC_GALLERY_LISTBOX),
00788                                AfxGetApp()->m_hInstance,
00789                                0 //pCreationData                
00790                                );
00791     }
00792 
00793 
00794     if (CreatedWindow == NULL) 
00795         return FALSE;
00796 
00797     Ctl3dSubClassCtl(CreatedWindow);
00798 
00799     ListBoxHWND = CreatedWindow;
00800    /*
00801     ControlHelpInfo Info;
00802     Info.pOpDesc = NULL;
00803     Info.BubbleID = _R(IDBBL_NOOP);
00804     Info.StatusID = 0;
00805     Info.Parent = GetSafeHwnd();
00806 
00807     ControlHelper::NotifyControlCreated(CreatedWindow,&Info); 
00808    */
00809 
00810     CSize NewGallerySize;
00811     
00812     if (pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
00813         NewGallerySize =((SuperGallery *) pOp)->GetGallerySize();
00814 
00815     if (NewGallerySize.cx == 0 && NewGallerySize.cy == 0)
00816     {
00817         NewGallerySize = pOp->GetBarRect().BottomRight();
00818     }
00819 
00820     if (NewGallerySize.cx > 0)
00821         GallerySize.cx = NewGallerySize.cx; 
00822     if (NewGallerySize.cy > 0)
00823         GallerySize.cy = NewGallerySize.cy; 
00824     ::SendMessage( CreatedWindow, WM_SETFONT, (WPARAM)ListFont->m_hObject, 0);
00825     return TRUE ;   
00826 
00827 }
00828 /********************************************************************************************
00829 
00830 >   virtual BOOL GalleryBar::SetStatusLineText()
00831 
00832     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00833     Created:    22/11/94
00834     Inputs:     -
00835     Outputs:    -
00836     Returns:    TRUE if I have put text on the StatusLine FALSE otherwise
00837     Purpose:    actually put text on the status line
00838     Errors:     -
00839     SeeAlso:    -
00840 
00841 ********************************************************************************************/
00842 
00843 BOOL GalleryBar::SetStatusLineText()
00844 {
00845     switch (DragType)
00846     {
00847         case    MOVE :
00848             GetApplication()->UpdateStatusBarText(&(String_256(_R(IDS_STATUSLINE_GALLERYDRAG))),FALSE); 
00849             return TRUE;
00850         case    GROW_NORTH:
00851         case    GROW_SOUTH:
00852         case    GROW_EAST:
00853         case    GROW_WEST:
00854             GetApplication()->UpdateStatusBarText(&(String_256(_R(IDS_STATUSLINE_BARRESIZE))),FALSE); 
00855             return TRUE;
00856         case NONE:
00857             return FALSE;
00858     }
00859 
00860     return FALSE;
00861 }
00862 
00863 /********************************************************************************************
00864 
00865 >   virtual BOOL GalleryBar::GetStatusText(String_256 * StatusText)
00866 
00867     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00868     Created:    22/11/94
00869     Inputs:     -
00870     Outputs:    -
00871     Returns:    TRUE if the buffer is valid FALSE otherwise
00872     Purpose:    put stauts text in a buffer
00873     Errors:     -
00874     SeeAlso:    -
00875 
00876 ********************************************************************************************/
00877 
00878 BOOL GalleryBar::GetStatusText(String_256 * StatusText)
00879 {
00880     switch (DragType)
00881     {
00882         case    MOVE :
00883             * StatusText = String_256(_R(IDS_STATUSLINE_GALLERYDRAG)); 
00884             return TRUE;
00885         case    GROW_NORTH:
00886         case    GROW_SOUTH:
00887         case    GROW_EAST:
00888         case    GROW_WEST:
00889             * StatusText = String_256(_R(IDS_STATUSLINE_BARRESIZE)); 
00890             return TRUE;
00891         case NONE:
00892             return FALSE;
00893     }
00894 
00895     return FALSE;
00896 }
00897 
00898 
00899 
00900 BOOL GalleryBar::OnMouseWheel(UINT32 nFlags, short zDelta, CPoint pt)
00901 {
00902     TRACEUSER( "Matt", _T("MouseWheel scrolled in GalleryBar!\n"));
00903     return TRUE;
00904 }
00905 
00906 
00907 CRect GalleryBar::GetFormatRect(DockBarType BarType)
00908 {
00909     OILDockingBar* DockBar = GetMainFrame()->GetDockBar(BarType);
00910     if (BarType == DOCKBAR_FLOAT)
00911     {
00912         OILDockingBar* DockBar = GetMainFrame()->GetDockBar(BarType);
00913         if (DockBar->IsBigControls())
00914         {
00915             if (FloatLargeRect.IsRectEmpty())
00916                 FormatFloatingBar(FALSE,FORCE_LARGE);
00917             return FloatLargeRect;
00918         }
00919         else
00920         {
00921             if (FloatSmallRect.IsRectEmpty())
00922                 FormatFloatingBar(FALSE,FORCE_SMALL);
00923             return FloatSmallRect;
00924         }
00925     }
00926     else
00927     {
00928         if (DockBar->IsBigControls())
00929         {
00930             if (VerticalLargeRect.IsRectEmpty())
00931                 FormatVerticalBar(FALSE,FORCE_LARGE);
00932             return VerticalLargeRect;
00933         }
00934         else
00935         {
00936             if (VerticalSmallRect.IsRectEmpty())
00937                 FormatVerticalBar(FALSE,FORCE_SMALL);
00938             return VerticalSmallRect;
00939         }
00940     }
00941 
00942     return CRect(0,0,0,0);
00943     
00944 //  return(BaseBar::GetFormatRect(BarType));
00945 //  return(CRect(0, 0, GallerySize.cx, GallerySize.cy));
00946 }
00947 
00948 
00949 /********************************************************************************************
00950 
00951 >   LRESULT GalleryBar::GetBarSize(WPARAM DockType, LPARAM ControlSize )
00952 
00953     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00954     Created:    7/5/94
00955     Inputs:     from windows
00956     Outputs:    -
00957     Returns:    -
00958     Purpose:    To return a pointer to a rectangle of bar size 
00959     Errors:     -
00960     SeeAlso:    -
00961 
00962 ********************************************************************************************/
00963 
00964 LRESULT GalleryBar::GetBarSize(WPARAM DockType , LPARAM ControlS)
00965 {
00966     DockBarType ThisDock = (DockBarType) DockType;
00967     ControlSizes ControlSize = (ControlSizes) ControlS;
00968 
00969     if (ThisDock == DOCKBAR_FLOAT)
00970     {
00971         if (ControlSize == LARGE_CONTROLS)
00972             return (LRESULT) &FloatLargeRect;
00973         else
00974             return (LRESULT) &FloatSmallRect;
00975     }
00976     else
00977     {
00978         if(ControlSize == LARGE_CONTROLS)
00979             return (LRESULT) &VerticalLargeRect ;
00980         else
00981             return (LRESULT) &VerticalSmallRect ; 
00982     }
00983 
00984     return(0);
00985 }
00986 
00987 
00988 /********************************************************************************************
00989 
00990 >   BOOL GalleryBar::PositionControls(BOOL DoRedraw = TRUE)
00991 
00992     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00993     Created:    4/5/94
00994     Inputs:     -
00995     Outputs:    -
00996     Returns:    -
00997     Purpose:    Format and place controls according to docking bar type
00998     Errors:     -
00999     SeeAlso:    -
01000 
01001 ********************************************************************************************/
01002 
01003 BOOL GalleryBar::PositionControls(BOOL DoRedraw)
01004 {
01005     // Position the controls in the bar
01006     // We also format the other type of bar so that strange things
01007     // don't happen to the window size when docking/undocking
01008     switch(ParentDockBarType)
01009     {
01010     case DOCKBAR_FLOAT:
01011         FormatFloatingBar(TRUE,USE_BAR);
01012         FormatVerticalBar(FALSE,USE_BAR);
01013         pOp->SetCurrentOrientation(Horizontal); 
01014         break;
01015 
01016     case DOCKBAR_LEFT:
01017     case DOCKBAR_RIGHT:
01018         FormatVerticalBar(TRUE,USE_BAR);
01019         FormatFloatingBar(FALSE,USE_BAR);
01020         pOp->SetCurrentOrientation(Horizontal); 
01021         break;
01022     
01023     default:
01024         ENSURE(FALSE,"Unknown Parent DockBar");
01025     }
01026     // Size the window correctly but don't redraw
01027     if (DoRedraw)
01028         SetBarSize(ParentDockBarType, DoRedraw);
01029     return TRUE ;
01030 }
01031 
01032 
01033 BOOL GalleryBar::FormatBar(BOOL MoveWindows,ForceControlSize ForceSize)
01034 {
01035     BOOL bRetVal = FALSE;
01036     switch(ParentDockBarType)
01037     {
01038         case DOCKBAR_FLOAT:
01039             bRetVal = FormatFloatingBar(MoveWindows, ForceSize);
01040             break;
01041 
01042         case DOCKBAR_LEFT:
01043         case DOCKBAR_RIGHT:
01044             bRetVal = FormatVerticalBar(MoveWindows, ForceSize);
01045             break;
01046     }
01047     return(bRetVal);
01048 }   
01049 
01050 
01051 /********************************************************************************************
01052 
01053 >   BOOL GalleryBar::FormatHorizontalBar(BOOL MoveWindows,ForceControlSize Force)
01054 
01055     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
01056     Created:    18/4/94
01057     Inputs:         
01058                 MoveWindows - flag to force a set window pos on the controls
01059                 Force normally we use the current dock size to format the bar - sometimes
01060                 however we need to know how big the bar would be large or small.
01061     Outputs:    -
01062     Returns:    -
01063     Purpose:    Format a Horizontal toolbar with separators 
01064     Errors:     -
01065     SeeAlso:    -
01066 
01067 ********************************************************************************************/
01068 BOOL GalleryBar::FormatHorizontalBar(BOOL MoveControls, ForceControlSize ForceSize)
01069 {
01070     return(TRUE);
01071 //  return(FormatFloatingBar(MoveControls, ForceSize));
01072 }
01073 
01074 /********************************************************************************************
01075 
01076 >   BOOL GalleryBar::FormatVerticalBar(BOOL MoveWindows,ForceControlSize Force)
01077 
01078     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
01079     Created:    18/4/94
01080     Inputs:         
01081                 MoveWindows - flag to force a set window pos on the controls
01082                 Force normally we use the current dock size to format the bar - sometimes
01083                 however we need to know how big the bar would be large or small.
01084     Outputs:    -
01085     Returns:    -
01086     Purpose:    Format a Horizontal toolbar with separators 
01087     Errors:     -
01088     SeeAlso:    -
01089 
01090 ********************************************************************************************/
01091 BOOL GalleryBar::FormatVerticalBar(BOOL MoveControls, ForceControlSize ForceSize)
01092 {
01093 //  return(FormatFloatingBar(MoveControls, ForceSize));
01094 
01095 //  TRACEUSER( "Gerry", _T("FormatVerticalBar\n"));
01096 
01097     HWND hcontrol;
01098     CSize BarSize(0,0);
01099     INT32 xpos = BAR_BORDERSIZE;
01100     INT32 ypos = BAR_BORDERSIZE;
01101     INT32 yOffset   = 0;
01102     INT32 MaxWidth = 0;
01103     INT32 DDeckerStart = 0;
01104     INT32 DDeckerEnd = 0;
01105 
01106     BarItem * pBarItem; 
01107     BarItem * LastItem = NULL;
01108 
01109     // Check Current Control Sizes in this Docking Bar
01110     INT32 ControlWidth = 0;
01111     INT32 ControlHeight = 0;
01112     ControlSizes ControlSize;
01113 
01114     DDeckerReadState DDeckerState = DDECKER_NONE;
01115     DDeckerControlHeights DDeckerHeight = SMALL_DDECKERS;
01116 
01117     //if we are dragging a bar check the size of the dock we are over
01118     // otherwise use control size of parent dock 
01119     OILDockingBar * ThisDock ;
01120     DockBarType CurrentType;
01121 
01122     CurrentType = (DragType==MOVE) ? DragDockBarType : ParentDockBarType; 
01123     ThisDock = GetMainFrame()->GetDockBar(CurrentType);
01124     
01125     BarItemType ThisControl;
01126     BarItemType LastControl = OTHERCONTROL;
01127 
01128     INT32 LargeWidth  = LARGEBUTTONWIDTH;
01129     INT32 LargeHeight = LARGEBUTTONHEIGHT;
01130     INT32 SmallWidth  = SMALLBUTTONWIDTH;
01131     INT32 SmallHeight = SMALLBUTTONHEIGHT;
01132     INT32 Control =0;
01133 
01134     // Get the current control size for this dock
01135     if (ForceSize == USE_BAR)
01136     {
01137         ForceSize = ThisDock->IsBigControls() ? FORCE_LARGE : FORCE_SMALL;
01138     }
01139 
01140     if (ForceSize == FORCE_LARGE)
01141     {
01142         ControlWidth = LargeWidth;
01143         ControlHeight = LargeHeight;        
01144 
01145     }
01146     else if (ForceSize == FORCE_SMALL)
01147     {
01148         ControlWidth = SmallWidth;
01149         ControlHeight = SmallHeight;        
01150     }
01151     
01152     
01153     if (ControlHeight == LargeHeight )
01154     {
01155         ControlSize = LARGE_CONTROLS;
01156         DDeckerHeight = LARGE_DDECKERS ;
01157     }
01158     else
01159     {
01160         ControlSize =  SMALL_CONTROLS;
01161         DDeckerHeight = SMALL_DDECKERS ;
01162     }           
01163     // if list is empty just set a minimum size 
01164     if (! pOp->IsListEmpty())
01165     {
01166 //      TRACEUSER( "chris", _T("\n --- FORMAT ---\n"));
01167         pBarItem = pOp->GetPtrBarHead(); 
01168 
01169         while (pBarItem != NULL)
01170         {
01171             ThisControl = GetEnumItemType(pBarItem);
01172             // Double Decker stuff...
01173             switch(ThisControl)
01174             {
01175                 case DECKER_TOP:
01176                 {
01177                     DDeckerState = DDECKER_TOP;
01178                     // xpos to come back to
01179                     DDeckerStart = xpos;
01180                 }
01181                 break;
01182                 case DECKER_BOTTOM:
01183                 {
01184                     DDeckerState = DDECKER_BOTTOM;
01185                     // extent of double decker
01186                     DDeckerEnd = xpos;
01187                     // go back to start
01188                     xpos = DDeckerStart;
01189                 
01190                 }
01191                 break;
01192                 case DECKER_END:
01193                 {
01194                     DDeckerState = DDECKER_NONE;
01195                     // check for longest line top or bottom ?
01196                     if(xpos < DDeckerEnd)
01197                         xpos = DDeckerEnd;
01198                 }
01199                 break;
01200                 case SEPARATOR:
01201                 // insert a separator normally this is horizontal but if the last control was
01202                 // a LineFeed we do a vertical separator
01203                 {
01204                     if(LastItem)
01205                     {
01206                         if (LastItem->IsKindOf(CC_RUNTIME_CLASS(BarLineFeed)))
01207                             ypos += SeparatorWidth;
01208                         else
01209                             xpos += SeparatorWidth;
01210                     }
01211 //                  TRACEUSER( "chris", _T("Separator\n"));
01212                 }
01213                 break;
01214                 case LINEFEED:
01215                 // move down to next line and reset xpos
01216                 {
01217                     ypos += ControlHeight+VERTICAL_SPACE;               // Move down to the next line
01218                     if(IS_CHICAGO && pOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
01219                         ypos +=4;
01220                     xpos = BAR_BORDERSIZE;
01221                     DDeckerStart = xpos;
01222                 }
01223                 break;
01224             }
01225             if (pBarItem->IsKindOf(CC_RUNTIME_CLASS(BarControl)))
01226             {
01227 //              TRACEUSER( "chris", _T("Control\n"));
01228                 hcontrol=(HWND)((BarControl*)pBarItem)->GetWinID(); // Get the Window Handle
01229                 CRect WindSize;
01230 
01231                 ::GetClientRect(hcontrol,&WindSize);                // Get the window size
01232                 switch (DDeckerState)
01233                 {
01234                 case DDECKER_TOP:
01235                     if(ThisControl == SMALLBITMAPBUTTON)
01236                     {
01237                         if (ControlSize == LARGE_CONTROLS)
01238                             yOffset = (ControlHeight / 2) - sLARGEBUTTONHEIGHT +1; //get offset to center control
01239                         else
01240                             yOffset = (ControlHeight / 2) - sSMALLBUTTONHEIGHT +1;
01241                         xpos++;
01242                     }
01243                     else
01244                     {
01245 //                      yOffset = (ControlHeight / 2) - WindSize.Height()+1;
01246                         yOffset = (ControlHeight / 2) - DDeckerHeight + 1 ;
01247                     }
01248 
01249                     // bodge to center static text
01250                     if(ThisControl == STATIC)
01251                         yOffset +=3;
01252 
01253                     break;
01254                 case DDECKER_BOTTOM :
01255                     yOffset = (ControlHeight / 2) ; //get offset to center control
01256                     // bodge to center static text
01257                     if(ThisControl == STATIC)
01258                         yOffset +=3;
01259                     if ( ThisControl == SMALLBITMAPBUTTON)
01260                     {
01261                         yOffset ++ ;
01262                         xpos ++;
01263                     }
01264                     if(IS_CHICAGO)
01265                     {
01266                         yOffset ++;
01267                     }
01268                     break;
01269                 case DDECKER_NONE :
01270                     yOffset = (ControlHeight - WindSize.Height()) / 2; //get offset to center control
01271                     break;
01272                 }
01273                 
01274                 if (MoveControls)
01275                     ::SetWindowPos(hcontrol,NULL,xpos,ypos + yOffset,0,0,   // Move the control 
01276                                    SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOZORDER|SWP_NOREDRAW);
01277                 
01278                 xpos += WindSize.Width()-1;
01279                 if(ThisControl == STATICBITMAP)
01280                     xpos ++;
01281                 else if(ThisControl == SLIDER)
01282                     xpos +=4;
01283                 LastControl = ThisControl ;
01284 
01285                 if(IS_CHICAGO)
01286                 {
01287                     if(ThisControl == EDIT)
01288                         xpos += 2;
01289                 }
01290                 
01291             }               
01292 
01293             // keep MaxWidth up to date 
01294             if (xpos > MaxWidth)
01295                     MaxWidth = xpos;
01296 
01297             // remember last control
01298             LastItem = pBarItem;
01299 
01300             // move to next item
01301             pBarItem = pOp->GetPtrBarNext(pBarItem); 
01302         }
01303     
01304         // 
01305         BarSize.cx = MaxWidth + BAR_BORDERSIZE + (1 * 2) + 1 ;
01306         BarSize.cy = ypos + ControlHeight + BAR_BORDERSIZE + (1 * 2)  ;
01307 
01308     }       
01309     // Set a Minimum Bar Height
01310     if (BarSize.cy < ControlHeight + (BAR_BORDERSIZE)+ (1 * 2))
01311         BarSize.cy = ControlHeight + (BAR_BORDERSIZE)+ (1 * 2); 
01312 
01313     // ----------------------------
01314     // Set a Minimum Bar Width
01315 
01316     String_32 Name = pOp->GetName();
01317 
01318     INT32 SmallestWidth = ControlWidth + (BAR_BORDERSIZE * 2)+ (1 * 2);
01319 
01320     // If this an empty bar make sure we can see the title
01321     if (pOp->IsListEmpty())
01322     { 
01323         // Select the title font into a screen dc and get the text extent of the title
01324         CDC *dc = GetWindowDC();
01325 
01326         CFont * OldFont=dc->SelectObject(TitleFont);
01327 
01328         CSize TextSize=dc->GetTextExtent(Name,camStrlen(Name));
01329 
01330         dc->SelectObject(OldFont);
01331 
01332         ReleaseDC(dc);
01333 
01334         // Check that the title string will be visible UIC
01335         if ((TextSize.cx + TitleBarHeight + (1 * 4) ) > SmallestWidth)
01336             SmallestWidth = TextSize.cx + TitleBarHeight + (1 * 4);
01337     }
01338 
01339     
01340     if (BarSize.cx < SmallestWidth)
01341         BarSize.cx = SmallestWidth ;    
01342 
01343     AdjustFormattedBarSize(&BarSize);
01344     if (MoveControls) 
01345         PositionExtraControls(BarSize,xpos,ypos+ControlHeight);
01346 
01347     // Cache the rectangle
01348     if (ForceSize == FORCE_LARGE)
01349     {
01350         VerticalLargeRect.right = BarSize.cx;
01351         VerticalLargeRect.bottom = BarSize.cy + TitleBarHeight;
01352     }
01353     else if (ForceSize == FORCE_SMALL)
01354     {
01355         VerticalSmallRect.right = BarSize.cx;
01356         VerticalSmallRect.bottom = BarSize.cy + TitleBarHeight;
01357     }
01358     return TRUE;
01359 }
01360 
01361 
01362 /********************************************************************************************
01363 
01364 >   CRect GalleryBar::SetBarSize(DockBarType BarType,BOOL DoRedraw)
01365 
01366     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
01367     Created:    4/5/94
01368     Inputs:     BarType - type of dock the bar is attached to
01369                 Redraw - flag to indicate a redraw is needed
01370     Outputs:    -
01371     Returns:    new size
01372     Purpose:    Set the Window size
01373     Errors:     -
01374     SeeAlso:    -
01375 
01376 ********************************************************************************************/
01377 
01378 CRect GalleryBar::SetBarSize(DockBarType BarType ,BOOL DoRedraw)
01379 {
01380     CRect temp;
01381     if (BarType == DOCKBAR_FLOAT)
01382     {
01383         if (ParentDockBar->IsBigControls())     
01384             temp = FloatLargeRect;
01385         else
01386             temp = FloatSmallRect;
01387     }
01388     else
01389     {
01390         if (ParentDockBar->IsBigControls())     
01391             temp = VerticalLargeRect;
01392         else
01393             temp = VerticalSmallRect;
01394     }
01395 
01396     UINT32 flags = SWP_NOMOVE|SWP_NOZORDER;
01397     if (!DoRedraw)
01398         flags |= SWP_NOREDRAW;
01399     SetWindowPos(NULL,0,0,temp.right,temp.bottom,flags);
01400 
01401     return temp;
01402 }
01403 
01404 
01405 void GalleryBar::OnNcPaint()
01406 {
01407     if (CurrentDlgBarMode == DIALOG)
01408     {
01409         PaintWin95DialogNonClient(Active);
01410     }
01411     else
01412     {
01413         PaintWin95BarNonClient(Active);
01414     }
01415 }
01416 
01417 void GalleryBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
01418 {
01419     if (CurrentDlgBarMode == DIALOG)
01420     {
01421         BaseBar::OnNcCalcSize(bCalcValidRects, lpncsp);
01422     }
01423     else
01424     {
01425         lpncsp->rgrc[0].left += 1;
01426         lpncsp->rgrc[0].top += TitleBarHeight + 1;  // UIC
01427         lpncsp->rgrc[0].right -= 1;
01428         lpncsp->rgrc[0].bottom -= 1;
01429 
01430 //      CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
01431 //      lpncsp->rgrc[0].top += TitleBarHeight;
01432     }
01433 }
01434 
01435 
01436 void GalleryBar::PaintWin95BarNonClient(BOOL IsActive)
01437 {
01438     // When the GalleryBar is in BAR mode we have to paint the fancy non-client area. 
01439 
01440     // Get the size of the window   
01441     CRect WinRect;
01442     GetWindowRect(&WinRect);
01443 
01444     // Set up the active non-client regions 
01445     SysMenuRect = CRect(WinRect.Width() - TitleBarHeight, 
01446                          3, 
01447                          WinRect.Width() - 2, 
01448                          TitleBarHeight);
01449 
01450 //  TRACE( _T("SMRG = (%d, %d)\n"), SysMenuRect.Width(), SysMenuRect.Height());
01451 
01452     TopBorderRect = CRect(0, 0, WinRect.Width(), 2);
01453 
01454     BottomBorderRect = CRect(0, WinRect.Height() - 2, WinRect.Width(), WinRect.Height());
01455 
01456     LeftBorderRect = CRect(0, 0, 2, WinRect.Height());
01457                          
01458     RightBorderRect = CRect(WinRect.Width() - 2, 0, WinRect.Width(), WinRect.Height());
01459 
01460     CaptionBarRect = CRect(1, 1, WinRect.Width() - 1, TitleBarHeight + 1);
01461 
01462     // Get a context onto the entire window area
01463     CDC *dc = GetWindowDC();
01464     
01465     // -------------------------------------------------------------------------------------
01466     // Paint the borders frame
01467 
01468 //  CRect WholeRect(0, 0, WinRect.Width(), WinRect.Height());
01469 //  CBrush TempBrush(GetSysColor(COLOR_INACTIVECAPTION));
01470 //  dc->FillRect(&WholeRect, &TempBrush);
01471 
01472 //  CBrush FrameBrush(GetSysColor(COLOR_BTNFACE));
01473 
01474 //  dc->FillRect(&TopBorderRect, &FrameBrush);
01475 //  dc->FillRect(&BottomBorderRect, &FrameBrush);
01476 //  dc->FillRect(&LeftBorderRect, &FrameBrush);
01477 //  dc->FillRect(&RightBorderRect, &FrameBrush);
01478     
01479     DWORD TopLeftCol = GetSysColor(COLOR_BTNHIGHLIGHT);
01480     DWORD BottomRightCol = GetSysColor(COLOR_BTNSHADOW);
01481 
01482     PatB(dc, 0, 0, 1, WinRect.Height(), TopLeftCol);
01483     
01484     PatB(dc, 0, 0, WinRect.Width(), 1, TopLeftCol);
01485     
01486     PatB(dc, WinRect.Width()-1, 0, 1, WinRect.Height(), BottomRightCol);
01487     
01488     PatB(dc, 0, WinRect.Height()-1, WinRect.Width(), 1, BottomRightCol);
01489 
01490     // Paint the caption
01491     // make sure that DrawCaption shows the correct title
01492     SetWindowText(pOp->GetName());
01493     
01494     UINT32 DrawFlags = DC_TEXT|DC_SMALLCAP;
01495     
01496     if (IsActive)
01497         DrawFlags |= DC_ACTIVE;
01498 
01499     // draw the caption
01500     ::DrawCaption(GetSafeHwnd(), dc->m_hDC, &CaptionBarRect, DrawFlags);
01501     
01502     // draw the new stretchy close button
01503     dc->DrawFrameControl(&SysMenuRect, DFC_CAPTION, DFCS_CAPTIONCLOSE);
01504 
01505     // Clean up release the DC
01506     ReleaseDC(dc) ;
01507     
01508 }   

Generated on Sat Nov 10 03:48:30 2007 for Camelot by  doxygen 1.4.4