bbtk::WxGUIBlackBoxList Class Reference

#include <bbtkWxGUIPackageBrowser2.h>

Collaboration diagram for bbtk::WxGUIBlackBoxList:

Collaboration graph
[legend]

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 127 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::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, 90  );
00133         InsertColumn( 1, _("Box"),
00134                       wxLIST_FORMAT_LEFT, 150 );
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   }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 208 of file bbtkWxGUIPackageBrowser2.cxx.

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

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

Here is the caller graph for this function:

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

Definition at line 529 of file bbtkWxGUIPackageBrowser2.cxx.

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

00530   {
00531     //wxLogMessage(_T("Item %ld: %s (item text = %s, data = %ld)"),
00532     //            event.GetIndex(), eventName,
00533     //              event.GetText().c_str(), event.GetData());
00534   }

Here is the caller graph for this function:

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

Definition at line 370 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00371   {
00372     LogEvent(event, _T("OnActivated"));
00373   }

Here is the call graph for this function:

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

Definition at line 244 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, bbtk::BlackBoxDescriptor::GetFullTypeName(), and bbtk::std2wx().

00245   {
00246           std::cout<<"RaC DRAG TABLE"<<std::endl;
00247 
00248           wxString text(this->GetItemText(event.GetIndex()));
00249           wxListItem info;
00250           info.m_itemId = event.m_itemIndex;
00251           info.m_col = 0;
00252           info.m_mask = wxLIST_MASK_DATA;
00253           wxString sendtext(_T(""));
00254           if ( GetItem(info) )
00255           {
00256                   // TO DO : STORE SMART PTR ?
00257                   BlackBoxDescriptor* d = (BlackBoxDescriptor*)(info.GetData());
00258                   if (d!=0)
00259                   {
00260                           sendtext += crea::std2wx(d->GetFullTypeName());
00261                   }
00262           }
00263           else
00264           {
00265                   wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed"));
00266           }
00267 
00268           wxTextDataObject tdo(sendtext);
00269           wxDropSource tds(tdo, this);
00270           tds.DoDragDrop();
00271 
00272     //    const wxPoint& pt = event.m_pointDrag;
00273 
00274     //wxLogMessage( wxT("OnBeginDrag at (%d, %d), item %ld."),
00275     //          pt.x, pt.y, HitTest(pt, flags) );
00276   }

Here is the call graph for this function:

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

Definition at line 284 of file bbtkWxGUIPackageBrowser2.cxx.

00285   {
00286     //wxLogMessage( wxT("OnBeginLabelEdit: %s"), event.m_item.m_text.c_str());
00287   }

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

Definition at line 278 of file bbtkWxGUIPackageBrowser2.cxx.

00279   {
00280     //wxLogMessage( wxT("OnBeginRDrag at %d,%d."),
00281     //        event.m_pointDrag.x, event.m_pointDrag.y );
00282   }

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

Definition at line 164 of file bbtkWxGUIPackageBrowser2.cxx.

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

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

Definition at line 480 of file bbtkWxGUIPackageBrowser2.cxx.

00481   {
00482     //wxLogMessage(_T("Got char event."));
00483 
00484     switch ( event.GetKeyCode() )
00485       {
00486       case 'n':
00487       case 'N':
00488       case 'c':
00489       case 'C':
00490         // these are the keys we process ourselves
00491         break;
00492 
00493       default:
00494         event.Skip();
00495       }
00496   }

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

Definition at line 221 of file bbtkWxGUIPackageBrowser2.cxx.

References LogColEvent().

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

Here is the call graph for this function:

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

Definition at line 180 of file bbtkWxGUIPackageBrowser2.cxx.

References SetColumnImage().

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

Here is the call graph for this function:

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

Definition at line 234 of file bbtkWxGUIPackageBrowser2.cxx.

References LogColEvent().

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

Here is the call graph for this function:

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

Definition at line 239 of file bbtkWxGUIPackageBrowser2.cxx.

References LogColEvent().

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

Here is the call graph for this function:

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

Definition at line 192 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and SetColumnImage().

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

Here is the call graph for this function:

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

Definition at line 568 of file bbtkWxGUIPackageBrowser2.cxx.

References ShowContextMenu().

