3 * Copyright (C) 2016-2020 William Morrow
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 #ifndef RECORDBATCHES_H
22 #define RECORDBATCHES_H
24 #include "arraylist.h"
26 #include "bclistbox.h"
27 #include "bclistboxitem.inc"
28 #include "channeldb.inc"
31 #include "recordbatches.inc"
32 #include "timeentry.h"
36 class RecordBatchesGUI;
41 RecordBatchesGUI *gui;
43 // Don't want to interrupt recording to edit a different batch.
44 int current_item; // Current batch being recorded.
45 int editing_item; // Current batch being edited.
47 static const char* default_batch_titles[];
48 const char *batch_titles[BATCH_COLUMNS];
49 static const int default_columnwidth[];
50 int column_widths[BATCH_COLUMNS];
51 ArrayList<BC_ListBoxItem*> data[BATCH_COLUMNS];
52 ArrayList<Batch*> batches;
53 double early_margin, late_margin;
54 char default_directory[BCTEXTLEN];
56 void load_defaults(ChannelDB *channeldb, Record *record=0);
57 void save_defaults(ChannelDB *channeldb);
58 void save_default_channel(ChannelDB *channeldb);
59 Batch *&operator [](int i) { return batches.values[i]; }
60 Batch* get_current_batch() { return batches.values[current_item]; }
61 Batch* get_editing_batch() { return batches.values[editing_item]; }
62 double *get_early_margin() { return &early_margin; }
63 double *get_late_margin() { return &late_margin; }
64 char *get_default_directory() { return default_directory; }
65 int total() { return batches.total; }
66 void append(Batch *batch) { batches.append(batch); }
67 void remove(Batch *batch);
69 RecordBatches(MWindow *mwindow);
73 class RecordBatchesGUI : public BC_ListBox
76 RecordBatches &batches;
80 virtual int selection_changed() = 0;
81 int update(int highlighted_item, int recalc_positions);
82 int update() { return update(get_highlighted_item(), 0); }
83 int column_resize_event();
84 int drag_start_event();
85 int drag_motion_event();
86 int drag_stop_event();
87 void set_row_color(int i, int color);
88 void calculate_batches(int selection_number);
89 void update_batch_news(int item);
90 void update_batches(int selection_item);
91 void update_batches() { return update_batches(get_selection_number(0, 0)); }
92 int editing_batch() { return batches.editing_item; }
93 int set_editing_batch(int i) { return batches.editing_item=i; }
94 int current_batch() { return batches.current_item; }
95 int set_current_batch(int i) { return batches.current_item=i; }
96 int count() { return batches.data[0].total; }
97 Batch* get_current_batch() { return batches.get_current_batch(); }
98 Batch* get_editing_batch() { return batches.get_editing_batch(); }
99 RecordBatchesGUI(RecordBatches &batches, int x, int y, int w, int h);
101 class Dir : public BC_TextBox {
103 RecordBatches &batches;
104 char (&directory)[BCTEXTLEN];
105 ArrayList<BC_ListBoxItem*> *dir_entries;
106 char entries_dir[BCTEXTLEN];
109 void load_dirs(const char *path);
110 char *get_directory() { return directory; }
112 Dir(RecordBatches &batches, const char *dir, int x, int y);
116 class Path : public BC_TextBox {
118 RecordBatches &batches;
122 Path(RecordBatches &batches, int x, int y);
126 class StartTime : public TimeEntry {
128 RecordBatches &batches;
130 StartTime(BC_Window *win, RecordBatches &batches,
131 int x, int y, int w=DEFAULT_TIMEW);
134 class Duration : public TimeEntry
137 RecordBatches &batches;
139 Duration(BC_Window *win, RecordBatches &batches,
140 int x, int y, int w=DEFAULT_TIMEW);
143 class Margin : public TimeEntry
145 RecordBatches &batches;
147 Margin(BC_Window *win, RecordBatches &batches, int x, int y);
153 ArrayList<BC_ListBoxItem*> sources;
156 class Source : protected Sources, public BC_PopupTextBox {
158 RecordBatches &batches;
160 Source(BC_Window *win, RecordBatches &batches, int x, int y);
163 class News : public BC_TextBox {
165 RecordBatches &batches;
167 News(RecordBatches &batches, int x, int y);
170 class NewBatch : public BC_GenericButton {
172 RecordBatches &batches;
174 NewBatch(RecordBatches &batches, int x, int y);
177 class DeleteBatch : public BC_GenericButton {
179 RecordBatches &batches;
181 DeleteBatch(RecordBatches &batches, int x, int y);
184 class StartBatches : public BC_GenericButton {
186 RecordBatches &batches;
188 StartBatches(RecordBatches &batches, int x, int y);
191 class StopBatches : public BC_GenericButton {
193 RecordBatches &batches;
195 StopBatches(RecordBatches &batches, int x, int y);
198 class ActivateBatch : public BC_GenericButton {
200 RecordBatches &batches;
202 ActivateBatch(RecordBatches &batches, int x, int y);
205 class ClearBatch : public BC_GenericButton {
207 RecordBatches &batches;
209 ClearBatch(RecordBatches &batches, int x, int y);