File: GTKNotebook.hpp

package info (click to toggle)
codelite 17.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 136,204 kB
  • sloc: cpp: 491,547; ansic: 280,393; php: 10,259; sh: 8,930; lisp: 7,664; vhdl: 6,518; python: 6,020; lex: 4,920; yacc: 3,123; perl: 2,385; javascript: 1,715; cs: 1,193; xml: 1,110; makefile: 804; cobol: 741; sql: 709; ruby: 620; f90: 566; ada: 534; asm: 464; fortran: 350; objc: 289; tcl: 258; java: 157; erlang: 61; pascal: 51; ml: 49; awk: 44; haskell: 36
file content (105 lines) | stat: -rw-r--r-- 4,416 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
#ifndef GTKNOTEBOOK_HPP
#define GTKNOTEBOOK_HPP

#include "cl_defs.h"

#ifdef __WXGTK__
#include "bitmap_loader.h"
#include "clTabHistory.h"
#include "clTabRenderer.h"
#include "cl_command_event.h"

#include <gtk/gtk.h>
#include <unordered_map>
#include <wx/menu.h>
#include <wx/notebook.h>

class clGTKNotebook : public wxNotebook
{
protected:
    size_t m_bookStyle = kNotebook_Default;

    struct UserData {
        wxString tooltip;
        int bitmap;
    };
    std::unordered_map<wxWindow*, UserData> m_userData;
    wxMenu* m_tabContextMenu = nullptr;
    clTabHistory::Ptr_t m_history;
    clBitmapList* m_bitmaps = nullptr;

protected:
    void DoFinaliseAddPage(wxWindow* page, const wxString& shortlabel, int bmp);
    bool GetPageDetails(wxWindow* page, int& curindex, wxString& label, int& imageId) const;
    void BindEvents();
    void Initialise(long style);
    void OnPageChanged(wxBookCtrlEvent& e);
    void OnPageChanging(wxBookCtrlEvent& e);
    wxWindow* DoUpdateHistoryPreRemove(wxWindow* page);
    void DoUpdateHistoryPostRemove(wxWindow* page, bool deletedSelection);

public:
    int FindPageByGTKHandle(WXWidget page) const;
    void TabButtonClicked(wxWindow* page);
    void TabReordered();
    void GTKLeftDClick(int index);
    void GTKMiddleDown(int index);
    void GTKRightDown(int index);
    void GTKActionButtonMenuClicked(GtkToolItem* button);
    void GTKActionButtonNewClicked(GtkToolItem* button);

public:
    clGTKNotebook(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
                  const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxNotebookNameStr);
    bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
                const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxNotebookNameStr);
    // dtor
    virtual ~clGTKNotebook();

    clBitmapList* GetBitmaps() const { return m_bitmaps; }
    int GetPageBitmapIndex(size_t index) const;
    void SetStyle(size_t bookStyle) { this->m_bookStyle = bookStyle; }
    size_t GetStyle() const { return m_bookStyle; }
    void SetTabDirection(wxDirection d);
    void EnableStyle(NotebookStyle style, bool enable);

    // API
    void AddPage(wxWindow* page, const wxString& label, bool selected = false, int bmp = wxNOT_FOUND,
                 const wxString& shortLabel = wxEmptyString);
    bool InsertPage(size_t index, wxWindow* page, const wxString& label, bool selected = false, int bmp = wxNOT_FOUND,
                    const wxString& shortLabel = wxEmptyString);

    bool RemovePage(size_t page, bool notify);
    bool DeletePage(size_t page, bool notify);
    bool RemovePage(size_t page) override;
    bool DeletePage(size_t page) override;

    wxWindow* GetCurrentPage() const;
    void SetPageBitmap(size_t index, int bmp);
    wxBitmap GetPageBitmap(size_t index) const;
    bool DeleteAllPages() override;
    int GetPageIndex(wxWindow* window) const;
    int GetPageIndex(const wxString& label) const;
    void GetAllPages(std::vector<wxWindow*>& pages);
    clTabRenderer::Ptr_t GetArt() { return clTabRenderer::Ptr_t(nullptr); }
    void SetArt(clTabRenderer::Ptr_t art) { wxUnusedVar(art); }
    size_t GetAllTabs(clTabInfo::Vec_t& tabs);
    clTabHistory::Ptr_t GetHistory() const;
    void SetMenu(wxMenu* menu) { m_tabContextMenu = menu; }
    bool SetPageToolTip(size_t page, const wxString& tooltip);
    bool MoveActivePage(int newIndex);
    int SetSelection(size_t nPage) override;
    int ChangeSelection(size_t nPage) override;
};

wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_BOOK_PAGE_CHANGING, wxBookCtrlEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_BOOK_PAGE_CHANGED, wxBookCtrlEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_BOOK_PAGE_CLOSING, wxBookCtrlEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_BOOK_PAGE_CLOSED, wxBookCtrlEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_BOOK_TAB_CONTEXT_MENU, wxBookCtrlEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_BOOK_PAGE_CLOSE_BUTTON, wxBookCtrlEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_BOOK_TAB_DCLICKED, wxBookCtrlEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_BOOK_NEW_PAGE, wxBookCtrlEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_BOOK_FILELIST_BUTTON_CLICKED, clContextMenuEvent);
#endif // defined(__WXGTK__)
#endif // GTKNOTEBOOK_HPP