00569   {
00570     wxPoint point = event.GetPosition();
00571     // If from keyboard
00572     if (point.x == -1 && point.y == -1) {
00573       wxSize size = GetSize();
00574       point.x = size.x / 2;
00575       point.y = size.y / 2;
00576     } else {
00577       point = ScreenToClient(point);
00578     }
00579     ShowContextMenu(point);
00580   }

Here is the call graph for this function:

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

Definition at line 304 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00305   {
00306     LogEvent(event, _T("OnDeleteAllItems"));
00307     event.Veto();
00308   }

Here is the call graph for this function:

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

Definition at line 296 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00297   {
00298     LogEvent(event, _T("OnDeleteItem"));
00299     std::cout << "cannot del"<<std::endl;
00300     event.Veto();
00301     //wxLogMessage( wxT("Number of items when delete event is sent: %d"), GetItemCount() );
00302   }

Here is the call graph for this function:

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

Definition at line 365 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00366   {
00367     LogEvent(event, _T("OnDeselected"));
00368   }

Here is the call graph for this function:

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

Definition at line 289 of file bbtkWxGUIPackageBrowser2.cxx.

00290   {
00291     //wxLogMessage( wxT("OnEndLabelEdit: %s"),
00292     //        event.IsEditCancelled() ? _T("[cancelled]")
00293     //                                      : event.m_item.m_text.c_str());
00294   }

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

Definition at line 375 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00376   {
00377     LogEvent(event, _T("OnFocused"));
00378 
00379     event.Skip();
00380   }

Here is the call graph for this function:

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

Definition at line 561 of file bbtkWxGUIPackageBrowser2.cxx.

References m_attr.

00562   {
00563     return item % 2 ? NULL : (wxListItemAttr *)&m_attr;
00564   }

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

Definition at line 550 of file bbtkWxGUIPackageBrowser2.cxx.

00551   {
00552     if (!column)
00553       return 0;
00554 
00555     if (!(item %3) && column == 1)
00556       return 0;
00557 
00558     return -1;
00559   }

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

Definition at line 536 of file bbtkWxGUIPackageBrowser2.cxx.

References _T.

00537   {
00538     /*
00539       if ( GetItemCount() == WXSIZEOF(SMALL_VIRTUAL_VIEW_ITEMS) )
00540       {
00541       return SMALL_VIRTUAL_VIEW_ITEMS[item][column];
00542       }
00543       else
00544       {
00545     */
00546     return wxString::Format(_T("Column %ld of item %ld"), column, item);
00547     //  }
00548   }

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

Definition at line 382 of file bbtkWxGUIPackageBrowser2.cxx.

References _T, and LogEvent().

00383   {
00384     long item;
00385 
00386     switch ( event.GetKeyCode() )
00387       {
00388       case 'c': // colorize
00389       case 'C':
00390         {
00391           wxListItem info;
00392           info.m_itemId = event.GetIndex();
00393           if ( info.m_itemId == -1 )
00394             {
00395               // no item
00396               break;
00397             }
00398 
00399           GetItem(info);
00400 
00401           wxListItemAttr *attr = info.GetAttributes();
00402           if ( !attr || !attr->HasTextColour() )
00403             {
00404               info.SetTextColour(*wxCYAN);
00405 
00406               SetItem(info);
00407 
00408               RefreshItem(info.m_itemId);
00409             }
00410         }
00411         break;
00412 
00413       case 'n': // next
00414       case 'N':
00415         item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
00416         if ( item++ == GetItemCount() - 1 )
00417           {
00418             item = 0;
00419           }
00420 
00421         //wxLogMessage(_T("Focusing item %ld"), item);
00422 
00423         SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
00424         EnsureVisible(item);
00425         break;
00426 
00427       case 'r': // show bounding Rect
00428       case 'R':
00429         {
00430           item = event.GetIndex();
00431           wxRect r;
00432           if ( !GetItemRect(item, r) )
00433             {
00434               //wxLogError(_T("Failed to retrieve rect of item %ld"), item);
00435               break;
00436             }
00437 
00438           //wxLogMessage(_T("Bounding rect of item %ld is (%d, %d)-(%d, %d)"),
00439           //   item, r.x, r.y, r.x + r.width, r.y + r.height);
00440         }
00441         break;
00442 
00443       case WXK_DELETE:
00444         item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
00445         /*
00446           while ( item != -1 )
00447           {
00448           DeleteItem(item);
00449 
00450           //wxLogMessage(_T("Item %ld deleted"), item);
00451 
00452           // -1 because the indices were shifted by DeleteItem()
00453           item = GetNextItem(item - 1,
00454           wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
00455           }
00456         */
00457         break;
00458 
00459       case WXK_INSERT:
00460         if ( GetWindowStyle() & wxLC_REPORT )
00461           {
00462             if ( GetWindowStyle() & wxLC_VIRTUAL )
00463               {
00464                 SetItemCount(GetItemCount() + 1);
00465               }
00466             else // !virtual
00467               {
00468                 //InsertItemInReportView(event.GetIndex());
00469               }
00470           }
00471         //else: fall through
00472 
00473       default:
00474         LogEvent(event, _T("OnListKeyDown"));
00475 
00476         event.Skip();
00477       }
00478   }

