xref: /haiku/src/apps/cortex/support/MediaIcon.h (revision 83b1a68c52ba3e0e8796282759f694b7fdddf06d)
1 /*
2  * Copyright (c) 1999-2000, Eric Moon.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions, and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions, and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 
32 // MediaIcon.h (Cortex/Support)
33 //
34 // * PURPOSE
35 //
36 //   Easy construction of an icon-representation for common
37 //   kinds of nodes
38 //
39 // * NOTES
40 //
41 //	 5dec99 i've included some workarounds for the buggy GetDormantNodeFor()
42 //			 function
43 //   24oct99 simple to use but *not* very efficient!
44 //
45 // * HISTORY
46 //   c.lenz		17oct99		Begun
47 //	 c.lenz		5dec99		Bugfixes & support of application icons
48 //
49 
50 #ifndef __MediaIcon_H__
51 #define __MediaIcon_H__
52 
53 // Interface Kit
54 #include <Bitmap.h>
55 #include <InterfaceDefs.h>
56 // Media Kit
57 #include <MediaDefs.h>
58 // Storage Kit
59 #include <Mime.h>
60 
61 class BRegion;
62 struct dormant_flavor_info;
63 
64 #include "cortex_defs.h"
65 __BEGIN_CORTEX_NAMESPACE
66 
67 class MediaIcon :
68 	public BBitmap {
69 
70 public:					// *** ctor/dtor
71 
72 						MediaIcon(
73 							const live_node_info &nodeInfo,
74 							icon_size size);
75 
76 						MediaIcon(
77 							const dormant_node_info &nodeInfo,
78 							icon_size size);
79 
80 	virtual				~MediaIcon();
81 
82 private:				// *** internal accessors
83 
84 	// return the basic node_kind
85 	bool				_isPhysicalInput() const;
86 	bool				_isPhysicalOutput() const;
87 	bool				_isProducer() const;
88 	bool				_isFilter() const;
89 	bool				_isConsumer() const;
90 
91 	// special cases (media-type independant)
92 	bool				_isSystemMixer() const;
93 	bool				_isFileInterface() const;
94 	bool				_isTimeSource() const;
95 
96 private:				// *** internal operations
97 
98 	void				_findIconFor(
99 							const live_node_info &nodeInfo);
100 
101 	void				_findIconFor(
102 							const dormant_node_info &nodeInfo);
103 
104 	void				_findDefaultIconFor(
105 							bool audioIn,
106 							bool audioOut,
107 							bool videoIn,
108 							bool videoOut);
109 
110 	static void			_getMediaTypesFor(
111 							const live_node_info &nodeInfo,
112 							bool *audioIn,
113 							bool *audioOut,
114 							bool *videoIn,
115 							bool *videoOut);
116 
117 	static void			_getMediaTypesFor(
118 							const dormant_flavor_info &flavorInfo,
119 							bool *audioIn,
120 							bool *audioOut,
121 							bool *videoIn,
122 							bool *videoOut);
123 
124 private:				// *** data
125 
126 	// the icon size: B_LARGE_ICON or B_MINI_ICON
127 	icon_size			m_size;
128 
129 	// the node kinds (e.g. B_BUFFER_PRODUCER)
130 	uint32				m_nodeKind;
131 };
132 
133 __END_CORTEX_NAMESPACE
134 #endif /* __MediaIcon_H__ */
135