xref: /haiku/docs/develop/servers/app_server/DesktopClasses.rst (revision bb83316a5811a550c4f850d07fa8e328e7ac0a94)
1 Screen class
2 ############
3 
4 The Screen class handles all infrastructure needed for each
5 monitor/video card pair. The Workspace class holds data and supplies
6 the infrastructure for drawing the screen.
7 
8 Member Functions
9 ================
10 
11 Screen(DisplayDriver \*gfxmodule, uint8 workspaces)
12 ---------------------------------------------------
13 
14 1. Set driver pointer to gfxmodule
15 2. If driver pointer is non-NULL and driver->Initialize() is true, set
16    initialized flag to true
17 3. If initialized, get the appropriate display driver info and save it
18    internally
19 4. Create and populate workspace list
20 5. Clear all workspaces
21 
22 
23 ~Screen(void)
24 -------------
25 
26 1. Remove all workspaces from the list and delete them
27 2. Delete the workspace list
28 
29 void AddWorkspace(int32 index=-1)
30 ---------------------------------
31 
32 Adds a workspace to the screen object, setting its settings to the
33 default, and adding it to the list in the specified index or the end
34 of the list if the index is -1
35 
36 
37 1. Create a workspace object
38 2. Add it to the workspace list - to the end if the index is -1, and to
39    the particular index if not
40 
41 void DeleteWorkspace(int32 index)
42 ---------------------------------
43 
44 Deletes the workspace at the specified index.
45 
46 
47 1. Remove the item at the specified index and if non-NULL, delete it.
48 
49 int32 CountWorkspaces(void)
50 ---------------------------
51 
52 Returns the number of workspaces kept by the particular Screen objects
53 
54 1. Return the workspace list's CountItems() value
55 
56 void SetWorkspaceCount(int32 count)
57 -----------------------------------
58 
59 Sets the number of workspaces available to count. If count is less
60 than the number of current workspaces, the last workspaces are deleted
61 first. Workspaces are added to the end of the list. If a delete
62 workspace should include the active workspace, then the workspace with
63 the index count-1 is activated. There must be at least one workspace.
64 
65 1. if count equals the workspace list's CountItems value, return
66 2. If count is less than 1, set count to 1. If greater than 32, set to 32.
67 3. If active workspace index is greater than count-1, call SetWorkspace(count-1)
68 4. If count is greater than the workspace list's CountItems value, call
69    AddWorkspace the appropriate number of times.
70 5. If count is less than the workspace list's CountItems, call
71    RemoveWorkspace the appropriate number of times
72 
73 int32 CurrentWorkspace(void)
74 ----------------------------
75 
76 Returns the active workspace index
77 
78 void SetWorkspace(int32 workspace)
79 ----------------------------------
80 
81 void Activate(bool active=true)
82 -------------------------------
83 
84 DisplayDriver \*GetDriver(void)
85 -------------------------------
86 
87 status_t SetSpace(int32 index, int32 res, bool stick=true)
88 ----------------------------------------------------------
89 
90 void AddWindow(ServerWindow \*win, int32 workspace=B_CURRENT_WORKSPACE)
91 -----------------------------------------------------------------------
92 
93 void RemoveWindow(ServerWindow \*win)
94 -------------------------------------
95 
96 ServerWindow \*ActiveWindow(void)
97 ---------------------------------
98 
99 void SetActiveWindow(ServerWindow \*win)
100 ----------------------------------------
101 
102 Layer \*GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE)
103 ---------------------------------------------------------
104 
105 bool IsInitialized(void)
106 ------------------------
107 
108 Workspace \*GetActiveWorkspace(void)
109 ------------------------------------
110 
111 Workspace class members
112 =======================
113 
114 Workspace(void)
115 ---------------
116 
117 1. Set background color to RGB(51,102,160)
118 2. Copy frame_buffer_info and graphics_card_info structure values
119 3. Create a RootLayer object using the values from the two structures
120 
121 ~Workspace(void)
122 ----------------
123 
124 1. Call the RootLayer object's PruneTree method and delete it
125 
126 void SetBGColor(const RGBColor &c)
127 ----------------------------------
128 
129 Sets the particular color for the workspace. Note that this does not
130 refresh the display.
131 
132 1. Set the internal background RGBColor object to the color parameter
133 
134 RGBColor BGColor(void)
135 ----------------------
136 
137 Returns the internal background color
138 
139 
140 RootLayer \*GetRoot(void)
141 -------------------------
142 
143 Returns the pointer to the RootLayer object
144 
145 
146 void SetData(graphics_card_info \*gcinfo, frame_buffer_info \*fbinfo)
147 ---------------------------------------------------------------------
148 
149 Changes the graphics data and resizes the RootLayer accordingly.
150 
151 
152 1. Copy the two structures to the internal one
153 2. Resize the RootLayer
154 3. If the RootLayer was resized larger, Invalidate the new areas
155 
156 
157 void GetData(graphics_card_info \*gcinfo, frame_buffer_info \*fbinfo)
158 ---------------------------------------------------------------------
159 
160 Copies the two data structures into the parameters passed.
161 
162 RootLayer class members
163 =======================
164 
165 RootLayer(BRect frame, const char \*name)
166 
167 
168 1. passes B_FOLLOW_NONE to Layer constructor
169 2. set level to 0
170 3. set the background color to the color for the workspace set in the
171    system preferences
172 
173 
174 ~RootLayer(void)
175 ----------------
176 
177 Does nothing.
178 
179 
180 void RequestDraw(const BRect &r)
181 --------------------------------
182 
183 Requests that the layer be drawn on screen. The rectangle passed is in
184 the layer's own coordinates.
185 
186 
187 1. call the display driver's FillRect on the rectangle, filling with
188    the layer's background color
189 2. recurse through each child and call its RequestDraw() function if it
190    intersects the child's frame
191 
192 void MoveBy(BPoint pt), void MoveBy(float x, float y)
193 -----------------------------------------------------
194 
195 Made empty so that the root layer cannot be moved
196 
197 void SetDriver(DisplayDriver \*d)
198 ---------------------------------
199 
200 Assigns a particular display driver object to the root layer if
201 non-NULL.
202 
203 
204 void RebuildRegions(bool recursive=false)
205 -----------------------------------------
206 
207 Rebuilds the visible and invalid layers based on the layer hierarchy.
208 Used to update the regions after a call to remove or add a child layer
209 is made or when a layer is hidden or shown.
210 
211 
212 1. get the frame
213 2. set full and visible regions to frame
214 3. iterate through each child and exclude its full region from the
215    visible region if the child is visible.
216 
217