1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : cc_box.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef __cc_box__
#define __cc_box__
/**
@file
Subclass of CCBoxBase, which is generated by wxFormBuilder.
*/
#include "cc_boxbase.h"
#include "comment_parser.h"
#include "entry.h"
#include <vector>
#include <map>
#include <wx/timer.h>
#include <wx/spinbutt.h>
extern const wxEventType wxCMD_EVENT_SET_EDITOR_ACTIVE;
// A custom event sent by the CodeCompletionBox class
// to make sure that any zombies instances are released
extern const wxEventType wxCMD_EVENT_DISMISS_CC_BOX;
class LEditor;
class CCBoxTipWindow;
/** Implementing CCBoxBase */
class CCBox : public CCBoxBase
{
int m_selectedItem;
std::vector<TagEntryPtr> m_tags;
bool m_showFullDecl;
int m_height;
bool m_autoHide;
bool m_insertSingleChoice;
std::map<wxString, int> m_userImages;
wxEvtHandler* m_owner;
bool m_constructing;
bool m_hideExtInfoPane;
CommentParseResult m_comments;
int m_startPos;
bool m_isTipBgDark;
CCItemInfo m_currentItem;
LEditor* m_editor;
wxTimer* m_refreshListTimer;
wxTimer* m_tipTimer;
bool m_isKeywordsList;
CCBoxTipWindow* m_tipWindow;
wxString m_initialWord;
bool m_displayingFileList;
public:
void OnTipClickedDown(wxCommandEvent& event);
void OnTipClickedUp(wxCommandEvent& event);
protected:
// Handlers for CCBoxBase events.
void OnItemActivated(wxListEvent& event);
void OnItemDeSelected(wxListEvent& event);
void OnItemSelected(wxListEvent& event);
void OnClose(wxCommandEvent& e);
void OnDisplayTooltip(wxTimerEvent& event);
void OnRefreshList(wxTimerEvent& event);
void Display(LEditor* editor);
void SortTags(std::vector<CCItemInfo>& tags, const wxString& userTyped);
protected:
// helper methods
int GetImageId(TagEntryPtr entry);
void SelectItem(long item);
void PostSelectItem(long item);
void Show(const wxString& word);
void DoInsertSelection(const wxString& word, bool triggerTip = true);
void DoFormatDescriptionPage(const CCItemInfo& tag);
void DoShowTagTip();
void DoFilterCompletionEntries(CCItemInfo& item);
public:
/** Constructor */
CCBox(LEditor* parent, bool autoHide = true, bool autoInsertSingleChoice = true);
virtual ~CCBox();
void HideCCBox();
void Show(const TagEntryPtrVector_t& tags, const wxString& word, bool isKeywordsList, wxEvtHandler* owner = NULL);
void InsertSelection();
// can this window have focus? (no)
bool AcceptsFocus() const { return false; }
void OnDismiss();
bool SelectWord(const wxString& word);
void Next();
void Previous();
// Setters
void SetAutoHide(const bool& autoHide) { this->m_autoHide = autoHide; }
void SetInsertSingleChoice(const bool& insertSingleChoice) { this->m_insertSingleChoice = insertSingleChoice; }
// Getters
const bool& GetAutoHide() const { return m_autoHide; }
const bool& GetInsertSingleChoice() const { return m_insertSingleChoice; }
/**
* @brief register new user image fot TagEntry kind
* @param kind the kind string that will be associated with the bitmap (TagEntry::GetKind())
* @param bmp 16x16 bitmap
*/
void RegisterImageForKind(const wxString& kind, const wxBitmap& bmp);
void NextPage();
void PreviousPage();
void SetEditor(LEditor* editor) { this->m_editor = editor; }
LEditor* GetEditor() { return m_editor; }
};
#endif // __cc_box__
|