27#define MULTIPLESEL (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)
30# if defined(BI_COMP_BORLANDC)
42# if defined(BI_COMP_BORLANDC)
51 SelIndices->Add(index);
60 int index = Items.Add(item);
62 SelIndices->Add(index);
76 SelIndices->Add(index);
82 for (
int i = 0; i < static_cast<int>(Items.size()); ++i)
83 if (Items[i]->GetText() == str)
93 return SelIndices->size();
111 TListBox(parent, id, x, y, w, h, module)
113 Attr.Style |= LBS_NOTIFY | LBS_OWNERDRAWVARIABLE | LBS_NOINTEGRALHEIGHT;
114 Attr.Style &= ~LBS_HASSTRINGS;
115 Attr.Style &= ~LBS_SORT;
117 for(
int i = 0; i < numItems; i++)
118 Items.Add(&items[i]);
133 TListBox(parent, id, x, y, w, h, module)
135 Attr.Style |= LBS_NOTIFY | LBS_OWNERDRAWVARIABLE | LBS_NOINTEGRALHEIGHT;
136 Attr.Style &= ~LBS_HASSTRINGS;
137 Attr.Style &= ~LBS_SORT;
139 for(
int i = 0; i < static_cast<int>(items.
Size()); i++)
156 TListBox(parent, resourceId, module)
158 for(
int i = 0; i < numItems; i++)
159 Items.Add(&items[i]);
163 TRACEX(OwlControl,
OWL_CDLEVEL,
"TCheckList constructed from resource @" << (
void*)
this);
174 TListBox(parent, resourceId, module)
176 for(
int i = 0; i < static_cast<int>(items.
Size()); i++)
181 TRACEX(OwlControl,
OWL_CDLEVEL,
"TCheckList constructed from resource @" << (
void*)
this);
215 while(i <
static_cast<int>(Items.Size())){
216 if(*Items[i] > *item)
220 if(i >=
static_cast<int>(Items.Size()))
227 return Items.Add(item);
250 idx = Items.Add(item);
252 Items.AddAt(item, idx);
268 Items.DetachItem(item);
328 TRACEX(OwlControl, 1,
"TCheckList::SetupWindow() @" << (
void*)
this);
337 SortArray(&Items[0],Items.Size());
338 for (
uint i = 0; i < Items.Size(); i++)
342 for (
uint i = 0; i < Items.Size(); i++)
343 AddString(
reinterpret_cast<LPCTSTR
>(Items[i]));
365 if (selIndex != LB_ERR)
407 const bool disabled = !item->
IsEnabled() || (drawInfo.itemState & ODS_DISABLED);
411 TDC dc(drawInfo.hDC);
415 TRect rect(drawInfo.rcItem);
421 TRect checkboxRect(rect.left+1,rect.top+1,
442 TRect textRect = rect;
443 textRect.left = checkboxRect.right + 2;
450 else if (drawInfo.itemState & ODS_SELECTED)
471 if (drawInfo.itemState & ODS_FOCUS)
482 if (index < 0 || index >=
GetCount())
487 if (index < 0 || index >=
static_cast<int>(Items.Size()))
496 if (!buffer && direction !=
tdSizeData)
return 0;
503 checkListData->
Clear(
false);
506 for(
int i =0; i < count; i++)
529 for (
int selIndex = 0; selIndex < selCount; selIndex++)
530 checkListData->
Select(selections[selIndex]);
539 const int noSelection = -1;
541 int selIndex = noSelection;
545 int index =
AddString(
reinterpret_cast<LPCTSTR
>(checkListData->
GetItem(i)));
547 for (
uint j = 0; j < selCount; j++)
548 if (checkListData->
GetSelIndices()[j] ==
static_cast<int>(i)) {
560 if (selIndex != noSelection && index <= selIndex)
564 if (selIndex != noSelection && !(style &
MULTIPLESEL))
591 else if (numTabs == 1 && tabs !=
nullptr){
598 else if(numTabs > 1 && tabs !=
nullptr){
603 for(
int i=0; i<numTabs; i++){
604 nStop = (tabs[i] * nBaseUnit) / 4;
605 if(nStop > nPrevStop){
639 int nBaseUnit = logFont.lfWidth;
641 nBaseUnit =
LoUint16(::GetDialogBaseUnits());
659 if (HasThreeStates) {
703 HasThreeStates =
true;
714 HasThreeStates = hasThreeStates;
734 HasThreeStates = d.HasThreeStates;
742 return (Text==d.Text && State == d.State &&
743 HasThreeStates == d.HasThreeStates && Enabled == d.Enabled);
Definition of class TCheckList, an ownerdrawn listbox to select multiple items.
#define PRECONDITION(condition)
#define TRACEX(group, level, message)
Pointer to an array of type T.
The GDI Brush class is derived from TGdiObject.
void SelectString(const tstring &str)
int AddStringItem(const tstring &str, UINT_PTR itemData, bool isSelected=false)
int AddItem(TCheckListItem *item)
TCheckListItem * GetItem(int index)
TIntArray & GetSelIndices()
void Clear(bool del=true)
int AddString(const tstring &str, bool isSelected=false)
TCheckList is an owner-drawn list box to select multiple items.
void ODAFocus(DRAWITEMSTRUCT &) override
Repaints the item entirely.
void EvLButtonDown(uint modKeys, const TPoint &point)
Toggles the checked state when the mouse is clicked in the checkbox.
void ODADrawEntire(DRAWITEMSTRUCT &) override
Repaints the item entirely.
~TCheckList() override
Destructs the checklist.
void SetupWindow() override
Adds the strings into the listbox.
void ODASelect(DRAWITEMSTRUCT &) override
int AddItem(TCheckListItem *item)
Adds the item into the checklist.
friend class TCheckListArray
virtual uint Transfer(TCheckListData &data, TTransferDirection direction)
Safe overload.
void Update()
Refreshes the window.
TCheckListItem * DetachItem(int idx)
Detaches the item in the list at the given position (starting at 0).
TCheckListItem * GetItem(int idx)
Returns the item at the specified index.
void PaintItem(DRAWITEMSTRUCT &)
Paints the item entirely.
virtual void PaintText(TDC &, const TRect &, const tstring &)
void EvChar(uint key, uint repeatCount, uint flags)
Toggles the checked state when the space key is pressed.
TCheckList(TWindow *parent, int id, int x, int y, int w, int h, TCheckListItem *=0, int numItems=0, TModule *=0)
Creates a checklist.
int InsertItem(TCheckListItem *item, int idx)
Inserts the item into the checklist box at the given position.
void ClearList() override
Each item displayed and manipulated by TCheckList.
void Toggle()
Toggles the state of the item.
void SetThreeStates(bool)
Sets the three-state property.
bool operator==(const TCheckListItem &d) const
bool IsEnabled() const
Returns true if the item is enabled.
bool IsChecked() const
Returns true if the item has been checked.
void Uncheck()
Unchecks the item.
TCheckListItem()
Initializes the state of TCheckListItem.
friend int SortCheckList(const void *a, const void *b)
void SetData(UINT_PTR data)
Sets the user-defined data for this item.
const tstring & GetText()
Returns the text of the item.
TCheckListItem & operator=(const TCheckListItem &d)
void Check()
Checks the item.
bool IsIndeterminate() const
Returns true if the item is in the indeterminate state.
void SetIndeterminate()
Makes the item indeterminate.
static const TColor SysGrayText
The symbolic system color value for grayed (disabled) text.
static const TColor SysHighlightText
The symbolic system color value for text selected in a control.
static const TColor SysHighlight
The symbolic system color value for items selected in a control.
static const TColor SysWindowText
The symbolic system color value for text in every window.
static const TColor SysWindow
The symbolic system color value for the background of each window.
TDC is the root class for GDI DC wrappers.
bool FillRect(int x1, int y1, int x2, int y2, const TBrush &brush)
Fills the given rectangle on this DC using the specified brush.
bool TextRect(int x1, int y1, int x2, int y2)
Fills the given rectangle, clipping any text to the rectangle.
bool DrawFocusRect(int x1, int y1, int x2, int y2)
Draws the given rectangle on this DC in the style used to indicate focus.
virtual TColor SetBkColor(const TColor &color)
Sets the current background color of this DC to the given color value or the nearest available.
virtual bool TabbedTextOut(const TPoint &p, const tstring &str, int count, int numPositions, const int *positions, int tabOrigin, TSize &size)
Draws up to count characters of the given null-terminated string in the current font on this DC.
virtual TColor SetTextColor(const TColor &color)
Sets the current text color of this DC to the given color value.
TFont(HFONT handle, TAutoDelete autoDelete=NoAutoDelete)
TFont encapsulates an HFONT.
An interface object that represents a corresponding list box element.
virtual LPARAM GetItemData(int index) const
Returns the custom value associated with the item at index set by SetItemData.
virtual int SetSelIndex(int index)
For single-selection list boxes.
virtual int AddString(LPCTSTR str)
Adds str to the list box, returning its position in the list (0 is the first position).
int GetSelIndexes(int *indexes, int maxCount) const
For multiple-selection list boxes.
virtual int SetTopIndex(int index)
The system scrolls the list box contents so that either the specified item appears at the top of the ...
virtual int InsertString(LPCTSTR str, int index)
Inserts str in the list box at the position supplied in index, and returns the item's actual position...
virtual int GetCount() const
Returns the number of items in the list box, or a negative value if an error occurs.
TListBox(TWindow *parent, int id, int x, int y, int w, int h, TModule *module=0)
Constructs a list box object with the supplied parent window (parent) library ID (module),...
virtual int DeleteString(int index)
Deletes the item in the list at the position (starting at 0) supplied in index.
int GetSelCount() const
Returns the number of selected items in the single- or multiple-selection list box or combo box.
virtual void ClearList()
Clears all the entries in the associated listbox.
int SetSel(int index, bool select)
For multiple-selection list boxes.
virtual int GetTopIndex() const
Returns the index of the first item displayed at the top of the list box.
int GetCaretIndex() const
Returns the index of the currently focused list-box item.
virtual int GetSelIndex() const
For single-selection list boxes.
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
TPoint is a support class, derived from tagPOINT.
TRect is a mathematical class derived from tagRect.
const TPoint & TopLeft() const
Returns the upperleft point.
bool SetTabStops(int numTabs=0, int *tabs=0)
Sets tab stops.
virtual void PaintText(TDC &dc, const TRect &textRect, const tstring &text)
int GetAverageCharWidths()
TState
Enumeration describing the various glyphs available for buttons, captions, menus and scrollbar parts.
@ Inactive
Draw button grayed.
@ Checked
Draw button as checked.
@ Button3State
Three-state button.
@ uiButton
Draw a button glyph.
TUIPart()
Empty constructor.
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
TWindow * GetParentO() const
Return the OWL's parent for this window.
void EnableTransfer()
Enables the transfer mechanism, which allows state data to be transferred between the window and a tr...
TResult HandleMessage(TMsgId, TParam1=0, TParam2=0)
Dispatches the given message using the response table.
void EvLButtonDown(uint modKeys, const TPoint &point)
Response method for an incoming WM_LBUTTONDOWN message.
uint32 GetStyle() const
Gets the style bits of the underlying window or the 'Style' member of the attribute structure associa...
HFONT GetWindowFont()
Gets the font the control uses to draw text.
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
virtual void SetupWindow()
Performs setup following creation of an associated MS-Windows window.
virtual void Invalidate(bool erase=true)
Invalidates (mark for painting) the entire client area of a window.
HWND GetHandle() const
Returns the handle of the window.
Definition of classes for CommonControl encapsulation.
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
@ tdSizeData
Return the size of data transferred by the class.
@ tdSetData
Set data from the buffer into the window.
@ tdGetData
Get data from the window into the buffer.
Object Windows Library (OWLNext Core).
int SortCheckList(const void *a, const void *b)
TTypedArray< int, int, TStandardAllocator > TIntArray
@ BF_UNCHECKED
Item is unchecked.
@ BF_GRAYED
Item is grayed.
@ BF_CHECKED
Item is checked.
LPARAM TParam2
Second parameter type.
uint16 LoUint16(LRESULT r)
TParam2 MkParam2(const T1 &lo, const T2 &hi)
const int CheckList_BoxWidth
DIAG_DECLARE_GROUP(OwlThread)
Definition of class TString, a flexible universal string envelope class.
Definition of the UI Helper Classes: TUIHandle, TUIBorder, TUIFace, TUIPart.