OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
drawitem.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1998, by Yura Bidus, All Rights Reserved
4//
5/// \file
6/// Implementation of class TDrawItemProxy, TDrawItem,TButtonTextDrawItem,
7/// TDrawMenuItem, TDrawMenuItemProxy. Owner draw family.
8//
9// Note this classes stil under development!!!!!!!!!!!!!!!
10//
11//----------------------------------------------------------------------------
12#include <owl/pch.h>
13#include <owl/uimetric.h>
14#include <owl/template.h>
15#include <owl/gadgetwi.h>
16#include <owl/celarray.h>
17#include <owl/uihelper.h>
18#include <owl/glyphbtn.h>
19
20#include <owl/drawitem.h>
21#include <owl/resource.h>
22
23#include <algorithm>
24
25using namespace std;
26
27namespace owl {
28
29//
30// class TDrawItemProxy
31// ~~~~~ ~~~~~~~~~~~~~~
32/// Constructs a TDrawItemProxy object using the specified font. Ownership of the
33/// font transfers to the new object.
34//
36:
37 Font(font ? font : new TGadgetWindowFont()), CelArray(0), DeleteCel(false)
38{
39 ItemArray = new TDrawItemArray;
40}
41//
42/// Deletes Font. If DeleteCel is true, delets CelArray.
43//
45{
46 delete Font;
47 if(DeleteCel)
48 delete CelArray;
49 delete ItemArray;
50}
51//
52/// Deletes Font and sets it to font. Ownership of font transfers to the
53/// TDrawItemProxy.
54//
56{
57 delete Font;
58 Font = font;
59}
60//
61/// If DeleteCel is true, deletes CelArray. CelArray is then set to celarray and
62/// DeleteCel is set to del.
63//
65{
66 if(DeleteCel)
67 delete CelArray;
68 CelArray = celarray;
69 DeleteCel = del == AutoDelete;
70}
71//
72/// Loads a TDib with resource id resId from module. It then uses this TDib and
73/// count to create a new TCelArray. SetCelArray is then called with this TCelArray
74/// and AutoDelete.
75//
81//
82/// Adds item to ItemArray.
83//
85{
86 ItemArray->Add(item);
87}
88//
89//---------------------------------------------------------------------------
90//
91// class TButtonTextDrawItem
92// ~~~~~ ~~~~~~~~~~~~~~~~~~~
93//
94const int TextSpaceH = 2;
95const int TextSpaceV = 2;
96const int TextSpaceE = 15;
97const int ButtonSpaceH = 0;
98const int ButtonSpaceV = 0;
99//---------------------------------------------------------------------------------------
100//
101/// Constructs a TButtonTextDrawItem with proxy as it's parent.
102//
104:
105 Text(0),
106 Index(-1),
107 Align(aLeft),
108 Style(sNone),
109 LayoutStyle(lTextRight),
110 Flags(0),
111 Font(0),
112 CelArray(0),
113 DeleteCel(false),
114 Proxy(proxy)
115{
116}
117//
118/// Destroys a TButtonTextDrawItem object. If DeleteCel is true, deletes CelArray.
119//
121{
122 if(DeleteCel)
123 delete CelArray;
124 delete[] Text;
125 delete Font;
126}
127//
128/// Deletes Text and clears the text style. If text is not NULL, a copy is assigned
129/// to Text and the sText style is added to Style.
130//
131void
133{
134 delete[] Text;
135 Text = 0;
136 uint style = (uint)Style;
137 style &= ~sText;
138 if(text){
139 Text = strnewdup(text);
140 // replace all '\a' to '\t'
141 // '\a' in *.rc becomes '\b' in *.res
142 tchar c = _T('\b');
143 tchar* p = _tcschr(Text,c);
144 while(p){
145 *p = _T('\t');
146 p = _tcschr(Text,_T('\b'));
147 }
148 style |= sText;
149 }
150 Style = (TStyle)style;
151}
152//
153/// Index is set to index and the sBitmap style is cleared from Style. If index >=
154/// 0, the sBitmap style is added to Style.
155//
156void
158{
159 Index = index;
160 uint style = (uint)Style;
161 style &= ~sBitmap;
162 if(Index >=0)
163 style |= sBitmap;
164 Style = (TStyle)style;
165}
166//
167/// Deletes Font and then assigns font to Font. Ownership of font is transferred to
168/// this instance.
169//
170void
172{
173 delete Font;
174 Font = font;
175}
176//
177/// If DeleteCel is true, CelArray is deleted. celarray is assigned to CelArray and
178/// del is assigned to DeleteCel.
179//
180void
182{
183 if(DeleteCel)
184 delete CelArray;
185 CelArray = celarray;
186 DeleteCel = del == AutoDelete;
187}
188//
189/// A bitmap with resource id resId is loaded from module and used to create a
190/// TCelArray with count cells. SetCelArray is then called with this TCelArray.
191//
192void
198//
199/// Extracts information from drawItem and calls Paint.
200//
201void
203{
204 Flags = drawItem.itemState;
205
206 TDC dc(drawItem.hDC);
207 TRect rect(drawItem.rcItem);
208 Paint(dc, rect);
209}
210//
211/// Calculates the area required to display the button and text.
212//
213void
226//
227/// Does an lstrcmp on Text from the instances contained in drawItem.
228//
229int
236//
237/// If selected returns TColor::SysActiveCaption; otherwise returns
238/// TColor::SysWindow.
239//
240TColor
245//
246/// If selected, returns TColor::Sys3dHilight if a 3d User interface is in use or
247/// TColor::SysGrayText otherwise.
248//
249TColor
251{
252 if (IsSelected() || !IsEnabled())
254 else
256}
257//
258/// Calculates the size of the rectangle need to paint the text.
259//
260void
262{
263 TFont* font = Font;
264 if(!font)
265 font = Proxy->GetFont();
266
267 TScreenDC dc;
268
269 if(font)
270 dc.SelectObject(*font);
271
272 dc.GetTextExtent(GetText(), static_cast<int>(::_tcslen(GetText())), size);
273
274 if(font)
275 dc.RestoreFont();
276}
277//
278/// Paint function.
279//
280void
282{
284
286
287 // 1. Erase all
289
290 dc.TextRect(rect);
291
292 PaintText(dc, textRect);
293
294 PaintBitmap(dc, btnRect);
295
297
298 PaintBorder(dc, rect);
299}
300//
301/// Layout Text and Bitmap
302///
303/// Determines the bounding rectangles for the current style.
304//
305void
307{
310
313
314 switch(LayoutStyle){
315
316 case lTextLeft:
317 textRect = TRect(faceRect.TopLeft(), TSize(textSize.cx,faceRect.Height()));
320 break;
321
322 case lTextRight:
326 faceRect.right-TextSpaceH, faceRect.bottom);
327
328 break;
329
330 case lTextTop:
331 textRect = TRect(faceRect.TopLeft(), TSize(faceRect.Width()-TextSpaceH,textSize.cy));
334 break;
335
336 case lTextBottom:
337 textRect = TRect(faceRect.left,faceRect.bottom-textSize.cy,
338 faceRect.right,faceRect.bottom);
341 break;
342 }
343}
344//
345/// Paint the text.
346//
347void
349{
350 if((Style&sText)==0)
351 return;
352
353 TFont* font = Font;
354 if (!font)
355 font = Proxy->GetFont();
356 if(font)
357 dc.SelectObject(*font);
358
360
362 switch(Align){
363 case aLeft:
364 format |= DT_LEFT;
365 break;
366 case aRight:
367 format |= DT_RIGHT;
368 break;
369 case aCenter:
370 format |= DT_CENTER;
371 break;
372 }
373 switch(LayoutStyle){
374 case lTextLeft:
375 case lTextRight:
377 break;
378 case lTextTop:
379 format |= DT_VCENTER;//DT_BOTTOM;
380 break;
381 case lTextBottom:
382 format |= DT_VCENTER;//DT_TOP;
383 break;
384 }
385
386 // Create a UI Face object for this button & let it paint the button face
387 //
389 TPoint dstPt(tRect.TopLeft());
390
392 if ((!IsEnabled()||IsGrayed()) && !IsSelected())
393 face.Paint(dc, dstPt, TUIFace::Disabled, false, false);
394 else
395 face.Paint(dc, dstPt, TUIFace::Normal, false, false);
396
398
399 if(font)
400 dc.RestoreFont();
401}
402//
403/// Calculates the size of button.
404//
405void
407{
408 btnSize = TSize(0,0);
409 if(Index == sepNoBitmap) // == -2
410 return;
411 TCelArray* celArray = CelArray ? CelArray : Proxy->GetCelArray();
412 if(celArray)
413 btnSize = celArray->CelSize();
414}
415//
416/// Paint the border of the gadget based on the BorderStyle member
417//
418void
424//
425/// Paint the bitmap.
426//
427void
429{
430 if((Style&sBitmap)==0 || Index < 0)
431 return;
432
433 // Determine which CelArray to paint from: ours or our Window's
434 //
435 TCelArray& celArray = CelArray ? *CelArray : *Proxy->GetCelArray();
436 // Create a UI Face object for this button & let it paint the button face
437 celArray.BitBlt(Index, dc, rect.left, rect.top);
438}
439//////////////////////////////////////////////////////////////////////////////////////
440//
441//
442
443//
444/// Called with the proxy parent, the command it, the index in the menu and the text
445/// to display.
446//
448:
449 TButtonTextDrawItem(proxy),CmdId(cmdId),CheckPainter(0)
450{
451 SetText(title);
452 SetIndex(index);
453}
454
455//
456/// String-aware overload
457//
459 : TButtonTextDrawItem(proxy), CmdId(cmdId), CheckPainter(0)
460{
461 SetText(title.c_str());
462 SetIndex(index);
463}
464
465//
466//
467//
468void
470{
472 size.cx += TextSpaceE;
474 size.cx += TextSpaceE;
475 size.cy = std::max((int)size.cy, 16);
476}
477//
478/// Get the size of the bitmap button.
479//
480void
482{
483 btnSize = TSize(0,0);
484 if(Index == sepNoBitmap) // == -2
485 return;
486 TCelArray* celArray = CelArray ? CelArray : Proxy->GetCelArray();
487 if(celArray){
488 btnSize = celArray->CelSize();
489 btnSize.cx += 3;
490 btnSize.cy += 3;
491 }
492}
493//
494/// If the menu item is selected returns TColor::SysActiveCaption; otherwise returns
495/// TColor::SysMenu.
496//
497TColor
502//
503/// Returns the text color.
504//
505TColor
507{
508 if (IsSelected() || !IsEnabled())
510 else
511 return TColor::SysMenuText;
512}
513//
514/// Paint the bitmap on the menu entry.
515//
516void
518{
519 if(((Style&sBitmap)==0 || Index < 0) && CheckPainter==0)
520 return;
521
523 dc.TextRect(rect);
524
525 if(CheckPainter){
526
527 if(IsChecked())
528 (this->*CheckPainter)(dc, rect);
529 else
531
533 return;
534 }
535
536 // Determine which CelArray to paint from: ours or our Window's
537 //
538 TCelArray& celArray = CelArray ? *CelArray : *Proxy->GetCelArray();
539
540 // Calc the source rect from the celarray. The dest point of the glyph is
541 // relative to the face rect.
542 //
543 TRect srcRect(celArray.CelRect(Index));
544
545 // Paint border
546 //
548 if(IsChecked())
550 else if(IsSelected()&&IsEnabled())
552 if(edge)
553 TUIBorder(rect, edge).Paint(dc);
554
555 rect.Inflate(-1,-1);
556
557 // Create a UI Face object for this button & let it paint the button face
558 //
559 TUIFace face(rect, celArray.operator TBitmap&());
560 TPoint dstPt(1,1);
561
562 if (!IsEnabled())
564 else if(IsGrayed())
566 else
567#if 0
568 face.Paint(dc, srcRect, (IsSelected() && !IsChecked()) ?
569 dstPt.Offset(-1,-1) : dstPt, TUIFace::Normal, IsChecked());
570#else
572#endif
574}
575//
576// Paint Text
577//
578void
580{
581 if((Style&sText)==0)
582 return;
583
584 TFont* font = Font;
585 if (!font)
586 font = Proxy->GetFont();
587 if(font)
588 dc.SelectObject(*font);
589
591
593 switch(Align){
594 case aLeft:
595 format |= DT_LEFT;
596 break;
597 case aRight:
598 format |= DT_RIGHT;
599 break;
600 case aCenter:
601 format |= DT_CENTER;
602 break;
603 }
604 switch(LayoutStyle){
605 case lTextLeft:
606 case lTextRight:
608 break;
609 case lTextTop:
610 format |= DT_VCENTER;//DT_BOTTOM;
611 break;
612 case lTextBottom:
613 format |= DT_VCENTER;//DT_TOP;
614 break;
615 }
616
617 // DT_RIGHT for \t
618 tstring cs1;
619 tstring cs(Text);
620 size_t t_pos = cs.find(_T("\t")); //JJH changed int -> size_t
621
623 tRect.right -= TextSpaceE;
624
625 // Accelerator can be \b instead of \t (NOTE: \a in .rc make a \b in res)
626 //
627 if (t_pos == cs.npos)
628 t_pos = cs.find(_T("\b"));
629
630 if (t_pos != cs.npos)
631 {
632 cs1 = cs.substr(t_pos+1);
633 cs = cs.substr(0, t_pos);
634 // Create a UI Face object for this button & let it paint the button face
635 //
636 TPoint dstPt(tRect.TopLeft());
637
638 TUIFace face1(tRect, cs.c_str(), GetBkColor(), format);
639 format &= ~DT_LEFT;
640 format |= DT_RIGHT;
641 TUIFace face2(tRect, cs1.c_str(), GetBkColor(), format);
642
643 if ((!IsEnabled()||IsGrayed()) && !IsSelected()){
644 face1.Paint(dc, dstPt, TUIFace::Disabled, false, false);
645 face2.Paint(dc, dstPt, TUIFace::Disabled, false, false);
646 }
647 else{
648 face1.Paint(dc, dstPt, TUIFace::Normal, false, false);
649 face2.Paint(dc, dstPt, TUIFace::Normal, false, false);
650 }
651 }
652 else{
653 // Create a UI Face object for this button & let it paint the button face
654 //
655 TPoint dstPt(tRect.TopLeft());
656
658 if ((!IsEnabled()||IsGrayed()) && !IsSelected())
659 face.Paint(dc, dstPt, TUIFace::Disabled, false, false);
660 else
661 face.Paint(dc, dstPt, TUIFace::Normal, false, false);
662 }
663
665
666 if(font)
667 dc.RestoreFont();
668}
669//
670/// If checked, clears the area in preparation for painting the check mark.
671//
672void
685///////////////////////////////////////////////////////////////////////////////////////////
686//
687// Check Draw functions
688//
689static TColor SelectColor(bool enabled)
690{
692}
693//
694/// Draw this:
695/// \code
696/// 01234567
697/// 0 ---x----
698/// 1 ---xx---
699/// 2 ---xxx--
700/// 3 ---xxxx-
701/// 4 ---xxx--
702/// 5 ---xx---
703/// 6 ---x----
704/// 7 --------
705/// \endcode
706//
707void
709{
710 //rect.Inflate(-3,-3);
711 //TPoint point(rect.left+3,rect.top+3);
712 rect.Inflate(-2,-2);
713 TPoint point(rect.left+3,rect.top+2);
714 TColor color = SelectColor(IsEnabled());
715
717
718 // Draw this:
719 //
720 // 01234567
721 // 0 ---x----
722 // 1 ---xx---
723 // 2 ---xxx--
724 // 3 ---xxxx-
725 // 4 ---xxx--
726 // 5 ---xx---
727 // 6 ---x----
728 // 7 --------
729 //
730 dc.SetPixel(point.x + 3, point.y + 0, color);
731 dc.SetPixel(point.x + 3, point.y + 1, color);
732 dc.SetPixel(point.x + 3, point.y + 2, color);
733 dc.SetPixel(point.x + 3, point.y + 3, color);
734 dc.SetPixel(point.x + 3, point.y + 4, color);
735 dc.SetPixel(point.x + 3, point.y + 5, color);
736 dc.SetPixel(point.x + 3, point.y + 6, color);
737 dc.SetPixel(point.x + 4, point.y + 1, color);
738 dc.SetPixel(point.x + 4, point.y + 2, color);
739 dc.SetPixel(point.x + 4, point.y + 3, color);
740 dc.SetPixel(point.x + 4, point.y + 4, color);
741 dc.SetPixel(point.x + 4, point.y + 5, color);
742 dc.SetPixel(point.x + 5, point.y + 2, color);
743 dc.SetPixel(point.x + 5, point.y + 3, color);
744 dc.SetPixel(point.x + 5, point.y + 4, color);
745 dc.SetPixel(point.x + 6, point.y + 3, color);
746 if(!IsEnabled()){
747 // Add this:
748 //
749 // 01234567
750 // 0 --------
751 // 1 --------
752 // 2 --------
753 // 3 --------
754 // 4 ------x-
755 // 5 -----x--
756 // 6 ----x---
757 // 7 ---x----
758 //
760 dc.SetPixel(point.x + 3, point.y + 7, clr);
761 dc.SetPixel(point.x + 4, point.y + 6, clr);
762 dc.SetPixel(point.x + 5, point.y + 5, clr);
763 dc.SetPixel(point.x + 6, point.y + 4, clr);
764 }
765}
766//
767/// Draw this:
768/// \code
769/// 01234567
770/// 0 ---x----
771/// 1 ---xx---
772/// 2 ---xxx--
773/// 3 xxxxxxx-
774/// 4 ---xxx--
775/// 5 ---xx---
776/// 6 ---x----
777/// 7 --------
778/// \endcode
779void
781{
782 //rect.Inflate(-3,-3);
783 //TPoint point(rect.left+4,rect.top+3);
784 rect.Inflate(-2,-2);
785 TPoint point(rect.left+4,rect.top+2);
786 TColor color = SelectColor(IsEnabled());
787
789
790 // Draw this:
791 //
792 // 01234567
793 // 0 ---x----
794 // 1 ---xx---
795 // 2 ---xxx--
796 // 3 xxxxxxx-
797 // 4 ---xxx--
798 // 5 ---xx---
799 // 6 ---x----
800 // 7 --------
801 //
802
803 dc.SetPixel(point.x + 0, point.y + 3, color);
804 dc.SetPixel(point.x + 1, point.y + 3, color);
805 dc.SetPixel(point.x + 2, point.y + 3, color);
806 dc.SetPixel(point.x + 3, point.y + 0, color);
807 dc.SetPixel(point.x + 3, point.y + 1, color);
808 dc.SetPixel(point.x + 3, point.y + 2, color);
809 dc.SetPixel(point.x + 3, point.y + 3, color);
810 dc.SetPixel(point.x + 3, point.y + 4, color);
811 dc.SetPixel(point.x + 3, point.y + 5, color);
812 dc.SetPixel(point.x + 3, point.y + 6, color);
813 dc.SetPixel(point.x + 4, point.y + 1, color);
814 dc.SetPixel(point.x + 4, point.y + 2, color);
815 dc.SetPixel(point.x + 4, point.y + 3, color);
816 dc.SetPixel(point.x + 4, point.y + 4, color);
817 dc.SetPixel(point.x + 4, point.y + 5, color);
818 dc.SetPixel(point.x + 5, point.y + 2, color);
819 dc.SetPixel(point.x + 5, point.y + 3, color);
820 dc.SetPixel(point.x + 5, point.y + 4, color);
821 dc.SetPixel(point.x + 6, point.y + 3, color);
822 if(!IsEnabled()){
823 // Add this:
824 //
825 // 01234567
826 // 0 --------
827 // 1 --------
828 // 2 --------
829 // 3 --------
830 // 4 ------x-
831 // 5 -----x--
832 // 6 ----x---
833 // 7 ---x----
834 //
836 dc.SetPixel(point.x + 3, point.y + 7, clr);
837 dc.SetPixel(point.x + 4, point.y + 6, clr);
838 dc.SetPixel(point.x + 5, point.y + 5, clr);
839 dc.SetPixel(point.x + 6, point.y + 4, clr);
840 }
841}
842//
843/// Draw this:
844/// \code
845/// 01234567
846/// 1 -xxxxxxx
847/// 2 -xxxxxxx
848/// 3 -xxxxxxx
849/// 4 -xxxxxxx
850/// 5 -xxxxxxx
851/// 6 -xxxxxxx
852/// 7 -xxxxxxx
853/// \endcode
854//
855void
857{
858 //rect.Inflate(-3,-3);
859 //TPoint point(rect.left+4,rect.top+3);
860 rect.Inflate(-2,-2);
861 TPoint point(rect.left+4,rect.top+2);
862 TColor color = SelectColor(IsEnabled());
863
865
866 // Draw this:
867 //
868 // 01234567
869 // 0 --------
870 // 1 -xxxxxxx
871 // 2 -xxxxxxx
872 // 3 -xxxxxxx
873 // 4 -xxxxxxx
874 // 5 -xxxxxxx
875 // 6 -xxxxxxx
876 // 7 -xxxxxxx
877 //
878
879 dc.TextRect(point.x + 1, point.y + 1, point.x + 7, point.y + 7, color);
880
881 if(!IsEnabled()){
882 // Add this:
883 //
884 // 01234567
885 // 0 --------
886 // 1 --------
887 // 2 --------x
888 // 3 --------x
889 // 4 --------x
890 // 5 --------x
891 // 6 --------x
892 // 7 --------x
893 // xxxxxxx
894 //
896 dc.SelectObject(pen);
897 dc.MoveTo(point.x + 2, point.y + 8);
898 dc.LineTo(point.x + 8, point.y + 8);
899 dc.MoveTo(point.x + 8, point.y + 2);
900 dc.LineTo(point.x + 8, point.y + 9);
901 dc.RestorePen();
902 }
903}
904//
905/// Draw this:
906/// \code
907/// 01234567
908/// 0 --------
909/// 1 ----x---
910/// 2 ---xxx--
911/// 3 --xxxxx-
912/// 4 -xxxxxxx
913/// 5 --xxxxx-
914/// 6 ---xxx--
915/// 7 ----x---
916/// \endcode
917void
919{
920 //rect.Inflate(-3,-3);
921 //TPoint point(rect.left+3,rect.top+2);
922 rect.Inflate(-2,-2);
923 TPoint point(rect.left+3,rect.top+1);
924 TColor color = SelectColor(IsEnabled());
925
927
928 // Draw this:
929 //
930 // 01234567
931 // 0 --------
932 // 1 ----x---
933 // 2 ---xxx--
934 // 3 --xxxxx-
935 // 4 -xxxxxxx
936 // 5 --xxxxx-
937 // 6 ---xxx--
938 // 7 ----x---
939 //
940
941 dc.SetPixel(point.x + 1, point.y + 4, color);
942 dc.SetPixel(point.x + 2, point.y + 3, color);
943 dc.SetPixel(point.x + 2, point.y + 4, color);
944 dc.SetPixel(point.x + 2, point.y + 5, color);
945 dc.SetPixel(point.x + 3, point.y + 2, color);
946 dc.SetPixel(point.x + 3, point.y + 3, color);
947 dc.SetPixel(point.x + 3, point.y + 4, color);
948 dc.SetPixel(point.x + 3, point.y + 5, color);
949 dc.SetPixel(point.x + 3, point.y + 6, color);
950 dc.SetPixel(point.x + 4, point.y + 1, color);
951 dc.SetPixel(point.x + 4, point.y + 2, color);
952 dc.SetPixel(point.x + 4, point.y + 3, color);
953 dc.SetPixel(point.x + 4, point.y + 4, color);
954 dc.SetPixel(point.x + 4, point.y + 5, color);
955 dc.SetPixel(point.x + 4, point.y + 6, color);
956 dc.SetPixel(point.x + 4, point.y + 7, color);
957 dc.SetPixel(point.x + 5, point.y + 2, color);
958 dc.SetPixel(point.x + 5, point.y + 3, color);
959 dc.SetPixel(point.x + 5, point.y + 4, color);
960 dc.SetPixel(point.x + 5, point.y + 5, color);
961 dc.SetPixel(point.x + 5, point.y + 6, color);
962 dc.SetPixel(point.x + 6, point.y + 3, color);
963 dc.SetPixel(point.x + 6, point.y + 4, color);
964 dc.SetPixel(point.x + 6, point.y + 5, color);
965 dc.SetPixel(point.x + 7, point.y + 4, color);
966 if(!IsEnabled()){
967 // Add this:
968 //
969 // 01234567
970 // 0 --------
971 // 1 --------
972 // 2 --------
973 // 3 --------
974 // 4 --------
975 // 5 -------x
976 // 6 ------x-
977 // 7 -----x--
978 // x
979 //
981 dc.SetPixel(point.x + 4, point.y + 8, clr);
982 dc.SetPixel(point.x + 5, point.y + 7, clr);
983 dc.SetPixel(point.x + 6, point.y + 6, clr);
984 dc.SetPixel(point.x + 7, point.y + 5, clr);
985 }
986}
987//
988/// Draw this:
989/// \code
990/// 01234567
991/// 0 ---xx---
992/// 1 --xxxx--
993/// 2 -xxxxxx-
994/// 3 -xxxxxx-
995/// 4 -xxxxxx-
996/// 5 --xxxx--
997/// 6 ---xx---
998/// 7 --------
999/// \endcode
1000//
1001void
1003{
1004 //rect.Inflate(-3,-3);
1005 //TPoint point(rect.left+4,rect.top+3);
1006 rect.Inflate(-2,-2);
1007 TPoint point(rect.left+4,rect.top+2);
1008 TColor color = SelectColor(IsEnabled());
1009
1010 PaintCheckFace(dc,rect);
1011
1012 // Draw this:
1013 //
1014 // 01234567
1015 // 0 ---xx---
1016 // 1 --xxxx--
1017 // 2 -xxxxxx-
1018 // 3 -xxxxxx-
1019 // 4 -xxxxxx-
1020 // 5 --xxxx--
1021 // 6 ---xx---
1022 // 7 --------
1023 //
1024
1025 TPen pen(color, 0, PS_SOLID);
1026 dc.SelectObject(pen);
1027
1028 dc.MoveTo(point.x + 1, point.y + 2);
1029 dc.LineTo(point.x + 1, point.y + 5);
1030 dc.MoveTo(point.x + 2, point.y + 1);
1031 dc.LineTo(point.x + 2, point.y + 6);
1032 dc.MoveTo(point.x + 3, point.y + 0);
1033 dc.LineTo(point.x + 3, point.y + 7);
1034 dc.MoveTo(point.x + 4, point.y + 0);
1035 dc.LineTo(point.x + 4, point.y + 7);
1036 dc.MoveTo(point.x + 5, point.y + 1);
1037 dc.LineTo(point.x + 5, point.y + 6);
1038 dc.MoveTo(point.x + 6, point.y + 2);
1039 dc.LineTo(point.x + 6, point.y + 5);
1040 dc.RestorePen();
1041 if(!IsEnabled()){
1042 // Add this:
1043 //
1044 // 01234567
1045 // 0 --------
1046 // 1 --------
1047 // 2 --------
1048 // 3 --------
1049 // 4 --------
1050 // 5 ------x-
1051 // 6 -----x--
1052 // 7 ---xx---
1053 //
1055 dc.SetPixel(point.x + 3, point.y + 7, clr);
1056 dc.SetPixel(point.x + 4, point.y + 7, clr);
1057 dc.SetPixel(point.x + 5, point.y + 6, clr);
1058 dc.SetPixel(point.x + 6, point.y + 5, clr);
1059 }
1060}
1061//
1062/// Draw this:
1063/// \code
1064/// 01234567
1065/// 0 --------
1066/// 1 --------
1067/// 2 --------
1068/// 3 --------
1069/// 4 --------
1070/// 5 --------
1071/// 6 --------
1072/// 7 --------
1073/// \endcode
1074//
1075void
1077{
1078 //rect.Inflate(-3,-3);
1079 rect.Inflate(-2,-2);
1080
1081 PaintCheckFace(dc,rect);
1082
1083 // Draw this:
1084 //
1085 // 01234567
1086 // 0 --------
1087 // 1 --------
1088 // 2 --------
1089 // 3 --------
1090 // 4 --------
1091 // 5 --------
1092 // 6 --------
1093 // 7 --------
1094 //
1095}
1096//
1097/// Draw this:
1098/// \code
1099/// 01234567
1100/// 0 --------
1101/// 1 ---xx---
1102/// 2 ---xx---
1103/// 3 -xxxxxx-
1104/// 4 -xxxxxx-
1105/// 5 ---xx---
1106/// 6 ---xx---
1107/// 7 --------
1108/// \endcode
1109//
1110void
1112{
1113 //rect.Inflate(-3,-3);
1114 //TPoint point(rect.left+4,rect.top+3);
1115 rect.Inflate(-2,-2);
1116 TPoint point(rect.left+4,rect.top+2);
1117 TColor color = SelectColor(IsEnabled());
1118
1119 PaintCheckFace(dc,rect);
1120
1121 // Draw this:
1122 //
1123 // 01234567
1124 // 0 --------
1125 // 1 ---xx---
1126 // 2 ---xx---
1127 // 3 -xxxxxx-
1128 // 4 -xxxxxx-
1129 // 5 ---xx---
1130 // 6 ---xx---
1131 // 7 --------
1132 //
1133
1134 TPen Pen(color, 0, PS_SOLID);
1135 dc.SelectObject(Pen);
1136
1137 dc.MoveTo(point.x + 3, point.y + 1);
1138 dc.LineTo(point.x + 3, point.y + 7);
1139 dc.MoveTo(point.x + 4, point.y + 1);
1140 dc.LineTo(point.x + 4, point.y + 7);
1141 dc.MoveTo(point.x + 1, point.y + 3);
1142 dc.LineTo(point.x + 7, point.y + 3);
1143 dc.MoveTo(point.x + 1, point.y + 4);
1144 dc.LineTo(point.x + 7, point.y + 4);
1145 dc.RestorePen();
1146 if(!IsEnabled()){
1147 // Add this:
1148 //
1149 // 01234567
1150 // 0 --------
1151 // 1 --------
1152 // 2 --------
1153 // 3 --------
1154 // 4 --------
1155 // 5 -----xx-
1156 // 6 -----x--
1157 // 7 ---xxx--
1158 //
1160 dc.SetPixel(point.x + 3, point.y + 7, clr);
1161 dc.SetPixel(point.x + 4, point.y + 7, clr);
1162 dc.SetPixel(point.x + 5, point.y + 7, clr);
1163 dc.SetPixel(point.x + 5, point.y + 6, clr);
1164 dc.SetPixel(point.x + 5, point.y + 5, clr);
1165 dc.SetPixel(point.x + 6, point.y + 5, clr);
1166 }
1167}
1168//
1169/// Draw this:
1170/// \code
1171/// 01234567
1172/// 0 ------x-
1173/// 1 -----xx-
1174/// 2 x---xxx-
1175/// 3 xx-xxx--
1176/// 4 xxxxx---
1177/// 5 -xxx----
1178/// 6 --x-----
1179/// 7 --------
1180/// \endcode
1181//
1182void
1184{
1185 //rect.Inflate(-3,-3);
1186 //TPoint point(rect.left+4,rect.top+3);
1187 rect.Inflate(-2,-2);
1188 TPoint point(rect.left+4,rect.top+2);
1189 TColor color = SelectColor(IsEnabled());
1190
1191 PaintCheckFace(dc,rect);
1192
1193 // Draw this:
1194 //
1195 // 01234567
1196 // 0 ------x-
1197 // 1 -----xx-
1198 // 2 x---xxx-
1199 // 3 xx-xxx--
1200 // 4 xxxxx---
1201 // 5 -xxx----
1202 // 6 --x-----
1203 // 7 --------
1204 //
1205
1206 dc.SetPixel(point.x + 0, point.y + 2, color);
1207 dc.SetPixel(point.x + 0, point.y + 3, color);
1208 dc.SetPixel(point.x + 0, point.y + 4, color);
1209 dc.SetPixel(point.x + 1, point.y + 3, color);
1210 dc.SetPixel(point.x + 1, point.y + 4, color);
1211 dc.SetPixel(point.x + 1, point.y + 5, color);
1212 dc.SetPixel(point.x + 2, point.y + 4, color);
1213 dc.SetPixel(point.x + 2, point.y + 5, color);
1214 dc.SetPixel(point.x + 2, point.y + 6, color);
1215 dc.SetPixel(point.x + 3, point.y + 3, color);
1216 dc.SetPixel(point.x + 3, point.y + 4, color);
1217 dc.SetPixel(point.x + 3, point.y + 5, color);
1218 dc.SetPixel(point.x + 4, point.y + 2, color);
1219 dc.SetPixel(point.x + 4, point.y + 3, color);
1220 dc.SetPixel(point.x + 4, point.y + 4, color);
1221 dc.SetPixel(point.x + 5, point.y + 1, color);
1222 dc.SetPixel(point.x + 5, point.y + 2, color);
1223 dc.SetPixel(point.x + 5, point.y + 3, color);
1224 dc.SetPixel(point.x + 6, point.y + 0, color);
1225 dc.SetPixel(point.x + 6, point.y + 1, color);
1226 dc.SetPixel(point.x + 6, point.y + 2, color);
1227 if(!IsEnabled()){
1228 // Add this:
1229 //
1230 // 01234567
1231 // 0 --------
1232 // 1 --------
1233 // 2 --------
1234 // 3 ------x-
1235 // 4 -----x--
1236 // 5 ----x---
1237 // 6 ---x----
1238 // 7 --x-----
1239 //
1241 dc.SetPixel(point.x + 2, point.y + 7, clr);
1242 dc.SetPixel(point.x + 3, point.y + 6, clr);
1243 dc.SetPixel(point.x + 4, point.y + 5, clr);
1244 dc.SetPixel(point.x + 5, point.y + 4, clr);
1245 dc.SetPixel(point.x + 6, point.y + 3, clr);
1246 }
1247}
1248//
1249/// Draw this:
1250/// \code
1251/// 01234567
1252/// 0 --------
1253/// 1 xx---xx-
1254/// 2 -xx-xx--
1255/// 3 --xx----
1256/// 4 ---xx---
1257/// 5 -xx-xx--
1258/// 6 xx---xx-
1259/// 7 --------
1260/// \endcode
1261//
1262void
1264{
1265 //rect.Inflate(-3,-3);
1266 rect.Inflate(-2,-2);
1267 TColor color = SelectColor(IsEnabled());
1268
1269 PaintCheckFace(dc,rect);
1270
1271 // Draw this:
1272 //
1273 // 01234567
1274 // 0 --------
1275 // 1 xx---xx-
1276 // 2 -xx-xx--
1277 // 3 --xx----
1278 // 4 ---xx---
1279 // 5 -xx-xx--
1280 // 6 xx---xx-
1281 // 7 --------
1282 //
1283 //TPoint point(rect.left+4,rect.top+3);
1284 TPoint point(rect.left+4,rect.top+2);
1285 dc.SetPixel(point.x + 0, point.y + 1, color);
1286 dc.SetPixel(point.x + 1, point.y + 1, color);
1287 dc.SetPixel(point.x + 1, point.y + 2, color);
1288 dc.SetPixel(point.x + 2, point.y + 2, color);
1289 dc.SetPixel(point.x + 2, point.y + 3, color);
1290 dc.SetPixel(point.x + 3, point.y + 3, color);
1291 dc.SetPixel(point.x + 3, point.y + 4, color);
1292 dc.SetPixel(point.x + 4, point.y + 4, color);
1293 dc.SetPixel(point.x + 4, point.y + 5, color);
1294 dc.SetPixel(point.x + 5, point.y + 5, color);
1295 dc.SetPixel(point.x + 5, point.y + 6, color);
1296 dc.SetPixel(point.x + 6, point.y + 6, color);
1297 dc.SetPixel(point.x + 5, point.y + 1, color);
1298 dc.SetPixel(point.x + 6, point.y + 1, color);
1299 dc.SetPixel(point.x + 4, point.y + 2, color);
1300 dc.SetPixel(point.x + 5, point.y + 2, color);
1301 dc.SetPixel(point.x + 1, point.y + 5, color);
1302 dc.SetPixel(point.x + 2, point.y + 5, color);
1303 dc.SetPixel(point.x + 0, point.y + 6, color);
1304 dc.SetPixel(point.x + 1, point.y + 6, color);
1305 if(!IsEnabled()){
1306 // Add this:
1307 //
1308 // 01234567
1309 // 0 --------
1310 // 1 --------
1311 // 2 ------x-
1312 // 3 ----x---
1313 // 4 --------
1314 // 5 ---x----
1315 // 6 --x-----
1316 // 7 -x------
1317 //
1319 dc.SetPixel(point.x + 6, point.y + 2, clr);
1320 dc.SetPixel(point.x + 4, point.y + 3, clr);
1321 dc.SetPixel(point.x + 3, point.y + 5, clr);
1322 dc.SetPixel(point.x + 2, point.y + 6, clr);
1323 dc.SetPixel(point.x + 1, point.y + 7, clr);
1324 }
1325}
1326
1327//-------------------------------------------------------------------------
1328//
1329// class TDrawMenuItemProxy
1330// ~~~~~ ~~~~~~~~~~~~~~~~~~
1331//
1332/// Creates a font for use in menu bars.
1333//
1334TFont*
1336{
1338 ncm.cbSize = sizeof(NONCLIENTMETRICS);
1340 return new TFont(ncm.lfMenuFont);
1341}
1342//
1343/// Constructs a TDrawMenuItemProxy object using the specified resource.
1344//
1346:
1347 TDrawItemProxy(CreateProxyMenuFont())
1348{
1349 Array = new TUIntAray;
1351 int numRows = barRes.GetBitmap().Height()/barRes.GetHeight();
1352 { // map colors
1354 }
1355
1357 &barRes.GetBitmap(),
1358 barRes.GetCount(),
1359 TSize(barRes.GetWidth(), barRes.GetHeight()),
1360 TPoint(0, 0), // offset
1361 numRows);
1363
1364 for(int i = 0; i < (int)barRes.GetCount(); i++){
1365 if(barRes.GetIds()[i] >0)
1366 Array->Add((uint)barRes.GetIds()[i]);
1367 }
1368}
1369//
1370/// Destroys the instance.
1371//
1376//
1377/// Returns the item with id cmdId if it exists; otherwise creates a new item and
1378/// returns it.
1379//
1380TDrawItem*
1382{
1383 TDrawItemArray& items = GetItems();
1384 int index = GetIndex((int)cmdId);
1385
1386 // if item already exist -> return existing one
1387 for(int i = 0; i < (int)items.Size(); i++){
1389 if(item->GetIndex() == index && item->GetText() == text)
1390 return items[i];
1391 }
1392 if(cmdId == static_cast<uint>(TButtonTextDrawItem::sepNoBitmap)) //JJH added static_cast
1394
1395 // if none found -> add new one
1396 TDrawMenuItem* item = new TDrawMenuItem(this, cmdId, index, text);
1397 RegisterItem(item);
1398
1399 return item;
1400}
1401//
1402/// Walks through the menu tree hMenu adding seperators.
1403//
1404void
1406{
1407 iRecurse = 0; // this->iRecurse = 0;
1408
1409 iRecurse++;
1410 int nItem = ::GetMenuItemCount(hMenu);
1411 while ((--nItem)>=0) {
1412 uint itemId = ::GetMenuItemID(hMenu, nItem);
1413 if (itemId == (uint) -1){
1414 HMENU pops = ::GetSubMenu(hMenu, nItem);
1415 if (pops)
1416 RemapMenu(pops);
1417 if (iRecurse>0){
1419 if (::GetMenuString(hMenu, nItem, buffer, MAX_PATH, MF_BYPOSITION) > 0){
1421 ::ModifyMenu(hMenu, nItem, MF_BYPOSITION|MF_OWNERDRAW, (uint)-1, (LPCTSTR)item);
1422 }
1423 }
1424 }
1425 else {
1426 uint oldState = ::GetMenuState(hMenu, nItem, MF_BYPOSITION);
1427 if (!(oldState&MF_OWNERDRAW) && !(oldState&MF_BITMAP)) {
1428 if ((oldState&MF_SEPARATOR) || itemId == 0){
1429 // Insert separator items only if a background bitmap is drawn
1430 //
1431 }
1432 else{
1434 if (::GetMenuString(hMenu, nItem, buffer, MAX_PATH, MF_BYPOSITION) > 0){
1437 (LPARAM)itemId, (LPCTSTR)item);
1438 }
1439 }
1440 }
1441 }
1442 }
1443 iRecurse--;
1444}
1445//
1446/// Returns true if a shortcut was pressed that fits into the menu and false if not.
1447//
1448bool
1450{
1453 int count = ::GetMenuItemCount(hMenu);
1454 while(count >= 0){
1455 uint itemId = ::GetMenuItemID(hMenu, count);
1456 if(itemId){
1458 if(::GetMenuItemInfo(hMenu, count, true, &itemInfo)){
1459 if(itemInfo.fType & MFT_OWNERDRAW){
1460 TDrawMenuItem* item = 0;
1461 try{
1463 }
1464 catch(...){
1465 //.........
1466 }
1467 if(item){
1468 const tchar* p = _tcschr(item->GetText(),_T('&'));
1469 if(p){
1470 p++;
1471 if(_totupper(*p) == keyPressed){
1472 // Shortcut found.
1473 param = MkUint32((uint16)count, 2);
1474 return true;
1475 }
1476 }
1477 }
1478 }
1479 }
1480 }
1481 count--;
1482 }
1483 // Shortcut not found.
1484 return false;
1485}
1486//
1487/// Returns the TDrawItem with id cmdId, or 0 if it doesn't exist.
1488//
1490{
1491 TDrawItemArray& items = GetItems();
1492 auto index = GetIndex(cmdId);
1493 if (index != items.NPOS)
1494 return items[index];
1495
1496 const auto n = static_cast<int>(items.Size());
1497 for (index = 0; index != n; ++index)
1498 {
1499 const auto m = dynamic_cast<TDrawMenuItem*>(items[index]);
1500 if (m && m->GetCmdId() == static_cast<int>(cmdId))
1501 break;
1502 }
1503 return index < n ? items[index] : nullptr;
1504}
1505//
1506/// Returns the array index of the item with id cmdId.
1507//
1509{
1510 return Array->Find(cmdId);
1511}
1512//
1513} // OWL namespace
1514
1515////////////////////////////////////////////////////////////////////////////////
1516
1517
Definition of a bitmap Cel array class.
#define PRECONDITION(condition)
Definition checks.h:227
TBitmap is the GDI bitmap class derived from TGdiObject.
Definition gdiobjec.h:510
TBtnBitmap is an enhanced version of TBitmap with the ability to update the face color of a bitmap to...
Definition glyphbtn.h:49
virtual void Measure(MEASUREITEMSTRUCT &drawItem)
Calculates the area required to display the button and text.
Definition drawitem.cpp:214
virtual int Compare(COMPAREITEMSTRUCT &drawItem)
Does an lstrcmp on Text from the instances contained in drawItem.
Definition drawitem.cpp:230
bool IsSelected()
Returns true if (Flags & ODS_SELECTED)==0; false otherwise.
Definition drawitem.h:142
@ lTextTop
Text top, bitmap bottom.
Definition drawitem.h:93
@ lTextRight
Text right, bitmap left.
Definition drawitem.h:94
@ lTextBottom
Text bottom, bitmap top.
Definition drawitem.h:95
@ lTextLeft
Text left, bitmap right.
Definition drawitem.h:92
virtual void PaintBitmap(TDC &rc, TRect &rect)
Paint the bitmap.
Definition drawitem.cpp:428
TStyle GetStyle() const
Returns Style: Bitmap only, Text only, or Bitmap and Text.
Definition drawitem.h:290
virtual void PaintText(TDC &rc, TRect &rect)
Paint the text.
Definition drawitem.cpp:348
bool IsChecked()
Returns true if (Flags & ODS_CHECKED)==0; false otherwise.
Definition drawitem.h:151
void SetFont(TFont *font)
Deletes Font and then assigns font to Font.
Definition drawitem.cpp:171
bool IsGrayed()
Returns true if (Flags & ODS_GRAYED)==0; false otherwise.
Definition drawitem.h:148
virtual void PaintBorder(TDC &rc, TRect &rect)
Paint the border of the gadget based on the BorderStyle member.
Definition drawitem.cpp:419
virtual TColor GetBkColor()
If selected returns TColor::SysActiveCaption; otherwise returns TColor::SysWindow.
Definition drawitem.cpp:241
virtual void Layout(const TRect &src, TRect &textRect, TRect &bmpRect)
Layout Text and Bitmap.
Definition drawitem.cpp:306
bool IsFocused()
Returns true if (Flags & ODS_FOCUS)==0; false otherwise.
Definition drawitem.h:145
~TButtonTextDrawItem()
Destroys a TButtonTextDrawItem object. If DeleteCel is true, deletes CelArray.
Definition drawitem.cpp:120
TButtonTextDrawItem(TDrawItemProxy *proxy=0)
Constructs a TButtonTextDrawItem with proxy as it's parent.
Definition drawitem.cpp:103
virtual void Draw(DRAWITEMSTRUCT &drawItem)
Extracts information from drawItem and calls Paint.
Definition drawitem.cpp:202
void SetText(LPCTSTR text)
Deletes Text and clears the text style.
Definition drawitem.cpp:132
virtual TColor GetTextColor()
If selected, returns TColor::Sys3dHilight if a 3d User interface is in use or TColor::SysGrayText oth...
Definition drawitem.cpp:250
void SetCelArray(TCelArray *celarray, TAutoDelete del=AutoDelete)
If DeleteCel is true, CelArray is deleted.
Definition drawitem.cpp:181
@ aRight
Aligns the text at the right edge of the bounding rectangle.
Definition drawitem.h:77
@ aLeft
Aligns the text at the left edge of the bounding rectangle.
Definition drawitem.h:75
@ aCenter
Aligns the text horizontally at the center of the bounding rectangle.
Definition drawitem.h:76
TStyle
TStyle contains values that defines how the button will be displayed.
Definition drawitem.h:82
@ sText
Only text is displayed.
Definition drawitem.h:85
@ sBitmap
Only the bitmap is displayed.
Definition drawitem.h:84
int GetIndex() const
Returns Index, the index of Bitmap in the Proxy CellArray or -1.
Definition drawitem.h:283
virtual void Paint(TDC &rc, TRect &rect)
Paint function.
Definition drawitem.cpp:281
bool IsEnabled()
Returns true if (Flags & ODS_DISABLED)==0; false otherwise.
Definition drawitem.h:139
LPCTSTR GetText() const
Returns Text, the text do display on the button.
Definition drawitem.h:276
virtual void GetTextSize(TSize &size)
Calculates the size of the rectangle need to paint the text.
Definition drawitem.cpp:261
virtual void GetButtonSize(TSize &btnSize)
Calculates the size of button.
Definition drawitem.cpp:406
void SetIndex(int index)
Index is set to index and the sBitmap style is cleared from Style.
Definition drawitem.cpp:157
TCelArray is a horizontal array of cels (a unit of animation) created by slicing a portion of or an e...
Definition celarray.h:35
Class wrapper for management of color values.
Definition color.h:245
static const TColor SysMenuText
The symbolic system color value for the text shown on menus.
Definition color.h:331
static const TColor SysActiveCaption
The symbolic system color value for the caption of the active window.
Definition color.h:326
static const TColor Sys3dHilight
The symbolic system color value for highlighted 3-dimensional display elements (for edges facing the ...
Definition color.h:344
static const TColor LtGray
Static TColor object with fixed Value set by RGB(192, 192, 192).
Definition color.h:306
static const TColor SysWindowText
The symbolic system color value for text in every window.
Definition color.h:332
static const TColor SysMenu
The symbolic system color value for the background of menus.
Definition color.h:328
static const TColor SysWindow
The symbolic system color value for the background of each window.
Definition color.h:329
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
bool MoveTo(int x, int y)
Moves the current position of this DC to the given x- and y-coordinates or to the given point.
Definition dc.h:1690
TColor SetPixel(int x, int y, const TColor &color)
Sets the color of the pixel at the given location to the given color and returns the pixel's previous...
Definition dc.h:2394
void SelectObject(const TBrush &brush)
Selects the given GDI brush object into this DC.
Definition dc.cpp:113
bool GetTextExtent(const tstring &str, int stringLen, TSize &size) const
Computes the extent (width and height) in logical units of the text line consisting of stringLen char...
Definition dc.h:2968
bool FillRect(int x1, int y1, int x2, int y2, const TBrush &brush)
Fills the given rectangle on this DC using the specified brush.
Definition dc.h:1802
void RestorePen()
Restores the original GDI pen object to this DC.
Definition dc.cpp:220
bool TextRect(int x1, int y1, int x2, int y2)
Fills the given rectangle, clipping any text to the rectangle.
Definition dc.h:1878
bool DrawFocusRect(int x1, int y1, int x2, int y2)
Draws the given rectangle on this DC in the style used to indicate focus.
Definition dc.h:1854
virtual TColor SetBkColor(const TColor &color)
Sets the current background color of this DC to the given color value or the nearest available.
Definition dc.cpp:405
virtual void RestoreFont()
Restores the original GDI font object to this DC.
Definition dc.cpp:246
bool LineTo(int x, int y)
Draws a line on this DC using the current pen object.
Definition dc.h:2148
virtual TColor SetTextColor(const TColor &color)
Sets the current text color of this DC to the given color value.
Definition dc.cpp:417
Proxy parent for TDrawItem.
Definition drawitem.h:40
void SetCelArray(TCelArray *celarray, TAutoDelete del=AutoDelete)
If DeleteCel is true, deletes CelArray.
Definition drawitem.cpp:64
void SetFont(TFont *font)
Deletes Font and sets it to font.
Definition drawitem.cpp:55
void RegisterItem(TDrawItem *item)
For automatic deletion of items.
Definition drawitem.cpp:84
virtual ~TDrawItemProxy()
Deletes Font. If DeleteCel is true, delets CelArray.
Definition drawitem.cpp:44
virtual TCelArray * GetCelArray()
Definition drawitem.h:51
virtual TFont * GetFont()
Definition drawitem.h:48
TIPtrArray< TDrawItem * > TDrawItemArray
Definition drawitem.h:42
TDrawItemArray & GetItems()
Returns ItemArray.
Definition drawitem.h:269
TDrawItemProxy(TFont *font=0)
Constructs a TDrawItemProxy object using the specified font.
Definition drawitem.cpp:35
Derived from TButtonTextDrawItem, the TDrawMenuItem class is used for owner drawn menus.
Definition drawitem.h:184
void PaintCheck_3Angle(TDC &dc, TRect &rect)
Draw this:
Definition drawitem.cpp:708
TDrawMenuItem(TDrawItemProxy *proxy, int cmdId, int index, LPCTSTR title=0)
Called with the proxy parent, the command it, the index in the menu and the text to display.
Definition drawitem.cpp:447
virtual void PaintText(TDC &rc, TRect &rect)
Definition drawitem.cpp:579
virtual void PaintBitmap(TDC &dc, TRect &rect)
Paint the bitmap on the menu entry.
Definition drawitem.cpp:517
void PaintCheck_Box(TDC &dc, TRect &rect)
Draw this:
Definition drawitem.cpp:856
void PaintCheck_Plus(TDC &dc, TRect &rect)
Draw this:
void PaintCheck_X(TDC &dc, TRect &rect)
Draw this:
void PaintCheck_Arrow(TDC &dc, TRect &rect)
Draw this:
Definition drawitem.cpp:780
void PaintCheck_V(TDC &dc, TRect &rect)
Draw this:
virtual void GetButtonSize(TSize &btnSize)
Get the size of the bitmap button.
Definition drawitem.cpp:481
void PaintCheck_Dot(TDC &dc, TRect &rect)
Draw this:
virtual void PaintCheckFace(TDC &dc, TRect &rect)
If checked, clears the area in preparation for painting the check mark.
Definition drawitem.cpp:673
virtual TColor GetTextColor()
Returns the text color.
Definition drawitem.cpp:506
void PaintCheck_None(TDC &dc, TRect &rect)
Draw this:
void PaintCheck_Diamond(TDC &dc, TRect &rect)
Draw this:
Definition drawitem.cpp:918
virtual TColor GetBkColor()
If the menu item is selected returns TColor::SysActiveCaption; otherwise returns TColor::SysMenu.
Definition drawitem.cpp:498
virtual void GetTextSize(TSize &size)
Definition drawitem.cpp:469
TDrawMenuItemProxy(TResId resId, TModule *module=&GetGlobalModule())
Constructs a TDrawMenuItemProxy object using the specified resource.
virtual TDrawItem * CreateItem(uint itemId, const tstring &text)
Returns the item with id cmdId if it exists; otherwise creates a new item and returns it.
virtual ~TDrawMenuItemProxy()
Destroys the instance.
void RemapMenu(HMENU hMenu)
Walks through the menu tree hMenu adding seperators.
static TFont * CreateProxyMenuFont()
Creates a font for use in menu bars.
TUIntAray * Array
Array of id's.
Definition drawitem.h:249
int GetIndex(int cmdId)
Returns the array index of the item with id cmdId.
TDrawItem * FindItem(uint cmdId)
Returns the TDrawItem with id cmdId, or 0 if it doesn't exist.
bool EvMenuChar(uint uChar, uint, HMENU hMenu, TParam2 &param)
Returns true if a shortcut was pressed that fits into the menu and false if not.
TTypedArray< uint, uint, TStandardAllocator > TUIntAray
Container of TDrawItem's.
Definition drawitem.h:232
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
Derived from TFont, TGadgetWindowFont is the default font used by TGadgetWindow.
Definition gadgetwi.h:92
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPen is derived from TGdiObject.
Definition gdiobjec.h:138
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
Derived from TWindowDC, TScreenDC is a DC class that provides direct access to the screen bitmap.
Definition dc.h:610
The tagSIZE struct is defined as.
Definition geometry.h:234
Assists in drawing borders of many styles.
Definition uihelper.h:270
TEdge
Enumeration describing the type of edge to be drawn.
Definition uihelper.h:315
@ RaisedInner
Raised inner edge only.
Definition uihelper.h:318
@ SunkenInner
Sunken inner edge only.
Definition uihelper.h:319
void Paint(TDC &dc) const
Paints this UIBorder object onto a given device context.
Definition uiborder.cpp:112
@ Recessed
Status field style recessed.
Definition uihelper.h:300
TUIFace assists in painting UI elements in various states.
Definition uihelper.h:367
static THatch8x8Brush & GetDitherBrush()
Internal static helper function that can be used alone.
Definition uiface.cpp:124
@ Disabled
Disabled or Unavailable state (embossed 3d no color)
Definition uihelper.h:376
@ Indeterm
Indeterminant, or mixed-value state.
Definition uihelper.h:375
@ Normal
Normal state.
Definition uihelper.h:373
#define MAX_PATH
Definition cygwin.h:98
#define _totupper
Definition cygwin.h:73
#define _tcslen
Definition cygwin.h:74
#define _T(x)
Definition cygwin.h:51
#define _tcschr
Definition cygwin.h:85
Definitions of classes TDrawItemProxy, TDrawItem,TButtonTextDrawItem, TDrawMenuItem,...
Definition of TGadgetList, TGadgetWindow & TGadgetWindowFont A list holding gadgets,...
Definition of class TGlyphButton.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
@ AutoDelete
Definition gdibase.h:70
@ NoAutoDelete
Definition gdibase.h:70
char * strnewdup(const char *s, size_t minAllocSize=0)
Definition memory.cpp:25
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
uint32 MkUint32(uint16 lo, uint16 hi)
Definition defs.h:261
const int TextSpaceV
Definition btntextg.cpp:94
char tchar
Definition defs.h:77
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
const int ButtonSpaceH
Definition drawitem.cpp:97
const int ButtonSpaceV
Definition drawitem.cpp:98
const int TextSpaceE
Definition drawitem.cpp:96
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
const int TextSpaceH
Definition btntextg.cpp:95
#define TYPESAFE_DOWNCAST(object, toClass)
Definition defs.h:269
Defines classes handling Windows resources.
Definition of container classes used and made available by OWL.
Definition of the UI Helper Classes: TUIHandle, TUIBorder, TUIFace, TUIPart.
Definition of TUIMetric, a UI metrics provider class.