summaryrefslogtreecommitdiff
path: root/ui/custom_grid.h
blob: 8a91e0bc6e791a0fbf8ab2feb25656cc45da0206 (plain)
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
// **************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html       *
// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved        *
// **************************************************************************

#ifndef CUSTOMGRID_H_INCLUDED
#define CUSTOMGRID_H_INCLUDED

#include <wx+/grid.h>
#include "grid_view.h"
#include "column_attr.h"
#include "../lib/icon_buffer.h"

namespace zen
{
//setup grid to show grid view within three components:
namespace gridview
{
void init(Grid& gridLeft, Grid& gridCenter, Grid& gridRight, const std::shared_ptr<const GridView>& gridDataView);

std::vector<Grid::ColumnAttribute> convertConfig(const std::vector<ColumnAttributeRim>& attribs); //+ make consistent
std::vector<ColumnAttributeRim>    convertConfig(const std::vector<Grid::ColumnAttribute>& attribs); //

void showSyncAction(Grid& gridCenter, bool value);

void setupIcons(Grid& gridLeft, Grid& gridCenter, Grid& gridRight, bool show, IconBuffer::IconSize sz);

void clearSelection(Grid& gridLeft, Grid& gridCenter, Grid& gridRight); //clear all components
void refresh(Grid& gridLeft, Grid& gridCenter, Grid& gridRight);

//mark rows selected in navigation/compressed tree and navigate to leading object
void setNavigationMarker(Grid& gridLeft,
                         std::vector<const HierarchyObject*>&& markedFiles,      //mark files/symlinks directly within a container
                         std::vector<const HierarchyObject*>&& markedContainer); //mark full container including child-objects
}

wxBitmap getSyncOpImage(SyncOperation syncOp);
wxBitmap getCmpResultImage(CompareFilesResult cmpResult);


//---------- custom events for middle grid ----------

//(UN-)CHECKING ROWS FROM SYNCHRONIZATION
extern const wxEventType EVENT_GRID_CHECK_ROWS;
//SELECTING SYNC DIRECTION
extern const wxEventType EVENT_GRID_SYNC_DIRECTION;

struct CheckRowsEvent : public wxCommandEvent
{
    CheckRowsEvent(ptrdiff_t rowFrom, ptrdiff_t rowTo, bool setIncluded) : wxCommandEvent(EVENT_GRID_CHECK_ROWS), rowFrom_(rowFrom), rowTo_(rowTo), setIncluded_(setIncluded) {}
    virtual wxEvent* Clone() const { return new CheckRowsEvent(*this); }

    const ptrdiff_t rowFrom_;
    const ptrdiff_t rowTo_;
    const bool setIncluded_;
};


struct SyncDirectionEvent : public wxCommandEvent
{
    SyncDirectionEvent(ptrdiff_t rowFrom, ptrdiff_t rowTo, SyncDirection direction) : wxCommandEvent(EVENT_GRID_SYNC_DIRECTION), rowFrom_(rowFrom), rowTo_(rowTo), direction_(direction) {}
    virtual wxEvent* Clone() const { return new SyncDirectionEvent(*this); }

    const ptrdiff_t rowFrom_;
    const ptrdiff_t rowTo_;
    const SyncDirection direction_;
};

typedef void (wxEvtHandler::*CheckRowsEventFunction)(CheckRowsEvent&);
typedef void (wxEvtHandler::*SyncDirectionEventFunction)(SyncDirectionEvent&);

#define CheckRowsEventHandler(func) \
    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(CheckRowsEventFunction, &func)

#define SyncDirectionEventHandler(func) \
    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(SyncDirectionEventFunction, &func)
}

#endif // CUSTOMGRID_H_INCLUDED
bgstack15