OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
picker.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------//
2// ObjectWindows, Copyright (c) 1998 by Yura Bidus. //
3// //
4// THIS CLASS AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF //
5// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO //
6// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A //
7// PARTICULAR PURPOSE. //
8// //
9// Implementation of class TPickerCell, TColorCell, TBitmapCell, TTextCell, //
10// TGridPicker, TColorPicker and TColorPickerGadget //
11//------------------------------------------------------------------------------
12#include <owl/pch.h>
13
14#include <owl/uihelper.h>
15#include <owl/celarray.h>
16#include <owl/tooltip.h>
17#include <owl/gadgetwi.h>
18#include <owl/chooseco.h>
19#include <owl/uimetric.h>
20#include <owl/picker.h>
21#include <owl/template.h>
22#include <owl/decframe.h>
23#if defined(BI_MULTI_THREAD_RTL)
24#include <owl/thread.h>
25#endif
26
27#include <algorithm>
28
29#define ID_STATITEM 0
30#define ID_CUSTITEM 1
31#define ID_DEFITEM 2
32#define ID_DELTA 3
33#define ID_MINITEM 2
34
35namespace owl {
36
38
39//------------------------------------------------------------------------------
40//
41// class TPickerCellArray
42// ~~~~~ ~~~~~~~~~~~~~~~~
43//
44class TPickerCellArray: public TIPtrArray<TPickerCell*>{
45 public:
46 TPickerCellArray(){}
47};
48
49//------------------------------------------------------------------------------
50//
51// class TDefTextCell
52// ~~~~~ ~~~~~~~~~~~~
53//
54class TDefTextCell: public TTextCell {
55 public:
56 TDefTextCell(int id=0, LPCTSTR text=_T(""),TPickerCell* cell=0);
57 virtual ~TDefTextCell();
58
59 virtual void PaintCell(TDC& dc, TRect& rect);
60 void SetCell(TPickerCell* cell) { delete Cell; Cell = cell; }
61 TPickerCell* GetCell() { return Cell; }
62
63 protected:
64 TPickerCell* Cell;
65};
66//------------------------------------------------------------------------------
67// class TLocalTipCell
68// ~~~~~ ~~~~~~~~~~~~~
69//
70class TLocalTipCell: public TTextCell {
71 public:
72 TLocalTipCell(int id=0, LPCTSTR text=_T(""));
73
74 virtual void PaintCell(TDC& dc, TRect& rect);
75};
76//------------------------------------------------------------------------------
77
78
79//------------------------------------------------------------------------------
80//
81// class TPickerCell
82// ~~~~~~~~~~~~~~~~~
83//
84//
85// Set the border style used by this gadget. Internal Border members are
86// updated and owning Window is notified of a size change.
87//
88void
95
96//
97void
99{
100 TRect rect(r ? *r : TRect(TPoint(0,0),Bounds.Size()));
101
102 if(!Parent->IsFlatStyle())
103 rect.Inflate(-1,-1);
104
105 if(drawbrd)
106 PaintBorder(dc, rect);
107
108 if(!Parent->IsFlatStyle())
109 PaintCell(dc, rect.Inflate(-2,-2));
110 else
111 PaintCell(dc, rect.Inflate(-4,-4));
112}
113
114//
115void
117{
118 if (BorderStyle == None)
119 return;
120
121 if(BorderStyle == Flat){
122 if(!Parent->IsFlatStyle()){
125
126 if(IsSet(csMouseIn))
127 style = TUIBorder::Embossed;
128 if(IsSet(csSelected))
130
132 }
133 else{
134 if(IsSet(csSelected)){
136 if(!IsSet(csMouseIn)){
137#if 1 // Y.B. Excell Style
138 dc.FillRect(rect.InflatedBy(-1, -1), TUIFace::GetDitherBrush());
139#else // Y.B. Dieter Windau style. What better ??????
140 dc.FillRect(rect.InflatedBy(-2, -2), TUIFace::GetDitherBrush());
141#endif
142 }
143 }
144 else if(IsSet(csMouseIn))
146 else{
148 dc.FrameRect(rect, br);
149 }
151 dc.FrameRect(rect.InflatedBy(-3, -3), shbr);
152 }
153 }
154 else{
155 if (BorderStyle == Plain) {
158 dc.RestoreBrush();
159 }
160 else
162 }
163}
164
165//
166void
168{
169 TSize size = TSize(13,13);
170 if(rect.Width() < size.cx)
171 rect.right = rect.left + size.cx;
172 if(rect.Height() < size.cy)
173 rect.bottom = rect.top + size.cy;
174}
175
176//
177void
182
183//
184void
189
190//
191void
193{
194 if(sel)
196 else
198}
199
200//------------------------------------------------------------------------------
201// class TColorCell
202// ~~~~~ ~~~~~~~~~~
203//
204void
211
212//------------------------------------------------------------------------------
213// class TBitmapCell
214// ~~~~~ ~~~~~~~~~~~
215TBitmapCell::TBitmapCell(int id, TCelArray* array, int index,TBorderStyle style)
216:
217 TPickerCell(id,style),
218 CelArray(array),
219 Index(index),
220 ShouldDelete(false)
221{
222}
223
224//
226{
227 if(ShouldDelete)
228 delete CelArray;
229}
230
231//
232void
234{
235 if(ShouldDelete)
236 delete CelArray;
237 CelArray = array;
239}
240
241//
242void
244{
245 if(CelArray){
246 if(rect.Size() == CelArray->CelSize())
247 CelArray->BitBlt(Index, dc, rect.left, rect.top);
248 else
250 }
251}
252
253//
254void
256{
257 TSize size;
258 if(CelArray){
259 if(Parent->IsFlatStyle())
260 size = CelArray->CelSize()+TSize(8,8);
261 else
262 size = CelArray->CelSize()+TSize(6,6);
263 }
264 else{
265 if(Parent->IsFlatStyle())
266 size = TSize(13,13);
267 else
268 size = TSize(9,9);
269 }
270 if(rect.Width() < size.cx)
271 rect.right = rect.left + size.cx;
272 if(rect.Height() < size.cy)
273 rect.bottom = rect.top + size.cy;
274}
275//------------------------------------------------------------------------------
276//
277// class TTextCell
278// ~~~~~ ~~~~~~~~~
279void
281{
282 if(!Parent->IsFlatStyle())
283 rect.Inflate(-1, -1);
284
285 TFont* font = Parent->GetFont();
286 if(font){
287 CHECK(font->IsGDIObject());
288 dc.SelectObject(*font);
289 }
290
291 int mode = dc.SetBkMode(TRANSPARENT);
292 tstring tmp (Text);
293 dc.DrawTextEx(&tmp[0], -1, &rect, Format);
294 dc.SetBkMode(mode);
295
296 if(font)
297 dc.RestoreFont();
298}
299//------------------------------------------------------------------------------
300//
301// class TDefTextCell
302// ~~~~~ ~~~~~~~~~~~~
303//
304//
305TDefTextCell::TDefTextCell(int id, LPCTSTR text,TPickerCell* cell)
306:
307 TTextCell(id,text),
308 Cell(cell)
309{
310}
311
312//
313TDefTextCell::~TDefTextCell()
314{
315 delete Cell;
316}
317
318//
319void
320TDefTextCell::PaintCell(TDC& dc, TRect& rect)
321{
322 if(!Parent->IsFlatStyle())
323 rect.Inflate(-1, -1);
324
325 if(Cell){
326 int width = Bounds.Height()-6;
327 TRect rc(rect.left-2, rect.top-2, rect.left+width, rect.top+width);
328 if(!Parent->IsFlatStyle())
329 rc.Inflate(1, 1);
330 Cell->Paint(dc, &rc, false);
331 if(Parent->IsFlatStyle())
332 dc.FrameRect(rc.InflatedBy(-3,-3), TBrush(TColor::Sys3dShadow));
333 rect.left += rc.Width()-5;
334 }
335 rect.Inflate(1,1);
337}
338
339//------------------------------------------------------------------------------
340// class TLocalTipCell
341// ~~~~~ ~~~~~~~~~~~~~
342//
343TLocalTipCell::TLocalTipCell(int id, LPCTSTR text)
344:
345 TTextCell(id,text, None)
346{
348}
349
350//
351void
352TLocalTipCell::PaintCell(TDC& dc, TRect&)
353{
354 TRect rect(TPoint(0,0),Bounds.Size());
355 rect.Inflate(-2,-2);
356
357 TColor clr;
358 if(!Parent->IsFlatStyle())
359 clr = dc.SetBkColor(TColor::White);
360
361 dc.TextRect(rect);
362
363 if(!Parent->IsFlatStyle())
364 dc.SetBkColor(clr);
365
367
368 TUIBorder(rect.InflatedBy(2,2), Parent->IsFlatStyle()?TUIBorder::Recessed:
369 TUIBorder::WndRecessed).Paint(dc);
370}
371//------------------------------------------------------------------------------
372//
373// Response Table
374//
375DEFINE_RESPONSE_TABLE1(TGridPicker, TControl)
376 //EV_WM_ACTIVATEAPP,
379 //EV_WM_GETDLGCODE,
388
389TGridPicker::TGridPicker(TWindow* parent, int id, int x, int y, int w, int h,
390 TModule* module)
391:
392 TControl(parent, id, nullptr, x, y, w, h, module)
393{
394 InitPicker();
395}
396
397//
399:
400 TControl(parent, resourceId, module)
401{
402 InitPicker();
403}
404
405//
406void
408{
409 Selected = -1;
410 Focused = -1;
411 NRows = 0;
412 NColumns = 4;
413// TextHeight = 0;
414 Margins = TMargins(TMargins::Pixels, 4, 4, 4, 4);
415 Font = nullptr;
416 Target = nullptr;
417 Tooltip = nullptr;
418 Cells = new TPickerCellArray;
419
420
422
424
425 // Create the font
427 ncm.cbSize = sizeof(NONCLIENTMETRICS);
429 Font = new TFont(ncm.lfMessageFont);
430
433 TextHeight = std::max(metrics.tmHeight + metrics.tmExternalLeading, 20l);
434
435
436 Add(new TLocalTipCell(ID_STATITEM)); // == 0
437 Add(new TDefTextCell(ID_CUSTITEM)); // == 1
438 Add(new TDefTextCell(ID_DEFITEM)); // == 2
439}
440
442{
443 delete Font;
444 delete Cells;
445}
446
447//
448void
450{
451 loc += ID_DELTA;
452 if(loc >= static_cast<int>(Cells->Size()) || loc < ID_MINITEM){
453 if(loc == ID_CUSTITEM){
455 (*Cells)[ID_CUSTITEM]->Select(true);
456 if(GetHandle())
457 InvalidateRect((*Cells)[ID_CUSTITEM]->Bounds,true);
458 }
459 return;
460 }
461 if(IsSet(ppButtonSel)){
463 (*Cells)[ID_CUSTITEM]->Select(false);
464 if(GetHandle())
465 InvalidateRect((*Cells)[ID_CUSTITEM]->Bounds,true);
466 }
467
468 if(Selected >= 0){
469 (*Cells)[Selected]->Select(false);
470 if(GetHandle())
471 InvalidateRect((*Cells)[Selected]->Bounds,true);
472 }
473 Selected = loc;
474 (*Cells)[Selected]->Select(true);
475 if(GetHandle()){
476 InvalidateRect((*Cells)[Selected]->Bounds,true);
477 }
478}
479//
480void
482{
483 if(GetHandle()){
484 Layout();
485 Invalidate();
486 }
487}
488
489//
490void
492{
493 NColumns = colmn;
495 if((Cells->Size()-ID_DELTA)%NColumns)
496 NRows++;
497
498 ApplyChanges();
499}
500
501//
502void
508
509//
510void
512{
513 delete Font;
514 Font = new TFont(font);
515}
516
517//
518void
520{
521 TDefTextCell* cell = TYPESAFE_DOWNCAST((*Cells)[ID_DEFITEM], TDefTextCell);
522 if(text){
524 if(cell){
525 cell->SetText(text);
526 cell->SetId(resId);
527 if(cl)
528 cl->Parent = this;
529 cell->SetCell(cl);
530 }
531 }
532 else{
534 if(cell)
535 cell->Bounds.SetEmpty();
536 }
537
538 ApplyChanges();
539}
540
541//
542void
544{
545 TDefTextCell* cell = TYPESAFE_DOWNCAST((*Cells)[ID_CUSTITEM], TDefTextCell);
546 if(text){
548 if(cell){
549 cell->SetText(text);
550 cell->SetId(resId);
551 if(cl)
552 cl->Parent = this;
553 cell->SetCell(cl);
554 }
555 }
556 else{
558 if(cell)
559 cell->Bounds.SetEmpty();
560 }
561
562 ApplyChanges();
563}
564
565//
566void
568{
569 if(on)
570 Set(on);
571 if(off)
572 Clear(off);
573
574 if(off & psLocalTips){
575 TLocalTipCell* cell = TYPESAFE_DOWNCAST((*Cells)[ID_STATITEM], TLocalTipCell);
576 if(cell)
577 cell->Bounds.SetEmpty();
578 }
579 ApplyChanges();
580}
581
582//
583int
585{
586 cell->Parent = this;
587 return Cells->Add(cell);
588}
589
590//
593{
594 if(loc >= static_cast<int>(Cells->Size()))
595 return nullptr;
596
597 TPickerCell* cell = (*Cells)[loc];
598 Cells->Detach(loc);
599
600 return cell;
601}
602
603//
606{
607 if(loc < static_cast<int>(Cells->Size()))
608 return (*Cells)[loc];
609 return nullptr;
610}
611
612//
613uint
615{
616 return Cells->Size();
617}
618
619//
620void
622{
623 int idx = Add(cell);
624 if(select)
627}
628
629//
632{
633 loc += ID_DELTA;
634 return Remove(loc);
635}
636
637//
640{
641 TDefTextCell* cell = TYPESAFE_DOWNCAST((*Cells)[ID_DEFITEM], TDefTextCell);
642 if(!cell)
643 return nullptr;
644 return cell->GetCell();
645}
646
647//
648// return child of default custom cell
649//
652{
653 TDefTextCell* cell = TYPESAFE_DOWNCAST((*Cells)[ID_CUSTITEM], TDefTextCell);
654 if(!cell)
655 return nullptr;
656 return cell->GetCell();
657}
658
659//
664
665//
666void
672
673//
674void
676{
678
679 Layout();
680
681 if (Tooltip && !Tooltip->GetHandle()){
682 // Make sure tooltip is disabled so it does not take input focus
684 Tooltip->Create();
685 }
686
687 if(Tooltip){
689 for (int i = 0; i < (int)Cells->Size(); i++) {
690 if((*Cells)[i]->GetId()){
691 text = LoadTipText((*Cells)[i]->GetId());
692 TToolInfo ti (*this, (*Cells)[i]->GetBounds(), (*Cells)[i]->GetId(),
693 text.empty() ? LPSTR_TEXTCALLBACK : text.c_str());
695 }
696 }
697 }
698}
699//
700void
702{
703 if (!Tooltip) {
704 // Create and initialize tooltip
705 //
706 SetTooltip(new TTooltip(this));
707 }
708 else {
709 if (Tooltip->GetHandle())
711 }
712}
713//
714void
716{
717 // Cleanup; via Condemned list if tooltip was created
718 //
719 if (Tooltip) {
720 if (Tooltip->GetHandle())
722 else
723 delete Tooltip;
724 }
725
726 // Store new tooltip and create if necessary
727 //
729 if (Tooltip) {
730 if(GetHandle() && !Tooltip->GetHandle()) {
731 // Make sure tooltip is disabled so it does not take input focus
733 Tooltip->Create();
734 }
735 }
736}
737
738//
739// Relay 'interesting' messages to the tooltip window
740//
741bool
743{
744 // Check if this message might be worth relaying to the tooltip window
745 //
746 if (Tooltip && Tooltip->IsWindow()) {
747 if (msg.hwnd == *this || IsChild(msg.hwnd)) {
748 if (msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST) {
750 }
751 }
752 }
753
754 // Always let event go through.
755 //
757}
758
759//
760//
761const int CellSpacing = 2;
762
763//
764void
766{
767 if(!GetHandle())
768 return;
769
770 TRect rect;
772
773 // 1. Check Max size
774 TRect crect;
776 if(crect.IsEmpty())
777 crect = TRect(TPoint(0,0),TSize(rect.Width()/NColumns,rect.Height()/NRows));
778
779 TSize size(crect.Width()*NColumns,crect.Height()*NRows);
780 int addHeight = 0;
787
788 size.cy += addHeight;
789
790 int leftM, rightM, topM, bottomM;
792 crect = TRect(TPoint(0,0),TSize(size.cx+leftM+rightM,size.cy+topM+bottomM));
793
794 bool move = false;
795 if(crect.Width() > rect.Width()){
796 rect.right = rect.left + crect.Width();
797 move = true;
798 }
799 if(crect.Height() > rect.Height()){
800 rect.bottom = rect.top + crect.Height();
801 move = true;
802 }
803
804 // 2. Reposition Window
805 if(move)
807
808 int w = (rect.Width()-leftM-rightM )/NColumns;
809 int h = (rect.Height()-addHeight-topM-bottomM)/NRows;
810
811 // 3. Find max rectangle
813 if(IsSet(ppShrCells))
815 if(cellRect.IsEmpty())
816 cellRect = TRect(0,0, w,h);
817 cellRect.Offset(leftM,topM);
818
819 addHeight = 0;
820 if(IsSet(ppShowDefItem)){
821 (*Cells)[ID_DEFITEM]->Bounds =
823 TSize(rect.Width()-leftM-rightM,TextHeight));
826 }
827
830 (*Cells)[ID_CUSTITEM]->Bounds =
832 TSize(rect.Width()-leftM-rightM,TextHeight));
834 }
835
838 (*Cells)[ID_STATITEM]->Bounds =
840 TSize(rect.Width()-leftM-rightM,TextHeight));
841 }
842
843 // 4. Layout Cells
844 rect = cellRect;
845 for(int i = 0; i < NRows; i++){
846 for(int j = 0; j < NColumns; j++){
847 int cell = i*NColumns+j + ID_DELTA;
848 if(cell < static_cast<int>(Cells->Size())){
849 (*Cells)[cell]->Bounds = cellRect;
850 cellRect.Offset(w,0);
851 }
852 }
853 cellRect = rect.Offset(0,cellRect.Height());
854 }
855}
856
857//
858int
860{
861 for(int i = 0; i < static_cast<int>(Cells->Size()); i++){
862 if((*Cells)[i]->PtIn(point))
863 return i;
864 }
865 return Cells->NPOS;
866}
867
868//
869void
871{
872 for(int i = ID_DELTA; i < static_cast<int>(Cells->Size()); i++){
873 TRect rec;
874 (*Cells)[i]->QueryBounds(rec);
875 cellRect |= rec;
876 }
877}
878
879//
880void
881TGridPicker::Paint(TDC& dc, bool /*erase*/, TRect& rect)
882{
884 for(int i = 0; i < static_cast<int>(Cells->Size()); i++){
885 if ((*Cells)[i]->GetBounds().Touches(rect)){
886 dc.SetViewportOrg((TPoint&)(*Cells)[i]->GetBounds());
887 (*Cells)[i]->Paint(dc);
888 }
889 }
891
893 TRect tr((*Cells)[ID_CUSTITEM]->GetBounds());
894 PaintDivider(dc, tr);
895 }
896
898 TRect tr((*Cells)[ID_STATITEM]->GetBounds());
899 PaintDivider(dc, tr);
900 }
901}
902
903//
904void
906{
907 TRect rect = r;
908 if(IsFlatStyle())
909 rect.Inflate(-1, -1);
910 rect.Offset(0,-(CellSpacing*3)-1);
911 rect.top += CellSpacing;
912 rect.bottom = rect.top + CellSpacing;
914}
915
916//
917bool
919{
920 return false;
921}
922
923//
924void
926{
927}
928
929//
930void
932{
933 if(Focused >= 0){
934 (*Cells)[Focused]->LeaveMouse();
935 InvalidateRect((*Cells)[Focused]->Bounds,true);
936 }
937 Focused = loc;
938 (*Cells)[loc]->EnterMouse();
939 InvalidateRect((*Cells)[loc]->Bounds,true);
940 // set text cell string
942 TLocalTipCell* cell = TYPESAFE_DOWNCAST((*Cells)[ID_STATITEM], TLocalTipCell);
943 if(cell && (*Cells)[loc]->GetId()){
944 cell->SetText(LoadTipText((*Cells)[loc]->GetId()).c_str());
945 InvalidateRect(cell->Bounds,true);
946 }
947 }
948 // Set/reset message box string
949 if(IsSet(ppMessageTips)){
950 if(loc > 0 && (*Cells)[loc]->GetId())
952 else
954 }
955 if(GetStyle() & BS_NOTIFY)
957}
958
959//
960//
961void
969
970//
971// WM_SETFOCUS handler
972//
973void
981
982//
983// WM_KILLFOCUS handler
984//
985void
995
996//
997// WM_LBUTTONDOWN handler. Grab focus and update button's state to be in
998// 'pushed' mode.
999//
1000void
1002{
1004
1005 SetCapture();
1006 if(!IsSet(ppFocus))
1007 SetFocus();
1008 const auto loc = Contains(point);
1009 if (loc != Cells->NPOS)
1010 {
1012 Set(ppPushed);
1013 }
1014}
1015
1016
1017//
1018// WM_LBUTTONDBLCLK handler. Simply forward to LBUTTONDOWN handler
1019//
1020void
1025
1026//
1027// WM_LBUTTONUP handler. Restore state of button and notify parent with a
1028// CLICKED message if necessary.
1029//
1030void
1032{
1033 if (GetCapture() == *this) {
1035
1036 if(IsSet(ppButtonSel)){
1038 (*Cells)[ID_CUSTITEM]->Select(false);
1039 InvalidateRect((*Cells)[ID_CUSTITEM]->Bounds,true);
1040
1042 if(!CallCustomBox()){
1044 return;
1045 }
1047
1048 if(Selected >= 0)
1049 (*Cells)[Selected]->Select(false);
1051 (*Cells)[ID_CUSTITEM]->Select(true);
1052
1054 ExitPicker(true);
1055 return;
1056 }
1057 TRect rect;
1059 if (rect.Contains(point) && Contains(point) >= ID_MINITEM){
1061 ExitPicker(true);
1062 }
1063 }
1064}
1065
1066//
1067// WM_MOUSEMOVE handler. Update state of button if we're in 'capture' mode.
1068//
1069void
1071{
1073 TRect rect;
1075
1076 int loc;
1077 if (!rect.Contains(point) || (loc = Contains(point)) == Cells->NPOS)
1078 ClearCell();
1079 else if(Focused != loc){
1081
1082 if (modKeys & MK_LBUTTON && GetCapture() == *this)
1084 }
1085 }
1086}
1087
1088//
1089// WM_KEYDOWN handler. Update state of button upon detecting that user
1090// pressed the space bar.
1091//
1092void
1094{
1095 TControl::EvKeyDown(key, repeatCount, flags);
1096
1097 switch (key){
1098 case VK_ESCAPE:
1099 ExitPicker(false);
1100 break;
1101
1102 case VK_RETURN:
1103 case VK_SPACE:
1104 Set(ppPushed);
1105 if(Focused < 0)
1106 Focused = 0;
1107 break;
1108
1109 case VK_LEFT:{
1110 int loc = Focused-1;
1111 if(Focused == -1 || Focused == ID_DEFITEM)
1113 else if(Focused == ID_CUSTITEM)
1114 loc = Cells->Size()-1;
1115 else if(loc < ID_DELTA && !IsSet(ppShowDefItem))
1117 else if( loc < ID_DELTA && IsSet(ppShowDefItem))
1118 loc = ID_DEFITEM;
1120 }
1121 break;
1122
1123 case VK_RIGHT: {
1124 int loc = Focused+1;
1125 int maxcell = Cells->Size()-1;
1126 if(Focused == -1 || Focused == ID_CUSTITEM ||
1129 else if(loc > maxcell && IsSet(ppShowCustItem))
1130 loc = ID_CUSTITEM;
1132 }
1133 break;
1134
1135 case VK_DOWN: {
1136 int loc = Focused+NColumns;
1137 int maxcell = Cells->Size()-1;
1138 if(Focused == -1)
1140 else if(Focused == ID_DEFITEM)
1141 loc = ID_MINITEM+1;
1142 else if(Focused == ID_CUSTITEM && IsSet(ppShowDefItem))
1143 loc = ID_DEFITEM;
1144 else if(loc >= maxcell && IsSet(ppShowCustItem)){
1145 loc = ID_CUSTITEM;
1146 }
1147 else if(loc >= maxcell && IsSet(ppShowDefItem)){
1148 loc = ID_DEFITEM;
1149 }
1150 else{
1151 if(loc > maxcell)
1152 loc -= NRows*NColumns;
1153 if(loc < ID_DELTA)
1154 loc += NRows;
1155 }
1157 }
1158 break;
1159
1160 case VK_UP:{
1161 int loc = Focused-NColumns;
1162 int maxcell = Cells->Size()-1;
1163 if(Focused == -1 || Focused == ID_DEFITEM)
1165 else if(Focused == ID_CUSTITEM)
1167 else if(loc < ID_DELTA && IsSet(ppShowDefItem))
1168 loc = ID_DEFITEM;
1169 else if(loc < ID_DELTA)
1170 loc += NRows*NColumns;
1172 }
1173 break;
1174
1175 case VK_HOME:
1177 break;
1178
1179 case VK_END:
1181 break;
1182 }
1183}
1184
1185//
1186// WM_KEYUP handler. Restore state of button and notify parent
1187//
1188void
1189TGridPicker::EvKeyUp(uint key, uint /*repeatCount*/, uint /*flags*/)
1190{
1191 if (IsSet(ppPushed) && (key == VK_SPACE || key == VK_RETURN)){
1193 Clear(ppPushed);
1194 if(IsSet(ppButtonSel)){
1196 (*Cells)[ID_CUSTITEM]->Select(false);
1197 InvalidateRect((*Cells)[ID_CUSTITEM]->Bounds,true);
1198
1200 if(!CallCustomBox()){
1203 ExitPicker(true);
1204 return;
1205 }
1207
1208 if(Selected >= 0)
1209 (*Cells)[Selected]->Select(false);
1211 (*Cells)[ID_CUSTITEM]->Select(true);
1212 }
1213 else{
1215 ExitPicker(true);
1216 }
1217 }
1218}
1219
1220//
1221//
1222//
1223void
1229
1230//
1231//
1232//
1233void
1235{
1236 if(Focused >= 0){
1237 (*Cells)[Focused]->LeaveMouse();
1238 InvalidateRect((*Cells)[Focused]->GetBounds(),true);
1239 Focused = -1;
1240 }
1241 if(IsSet(ppButtonSel)){
1243 (*Cells)[ID_CUSTITEM]->Select(false);
1244 InvalidateRect((*Cells)[ID_CUSTITEM]->Bounds,true);
1245 }
1246 if(IsSet(ppMessageTips))
1248 if(IsSet(ppShowTipsCell)){
1249 TLocalTipCell* cell = TYPESAFE_DOWNCAST((*Cells)[ID_STATITEM], TLocalTipCell);
1250 if(cell){
1251 cell->SetText(_T(""));
1252 InvalidateRect(cell->GetBounds(),true);
1253 }
1254 }
1255}
1256
1257//
1258// Release caption if we are in 'capture' mode. Reset internal flags
1259// appropriately.
1260//
1261void
1263{
1264 if (GetCapture() == *this)
1266 Clear(ppPushed);
1267}
1268
1269//
1270// ??????????????????????????????
1271// Maeby better to use TEnabler mechanism
1272//
1273tstring
1275{
1277 if(tipText.length() == 0)
1278 {
1279 TModule* module = TModule::FindResModule(resId/16+1, RT_STRING);
1280 if (module)
1281 tipText = module->LoadString(resId);
1282 }
1283 if (tipText.length() > 0)
1284 {
1285 tstring::size_type i = tipText.find_first_of(_T('\n'));
1286 if (i != tstring::npos)
1287 tipText = tipText.substr(i + 1);
1288 else
1289 {
1290 TWindow* parent = GetParentO();
1291 TDecoratedFrame* frame = parent ? TYPESAFE_DOWNCAST(parent, TDecoratedFrame) : nullptr;
1292 while (parent && !frame)
1293 {
1294 parent = parent->GetParentO();
1295 if (parent)
1296 frame = TYPESAFE_DOWNCAST(parent, TDecoratedFrame);
1297 }
1298 tstring hint;
1299 if (frame)
1300 hint = frame->GetHintText(resId, htTooltip);
1301 tipText = hint;
1302 }
1303 }
1304 return tipText;
1305}
1306
1307//
1308// We display a message on the status bar.
1309//
1310void
1312{
1313 TWindow* parent= GetParentO();
1314 TDecoratedFrame* frame= parent ? TYPESAFE_DOWNCAST(parent, TDecoratedFrame) : nullptr;
1315 while (parent && !frame){
1316 parent = parent->GetParentO();
1317 if (parent)
1318 frame = TYPESAFE_DOWNCAST(parent, TDecoratedFrame);
1319 }
1320 if (frame){
1321 if (id > 0)
1322 frame->HandleMessage(WM_MENUSELECT, id, 0);
1323 else
1324 frame->HandleMessage(WM_MENUSELECT, 0xFFFF0000, 0);
1326 }
1327}
1328
1329//------------------------------------------------------------------------------
1330// class TPopupPicker
1331// ~~~~~ ~~~~~~~~~~~~
1332//
1337
1338//
1339TPopupPicker::TPopupPicker(TWindow* parent, int id, int x, int y, int w, int h,
1340 TModule* module)
1341:
1342 TGridPicker(parent, id, x, y, w, h, module)
1343{
1346}
1347
1348//
1350:
1351 TGridPicker(parent, resourceId, module)
1352{
1353}
1354
1355//
1356void
1362
1363//
1364void
1373
1374
1375//
1376// WM_LBUTTONDOWN handler. Grab focus and update button's state to be in
1377// 'pushed' mode.
1378//
1379void
1387
1388//
1389void
1398
1399// Another application has the focus, so we hide the picker window.
1400void
1408
1409//
1410void
1412{
1415 if(status)
1416 Set(ppSelected);
1417 else
1419}
1420
1421//
1422bool
1424{
1425 TSize size(Attr.W, Attr.H);
1426 TSize checksize(size.cx + 1, size.cy + 1);
1427 TPoint point(p);
1429
1430 // Check the vertical position.
1431 //
1432 if (point.y + size.cy > scrSize.cy) {
1433 if ((rect.top >= 0) && (rect.bottom >= 0) && (rect.top - checksize.cy >= 0))
1434 point.y = rect.top - checksize.cy;
1435 else point.y = scrSize.cy - checksize.cy;
1436 }
1437
1438 // Check the horizontal position.
1439 //
1440 if (point.x + checksize.cx > scrSize.cx)
1441 point.x = scrSize.cx - checksize.cx;
1442 SetWindowPos(HWND_TOPMOST, point.x, point.y, size.cx, size.cy, SWP_SHOWWINDOW);
1443 SetCapture();
1444
1445 HWND hWnd = GetHandle();
1448
1449 if(!::IsWindow(hWnd))
1450 return false;
1451
1452 bool Ok = IsSet(ppSelected);
1454 return Ok;
1455}
1456//------------------------------------------------------------------------------
1457//
1458// class TPickerGadget
1459// ~~~~~ ~~~~~~~~~~~~~
1460//
1462 TStyle style, TPopupType poptype, TType type, bool enabled, TState state,
1464:
1466 enabled, state, sharedGlyph, numChars),
1467 Picker(&picker),
1468 Selected(nullptr)
1469{
1470 // it does not have style WS_CHILD, so this member should be
1471 // menu handle or 0;
1472 picker.GetWindowAttr().Id = 0;
1473}
1474
1475//
1476//
1477//
1479{
1480 if(Picker)
1481 Picker->Destroy(0);
1482 delete Picker;
1483}
1484
1485//
1486//
1487//
1488void
1490{
1491 // do something
1492 TRect rect = GetBounds();
1493 TPoint p2(rect.TopLeft());
1494 Window->ClientToScreen(p2);
1495 rect.right = p2.x + rect.Width();
1496 rect.bottom = p2.y + rect.Height();
1497 rect.left = p2.x;
1498 rect.top = p2.y;
1499 p2.y = rect.bottom;
1500
1501 // We tell the picker where the picker has to be displayed.
1502 HWND hWnd = *Picker;
1503 const auto ok = Picker->ShowPicker(p2, rect);
1504 if (ok)
1505 GetSelection();
1506
1507 if(!IsWindow(hWnd))
1508 return;
1509
1511 if (ok)
1512 {
1513 TPoint tp;
1514 Activate(tp);
1515 }
1516}
1517
1518//
1519//
1520//
1521void
1523{
1525 if (Window->GetHandle() && !Picker->GetHandle()){
1526 Picker->Create();
1528 }
1529 if(Picker->GetHandle())
1531}
1532
1533//
1534//
1535//
1536void
1543
1544//
1545//
1546//
1547void
1549{
1551 int sel = Picker->GetSelection();
1552 if(sel == -1) // default selection
1554
1555 if(!cell)
1557 if(cell)
1558 Selected = cell;
1559}
1560
1561//------------------------------------------------------------------------------
1562//
1563// class TColorPicker
1564// ~~~~~ ~~~~~~~~~~~~
1565//
1566// Gray default custom colors for SelectColor Dlg
1567struct TCustomColors
1569 : public TLocalObject
1570#endif
1571{
1572 TCustomColors();
1573
1574 TColor Colors[16];
1575#if defined(BI_MULTI_THREAD_RTL)
1576// TMRSWSection Lock;
1577#endif
1578};
1579
1580TCustomColors::TCustomColors()
1581{
1582 Colors[0] = RGB(0x01, 0x01, 0x01);
1583 Colors[1] = RGB(0x10, 0x10, 0x10);
1584 Colors[2] = RGB(0x20, 0x20, 0x20);
1585 Colors[3] = RGB(0x30, 0x30, 0x30);
1586
1587 Colors[4] = RGB(0x40, 0x40, 0x40);
1588 Colors[5] = RGB(0x50, 0x50, 0x50);
1589 Colors[6] = RGB(0x60, 0x60, 0x60);
1590 Colors[7] = RGB(0x70, 0x70, 0x70);
1591
1592 Colors[8] = RGB(0x80, 0x80, 0x80);
1593 Colors[9] = RGB(0x90, 0x90, 0x90);
1594 Colors[10] = RGB(0xA0, 0xA0, 0xA0);
1595 Colors[11] = RGB(0xB0, 0xB0, 0xB0);
1596
1597 Colors[12] = RGB(0xC0, 0xC0, 0xC0);
1598 Colors[13] = RGB(0xD0, 0xD0, 0xD0);
1599 Colors[14] = RGB(0xE0, 0xE0, 0xE0);
1600 Colors[15] = RGB(0xF0, 0xF0, 0xF0);
1601}
1602
1603//
1604// Static instance of the colors
1605//
1606static TCustomColors& GetCustomColors()
1607{
1608#if defined(BI_MULTI_THREAD_RTL)
1610 return customColors.Get();
1611#else
1612 static TCustomColors customColors;
1613 return customColors;
1614#endif
1615};
1616
1617namespace
1618{
1619 //
1620 // Ensure singleton initialization at start-up (single-threaded, safe).
1621 //
1622 TCustomColors& InitCustomColors = GetCustomColors();
1623}
1624
1625#if defined(BI_MULTI_THREAD_RTL)
1626#define LOCKCOLORS //TMRSWSection::TLock Lock(GetBrushCache().Lock);
1627#else
1628#define LOCKCOLORS
1629#endif
1630
1631//
1632// Build a response table for all messages/commands handled by the application.
1633//
1634DEFINE_RESPONSE_TABLE1(TColorPicker, TPopupPicker)
1638
1639//
1640TColorPicker::TColorPicker(TWindow* parent, int id, int x, int y, int w, int h,
1641 TModule* module)
1642:
1643 TPopupPicker(parent, id, x, y, w, h, module),
1644 Palette(nullptr),
1645 CustomColors(GetCustomColors().Colors),
1646 WorkPalette(nullptr),
1647 PaletteRealized(false)
1648{
1649}
1650
1651//
1653:
1654 TPopupPicker(parent, resourceId, module),
1655 Palette(nullptr),
1656 CustomColors(GetCustomColors().Colors),
1657 WorkPalette(nullptr),
1658 PaletteRealized(false)
1659{
1660}
1661
1662//
1664{
1665 delete Palette;
1666}
1667
1668//
1669void
1671{
1672/* // palette not working for now ??????????????????
1673 if (TScreenDC().GetDeviceCaps(RASTERCAPS) & RC_PALETTE){
1674 TAPointer<char> __clnObj = new char[sizeof(LOGPALETTE)+sizeof(PALETTEENTRY)*Cells->Size()];
1675 LOGPALETTE* lpPalette = (LOGPALETTE*)(char*)__clnObj;
1676
1677 lpPalette->palVersion = 0x300;
1678 lpPalette->palNumEntries = (uint16)Cells->Size();
1679 for(int i = 0; i < Cells->Size(); i++){
1680 TColorCell* cell = TYPESAFE_DOWNCAST(GetSelectedCell(), TColorCell);
1681 if(cell){
1682 lpPalette->palPalEntry[i].peRed = cell->GetColor().Red();
1683 lpPalette->palPalEntry[i].peGreen = cell->GetColor().Green();
1684 lpPalette->palPalEntry[i].peBlue = cell->GetColor().Blue();
1685 lpPalette->palPalEntry[i].peFlags = PC_RESERVED;
1686 }
1687 }
1688 Palette = new TPalette(lpPalette);
1689 }
1690*/
1692}
1693
1694//
1695void
1697{
1698 if(colors)
1699 CustomColors = colors;
1700 else
1701 CustomColors = GetCustomColors().Colors;
1702}
1703
1704//
1705void
1707{
1709 if(cell){
1710 const HWND w = Target ? Target->GetHandle() : ::GetParent(*this);
1711 const HWND c = reinterpret_cast<HWND>(static_cast<UINT_PTR>(cell->GetColor().GetValue()));
1713 }
1714}
1715
1716//
1717void
1719{
1720 if (Palette){
1721 WorkPalette = new TPalette(*Palette);
1722 dc.SelectObject(*WorkPalette);
1723 PaletteRealized = (dc.RealizePalette() > 0);
1724
1725 // set palette index value
1726 if(PaletteRealized){
1727 for(int i = 3; i < static_cast<int>(Cells->Size()); i++){
1729 if(cell)
1731 }
1732 }
1733 }
1734
1736
1737 // and reset colors
1738 if(WorkPalette){
1739 if(PaletteRealized){
1740 uint ncolors = WorkPalette->GetNumEntries();
1741 if(ncolors){
1743 WorkPalette->GetPaletteEntries(0, static_cast<uint16>(ncolors), _entries);
1744
1745 for(int i = 3; i < static_cast<int>(Cells->Size()); i++){
1747 if(cell)
1748 cell->SetColor(TColor(_entries[i]));
1749 }
1750 }
1751 }
1752 dc.RestorePalette();
1753 delete WorkPalette;
1754 WorkPalette = nullptr;
1755 }
1756}
1757
1758// Someone has changed the palette. We must realize our palette again.
1759//
1760void
1767
1768// Give us the chance to realize our palette.
1769//
1770bool
1772{
1773 Invalidate();
1774 return TPopupPicker::EvQueryNewPalette() | PaletteRealized;
1775}
1776
1777//
1778//
1779bool
1781{
1784 if(cell)
1785 color = cell->GetColor();
1786
1788
1789 choose.Flags = CC_RGBINIT;
1790 choose.Color = color;
1791 choose.CustColors = CustomColors;
1792 if (TChooseColorDialog(this, choose).Execute() == IDOK) {
1793 CustomColor = choose.Color;
1794 return true;
1795 }
1796 return false;
1797}
1798
1799//------------------------------------------------------------------------------
1800//
1801// class TColorPickerGadget
1802// ~~~~~ ~~~~~~~~~~~~~~~~~~
1803//
1813
1814void
1816{
1817 int sel = Picker->GetSelection();
1818 if(sel == -2){
1820 if(cPicker)
1821 ColorSel = cPicker->GetCustomColor();
1822 }
1823 else{
1826 if(cell)
1827 ColorSel = cell->GetColor();
1828 }
1829}
1830
1831//
1832void
1834{
1835 TSize size = CelArray ? CelArray->CelSize() : Window->GetCelArray().CelSize();
1836
1837 rect.left = faceRect.left+(faceRect.Width()-size.cx)/2;
1838 rect.top = faceRect.bottom-5;
1839 rect.right = rect.left + size.cx;
1840 rect.bottom = faceRect.bottom-1;
1841}
1842
1843//
1844void
1846{
1848
1849 // now add color rectangle
1850 if(GetEnabled() && ColorSel != TColor::None){
1851
1852 // Copy only the RGB values for the color that will be draw
1853 //
1855
1858
1859 dc.FillRect(Pressed ? fillRect.Offset(1,1) : fillRect, TBrush(color));
1860
1862 dc.FrameRect(fillRect, shbr);
1863 }
1864}
1865
1866//
1867// class TBitmapPickerGadget
1868//
1869//
1870// class TBitmapPickerGadget
1871// ~~~~~ ~~~~~~~~~~~~~~~~~~~
1872//
1881
1882//
1883// helper functions
1884//
1885void
1887{
1889 if(cell){
1890 TCelArray& dstArray = CelArray ? *CelArray : Window->GetCelArray();
1891 TCelArray& srcArray = *cell->GetCelArray();
1894
1895 TSize size(dstArray.CelSize().cx,dstArray.CelSize().cx*dstArray.NumRows());
1896 TRect dstRect(dstArray.CelOffset(GlyphIndex), size);
1897
1898 int curRow = srcArray.CurRow();
1899 TRect srcRect(srcArray.CelRect(cell->GetIndex()));
1900 srcArray.SetCurRow(curRow);
1901
1902 size = TSize(srcRect.Size());
1903 srcRect = TRect(srcRect.TopLeft(),TSize(size.cx, size.cy*srcArray.NumRows()));
1904
1905 //rect.Inflate(-2,-2);
1906
1907 dstDC.StretchBlt(dstRect, srcDC, srcRect);
1908 }
1909}
1910
1911//
1912//
1913//
1914void
1920
1921//
1922//
1923//
1924void
1933
1934
1935} // OWL namespace
1936
1937//==============================================================================
1938
Definition of a bitmap Cel array class.
#define CHECK(condition)
Definition checks.h:239
Definition of Choose Color Common Dialog class.
uint Size() const
Definition template.h:601
static const auto NPOS
Definition template.h:608
uint Clear(uint t)
Clear the bits that are enabled in the specified parameter.
Definition bitset.h:188
bool IsSet(uint t) const
Return true of the ON bits of the parameter are currently enabled.
Definition bitset.h:198
uint Set(uint t)
Activate the bits that are enabled in the specified parameter.
Definition bitset.h:179
virtual ~TBitmapCell()
Definition picker.cpp:225
virtual void PaintCell(TDC &dc, TRect &rect)
Definition picker.cpp:243
virtual void QueryBounds(TRect &rect)
Definition picker.cpp:255
TCelArray * CelArray
Definition picker.h:153
void SetCelArray(TCelArray *array, TAutoDelete=NoAutoDelete)
Definition picker.cpp:233
bool ShouldDelete
Definition picker.h:155
TBitmapCell(int id=0, TCelArray *array=0, int index=0, TBorderStyle borderStyle=Flat)
Definition picker.cpp:215
TBitmap is the GDI bitmap class derived from TGdiObject.
Definition gdiobjec.h:510
virtual void GetSelection()
Definition picker.cpp:1925
virtual void BuildCelArray()
Definition picker.cpp:1915
TBitmapPickerGadget(TPopupPicker &picker, TResId glyphResIdOrIndex, TStyle style=sBitmapText, TPopupType poptype=DownArrowAction, TType type=Command, bool enabled=false, TState state=Up, bool sharedGlyph=false, uint numChars=4)
Definition picker.cpp:1873
The GDI Brush class is derived from TGdiObject.
Definition gdiobjec.h:180
TState
TState enumerates the three button positions during which the button can be pressed: up (0),...
Definition buttonga.h:80
TType
Enumerates the types of button gadgets.
Definition buttonga.h:69
virtual void BuildCelArray()
Build the CelArray member using the resource bitmap as the base glyph CelArray may contain an existin...
Definition buttonga.cpp:386
virtual void Activate(const TPoint &p)
The action method called on a completed 'click', generates WM_COMMAND.
Definition buttonga.cpp:620
virtual void PaintFace(TDC &dc, const TRect &rect)
Paints the face of the button.
Definition buttonga.cpp:514
TStyle
TStyle contains values that defines how gadget will be displayed:
Definition btntextg.h:62
virtual void Created()
Calls TButtonGadget::Created and if Text == 0 and (Style & sText) retrieves text from menu or resourc...
Definition btntextg.cpp:255
TCelArray is a horizontal array of cels (a unit of animation) created by slicing a portion of or an e...
Definition celarray.h:35
TSize CelSize() const
Return the size of the celarray.
Definition celarray.h:133
bool StretchBlt(int index, TDC &dc, const TRect &dstRect, uint32 rop=SRCCOPY)
Draws the image of the cel onto the DC.
Definition celarray.cpp:315
bool BitBlt(int index, TDC &dc, int x, int y, uint32 rop=SRCCOPY)
Draws the cel at index onto the DC at position x and y.
Definition celarray.cpp:290
Defines information necessary to initialize the dialog box with the user's color selection.
Definition chooseco.h:43
Wrapper for the Choose-Color common dialog.
Definition chooseco.h:38
virtual void PaintCell(TDC &dc, TRect &rect)
Definition picker.cpp:205
TColor Color
Definition picker.h:133
Class wrapper for management of color values.
Definition color.h:245
static const TColor None
not-a-color
Definition color.h:318
static const TColor SysWindowFrame
The symbolic system color value for the frame around each window.
Definition color.h:330
uint8 Blue() const
Return the color's blue component.
Definition color.cpp:256
static const TColor Sys3dShadow
The symbolic system color value for the shadow regions of 3-dimensional display elements (for edges f...
Definition color.h:340
static const TColor Sys3dFace
The symbolic system color value for the face color of 3-dimensional display elements.
Definition color.h:339
uint8 Red() const
Return the color's red component.
Definition color.cpp:238
static const TColor White
Static TColor object with fixed Value set by RGB(255, 255, 255).
Definition color.h:314
static TColor CreateFromPaletteIndex(int index)
Construct a color that is an index into a palette.
Definition color.h:561
uint8 Green() const
Return the color's green component.
Definition color.cpp:247
static const TColor Black
Static TColor object with fixed Value set by RGB(0, 0, 0).
Definition color.h:305
virtual void GetFillRect(TRect &rect, const TRect &faceRect)
Definition picker.cpp:1833
TColorPickerGadget(TColorPicker &picker, TResId glyphResIdOrIndex, TStyle style=sBitmapText, TPopupType poptype=DownArrowAction, TType type=Command, bool enabled=false, TState state=Up, bool sharedGlyph=false, uint numChars=4)
Definition picker.cpp:1804
virtual void PaintFace(TDC &dc, const TRect &rect)
Definition picker.cpp:1845
virtual void GetSelection()
Definition picker.cpp:1815
TColor ColorSel
currect selected color
Definition picker.h:463
bool EvQueryNewPalette()
Definition picker.cpp:1771
auto CallCustomBox() -> bool override
Definition picker.cpp:1780
void NotifyParent(uint code) override
Definition picker.cpp:1706
void EvPaletteChanged(HWND hWndPalChg)
Definition picker.cpp:1761
void SetCustomColors(TColor *colors)
Definition picker.cpp:1696
TColorPicker(TWindow *parent, int id, int x, int y, int w=0, int h=0, TModule *module=0)
Definition picker.cpp:1640
void SetupWindow() override
Definition picker.cpp:1670
void Paint(TDC &, bool erase, TRect &) override
Definition picker.cpp:1718
TControl unifies its derived control classes, such as TScrollBar, TControlGadget, and TButton.
Definition control.h:38
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
virtual bool SetViewportOrg(const TPoint &origin, TPoint *oldOrg=nullptr)
Sets this DC's viewport origin to the given origin value, and saves the previous origin in oldOrg.
Definition dc.cpp:444
bool FrameRect(int x1, int y1, int x2, int y2, const TBrush &brush)
Draws a border on this DC around the given rectangle, rect, using the given brush,...
Definition dc.h:1781
virtual int DrawTextEx(TCHAR *str, int count, TRect *=nullptr, uint format=0, LPDRAWTEXTPARAMS=nullptr)
Formats and draws in the given rectangle, r, up to count characters of the null-terminated string usi...
Definition dc.cpp:785
bool GetViewportOrg(TPoint &point) const
The first version sets in the point argument the x- and y-extents (in device-units) of this DC's view...
Definition dc.h:1303
void SelectObject(const TBrush &brush)
Selects the given GDI brush object into this DC.
Definition dc.cpp:113
void RestorePalette()
Restores the original GDI palette object to this DC.
Definition dc.cpp:259
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
bool TextRect(int x1, int y1, int x2, int y2)
Fills the given rectangle, clipping any text to the rectangle.
Definition dc.h:1878
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
void RestoreBrush()
Restores the original GDI brush object to this DC.
Definition dc.cpp:233
virtual void RestoreFont()
Restores the original GDI font object to this DC.
Definition dc.cpp:246
int RealizePalette()
Maps to the system palette the logical palette entries selected into this DC.
Definition dc.h:1054
int SetBkMode(int mode)
Sets the background mode to the given mode argument, which can be either OPAQUE or TRANSPARENT.
Definition dc.h:1116
void OWLFastWindowFrame(TBrush &brush, TRect &r, int xWidth, int yWidth, uint32 rop=PATCOPY)
Draws a frame of the specified size and thickness with the given brush.
Definition dc.cpp:331
TDecoratedFrame automatically positions its client window (you must supply a client window) so that i...
Definition decframe.h:74
virtual tstring GetHintText(uint id, THintText hintType) const
Retrieves the text specified by the resource id.
Definition decframe.cpp:293
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
TEXTMETRIC GetTextMetrics(TDC &dc) const
Retrieves information about this font when selected in the specified dc.
Definition font.cpp:161
TRect & GetBounds()
Returns the boundary rectangle for the gadget.
Definition gadget.h:440
bool GetEnabled() const
Determines whether keyboard and mouse input have been enabled for the specified gadget.
Definition gadget.h:458
virtual void Inserted()
Called after a gadget is inserted into a window.
Definition gadget.cpp:325
int GetId() const
Gets the ID for the gadget.
Definition gadget.h:406
TPickerCellArray * Cells
Definition picker.h:324
void SetSelection(int sel=0)
Definition picker.cpp:449
virtual void PaintDivider(TDC &dc, const TRect &rect)
paint divider
Definition picker.cpp:905
void AddCell(TPickerCell *cells, bool select=false)
Definition picker.cpp:621
int Contains(const TPoint &point)
Definition picker.cpp:859
void EnableTooltip(bool enable=true) override
Definition picker.cpp:701
void EvMouseMove(uint modKeys, const TPoint &point)
Definition picker.cpp:1070
void GetCellRect(TRect &rect)
Definition picker.cpp:870
void InitPicker()
Definition picker.cpp:407
TTooltip * Tooltip
Definition picker.h:333
void EvKillFocus(THandle hWndGetFocus)
Definition picker.cpp:986
void EnableButton(LPCTSTR text=0, int resId=0, TPickerCell *cl=0)
Definition picker.cpp:543
void EnableDefault(LPCTSTR text=0, int resId=0, TPickerCell *cl=0)
Definition picker.cpp:519
void SetTooltip(TTooltip *tooltip)
Definition picker.cpp:715
void ApplyChanges()
Definition picker.cpp:481
void EvActivateApp(bool active, DWORD threadId)
Definition picker.h:279
void EvKeyUp(uint key, uint repeatCount, uint flags)
Definition picker.cpp:1189
void EvLButtonUp(uint modKeys, const TPoint &point)
Definition picker.cpp:1031
void RefocusCell(int loc)
Definition picker.cpp:931
virtual void Layout()
Definition picker.cpp:765
TPickerCell * GetDefaultCell()
Definition picker.cpp:639
void SetupWindow() override
Definition picker.cpp:675
TFont * GetFont()
Definition picker.h:698
void SetFont(const TFont &font)
Definition picker.cpp:511
TGridPicker(TWindow *parent, int id, int x, int y, int w=0, int h=0, TModule *module=0)
Definition picker.cpp:389
virtual tstring LoadTipText(int resId)
load tiptext from resource
Definition picker.cpp:1274
int Add(TPickerCell *cell)
Definition picker.cpp:584
TFont * Font
Definition picker.h:331
auto GetWindowClassName() -> TWindowClassName override
Definition picker.cpp:660
void EvKeyDown(uint key, uint repeatCount, uint flags)
Definition picker.cpp:1093
void EvLButtonDown(uint modKeys, const TPoint &point)
Definition picker.cpp:1001
void ClearCapture()
Definition picker.cpp:1262
void EvSetFocus(THandle hWndLostFocus)
Definition picker.cpp:974
void ModifyPopStyle(uint off, uint on)
Definition picker.cpp:567
virtual void NotifyParent(uint code)
notify parent on event -> BN_CLICKED and BN_HILITE
Definition picker.cpp:962
void EvCancelMode()
Definition picker.cpp:1224
TPickerCell * GetCell(int loc)
Definition picker.cpp:605
TMargins Margins
Definition picker.h:330
int GetSelection()
Definition picker.h:656
void SetMargins(const TMargins &margins)
Definition picker.cpp:503
TWindow * Target
Definition picker.h:332
void GetWindowClass(WNDCLASS &) override
Definition picker.cpp:667
virtual bool IsFlatStyle()
Definition picker.h:712
auto PreProcessMsg(MSG &) -> bool override
Definition picker.cpp:742
void Paint(TDC &, bool erase, TRect &) override
Definition picker.cpp:881
~TGridPicker() override
Definition picker.cpp:441
virtual bool CallCustomBox()
call user defined custom box if pressed custom button
Definition picker.cpp:918
void EvLButtonDblClk(uint modKeys, const TPoint &point)
Definition picker.cpp:1021
virtual void SetStatusBarMessage(int id)
send WM_MENUSELECT and WM_ENTERIDLE to frame window
Definition picker.cpp:1311
TPickerCell * GetSelectedCell()
Definition picker.h:670
void SetColumns(int colmn=4)
Definition picker.cpp:491
TPickerCell * GetCustomCell()
Definition picker.cpp:651
TPickerCell * Remove(int loc)
Definition picker.cpp:592
TPickerCell * RemoveCell(int loc)
Definition picker.cpp:631
virtual void ExitPicker(bool status=false)
do noting here
Definition picker.cpp:925
A device context (DC) class derived from TCreatedDC, TMemoryDC provides access to a memory DC.
Definition dc.h:784
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
bool PumpWaitingMessages()
The inner message loop.
Definition msgthred.cpp:123
TPalette is the GDI Palette class derived from TGdiObject.
Definition gdiobjec.h:413
uint GetPaletteEntries(uint16 start, uint16 count, PALETTEENTRY *entries) const
Retrieves a range of entries in this logical palette and places them in the entries array.
Definition gdiobjec.h:1306
uint16 GetNumEntries() const
Returns the number of entries in this palette, or 0 if the call fails.
Definition gdiobjec.h:1344
bsabstract base class
Definition picker.h:59
void SetBorderStyle(TBorderStyle bs)
Definition picker.cpp:89
virtual void EnterMouse()
Definition picker.cpp:178
virtual void LeaveMouse()
Definition picker.cpp:185
virtual void Paint(TDC &dc, TRect *r=0, bool drawbrd=true)
Definition picker.cpp:98
virtual void PaintBorder(TDC &dc, TRect &rect)
Definition picker.cpp:116
virtual void Select(bool sel=true)
Definition picker.cpp:192
TBorderStyle
Cell border styles. These match TIUBorder's TStyles exactly.
Definition picker.h:65
@ None
No border painted at all.
Definition picker.h:66
@ Plain
Plain plain window frame.
Definition picker.h:67
@ Flat
Use flat style.
Definition picker.h:77
@ WndRecessed
Input field & other window recessed.
Definition picker.h:75
virtual void PaintCell(TDC &dc, TRect &rect)=0
TPickerCell(int id=0, TBorderStyle borderStyle=Flat)
Definition picker.h:504
TGridPicker * Parent
Definition picker.h:114
TBorderStyle BorderStyle
Definition picker.h:115
virtual void QueryBounds(TRect &rect)
Definition picker.cpp:167
TPickerGadget(TPopupPicker &picker, TResId glyphResIdOrIndex, TStyle style=sBitmapText, TPopupType poptype=DownArrowAction, TType type=Command, bool enabled=false, TState state=Up, bool sharedGlyph=false, uint numChars=4)
Definition picker.cpp:1461
TPopupPicker * Picker
Definition picker.h:434
TPickerCell * Selected
currect selected cell
Definition picker.h:435
virtual void GetSelection()
Definition picker.cpp:1548
virtual ~TPickerGadget()
Definition picker.cpp:1478
virtual void Created()
Definition picker.cpp:1522
virtual void PopupAction()
Definition picker.cpp:1489
virtual void Inserted()
Definition picker.cpp:1537
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
virtual void PopupAction()
Start the PopupAction if the user click.
Definition popupgad.cpp:348
void Paint(TDC &, bool erase, TRect &) override
Definition picker.cpp:1365
void ExitPicker(bool status=false) override
Definition picker.cpp:1411
void EvActivateApp(bool active, DWORD taskId)
Definition picker.cpp:1401
TPopupPicker(TWindow *parent, int id, int x, int y, int w=0, int h=0, TModule *module=0)
Definition picker.cpp:1339
virtual bool ShowPicker(TPoint &p, TRect &rect)
Definition picker.cpp:1423
void GetWindowClass(WNDCLASS &) override
Definition picker.cpp:1357
void EvLButtonDown(uint modKeys, const TPoint &point)
Definition picker.cpp:1380
void EvKillFocus(THandle hWndGetFocus)
Definition picker.cpp:1390
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
int Height() const
Returns the height of this rectangle (bottom - top).
Definition geometry.h:1048
TSize Size() const
Returns the size of rectangle.
Definition geometry.h:1057
The tagSIZE struct is defined as.
Definition geometry.h:234
virtual void PaintCell(TDC &dc, TRect &rect)
Definition picker.cpp:280
tstring Text
Definition picker.h:174
TToolInfo contains information about a particular tool (a tool is either a window or an application-d...
Definition tooltip.h:35
TTooltip encapsulates a tooltip window - i.e.
Definition tooltip.h:175
bool AddTool(const TToolInfo &)
Registers a tool with the tooltip control.
Definition tooltip.h:406
void RelayEvent(MSG &)
Passes a mouse message to the tooltip control for processing.
Definition tooltip.h:524
void Activate(bool activate=true)
Set state of tooltip.
Definition tooltip.h:394
bool Detach(int loc)
Definition template.h:1436
Assists in drawing borders of many styles.
Definition uihelper.h:270
TFlag
Constructor flags to limit or modify border.
Definition uihelper.h:274
@ Mono
Monochrome.
Definition uihelper.h:291
@ Adjust
Adjust passed rect to client (Not Applicable)
Definition uihelper.h:289
@ Soft
Soft edge look for buttons.
Definition uihelper.h:288
@ RaisedInner
Raised inner edge only.
Definition uihelper.h:318
void Paint(TDC &dc) const
Paints this UIBorder object onto a given device context.
Definition uiborder.cpp:112
TStyle
Enumeration describing hilevel border styles.
Definition uihelper.h:296
@ WndRecessed
Input field & other window recessed.
Definition uihelper.h:306
@ Recessed
Status field style recessed.
Definition uihelper.h:300
@ Embossed
Grouping raised emboss bead.
Definition uihelper.h:301
@ ButtonUp
Button in up position.
Definition uihelper.h:303
static THatch8x8Brush & GetDitherBrush()
Internal static helper function that can be used alone.
Definition uiface.cpp:124
static const TUIMetric CxScreen
Definition uimetric.h:34
static const TUIMetric CyBorder
Definition uimetric.h:40
static const TUIMetric CyScreen
Definition uimetric.h:35
static const TUIMetric CxBorder
Definition uimetric.h:39
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
Definition module.h:47
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
HWND SetFocus()
Sets the keyboard focus to current window and activates the window that receives the focus by sending...
Definition window.h:2151
HWND SetCapture()
Sets the mouse capture to the current window.
Definition window.h:2121
tstring LoadString(uint id) const
Definition window.h:608
static HWND GetCapture()
Returns the handle of the window that has captured the mouse.
Definition window.h:2112
void EvKeyDown(uint key, uint repeatCount, uint flags)
The default message handler for WM_KEYDOWN.
Definition window.h:3771
virtual void SetParent(TWindow *newParent)
Sets the parent for the specified window by setting Parent to the specified new Parent window object.
Definition window.cpp:738
TApplication * GetApplication() const
Gets a pointer to the TApplication object associated with this.
Definition window.h:1855
void SetBkgndColor(TColor color, bool shouldUpdate=true)
Sets the background color for the window.
Definition window.h:1925
virtual void GetWindowClass(WNDCLASS &wndClass)
Redefined by derived classes, GetWindowClass fills the supplied MS-Windows registration class structu...
Definition window.cpp:2247
bool SetWindowPos(HWND hWndInsertAfter, const TRect &rect, uint flags)
Changes the size of the window pointed to by rect.
Definition window.h:2809
virtual int Execute()
Creates the underlying HWND and makes it modal with the help of TApplication's BeginModal support.
Definition window.cpp:2498
virtual bool PreProcessMsg(MSG &msg)
Called from TApplication::ProcessAppMsg() to give the window an opportunity to perform preprocessing ...
Definition window.cpp:644
virtual void Destroy(int retVal=0)
Destroys an MS-Windows element associated with the TWindow.
Definition window.cpp:2160
virtual bool Create()
Creates the window interface element to be associated with this ObjectWindows interface element.
Definition window.cpp:2399
int GetId() const
Returns Attr.Id, the ID used to find the window in a specified parent's child list.
Definition window.h:1881
TWindow * GetParent() const
Retrieves the OWL object of the parent window. If none exists, returns 0.
Definition window.h:2013
TRect GetWindowRect() const
Gets the screen coordinates of the window's rectangle.
Definition window.h:2257
virtual void InvalidateRect(const TRect &rect, bool erase=true)
Invalidates a specified client area.
Definition window.h:2834
TWindow * GetParentO() const
Return the OWL's parent for this window.
Definition window.h:2006
static void ReleaseCapture()
Releases the mouse capture from this window.
Definition window.h:2130
TWindowAttr & GetWindowAttr()
Returns the TWindowAttr structure, which contains the window's creation attributes.
Definition window.h:1886
void MapWindowPoints(HWND hWndTo, TPoint *pts, int count) const
Maps a set of points in one window to a relative set of points in another window.
Definition window.h:2206
bool EvQueryNewPalette()
The default message handler for WM_QUERYNEWPALETTE.
Definition window.h:4028
bool IsWindow() const
Returns true if an HWND is being used.
Definition window.h:2040
void EvKillFocus(HWND hWndGetFocus)
Handle WM_KILLFOCUS so that we can have a parent window hold onto our Handle and possibly restore foc...
Definition window.cpp:1611
bool IsChild(HWND hWnd) const
Returns true if the window is a child window or a descendant window of this window.
Definition window.h:3176
TResult HandleMessage(TMsgId, TParam1=0, TParam2=0)
Dispatches the given message using the response table.
Definition window.cpp:1392
void EvLButtonDown(uint modKeys, const TPoint &point)
Response method for an incoming WM_LBUTTONDOWN message.
Definition window.cpp:2101
bool ModifyStyle(uint32 offBits, uint32 onBits, uint swpFlags=0)
Modifies the style bits of the window.
Definition window.cpp:3591
uint32 GetStyle() const
Gets the style bits of the underlying window or the 'Style' member of the attribute structure associa...
Definition window.cpp:3558
TRect GetClientRect() const
Gets the coordinates of the window's client area (the area in a window you can use for drawing).
Definition window.h:2217
int GetDlgCtrlID() const
Returns the ID of the control.
Definition window.h:3097
void EvSetFocus(HWND hWndLostFocus)
The default message handler for WM_SETFOCUS.
Definition window.h:4084
void SendNotification(int id, int notifyCode, HWND hCtl, TMsgId=WM_COMMAND)
Repacks a command message (msg) so that a child window (hCtl) can send a message to its parent regard...
Definition window.h:2055
bool IsWindowVisible() const
Returns true if the window is visible.
Definition window.h:2605
virtual bool ShowWindow(int cmdShow)
Displays this TWindow in a given state.
Definition window.cpp:3713
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
Definition window.cpp:3288
virtual void SetupWindow()
Performs setup following creation of an associated MS-Windows window.
Definition window.cpp:2575
bool ModifyExStyle(uint32 offBits, uint32 onBits, uint swpFlags=0)
Modifies the style bits of the window.
Definition window.cpp:3599
void EvPaletteChanged(HWND hWndPalChg)
The default message handler for WM_PALETTECHANGED.
Definition window.h:3960
HWND THandle
TWindow encapsulates an HWND.
Definition window.h:418
virtual void Invalidate(bool erase=true)
Invalidates (mark for painting) the entire client area of a window.
Definition window.h:2822
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
#define _T(x)
Definition cygwin.h:51
Definition of class TDecoratedFrame, a TFrameWindow that can manage decorations around the client win...
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Definition eventhan.h:492
Definition of TGadgetList, TGadgetWindow & TGadgetWindowFont A list holding gadgets,...
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
@ AutoDelete
Definition gdibase.h:70
@ htTooltip
Shorter text displayed in a tooltip.
Definition decframe.h:53
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
EV_WM_LBUTTONUP
Definition docking.cpp:2056
EV_WM_CANCELMODE
Definition glyphbtn.cpp:318
EV_WM_PALETTECHANGED
Definition framewin.cpp:40
EV_WM_LBUTTONDBLCLK
Definition docking.cpp:962
EV_WM_MOUSEMOVE
Definition docking.cpp:2054
EV_WM_KILLFOCUS
Definition edit.cpp:85
const int CellSpacing
Definition picker.cpp:761
EV_WM_KEYDOWN
Definition edit.cpp:82
EV_WM_ACTIVATEAPP
Definition floatfra.cpp:32
OWL_DIAGINFO
Definition animctrl.cpp:14
EV_WM_SETFOCUS
Definition edit.cpp:84
END_RESPONSE_TABLE
Definition button.cpp:26
EV_WM_QUERYNEWPALETTE
Definition framewin.cpp:39
std::string tstring
Definition defs.h:79
EV_WM_KEYUP
Definition glyphbtn.cpp:316
unsigned int uint
Definition number.h:25
EV_WM_LBUTTONDOWN
Definition checklst.cpp:195
#define TYPESAFE_DOWNCAST(object, toClass)
Definition defs.h:269
#define ID_CUSTITEM
Definition picker.cpp:30
#define ID_DELTA
Definition picker.cpp:32
#define ID_DEFITEM
Definition picker.cpp:31
#define ID_MINITEM
Definition picker.cpp:33
#define ID_STATITEM
Definition picker.cpp:29
Definition of classes TPickerCell, TColorCell, TBitmapCell, TTextCell, TGridPicker,...
#define OWL_PICKER
Definition picker.h:32
Used by the TGadgetWindow and TGadget classes, TMargins contains the measurements of the margins for ...
Definition gadget.h:54
void GetPixels(int &left, int &right, int &top, int &bottom, int fontHeight) const
Definition gadget.cpp:55
int Id
Contains the identifier of the child window.
Definition window.h:351
Definition of container classes used and made available by OWL.
Definition of the TTooltip class and helper objects.
Definition of the UI Helper Classes: TUIHandle, TUIBorder, TUIFace, TUIPart.
Definition of TUIMetric, a UI metrics provider class.
#define WS_EX_WINDOWEDGE
Definition wsysinc.h:30