5 skipped lines |
|
|
|
9 | | #include <wx/wx.h> | | 9 | | #include "wx/wx.h" |
10 | | #include <wx/encconv.h> | | 10 | | #include "wx/encconv.h" |
11 | | #include <wx/listctrl.h> | | 11 | | #include "wx/listctrl.h" |
12 | | #include <wx/mstream.h> | | 12 | | #include "wx/mstream.h" |
13 | | #include <wx/image.h> | | 13 | | #include "wx/image.h" |
14 | | #include <wx/imaglist.h> | | 14 | | #include "wx/imaglist.h" |
| | 15 | | #include "wx/tokenzr.h" |
|
16 | | 17 | | #include "Platform.h" |
|
17 | | 18 | | #include "PlatWX.h" |
|
89 skipped lines |
107 | | 108 | | // so we adjust the encoding before passing it to Scintilla. See also |
|
108 | | 109 | | // wxStyledTextCtrl::StyleSetCharacterSet |
|
109 | | 110 | | wxFontEncoding encoding = (wxFontEncoding)(characterSet-1); |
|
110 | | | | 111 | | |
111 | | 112 | | wxFontEncodingArray ea = wxEncodingConverter::GetPlatformEquivalents(encoding); |
|
112 | | 113 | | if (ea.GetCount()) |
|
113 | | 114 | | encoding = ea[0]; |
|
487 skipped lines |
|
|
603 | | 604 | | void Window::SetTitle(const char *s) { |
|
604 | | GETWIN(id)->SetTitle(stc2wx(s)); | | 605 | | GETWIN(id)->SetLabel(stc2wx(s)); |
|
|
|
58 skipped lines |
|
|
|
669 | | #if wxUSE_POPUPWIN //----------------------------------- | | 670 | | #if wxUSE_POPUPWIN //----------------------------------- |
670 | | 671 | | #include <wx/popupwin.h> |
|
|
|
3 skipped lines |
676 | | 677 | | // implement wxPopupWindow for the Mac!!) |
|
|
678 | | 679 | | // In the meantime, be careful to duplicate any changes as needed... |
|
679 | | // | | 680 | | // |
680 | | | | 681 | | |
681 | | // A popup window to place the wxSTCListBox upon | | 682 | | // A popup window to place the wxSTCListBox upon |
682 | | 683 | | class wxSTCListBoxWin : public wxPopupWindow |
|
|
|
1 skipped line |
686 | | 687 | | CallBackAction doubleClickAction; |
|
687 | | 688 | | void* doubleClickActionData; |
|
|
689 | | wxSTCListBoxWin(wxWindow* parent, wxWindowID id) : | | 690 | | wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point WXUNUSED(location)) : |
690 | | 691 | | wxPopupWindow(parent, wxBORDER_NONE) |
|
|
692 | | 693 | | SetBackgroundColour(*wxBLACK); // for our simple border |
|
9 skipped lines |
702 | | 703 | | // "right" to the user. But since the wxPopupWindow or its children |
|
703 | | 704 | | // can't receive focus then we have to pull a fast one and temporarily |
|
704 | | 705 | | // parent the listctrl on the STC window and then call SetFocus and |
|
705 | | // then reparent it back to the popup. | | 706 | | // then reparent it back to the popup. |
|
707 | | 708 | | lv->Reparent(this); |
|
|
84 skipped lines |
793 | | 794 | | EVT_LIST_ITEM_ACTIVATED(wxID_ANY, wxSTCListBoxWin::OnActivate) |
|
794 | | 795 | | END_EVENT_TABLE() |
|
|
796 | | | | 797 | | |
|
798 | | 799 | | #else // wxUSE_POPUPWIN ----------------------------------- |
|
|
4 skipped lines |
804 | | 805 | | CallBackAction doubleClickAction; |
|
805 | | 806 | | void* doubleClickActionData; |
|
|
807 | | wxSTCListBoxWin(wxWindow* parent, wxWindowID id) : | | 808 | | wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point location) : |
808 | | wxWindow(parent, id, wxDefaultPosition, wxSize(0,0), wxSIMPLE_BORDER ) | | 809 | | wxWindow(parent, id, wxPoint(location.x, location.y), wxSize(0,0), wxSIMPLE_BORDER ) |
|
|
811 | | 812 | | lv = new wxSTCListBox(this, id, wxDefaultPosition, wxDefaultSize, |
|
69 skipped lines |
|
|
|
884 | | | | 885 | | |
885 | | 886 | | void OnActivate(wxListEvent& WXUNUSED(event)) { |
|
886 | | 887 | | doubleClickAction(doubleClickActionData); |
|
|
30 skipped lines |
918 | | 919 | | bool unicodeMode; |
|
919 | | 920 | | int desiredVisibleRows; |
|
920 | | 921 | | int aveCharWidth; |
|
921 | | int maxStrWidth; | | 922 | | size_t maxStrWidth; |
| | 923 | | Point location; // Caret location at which the list is opened |
922 | | 924 | | wxImageList* imgList; |
|
923 | | 925 | | wxArrayInt* imgTypeMap; |
|
|
2 skipped lines |
|
|
929 | | 931 | | virtual void SetFont(Font &font); |
|
930 | | virtual void Create(Window &parent, int ctrlID, int lineHeight_, bool unicodeMode_); | | 932 | | virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_); |
931 | | 933 | | virtual void SetAverageCharWidth(int width); |
|
932 | | 934 | | virtual void SetVisibleRows(int rows); |
|
| | 935 | | virtual int GetVisibleRows() const; |
933 | | 936 | | virtual PRectangle GetDesiredRect(); |
|
934 | | 937 | | virtual int CaretFromEdge(); |
|
935 | | 938 | | virtual void Clear(); |
|
936 | | 939 | | virtual void Append(char *s, int type = -1); |
|
| | 940 | | void Append(const wxString& text, int type); |
937 | | 941 | | virtual int Length(); |
|
938 | | 942 | | virtual void Select(int n); |
|
939 | | 943 | | virtual int GetSelection(); |
|
2 skipped lines |
942 | | 946 | | virtual void RegisterImage(int type, const char *xpm_data); |
|
943 | | 947 | | virtual void ClearRegisteredImages(); |
|
944 | | 948 | | virtual void SetDoubleClickAction(CallBackAction, void *); |
|
945 | | | | 949 | | virtual void SetList(const char* list, char separator, char typesep); |
|
|
|
21 skipped lines |
|
|
|
973 | | void ListBoxImpl::Create(Window &parent, int ctrlID, int lineHeight_, bool unicodeMode_) { | | 977 | | void ListBoxImpl::Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_) { |
| | 978 | | location = location_; |
974 | | 979 | | lineHeight = lineHeight_; |
|
975 | | 980 | | unicodeMode = unicodeMode_; |
|
|
977 | | id = new wxSTCListBoxWin(GETWIN(parent.GetID()), ctrlID); | | 982 | | id = new wxSTCListBoxWin(GETWIN(parent.GetID()), ctrlID, location); |
978 | | 983 | | if (imgList != NULL) |
|
979 | | 984 | | GETLB(id)->SetImageList(imgList, wxIMAGE_LIST_SMALL); |
|
|
9 skipped lines |
|
|
|
| | 998 | | int ListBoxImpl::GetVisibleRows() const { |
| | 999 | | return desiredVisibleRows; |
| | 1000 | | } |
| | 1001 | | |
993 | | 1002 | | PRectangle ListBoxImpl::GetDesiredRect() { |
|
994 | | 1003 | | // wxListCtrl doesn't have a DoGetBestSize, so instead we kept track of |
|
995 | | 1004 | | // the max size in Append and calculate it here... |
|
996 | | int maxw = maxStrWidth; | | 1005 | | int maxw = maxStrWidth * aveCharWidth; |
|
|
999 | | 1008 | | // give it a default if there are no lines, and/or add a bit more |
|
39 skipped lines |
|
|
1041 | | 1050 | | void ListBoxImpl::Append(char *s, int type) { |
|
1042 | | wxString text = stc2wx(s); | | 1051 | | Append(stc2wx(s), type); |
| | 1052 | | } |
| | 1053 | | |
| | 1054 | | void ListBoxImpl::Append(const wxString& text, int type) { |
1043 | | 1055 | | long count = GETLB(id)->GetItemCount(); |
|
1044 | | 1056 | | long itemID = GETLB(id)->InsertItem(count, wxEmptyString); |
|
1045 | | 1057 | | GETLB(id)->SetItem(itemID, 1, text); |
|
1046 | | int itemWidth = 0; | | |
1047 | | GETLB(id)->GetTextExtent(text, &itemWidth, NULL); | | |
1048 | | maxStrWidth = wxMax(maxStrWidth, itemWidth); | | 1058 | | maxStrWidth = wxMax(maxStrWidth, text.length()); |
1049 | | 1059 | | if (type != -1) { |
|
1050 | | 1060 | | wxCHECK_RET(imgTypeMap, wxT("Unexpected NULL imgTypeMap")); |
|
1051 | | 1061 | | long idx = imgTypeMap->Item(type); |
|
1 skipped line |
|
|
|
| | 1066 | | void ListBoxImpl::SetList(const char* list, char separator, char typesep) { |
| | 1067 | | GETLB(id)->Freeze(); |
| | 1068 | | Clear(); |
| | 1069 | | wxStringTokenizer tkzr(stc2wx(list), (wxChar)separator); |
| | 1070 | | while ( tkzr.HasMoreTokens() ) { |
7 skipped lines |
| | 1078 | | Append(token, (int)type); |
| | 1079 | | } |
| | 1080 | | GETLB(id)->Thaw(); |
| | 1081 | | } |
| | 1082 | | |
|
1057 | | 1084 | | int ListBoxImpl::Length() { |
|
1058 | | 1085 | | return GETLB(id)->GetItemCount(); |
|
74 skipped lines |
|
|
|
1136 | | | | |
1137 | | 1163 | | ListBox::ListBox() { |
|
|
|
230 skipped lines |
|
|
|
1373 | | | | |
1374 | | | | |
1375 | | | | |
1376 | | | | |
1377 | | | | |
1378 | | | | |
|