File: php_open_resource_dlg.h

package info (click to toggle)
codelite 12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 95,112 kB
  • sloc: cpp: 424,040; ansic: 18,284; php: 9,569; lex: 4,186; yacc: 2,820; python: 2,294; sh: 312; makefile: 51; xml: 13
file content (141 lines) | stat: -rw-r--r-- 4,666 bytes parent folder | download | duplicates (2)
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
139
140
141
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// Copyright            : (C) 2015 Eran Ifrah
// File name            : php_open_resource_dlg.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 __php_open_resource_dlg__
#define __php_open_resource_dlg__

#include "php_ui.h"
#include <vector>
#include "PHPEntityVariable.h"
#include "PHPEntityBase.h"
#include "PHPLookupTable.h"
#include "bitmap_loader.h"

struct ResourceItem {
    enum { kRI_Invalid = -1, kRI_File, kRI_Class, kRI_Constant, kRI_Function, kRI_Member, kRI_Variable, kRI_Namespace };
    wxString displayName;
    wxFileName filename;
    int line;
    int type;

    ResourceItem()
        : line(0)
        , type(kRI_Invalid)
    {
    }

    void SetType(PHPEntityBase::Ptr_t match)
    {
        if(match->Is(kEntityTypeClass)) {
            type = kRI_Class;
        } else if(match->Is(kEntityTypeFunction)) {
            type = kRI_Function;
        } else if(match->Is(kEntityTypeVariable)) {
            if(match->Cast<PHPEntityVariable>()->IsConst()) {
                type = kRI_Constant;
            } else if(match->Cast<PHPEntityVariable>()->IsMember()) {
                type = kRI_Member;
            } else {
                type = kRI_Variable;
            }
        } else if(match->Is(kEntityTypeNamespace)) {
            type = kRI_Namespace;
        }
    }

    wxString TypeAsString() const
    {
        switch(type) {
        case ResourceItem::kRI_Namespace:
            return "Namespace";
        case ResourceItem::kRI_Class:
            return "Class";
        case ResourceItem::kRI_Constant:
            return "Constant";
        case ResourceItem::kRI_File:
            return "File";
        case ResourceItem::kRI_Function:
            return "Function";
        case ResourceItem::kRI_Member:
            return "Member";
        case ResourceItem::kRI_Invalid:
            return "Invalid";
        default:
        case ResourceItem::kRI_Variable:
            return "Variable";
        }
    }
};

typedef std::vector<ResourceItem> ResourceVector_t;

class IManager;
class OpenResourceDlg : public OpenResourceDlgBase
{
public:
    wxString m_lastFilter;
    IManager* m_mgr;
    wxTimer* m_timer;
    ResourceVector_t m_allFiles;
    ResourceVector_t m_resources;
    ResourceItem* m_selectedItem;
    PHPLookupTable m_table;
    BitmapLoader::BitmapMap_t m_fileImages;

protected:
    virtual void OnDVItemActivated(wxDataViewEvent& event);

    bool IsMatchesFilter(const wxString& filter, const wxString& key);
    ResourceVector_t DoGetFiles(const wxString& filter);
    void DoGetResources(const wxString& filter);
    ResourceItem* DoGetItemData(const wxDataViewItem& item);
    wxBitmap DoGetImgIdx(const ResourceItem* item);

protected:
    void DoSelectNext();
    void DoSelectPrev();
    void DoInitialize();
    void DoPopulateListCtrl(const ResourceVector_t& items);

protected:
    // Handlers for OpenResourceDlgBase events.
    void OnFilterEnter(wxCommandEvent& event);
    void OnFilterText(wxCommandEvent& event);
    void OnKeyDown(wxKeyEvent& event);

    DECLARE_EVENT_TABLE()
    void OnTimer(wxTimerEvent& event);

public:
    /** Constructor */
    OpenResourceDlg(wxWindow* parent, IManager* manager);
    OpenResourceDlg(wxWindow* parent, const ResourceVector_t& items, IManager* manager);
    virtual ~OpenResourceDlg();

    void SetSelectedItem(ResourceItem* selectedItem) { this->m_selectedItem = selectedItem; }
    ResourceItem* GetSelectedItem() { return m_selectedItem; }
};

#endif // __php_open_resource_dlg__