Here is the call graph for this function:

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

Definition at line 498 of file bbtkWxGUIPackageBrowser2.cxx.

References _T.

00499   {
00500     if ( !event.ControlDown() )
00501       {
00502         event.Skip();
00503         return;
00504       }
00505 
00506     int flags;
00507     long subitem;
00508     //    long item =
00509     HitTest(event.GetPosition(), flags, &subitem);
00510 
00511     wxString where;
00512     switch ( flags )
00513       {
00514       case wxLIST_HITTEST_ABOVE:       where = _T("above");           break;
00515       case wxLIST_HITTEST_BELOW:       where = _T("below");           break;
00516       case wxLIST_HITTEST_NOWHERE:     where = _T("nowhere near");    break;
00517       case wxLIST_HITTEST_ONITEMICON:  where = _T("on icon of");      break;
00518       case wxLIST_HITTEST_ONITEMLABEL: where = _T("on label of");     break;
00519       case wxLIST_HITTEST_ONITEMRIGHT: where = _T("right on");        break;
00520       case wxLIST_HITTEST_TOLEFT:      where = _T("to the left of");  break;
00521       case wxLIST_HITTEST_TORIGHT:     where = _T("to the right of"); break;
00522       default: where = _T("not clear exactly where on");              break;
00523       }
00524 
00525     //wxLogMessage(_T("Right double click %s item %ld, subitem %ld"),
00526     //             where.c_str(), item, subitem);
00527   }

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

Definition at line 345 of file bbtkWxGUIPackageBrowser2.cxx.

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

00346   {
00347     if (mUser==0) return;
00348 
00349     wxListItem info;
00350     info.m_itemId = event.m_itemIndex;
00351     info.m_col = 0;
00352     info.m_mask = wxLIST_MASK_DATA;
00353     if ( GetItem(info) )
00354       {
00355         // TO DO : STORE SMART PTR ?
00356         BlackBoxDescriptor* d = (BlackBoxDescriptor*)(info.GetData());
00357         if (d!=0) mUser->WxGUIBlackBoxListUserOnSelected(d);
00358       }
00359     else
00360       {
00361         wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed"));
00362       }
00363   }

Here is the call graph for this function:

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

Definition at line 170 of file bbtkWxGUIPackageBrowser2.cxx.

Referenced by OnColClick(), and OnColRightClick().

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

Here is the caller graph for this function:

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

Definition at line 137 of file bbtkWxGUIPackageBrowser2.h.

References mUser.

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

00137 { mUser = u; }

Here is the caller graph for this function:

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

Definition at line 583 of file bbtkWxGUIPackageBrowser2.cxx.

References _T.

Referenced by OnContextMenu().

00584   {
00585     wxMenu menu;
00586 
00587     menu.Append(wxID_ABOUT, _T("&About"));
00588     menu.AppendSeparator();
00589     menu.Append(wxID_EXIT, _T("E&xit"));
00590 
00591     PopupMenu(&menu, pos.x, pos.y);
00592   }

Here is the caller graph for this function:


Member Data Documentation

wxListItemAttr bbtk::WxGUIBlackBoxList::m_attr [private]

Definition at line 187 of file bbtkWxGUIPackageBrowser2.h.

Referenced by OnGetItemAttr().

Definition at line 185 of file bbtkWxGUIPackageBrowser2.h.

Referenced by OnSelected(), and SetUser().


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

Generated on Thu May 31 14:15:26 2012 for BBTK by  doxygen 1.5.7.1