File: controller.h.n

package info (click to toggle)
mixviews 1.20-10.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,928 kB
  • ctags: 5,960
  • sloc: cpp: 32,879; ansic: 2,110; makefile: 445; sh: 17
file content (155 lines) | stat: -rw-r--r-- 4,998 bytes parent folder | download | duplicates (3)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// controller.h

/******************************************************************************
 *
 *  MiXViews - an X window system based sound & data editor/processor
 *
 *  Copyright (c) 1993, 1994 Regents of the University of California
 *
 *  Author:     Douglas Scott
 *  Date:       December 13, 1994
 *
 *  Permission to use, copy and modify this software and its documentation
 *  for research and/or educational purposes and without fee is hereby granted,
 *  provided that the above copyright notice appear in all copies and that
 *  both that copyright notice and this permission notice appear in
 *  supporting documentation. The author reserves the right to distribute this
 *  software and its documentation.  The University of California and the author
 *  make no representations about the suitability of this software for any 
 *  purpose, and in no event shall University of California be liable for any
 *  damage, loss of data, or profits resulting from its use.
 *  It is provided "as is" without express or implied warranty.
 *
 ******************************************************************************/


// The Controller class is one of the three central classes in MiXViews.  It is
// named such because of its role in the Model-View-Controller paradigm on
// which MiXViews is based.  It coordinates and routes messages between various
// other graphic and non-graphic components.  It contains pointers to an Editor
// subclass instance, a DataView subclass instance, and a DataWindow instance.
// It controls the creation and destruction of each display window and all of
// its associated parts.  Each is connected via a doubly-linked circular list,
// each instance being a link in the list.  Operations that pass data between
// windows do so via methods invoked upon the Controller via the DataEditor 
// subclass member, and the entire list can be searched from anywhere on itself.

#ifndef CONTROLLER_H
#ifdef __GNUG__
#pragma interface
#endif
#define CONTROLLER_H

#include <InterViews/resource.h>
#include "localdefs.h"
#include "range.h"
#include <String.h>

class DataFile;
class Data;
class DataWindow;
class DataView;
class ViewInfo;
class World;
class Event;
class DataEditor;
class Request;
class StatusAction;
class EditStatusDelegate;

class Controller : public Resource {
private:
	static Controller* head;
	static int numControllers;
	static int quitting;
	Controller* prev;
	Controller* next;
	enum ViewType { AsChannels, AsFrames };
	static ViewInfo& DefaultViewInfo;
private:
	void addToList();
	void removeFromList();
	boolean closeChain();
public:
	static Controller* create(DataFile *);
	Controller(Data *, const char *name = nil, ViewInfo &info=DefaultViewInfo);

	void display(World *);
	const char *fileName() const;
	const char* windowName () const;
	Data* model() const;
	DataEditor* editor() const { return myEditor; }

	void busy(boolean);

	// methods used (called by) Graphs	
	void setEditRegion(const Range &region, int chan);
	void setInsertPoint(int point, int chan);

	// methods used by editor
	World *world();	
	boolean handleEvent(Event &);
	boolean handleKeyEvent(Event &);
	int handleRequest(Request &);
	boolean keyCommand(unsigned long);
	Data* findSelection();
	void showInsertPoint(int, const Range &, boolean scroll = false);
	void showEditRegion(const Range &, const Range &, boolean scroll = false);
	void unselectView();
	void resetScaleTimes();
	void alert(const char* m1, const char* m2=nil,
		const char* m3=nil, const char* ="  ok  ");
	boolean confirm(const char* m1, const char* m2=nil,
		const char* m3=nil, Response r=Yes, const char* ="confirm",
		const char* ="cancel");
	Response choice(const char* m1, const char* m2=nil,
		const char* m3=nil, Response r=Yes, const char* =" yes ",
		const char* ="  no  ", const char* ="cancel");

	// methods called via menus or keyboard
	void newViewOfSelection();
	void viewAsFrames();
	void viewAsChannels();
	void zoomToSelection();
	void zoomToFull();
	boolean close();
	void showVersion();
	void quit();
	void changeName();
	void setProgramOptions();
protected:
	Controller(const char *);
	virtual ~Controller();
	Data* getSelection(long &timestamp);
	void setFileName(const char *);
	void viewAs(ViewType type);
 	// converter methods
	StatusAction* getConverterAction() { return converterAction; }
private:
	void earlyInit();
	boolean initialize(ViewInfo &info=DefaultViewInfo);
	DataView* newView(ViewInfo &);
	void createAndAttachView(ViewInfo &info=DefaultViewInfo);
	void detachView();
	int checkForStop();
private:
	String filename;
	DataWindow *window;
	DataView *myView;
	DataEditor *myEditor;
	StatusAction *converterAction;
	EditStatusDelegate* editDelegate;
	friend DataEditor;
	friend class SoundEditor;
	friend class FFTEditor;
	friend class LPCEditor;
	friend class PCHEditor;
	friend class EnvelopeEditor;
	friend class ProcessFunction;
	friend class FileSaver;
};

inline const char *
Controller::fileName() const { return filename; }

#endif