bbtk::WxGUIBlackBoxList Class Reference

#include <bbtkWxGUIPackageBrowser2.h>

List of all members.

Public Member Functions

 WxGUIBlackBoxList (wxWindow *parent, const wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
void SetUser (WxGUIBlackBoxListUser *u)
void Insert (BlackBoxDescriptor::Pointer d)
void OnColClick (wxListEvent &event)
void OnColRightClick (wxListEvent &event)
void OnColBeginDrag (wxListEvent &event)
void OnColDragging (wxListEvent &event)
void OnColEndDrag (wxListEvent &event)
void OnBeginDrag (wxListEvent &event)
void OnBeginRDrag (wxListEvent &event)
void OnBeginLabelEdit (wxListEvent &event)
void OnEndLabelEdit (wxListEvent &event)
void OnDeleteItem (wxListEvent &event)
void OnDeleteAllItems (wxListEvent &event)
void OnSelected (wxListEvent &event)
void OnDeselected (wxListEvent &event)
void OnListKeyDown (wxListEvent &event)
void OnActivated (wxListEvent &event)
void OnFocused (wxListEvent &event)
void OnCacheHint (wxListEvent &event)
void OnChar (wxKeyEvent &event)
void OnContextMenu (wxContextMenuEvent &event)
void OnRightClick (wxMouseEvent &event)

Private Member Functions

void ShowContextMenu (const wxPoint &pos)
void SetColumnImage (int col, int image)
void LogEvent (const wxListEvent &event, const wxChar *eventName)
void LogColEvent (const wxListEvent &event, const wxChar *eventName)
virtual wxString OnGetItemText (long item, long column) const
virtual int OnGetItemColumnImage (long item, long column) const
virtual wxListItemAttr * OnGetItemAttr (long item) const

Private Attributes

WxGUIBlackBoxListUsermUser
wxListItemAttr m_attr


Detailed Description

Definition at line 124 of file bbtkWxGUIPackageBrowser2.h.


Constructor & Destructor Documentation

bbtk::WxGUIBlackBoxList::WxGUIBlackBoxList ( wxWindow *  parent,
const wxWindowID  id,
const wxPoint &  pos,
const wxSize &  size,
long  style 
)

Definition at line 113 of file bbtkWxGUIPackageBrowser2.cxx.

00118     : wxListCtrl(parent, id, pos, size, style),
00119       mUser(0),
00120       m_attr(*wxBLUE, *wxLIGHT_GREY, wxNullFont)
00121   {
00122 #ifdef __POCKETPC__
00123     EnableContextMenu();
00124 #endif
00125   }


Member Function Documentation

void bbtk::WxGUIBlackBoxList::SetUser ( WxGUIBlackBoxListUser u  )  [inline]

Definition at line 134 of file bbtkWxGUIPackageBrowser2.h.

References mUser, and SetUser().

Referenced by SetUser(), and bbtk::WxGUIPackageBrowser2::WxGUIPackageBrowser2().

00134 { mUser = u; }

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::WxGUIBlackBoxList::Insert ( BlackBoxDescriptor::Pointer  d  ) 

Definition at line 127 of file bbtkWxGUIPackageBrowser2.cxx.

References bbtk::std2wx().

Referenced by bbtk::WxGUIPackageBrowser2::RebuildList().

00128   {
00129     if (GetColumnCount()!=3)
00130       {
00131         InsertColumn( 0, _("Package"), 
00132                       wxLIST_FORMAT_LEFT, 60  ); 
00133         InsertColumn( 1, _("Box"), 
00134                       wxLIST_FORMAT_LEFT, 200 ); 
00135         InsertColumn( 2, _("Description"), 
00136                       wxLIST_FORMAT_LEFT, 500  ); 
00137       }
00138     
00139     wxListItem kNewItem;
00140     kNewItem.SetAlign(wxLIST_FORMAT_LEFT);
00141     
00142     int nID = this->GetItemCount();
00143     kNewItem.SetId(nID);
00144     kNewItem.SetMask(wxLIST_MASK_DATA);
00145     // TO DO : STORE SMART POINTER ?
00146     kNewItem.SetData(d.get());  
00147     //    BlackBoxDescriptor::Pointer* d2 = (BlackBoxDescriptor::Pointer*)kNewItem.GetData();
00148     //    std::cout << "Descr = "<<d<<" = "<<d2<<std::endl;
00149     this->InsertItem(kNewItem);
00150     this->SetItem(nID, 0, std2wx(d->GetPackage()->GetName()) );
00151     this->SetItem(nID, 1, std2wx(d->GetTypeName()) );
00152     this->SetItem(nID, 2, std2wx(d->GetDescription()) );
00153     
00154     /*
00155       if (nID % 2)
00156       {
00157       kNewItem.SetBackgroundColour(wxColour(192,192,192));
00158       this->SetItem(kNewItem);
00159       }
00160     */
00161     
00162   }

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::WxGUIBlackBoxList::OnColClick ( wxListEvent &  event  ) 

Definition at line 181 of file bbtkWxGUIPackageBrowser2.cxx.

References SetColumnImage().

00182   {
00183     int col = event.GetColumn();
00184 
00185     // set or unset image
00186     static bool x = false;
00187     x = !x;
00188     SetColumnImage(col, x ? 0 : -1);
00189 
00190     //    wxLogMessage( wxT("OnColumnClick at %d."), col );
00191   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnColRightClick ( wxListEvent &  event  ) 

Definition at line 193 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and SetColumnImage().

00194   {
00195     int col = event.GetColumn();
00196     if ( col != -1 )
00197       {
00198         SetColumnImage(col, -1);
00199       }
00200 
00201     // Show popupmenu at position
00202     wxMenu menu(wxT("Test"));
00203     menu.Append(-1, _T("&About"));
00204     PopupMenu(&menu, event.GetPoint());
00205 
00206     //wxLogMessage( wxT("OnColumnRightClick at %d."), event.GetColumn() );
00207   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnColBeginDrag ( wxListEvent &  event  ) 

Definition at line 222 of file bbtkWxGUIPackageBrowser2.cxx.

References LogColEvent().

00223   {
00224     LogColEvent( event, wxT("OnColBeginDrag") );
00225     /*
00226       if ( event.GetColumn() == 0 )
00227       {
00228       //wxLogMessage(_T("Resizing this column shouldn't work."));
00229 
00230       event.Veto();
00231       }
00232     */
00233   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnColDragging ( wxListEvent &  event  ) 

Definition at line 235 of file bbtkWxGUIPackageBrowser2.cxx.

References LogColEvent().

00236   {
00237     LogColEvent( event, wxT("OnColDragging") );
00238   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnColEndDrag ( wxListEvent &  event  ) 

Definition at line 240 of file bbtkWxGUIPackageBrowser2.cxx.

References LogColEvent().

00241   {
00242     LogColEvent( event, wxT("OnColEndDrag") );
00243   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnBeginDrag ( wxListEvent &  event  ) 

Definition at line 245 of file bbtkWxGUIPackageBrowser2.cxx.

00246   {
00247     //    const wxPoint& pt = event.m_pointDrag;
00248 
00249     //wxLogMessage( wxT("OnBeginDrag at (%d, %d), item %ld."),
00250     //          pt.x, pt.y, HitTest(pt, flags) );
00251   }

void bbtk::WxGUIBlackBoxList::OnBeginRDrag ( wxListEvent &  event  ) 

Definition at line 253 of file bbtkWxGUIPackageBrowser2.cxx.

00254   {
00255     //wxLogMessage( wxT("OnBeginRDrag at %d,%d."),
00256     //        event.m_pointDrag.x, event.m_pointDrag.y );
00257   }

void bbtk::WxGUIBlackBoxList::OnBeginLabelEdit ( wxListEvent &  event  ) 

Definition at line 259 of file bbtkWxGUIPackageBrowser2.cxx.

00260   {
00261     //wxLogMessage( wxT("OnBeginLabelEdit: %s"), event.m_item.m_text.c_str());
00262   }

void bbtk::WxGUIBlackBoxList::OnEndLabelEdit ( wxListEvent &  event  ) 

Definition at line 264 of file bbtkWxGUIPackageBrowser2.cxx.

00265   {
00266     //wxLogMessage( wxT("OnEndLabelEdit: %s"),
00267     //        event.IsEditCancelled() ? _T("[cancelled]")
00268     //                                      : event.m_item.m_text.c_str());
00269   }

void bbtk::WxGUIBlackBoxList::OnDeleteItem ( wxListEvent &  event  ) 

Definition at line 271 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00272   {
00273     LogEvent(event, _T("OnDeleteItem"));
00274     std::cout << "cannot del"<<std::endl;
00275     event.Veto();
00276     //wxLogMessage( wxT("Number of items when delete event is sent: %d"), GetItemCount() );
00277   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnDeleteAllItems ( wxListEvent &  event  ) 

Definition at line 279 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00280   {
00281     LogEvent(event, _T("OnDeleteAllItems"));
00282     event.Veto();
00283   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnSelected ( wxListEvent &  event  ) 

Definition at line 320 of file bbtkWxGUIPackageBrowser2.cxx.

References mUser, and bbtk::WxGUIBlackBoxListUser::WxGUIBlackBoxListUserOnSelected().

00321   {
00322     if (mUser==0) return;
00323 
00324     wxListItem info;
00325     info.m_itemId = event.m_itemIndex;
00326     info.m_col = 0;
00327     info.m_mask = wxLIST_MASK_DATA;
00328     if ( GetItem(info) )
00329       {
00330         // TO DO : STORE SMART PTR ?
00331         BlackBoxDescriptor* d = (BlackBoxDescriptor*)(info.GetData());
00332         if (d!=0) mUser->WxGUIBlackBoxListUserOnSelected(d);
00333       }
00334     else
00335       {
00336         wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed"));
00337       }
00338   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnDeselected ( wxListEvent &  event  ) 

Definition at line 340 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00341   {
00342     LogEvent(event, _T("OnDeselected"));
00343   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnListKeyDown ( wxListEvent &  event  ) 

Definition at line 357 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00358   {
00359     long item;
00360 
00361     switch ( event.GetKeyCode() )
00362       {
00363       case 'c': // colorize
00364       case 'C':
00365         {
00366           wxListItem info;
00367           info.m_itemId = event.GetIndex();
00368           if ( info.m_itemId == -1 )
00369             {
00370               // no item
00371               break;
00372             }
00373 
00374           GetItem(info);
00375 
00376           wxListItemAttr *attr = info.GetAttributes();
00377           if ( !attr || !attr->HasTextColour() )
00378             {
00379               info.SetTextColour(*wxCYAN);
00380 
00381               SetItem(info);
00382 
00383               RefreshItem(info.m_itemId);
00384             }
00385         }
00386         break;
00387 
00388       case 'n': // next
00389       case 'N':
00390         item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
00391         if ( item++ == GetItemCount() - 1 )
00392           {
00393             item = 0;
00394           }
00395 
00396         //wxLogMessage(_T("Focusing item %ld"), item);
00397 
00398         SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
00399         EnsureVisible(item);
00400         break;
00401 
00402       case 'r': // show bounding Rect
00403       case 'R':
00404         {
00405           item = event.GetIndex();
00406           wxRect r;
00407           if ( !GetItemRect(item, r) )
00408             {
00409               //wxLogError(_T("Failed to retrieve rect of item %ld"), item);
00410               break;
00411             }
00412 
00413           //wxLogMessage(_T("Bounding rect of item %ld is (%d, %d)-(%d, %d)"),
00414           //   item, r.x, r.y, r.x + r.width, r.y + r.height);
00415         }
00416         break;
00417 
00418       case WXK_DELETE:
00419         item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
00420         /*
00421           while ( item != -1 )
00422           {
00423           DeleteItem(item);
00424 
00425           //wxLogMessage(_T("Item %ld deleted"), item);
00426 
00427           // -1 because the indices were shifted by DeleteItem()
00428           item = GetNextItem(item - 1,
00429           wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
00430           }
00431         */
00432         break;
00433 
00434       case WXK_INSERT:
00435         if ( GetWindowStyle() & wxLC_REPORT )
00436           {
00437             if ( GetWindowStyle() & wxLC_VIRTUAL )
00438               {
00439                 SetItemCount(GetItemCount() + 1);
00440               }
00441             else // !virtual
00442               {
00443                 //InsertItemInReportView(event.GetIndex());
00444               }
00445           }
00446         //else: fall through
00447 
00448       default:
00449         LogEvent(event, _T("OnListKeyDown"));
00450 
00451         event.Skip();
00452       }
00453   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnActivated ( wxListEvent &  event  ) 

Definition at line 345 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00346   {
00347     LogEvent(event, _T("OnActivated"));
00348   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnFocused ( wxListEvent &  event  ) 

Definition at line 350 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00351   {
00352     LogEvent(event, _T("OnFocused"));
00353 
00354     event.Skip();
00355   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnCacheHint ( wxListEvent &  event  ) 

Definition at line 165 of file bbtkWxGUIPackageBrowser2.cxx.

00166   {
00167     //wxLogMessage( wxT("OnCacheHint: cache items %ld..%ld"),
00168     //                  event.GetCacheFrom(), event.GetCacheTo() );
00169   }

void bbtk::WxGUIBlackBoxList::OnChar ( wxKeyEvent &  event  ) 

Definition at line 455 of file bbtkWxGUIPackageBrowser2.cxx.

00456   {
00457     //wxLogMessage(_T("Got char event."));
00458 
00459     switch ( event.GetKeyCode() )
00460       {
00461       case 'n':
00462       case 'N':
00463       case 'c':
00464       case 'C':
00465         // these are the keys we process ourselves
00466         break;
00467 
00468       default:
00469         event.Skip();
00470       }
00471   }

void bbtk::WxGUIBlackBoxList::OnContextMenu ( wxContextMenuEvent &  event  ) 

Definition at line 543 of file bbtkWxGUIPackageBrowser2.cxx.

References ShowContextMenu().

00544   {
00545     wxPoint point = event.GetPosition();
00546     // If from keyboard
00547     if (point.x == -1 && point.y == -1) {
00548       wxSize size = GetSize();
00549       point.x = size.x / 2;
00550       point.y = size.y / 2;
00551     } else {
00552       point = ScreenToClient(point);
00553     }
00554     ShowContextMenu(point);
00555   }

Here is the call graph for this function:

void bbtk::WxGUIBlackBoxList::OnRightClick ( wxMouseEvent &  event  ) 

Definition at line 473 of file bbtkWxGUIPackageBrowser2.cxx.

References _T.

00474   {
00475     if ( !event.ControlDown() )
00476       {
00477         event.Skip();
00478         return;
00479       }
00480 
00481     int flags;
00482     long subitem;
00483     //    long item = 
00484     HitTest(event.GetPosition(), flags, &subitem);
00485 
00486     wxString where;
00487     switch ( flags )
00488       {
00489       case wxLIST_HITTEST_ABOVE: where = _T("above"); break;
00490       case wxLIST_HITTEST_BELOW: where = _T("below"); break;
00491       case wxLIST_HITTEST_NOWHERE: where = _T("nowhere near"); break;
00492       case wxLIST_HITTEST_ONITEMICON: where = _T("on icon of"); break;
00493       case wxLIST_HITTEST_ONITEMLABEL: where = _T("on label of"); break;
00494       case wxLIST_HITTEST_ONITEMRIGHT: where = _T("right on"); break;
00495       case wxLIST_HITTEST_TOLEFT: where = _T("to the left of"); break;
00496       case wxLIST_HITTEST_TORIGHT: where = _T("to the right of"); break;
00497       default: where = _T("not clear exactly where on"); break;
00498       }
00499 
00500     //wxLogMessage(_T("Right double click %s item %ld, subitem %ld"),
00501     //             where.c_str(), item, subitem);
00502   }

void bbtk::WxGUIBlackBoxList::ShowContextMenu ( const wxPoint &  pos  )  [private]

Definition at line 558 of file bbtkWxGUIPackageBrowser2.cxx.

References _T.

Referenced by OnContextMenu().

00559   {
00560     wxMenu menu;
00561   
00562     menu.Append(wxID_ABOUT, _T("&About"));
00563     menu.AppendSeparator();
00564     menu.Append(wxID_EXIT, _T("E&xit"));
00565   
00566     PopupMenu(&menu, pos.x, pos.y);
00567   }

Here is the caller graph for this function:

void bbtk::WxGUIBlackBoxList::SetColumnImage ( int  col,
int  image 
) [private]

Definition at line 171 of file bbtkWxGUIPackageBrowser2.cxx.

Referenced by OnColClick(), and OnColRightClick().

00172   {
00173     /*
00174       wxListItem item;
00175       item.SetMask(wxLIST_MASK_IMAGE);
00176       item.SetImage(image);
00177       SetColumn(col, item);
00178     */
00179   }

Here is the caller graph for this function:

void bbtk::WxGUIBlackBoxList::LogEvent ( const wxListEvent &  event,
const wxChar *  eventName 
) [private]

Definition at line 504 of file bbtkWxGUIPackageBrowser2.cxx.

Referenced by OnActivated(), OnDeleteAllItems(), OnDeleteItem(), OnDeselected(), OnFocused(), and OnListKeyDown().

00505   {
00506     //wxLogMessage(_T("Item %ld: %s (item text = %s, data = %ld)"),
00507     //            event.GetIndex(), eventName,
00508     //              event.GetText().c_str(), event.GetData());
00509   }

Here is the caller graph for this function:

void bbtk::WxGUIBlackBoxList::LogColEvent ( const wxListEvent &  event,
const wxChar *  eventName 
) [private]

Definition at line 209 of file bbtkWxGUIPackageBrowser2.cxx.

Referenced by OnColBeginDrag(), OnColDragging(), and OnColEndDrag().

00210   {
00211     //    const int col = event.GetColumn();
00212 
00213     /*
00214       wxLogMessage(wxT("%s: column %d (width = %d or %d)."),
00215       name,
00216       col,
00217       event.GetItem().GetWidth(),
00218       GetColumnWidth(col));
00219     */
00220   }

Here is the caller graph for this function:

wxString bbtk::WxGUIBlackBoxList::OnGetItemText ( long  item,
long  column 
) const [private, virtual]

Definition at line 511 of file bbtkWxGUIPackageBrowser2.cxx.

References _T.

00512   {
00513     /*
00514       if ( GetItemCount() == WXSIZEOF(SMALL_VIRTUAL_VIEW_ITEMS) )
00515       {
00516       return SMALL_VIRTUAL_VIEW_ITEMS[item][column];
00517       }
00518       else
00519       {
00520     */
00521     return wxString::Format(_T("Column %ld of item %ld"), column, item);
00522     //  }
00523   }

int bbtk::WxGUIBlackBoxList::OnGetItemColumnImage ( long  item,
long  column 
) const [private, virtual]

Definition at line 525 of file bbtkWxGUIPackageBrowser2.cxx.

00526   {
00527     if (!column)
00528       return 0;
00529 
00530     if (!(item %3) && column == 1)
00531       return 0;
00532 
00533     return -1;
00534   }

wxListItemAttr * bbtk::WxGUIBlackBoxList::OnGetItemAttr ( long  item  )  const [private, virtual]

Definition at line 536 of file bbtkWxGUIPackageBrowser2.cxx.

References m_attr.

00537   {
00538     return item % 2 ? NULL : (wxListItemAttr *)&m_attr;
00539   }


Member Data Documentation

WxGUIBlackBoxListUser* bbtk::WxGUIBlackBoxList::mUser [private]

Definition at line 182 of file bbtkWxGUIPackageBrowser2.h.

Referenced by OnSelected(), and SetUser().

wxListItemAttr bbtk::WxGUIBlackBoxList::m_attr [private]

Definition at line 184 of file bbtkWxGUIPackageBrowser2.h.

Referenced by OnGetItemAttr().


The documentation for this class was generated from the following files:

Generated on Wed Nov 12 11:38:59 2008 for BBTK by  doxygen 1.5.6