00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 #include "camtypes.h"
00104 #include "galbar.h"
00105 #include "gallery.h"
00106
00107
00108 #include "mainfrm.h"
00109 #include "oilmods.h"
00110 #include "dlgmgr.h"
00111 #include "bitbutn.h"
00112
00113 #include "childbar.h"
00114 #include "bbutdef.h"
00115 #include "ctrlhelp.h"
00116
00117 #include "camelot.h"
00118 #include "ctl3d.h"
00119 #include "fonts.h"
00120
00121
00122
00123 #define MIN(a,b) (((a)>(b)) ? (b) : (a))
00124 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
00125
00126
00127
00128
00129 #define MINIMUM_GALLERY_HEIGHT 40
00130
00131 void Ctl3dSubClassCtl(HWND Hwnd);
00132
00133
00134 IMPLEMENT_DYNCREATE( GalleryBar,BaseBar )
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
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
00167
00168 BEGIN_MESSAGE_MAP(GalleryBar, BaseBar)
00169
00170 ON_WM_NCCALCSIZE()
00171 ON_WM_NCPAINT()
00172
00173
00174 ON_WM_NCHITTEST()
00175 ON_WM_MOUSEMOVE()
00176 ON_WM_NCLBUTTONDOWN()
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 ON_WM_MOUSEWHEEL()
00189
00190 ON_MESSAGE(WM_GETBARSIZE,GetBarSize)
00191 ON_MESSAGE(WM_SETGALLERYSIZE,SetGallerySize)
00192
00193 END_MESSAGE_MAP()
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 GalleryBar::GalleryBar() : BaseBar()
00211 {
00212
00213 GallerySize.cx = 1;
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
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
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248 void GalleryBar::OnMouseMove(UINT32 Flags, CPoint Point)
00249 {
00250
00251 static INT32 LastFormatWidth=0;
00252
00253
00254 ClientToScreen(&Point);
00255
00256
00257 if (DragType == TRYING)
00258 {
00259 if (CanStartDrag(Point))
00260 {
00261
00262 ReleaseCapture();
00263
00264 PaintXORDragRect(OldDragRect,ParentDockBarType);
00265
00266 StartDrag(StartDragPoint,MOVE);
00267 }
00268 }
00269 if (DragType != NONE && DragType != TRYING)
00270 {
00271
00272
00273
00274
00275
00276 CRect NewDragRect = OldDragRect;
00277
00278 switch (DragType)
00279 {
00280 case MOVE:
00281 {
00282
00283
00284 DockBarType TempDockBarType = BarCloseToDock(Point);
00285 if ( TempDockBarType != DOCKBAR_INVALID )
00286 {
00287
00288 DragDockBarType = TempDockBarType;
00289 CalcDragOffsetDirection(DragDockBarType, Point);
00290 DragOffset = CalcDragOffset(GetFormatRect(DragDockBarType),
00291 Point,
00292 DragOffsetFromLeft,
00293 DragOffsetFromTop);
00294 }
00295 else
00296 {
00297
00298 DragDockBarType = DOCKBAR_FLOAT;
00299 DragOffset = CalcDragOffset(GetFormatRect(DragDockBarType),
00300 Point,
00301 DragOffsetFromLeft,
00302 DragOffsetFromTop);
00303 }
00304
00305
00306
00307 NewDragRect = GetFormatRect(DragDockBarType);
00308 NewDragRect.OffsetRect(Point.x-DragOffset.x,Point.y - DragOffset.y);
00309
00310
00311
00312
00313 break;
00314 }
00315
00316 case GROW_NORTH:
00317 {
00318 INT32 NewWidth;
00319
00320 GallerySize.cx = MAX(0,DragStartRect.right-DragStartRect.left);
00321
00322 GallerySize.cy = MAX(0,DragStartRect.bottom-Point.y-TITLE_BAR_HEIGHT);
00323 NewWidth = GallerySize.cx ;
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 ;
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 ;
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 ;
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 ;
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 ;
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
00444 NewWidth = GallerySize.cx;
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
00462 NewWidth = GallerySize.cx;
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
00483
00484 PaintDragRect(NewDragRect,OldDragRect,DragDockBarType,OldDragBarType);
00485 OldDragBarType=DragDockBarType;
00486 OldDragRect = NewDragRect;
00487 }
00488 }
00489
00490 }
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
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
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
00526
00527
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
00555 return HTCLIENT;
00556 }
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
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
00578
00579
00580 switch (nHitTest)
00581 {
00582 case HTCLIENT:
00583 {
00584 CWnd::OnNcLButtonDown(nHitTest, point);
00585 break;
00586 }
00587
00588 case HTSYSMENU:
00589 {
00590
00591 DialogMsg tmp(this->GetSafeHwnd(), DIM_CANCEL, NULL);
00592 pOp->Message(&tmp);
00593 break;
00594 }
00595
00596
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
00661
00662
00663
00664
00665
00666 return;
00667
00668 }
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690 void GalleryBar::AdjustFormattedBarSize(CSize* pBarSize)
00691 {
00692
00693
00694 GallerySize.cy = pBarSize->cy = MAX((pBarSize->cy + MINIMUM_GALLERY_HEIGHT), GallerySize.cy);
00695
00696 GallerySize.cx = pBarSize->cx = MAX(pBarSize->cx, GallerySize.cx);
00697
00698
00699
00700
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
00710 }
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
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),
00739 SWP_NOZORDER);
00740 }
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760 INT32 GalleryBar::CreateExtraControls()
00761 {
00762 OILDockingBar * ThisDock =GetMainFrame()->GetDockBar(ParentDockBarType);
00763
00764 DWORD ExtraStyleFlags = 0;
00765
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
00773 CreatedWindow = ::CreateWindowEx(
00774
00775
00776
00777 0,
00778
00779 "cc_DialogDraw",
00780 0,
00781 WS_BORDER | WS_CHILD |WS_VISIBLE,
00782 0,
00783 0,
00784 10,
00785 10,
00786 GetSafeHwnd(),
00787 (HMENU)_R(IDC_GALLERY_LISTBOX),
00788 AfxGetApp()->m_hInstance,
00789 0
00790 );
00791 }
00792
00793
00794 if (CreatedWindow == NULL)
00795 return FALSE;
00796
00797 Ctl3dSubClassCtl(CreatedWindow);
00798
00799 ListBoxHWND = CreatedWindow;
00800
00801
00802
00803
00804
00805
00806
00807
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
00831
00832
00833
00834
00835
00836
00837
00838
00839
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
00866
00867
00868
00869
00870
00871
00872
00873
00874
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
00945
00946 }
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
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
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003 BOOL GalleryBar::PositionControls(BOOL DoRedraw)
01004 {
01005
01006
01007
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
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
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068 BOOL GalleryBar::FormatHorizontalBar(BOOL MoveControls, ForceControlSize ForceSize)
01069 {
01070 return(TRUE);
01071
01072 }
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091 BOOL GalleryBar::FormatVerticalBar(BOOL MoveControls, ForceControlSize ForceSize)
01092 {
01093
01094
01095
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
01110 INT32 ControlWidth = 0;
01111 INT32 ControlHeight = 0;
01112 ControlSizes ControlSize;
01113
01114 DDeckerReadState DDeckerState = DDECKER_NONE;
01115 DDeckerControlHeights DDeckerHeight = SMALL_DDECKERS;
01116
01117
01118
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
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
01164 if (! pOp->IsListEmpty())
01165 {
01166
01167 pBarItem = pOp->GetPtrBarHead();
01168
01169 while (pBarItem != NULL)
01170 {
01171 ThisControl = GetEnumItemType(pBarItem);
01172
01173 switch(ThisControl)
01174 {
01175 case DECKER_TOP:
01176 {
01177 DDeckerState = DDECKER_TOP;
01178
01179 DDeckerStart = xpos;
01180 }
01181 break;
01182 case DECKER_BOTTOM:
01183 {
01184 DDeckerState = DDECKER_BOTTOM;
01185
01186 DDeckerEnd = xpos;
01187
01188 xpos = DDeckerStart;
01189
01190 }
01191 break;
01192 case DECKER_END:
01193 {
01194 DDeckerState = DDECKER_NONE;
01195
01196 if(xpos < DDeckerEnd)
01197 xpos = DDeckerEnd;
01198 }
01199 break;
01200 case SEPARATOR:
01201
01202
01203 {
01204 if(LastItem)
01205 {
01206 if (LastItem->IsKindOf(CC_RUNTIME_CLASS(BarLineFeed)))
01207 ypos += SeparatorWidth;
01208 else
01209 xpos += SeparatorWidth;
01210 }
01211
01212 }
01213 break;
01214 case LINEFEED:
01215
01216 {
01217 ypos += ControlHeight+VERTICAL_SPACE;
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
01228 hcontrol=(HWND)((BarControl*)pBarItem)->GetWinID();
01229 CRect WindSize;
01230
01231 ::GetClientRect(hcontrol,&WindSize);
01232 switch (DDeckerState)
01233 {
01234 case DDECKER_TOP:
01235 if(ThisControl == SMALLBITMAPBUTTON)
01236 {
01237 if (ControlSize == LARGE_CONTROLS)
01238 yOffset = (ControlHeight / 2) - sLARGEBUTTONHEIGHT +1;
01239 else
01240 yOffset = (ControlHeight / 2) - sSMALLBUTTONHEIGHT +1;
01241 xpos++;
01242 }
01243 else
01244 {
01245
01246 yOffset = (ControlHeight / 2) - DDeckerHeight + 1 ;
01247 }
01248
01249
01250 if(ThisControl == STATIC)
01251 yOffset +=3;
01252
01253 break;
01254 case DDECKER_BOTTOM :
01255 yOffset = (ControlHeight / 2) ;
01256
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;
01271 break;
01272 }
01273
01274 if (MoveControls)
01275 ::SetWindowPos(hcontrol,NULL,xpos,ypos + yOffset,0,0,
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
01294 if (xpos > MaxWidth)
01295 MaxWidth = xpos;
01296
01297
01298 LastItem = pBarItem;
01299
01300
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
01310 if (BarSize.cy < ControlHeight + (BAR_BORDERSIZE)+ (1 * 2))
01311 BarSize.cy = ControlHeight + (BAR_BORDERSIZE)+ (1 * 2);
01312
01313
01314
01315
01316 String_32 Name = pOp->GetName();
01317
01318 INT32 SmallestWidth = ControlWidth + (BAR_BORDERSIZE * 2)+ (1 * 2);
01319
01320
01321 if (pOp->IsListEmpty())
01322 {
01323
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
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
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
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
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;
01427 lpncsp->rgrc[0].right -= 1;
01428 lpncsp->rgrc[0].bottom -= 1;
01429
01430
01431
01432 }
01433 }
01434
01435
01436 void GalleryBar::PaintWin95BarNonClient(BOOL IsActive)
01437 {
01438
01439
01440
01441 CRect WinRect;
01442 GetWindowRect(&WinRect);
01443
01444
01445 SysMenuRect = CRect(WinRect.Width() - TitleBarHeight,
01446 3,
01447 WinRect.Width() - 2,
01448 TitleBarHeight);
01449
01450
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
01463 CDC *dc = GetWindowDC();
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
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
01491
01492 SetWindowText(pOp->GetName());
01493
01494 UINT32 DrawFlags = DC_TEXT|DC_SMALLCAP;
01495
01496 if (IsActive)
01497 DrawFlags |= DC_ACTIVE;
01498
01499
01500 ::DrawCaption(GetSafeHwnd(), dc->m_hDC, &CaptionBarRect, DrawFlags);
01501
01502
01503 dc->DrawFrameControl(&SysMenuRect, DFC_CAPTION, DFCS_CAPTIONCLOSE);
01504
01505
01506 ReleaseDC(dc) ;
01507
01508 }