#include <griddropdown.h>
Inheritance diagram for CGridDropDown:
Public Member Functions | |
CGridDropDown () | |
virtual | ~CGridDropDown () |
virtual BOOL | Init (CWindowID ParentWindow, CGadgetID ParentControl) |
void | SetSelected (INT32 iSelectedIndex) |
INT32 | GetSelected () |
void | SetColumns (INT32 iColumns) |
void | SetItemSize (wxSize szItem) |
wxSize | GetItemSize () |
INT32 | GetItemsNum (void) |
void | Clear (void) |
void | DeleteItem (INT32 index) |
Static Public Member Functions | |
static void | KillDropDownsByWindow (CWindowID Window) |
Kills all the dropdowns associated with a particular window This is called when that window is dying. We can't delete the dropdowns but we can deinit them so they won't cause anyone eny hassle. | |
Protected Member Functions | |
virtual void | KillList () |
virtual void | DrawItem (wxDC &dc, const wxRect &rect, INT32 iItem, INT32 iFlags) |
virtual wxRect | PreDrawItem (wxDC &dc, const wxRect &rect, INT32 iItem, INT32 iFlags) |
virtual void | DrawItemCore (wxDC &dc, const wxRect &rect, INT32 iItem, INT32 iFlags)=0 |
virtual void | PostDrawItem (wxDC &dc, const wxRect &rect, INT32 iItem, INT32 iFlags) |
void | SetListRedraw (BOOL Enable) |
void | AddItem (CGridComboUserData *pItemData) |
CGridComboUserData * | GetItemData (INT32 iItem) |
wxGridCombo * | GetBox () |
void | DrawShadedRect (wxDC &dc, const wxRect &rect, const wxPen &pen1, const wxPen &pen2) |
Protected Attributes | |
BOOL | m_bInitialised |
CWindowID | m_widParentDlg |
CGadgetID | m_gidParentGadget |
wxCamGridPopup * | m_pPopup |
Static Protected Attributes | |
static List | CurrentDropDowns |
Friends | |
class | wxCamGridPopup |
Definition at line 149 of file griddropdown.h.
|
Definition at line 166 of file griddropdown.cpp. 00167 { 00168 m_widParentDlg = NULL; 00169 m_pPopup = NULL; 00170 m_gidParentGadget = 0; 00171 m_bInitialised = FALSE; 00172 }
|
|
Definition at line 176 of file griddropdown.cpp. 00177 { 00178 if (m_bInitialised) 00179 { 00180 // Do any deinit here 00181 Init(NULL, 0); 00182 } 00183 }
|
|
Function : CGridDropDown::AddItem Author : Mikhail Tatarnikov Purpose : Adds a new item Returns : void Exceptions: Parameters: [in] CGridComboUserData* pItemData - new data to associate with the item. Notes : Definition at line 317 of file griddropdown.cpp. 00318 { 00319 wxGridCombo* pGadget = GetBox(); 00320 pGadget->AddItem(pItemData); 00321 }
|
|
Function : CGridDropDown::Clear Author : Mikhail Tatarnikov Purpose : Remove all items from the control Returns : void Exceptions: Parameters: Notes : Definition at line 332 of file griddropdown.cpp. 00333 { 00334 wxGridCombo* pGadget = GetBox(); 00335 if (!pGadget) 00336 return; 00337 pGadget->Clear(); 00338 }
|
|
Function : CGridDropDown::DeleteItem Author : Mikhail Tatarnikov Purpose : Deletes a specific item. Returns : void Exceptions: Parameters: [in] INT32 index - item to delete. Notes : Definition at line 350 of file griddropdown.cpp.
|
|
Function : CGridDropDown::DrawItem Author : Mikhail Tatarnikov Purpose : Draws an item Returns : void Exceptions: Parameters: [in] wxDC& dc - the device context to draw to; [in] wxRect& rect - the area of the item; [in] int iItem - item index; TYPENOTE: Correct [in] int iFlags - additional flags (selected, highlighted, ...) TYPENOTE: Correct Notes : Definition at line 506 of file griddropdown.cpp. 00507 { 00508 // Erase the background first. 00509 static wxPen penBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); 00510 static wxBrush brBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); 00511 00512 dc.SetPen(penBackground); 00513 dc.SetBrush(brBackground); 00514 00515 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); 00516 00517 dc.SetBrush(wxNullBrush); 00518 dc.SetPen(wxNullPen); 00519 00520 // Check if we have a valid item and should to continue 00521 // drawing. 00522 if (iItem >= GetItemsNum()) 00523 return; 00524 00525 wxRect rcCore = PreDrawItem(dc, rect, iItem, iFlags); 00526 00527 DrawItemCore(dc, rcCore, iItem, iFlags); 00528 00529 // Post-draw the item. 00530 PostDrawItem(dc, rect, iItem, iFlags); 00531 }
|
|
Implemented in CBitmapGridDropDown. |
|
Function : CGridDropDown::DrawShadedRect Author : Mikhail Tatarnikov Purpose : A helper function to draw a shaded box Returns : void Exceptions: Parameters: [in] wxDC& dc - device context to draw to; [in] const wxRect& rect - box to draw; [in] const wxPen& pen1 - pen to draw top-left sides; [in] const wxPen& pen2 - pen to draw bottom-right sides; Notes : Definition at line 446 of file griddropdown.cpp. 00447 { 00448 // draw the rectangle 00449 dc.SetPen(pen1); 00450 dc.DrawLine(rect.GetLeft(), rect.GetTop(), 00451 rect.GetLeft(), rect.GetBottom()); 00452 dc.DrawLine(rect.GetLeft() + 1, rect.GetTop(), 00453 rect.GetRight(), rect.GetTop()); 00454 dc.SetPen(pen2); 00455 dc.DrawLine(rect.GetRight(), rect.GetTop(), 00456 rect.GetRight(), rect.GetBottom()); 00457 dc.DrawLine(rect.GetLeft(), rect.GetBottom(), 00458 rect.GetRight() + 1, rect.GetBottom()); 00459 00460 }
|
|
Function : CGridDropDown::GetBox Author : Mikhail Tatarnikov Purpose : Helper function to get the control gadget Returns : wxGridCombo* - the combo cobtrol the object controls. Exceptions: Parameters: None Notes : Definition at line 194 of file griddropdown.cpp. 00195 { 00196 wxWindow* pGadget = DialogManager::GetGadget(m_widParentDlg, m_gidParentGadget); 00197 ERROR2IF(!pGadget || !pGadget->IsKindOf(CLASSINFO(wxGridCombo)), NULL, "Bad GridDropdown Gadget"); 00198 return (wxGridCombo*)pGadget; 00199 }
|
|
Function : CGridDropDown::GetItemData Author : Mikhail Tatarnikov Purpose : Obtains the user data associated with the item. Returns : CGridComboUserData* - the user data for the item. Exceptions: Parameters: [in] INT32 iItem - item to obtain the user data for. Notes : Reimplemented in CBitmapGridDropDown. Definition at line 395 of file griddropdown.cpp. 00396 { 00397 wxGridCombo* pGadget = GetBox(); 00398 return pGadget->GetUserData(iItem); 00399 }
|
|
Function : CGridDropDown::GetItemSize Author : Mikhail Tatarnikov Purpose : Obtains items size. Returns : wxSize - the items size. Exceptions: Parameters: None Notes : Definition at line 487 of file griddropdown.cpp. 00488 { 00489 wxGridCombo* pGadget = GetBox(); 00490 return pGadget->GetItemSize(); 00491 }
|
|
Function : CGridDropDown::GetItemsNum Author : Mikhail Tatarnikov Purpose : Gets the number of items Returns : INT32 - the number of items in the control. Exceptions: Parameters: None Notes : Definition at line 411 of file griddropdown.cpp. 00412 { 00413 wxGridCombo* pGadget = GetBox(); 00414 return pGadget->GetItemsNum(); 00415 }
|
|
Function : CGridDropDown::GetSelected Author : Mikhail Tatarnikov Purpose : Gets the selected item. Returns : INT32 - the item selected, -1 if none. Exceptions: Parameters: None Notes : Definition at line 379 of file griddropdown.cpp. 00380 { 00381 wxGridCombo* pGadget = GetBox(); 00382 return pGadget->GetSelected(); 00383 }
|
|
Function : CGridDropDown::Init Author : Mikhail Tatarnikov Purpose : Intialization of the control Returns : BOOL - Exceptions: Parameters: [in] CWindowID Window - window the control resides; [in] CGadgetID Gadget - control ID. Notes : Definition at line 212 of file griddropdown.cpp. 00213 { 00214 if (Window) 00215 { 00216 wxWindow* pGadget = DialogManager::GetGadget(Window, Gadget); 00217 if (pGadget && pGadget->IsKindOf(CLASSINFO(wxGridCombo))) 00218 { 00219 m_widParentDlg = Window; 00220 m_gidParentGadget = Gadget; 00221 00222 if (!m_bInitialised) // Only ever add myself to the list once 00223 { 00224 m_pPopup = new wxCamGridPopup(this, GetBox()); 00225 ERROR2IF(!m_pPopup, FALSE, "Could not get new list popup"); 00226 ((wxGridCombo*)pGadget)->SetPopupControl(m_pPopup); 00227 CurrentDropDowns.AddHead(this); 00228 } 00229 00230 00231 m_bInitialised = TRUE; 00232 return(TRUE); 00233 } 00234 ERROR3("CGridDropDown::Init failed - illegal Gadget"); 00235 return(FALSE); 00236 } 00237 else 00238 { 00239 // release all memory 00240 KillList(); 00241 Clear(); 00242 m_widParentDlg = NULL; 00243 m_gidParentGadget=0; 00244 m_bInitialised=FALSE; 00245 CurrentDropDowns.RemoveItem(this); 00246 return TRUE; 00247 } 00248 }
|
|
Kills all the dropdowns associated with a particular window This is called when that window is dying. We can't delete the dropdowns but we can deinit them so they won't cause anyone eny hassle.
Definition at line 262 of file griddropdown.cpp. 00263 { 00264 // First kill any associated with this window 00265 CGridDropDown* Ptr = (CGridDropDown*) CurrentDropDowns.GetHead(); 00266 while (Ptr != NULL) 00267 { 00268 CGridDropDown* Next = (CGridDropDown*) CurrentDropDowns.GetNext(Ptr); // as we may remove this item from the list 00269 if (Ptr->m_bInitialised && (Ptr->m_widParentDlg == Window)) 00270 Ptr->Init(NULL, 0); 00271 Ptr = Next; 00272 } 00273 00274 // Now process children if any 00275 wxWindowList::Node * pNode = Window->GetChildren().GetFirst(); 00276 while (pNode) 00277 { 00278 KillDropDownsByWindow(pNode->GetData()); 00279 pNode = pNode->GetNext(); 00280 } 00281 return; 00282 }
|
|
Definition at line 185 of file griddropdown.h.
|
|
Function : CGridDropDown::PostDrawItem Author : Mikhail Tatarnikov Purpose : Post-draws item Returns : void Exceptions: Parameters: [in] wxDC& dc - the device context to draw to; [in] wxRect& rect - the area of the item; [in] INT32 iItem - item index; [in] INT32 iFlags - additional flags (selected, highlighted, ...) Notes : Here we highlight the selected item. Definition at line 584 of file griddropdown.cpp. 00585 { 00586 // Shouldn't do anything if the combobox itself is drawn - no reason 00587 // to draw selection in the combobox itslef. 00588 if (iFlags & wxGridComboPopup::keComboControl) 00589 return; 00590 00591 // Check whether we have to highligt the selected item or not. 00592 if ((iFlags & wxGridComboPopup::keSelected) == 0) 00593 return; 00594 00595 dc.SetPen(*wxRED_PEN); 00596 dc.SetBrush(*wxTRANSPARENT_BRUSH); 00597 00598 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); 00599 00600 dc.SetBrush(wxNullBrush); 00601 dc.SetPen(wxNullPen); 00602 }
|
|
Function : CGridDropDown::PreDrawItem Author : Mikhail Tatarnikov Purpose : Predraws an item (e.g. erases background) Returns : wxRect - the area where the item should be drawn. Exceptions: Parameters: [in] wxDC& dc - the device context to draw to; [in] wxRect& rect - the area of the item; [in] INT32 iItem - item index; [in] INT32 iFlags - additional flags (selected, highlighted, ...) Notes : The return rect specifies where the item should be drawn. It can be smaller if we draw a frame and want the item itself to be drawn inside this frame. Definition at line 547 of file griddropdown.cpp. 00548 { 00549 // Shouldn't do anything if the combobox itself is drawn. 00550 if (iFlags & wxGridComboPopup::keComboControl) 00551 return rect; 00552 00553 wxRect rcRect = rect; 00554 00555 static wxPen penDarkGrey(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)); 00556 static wxPen penHighlight(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT)); 00557 00558 // Depending on whether the 00559 if (iFlags & wxGridComboPopup::keHighlight) 00560 DrawShadedRect(dc, rect, penDarkGrey, penHighlight); 00561 else 00562 DrawShadedRect(dc, rect, penHighlight, penDarkGrey); 00563 00564 00565 // Adjust the drawing rectangle - we want the other painting to be 00566 // done inside our 3d rectangle. 00567 rcRect.Deflate(1); 00568 00569 return rcRect; 00570 }
|
|
Function : CGridDropDown::SetColumns Author : Mikhail Tatarnikov Purpose : Sets the number of column to display in the popup Returns : void Exceptions: Parameters: [in] INT32 iColumns - column number to display. Notes : Definition at line 427 of file griddropdown.cpp. 00428 { 00429 wxGridCombo* pGadget = GetBox(); 00430 pGadget->SetColumns(iColumns); 00431 }
|
|
Function : CGridDropDown::SetItemSize Author : Mikhail Tatarnikov Purpose : Sets the size of items Returns : void Exceptions: Parameters: [in] wxSize szItem - items size. Notes : Definition at line 471 of file griddropdown.cpp. 00472 { 00473 wxGridCombo* pGadget = GetBox(); 00474 pGadget->SetItemSize(szItem); 00475 }
|
|
Function : CGridDropDown::SetListRedraw Author : Mikhail Tatarnikov Purpose : Pause/resume control drawing. Returns : void Exceptions: Parameters: [in] BOOL Enable - TRUE for enabling redraw, FALSE otherwise. Notes : Definition at line 295 of file griddropdown.cpp. 00296 { 00297 wxGridCombo* pGadget = GetBox(); 00298 if (!pGadget) 00299 return; 00300 if (Enable) 00301 pGadget->Thaw(); 00302 else 00303 pGadget->Freeze(); 00304 }
|
|
Function : CGridDropDown::SetSelected Author : Mikhail Tatarnikov Purpose : Select an item. Returns : void Exceptions: Parameters: [in] INT32 iSelectedIndex - an item to select. Notes : Definition at line 364 of file griddropdown.cpp. 00365 { 00366 wxGridCombo* pGadget = GetBox(); 00367 pGadget->SetSelected(iSelectedIndex); 00368 }
|
|
Definition at line 151 of file griddropdown.h. |
|
Definition at line 183 of file griddropdown.h. |
|
Definition at line 215 of file griddropdown.h. |
|
Definition at line 218 of file griddropdown.h. |
|
Definition at line 219 of file griddropdown.h. |
|
Definition at line 217 of file griddropdown.h. |