Forge
window.h
Go to the documentation of this file.
1 /*******************************************************
2  * Copyright (c) 2015-2019, ArrayFire
3  * All rights reserved.
4  *
5  * This file is distributed under 3-clause BSD license.
6  * The complete license agreement can be obtained at:
7  * http://arrayfire.com/licenses/BSD-3-Clause
8  ********************************************************/
9 
10 #pragma once
11 
12 #include <fg/defines.h>
13 #include <fg/font.h>
14 #include <fg/image.h>
15 #include <fg/chart.h>
16 #include <fg/surface.h>
17 #include <fg/histogram.h>
18 
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
42  const int pWidth, const int pHeight,
43  const char* pTitle,
44  const fg_window pShareWindow,
45  const bool pInvisible);
46 
56 
67 
76 FGAPI fg_err fg_set_window_font(fg_window pWindow, const fg_font pFont);
77 
86 FGAPI fg_err fg_set_window_title(fg_window pWindow, const char* pTitle);
87 
97 FGAPI fg_err fg_set_window_position(fg_window pWindow, const int pX, const int pY);
98 
108 FGAPI fg_err fg_set_window_size(fg_window pWindow, const unsigned pWidth, const unsigned pHeight);
109 
118 FGAPI fg_err fg_set_window_colormap(fg_window pWindow, const fg_color_map pColorMap);
119 
128 FGAPI fg_err fg_get_window_context_handle(long long *pContext, const fg_window pWindow);
129 
138 FGAPI fg_err fg_get_window_display_handle(long long *pDisplay, const fg_window pWindow);
139 
148 FGAPI fg_err fg_get_window_width(int *pWidth, const fg_window pWindow);
149 
158 FGAPI fg_err fg_get_window_height(int *pHeight, const fg_window pWindow);
159 
168 
176 FGAPI fg_err fg_hide_window(const fg_window pWindow);
177 
185 FGAPI fg_err fg_show_window(const fg_window pWindow);
186 
195 FGAPI fg_err fg_close_window(bool* pIsClosed, const fg_window pWindow);
196 
206 FGAPI fg_err fg_draw_image(const fg_window pWindow, const fg_image pImage, const bool pKeepAspectRatio);
207 
216 FGAPI fg_err fg_draw_chart(const fg_window pWindow, const fg_chart pChart);
217 
237 FGAPI fg_err fg_draw_image_to_cell(const fg_window pWindow, const int pRows, const int pCols, const int pIndex,
238  const fg_image pImage, const char* pTitle, const bool pKeepAspectRatio);
239 
258 FGAPI fg_err fg_draw_chart_to_cell(const fg_window pWindow, const int pRows, const int pCols, const int pIndex,
259  const fg_chart pChart, const char* pTitle);
260 
269 
281 FGAPI fg_err fg_save_window_framebuffer(const char* pFullPath, const fg_window pWindow);
282 
285 #ifdef __cplusplus
286 }
287 #endif
288 
289 
290 #ifdef __cplusplus
291 
292 namespace forge
293 {
294 
300 class Window {
301  private:
302  fg_window mValue;
303 
304  Window() {}
305 
306  public:
319  FGAPI Window(const int pWidth, const int pHeight, const char* pTitle,
320  const Window* pWindow=0, const bool invisible = false);
321 
327  FGAPI Window(const Window& other);
328 
334  FGAPI ~Window();
335 
341  FGAPI void setFont(Font* pFont);
342 
348  FGAPI void setTitle(const char* pTitle);
349 
356  FGAPI void setPos(const int pX, const int pY);
357 
364  FGAPI void setSize(const unsigned pWidth, const unsigned pHeight);
365 
371  FGAPI void setColorMap(const ColorMap cmap);
372 
377  FGAPI long long context() const;
378 
383  FGAPI long long display() const;
384 
388  FGAPI int width() const;
389 
393  FGAPI int height() const;
394 
398  FGAPI fg_window get() const;
399 
403  FGAPI void makeCurrent();
404 
408  FGAPI void hide();
409 
413  FGAPI void show();
414 
422  FGAPI bool close();
423 
434  FGAPI void draw(const Image& pImage, const bool pKeepAspectRatio=true);
435 
444  FGAPI void draw(const Chart& pChart);
445 
464  FGAPI void draw(const int pRows, const int pCols, const int pIndex,
465  const Image& pImage, const char* pTitle=0, const bool pKeepAspectRatio=true);
466 
483  FGAPI void draw(const int pRows, const int pCols, const int pIndex,
484  const Chart& pChart, const char* pTitle = 0);
485 
492  FGAPI void swapBuffers();
493 
504  FGAPI void saveFrameBuffer(const char* pFullPath);
505 };
506 
507 }
508 
509 #endif
FGAPI fg_err fg_set_window_position(fg_window pWindow, const int pX, const int pY)
Set the window origin of Window Object w.r.t screen origin.
FGAPI fg_err fg_create_window(fg_window *pWindow, const int pWidth, const int pHeight, const char *pTitle, const fg_window pShareWindow, const bool pInvisible)
Create a Window object.
FGAPI int width() const
FGAPI fg_err fg_hide_window(const fg_window pWindow)
Hide the Window.
FGAPI fg_err fg_draw_image_to_cell(const fg_window pWindow, const int pRows, const int pCols, const int pIndex, const fg_image pImage, const char *pTitle, const bool pKeepAspectRatio)
Render given image to Window's particular sub-view.
void * fg_chart
Definition: defines.h:42
FGAPI long long display() const
Get Native Window display handle.
Definition: chart.h:304
FGAPI fg_window get() const
FGAPI fg_err fg_retain_window(fg_window *pOut, fg_window pWindow)
Increment the internal reference count for Window.
FGAPI int height() const
FGAPI fg_err fg_get_window_width(int *pWidth, const fg_window pWindow)
Get the width of Window.
FGAPI long long context() const
Get rendering backend context handle.
FGAPI bool close()
Check if the window is ready for close.
FGAPI void hide()
Hide the window.
FGAPI fg_err fg_draw_chart_to_cell(const fg_window pWindow, const int pRows, const int pCols, const int pIndex, const fg_chart pChart, const char *pTitle)
Render given chart to Window's particular sub-view.
FGAPI fg_err fg_swap_window_buffers(const fg_window pWindow)
Swap back buffer with front buffer.
FGAPI void show()
Show the window if hidden, otherwise no effect.
fg_color_map
Color maps.
Definition: defines.h:125
FGAPI void makeCurrent()
Make the current window's rendering context active context.
FGAPI void draw(const Image &pImage, const bool pKeepAspectRatio=true)
Render an Image to Window.
FGAPI void setPos(const int pX, const int pY)
Set the start position where the window will appear.
#define FGAPI
Definition: defines.h:28
FGAPI fg_err fg_save_window_framebuffer(const char *pFullPath, const fg_window pWindow)
Save the current frame buffer to a file at provided path.
FGAPI fg_err fg_show_window(const fg_window pWindow)
Show the Window.
FGAPI fg_err fg_get_window_display_handle(long long *pDisplay, const fg_window pWindow)
Get the display device handle of Window.
Font object is essentially a resource handler for the specific font you want to use.
Definition: font.h:86
FGAPI fg_err fg_make_window_current(const fg_window pWindow)
Make the window's backend specific context the active context in given thread.
FGAPI fg_err fg_close_window(bool *pIsClosed, const fg_window pWindow)
Check if the Window is closed.
void * fg_image
Definition: defines.h:43
FGAPI void setFont(Font *pFont)
Set font to be used by the window to draw text.
FGAPI void swapBuffers()
Swaps background buffer with front buffer.
FGAPI fg_err fg_release_window(fg_window pWindow)
Destroy Window Object.
fg_err
Definition: defines.h:49
Chart is base canvas where other plottable objects are rendered.
Definition: chart.h:316
FGAPI fg_err fg_set_window_colormap(fg_window pWindow, const fg_color_map pColorMap)
Set the colormap to be used by the Window Object.
FGAPI fg_err fg_set_window_title(fg_window pWindow, const char *pTitle)
Set the title of Window Object.
void * fg_font
Definition: defines.h:41
FGAPI void setSize(const unsigned pWidth, const unsigned pHeight)
Set the size of the window programmatically.
FGAPI void setColorMap(const ColorMap cmap)
Set the colormap to be used for subsequent rendering calls.
FGAPI void saveFrameBuffer(const char *pFullPath)
Save window frame buffer to give location in provided image format.
FGAPI void setTitle(const char *pTitle)
Set the window title.
FGAPI ~Window()
Window Destructor.
FGAPI fg_err fg_draw_chart(const fg_window pWindow, const fg_chart pChart)
Render given chart to Window.
Image is plain rendering of an image over the window or sub-region of it.
Definition: image.h:174
Window is where other objects such as Images, Plots etc.
Definition: window.h:300
FGAPI fg_err fg_get_window_context_handle(long long *pContext, const fg_window pWindow)
Get the backend specific context handle of Window.
void * fg_window
Definition: defines.h:40
FGAPI fg_err fg_set_window_size(fg_window pWindow, const unsigned pWidth, const unsigned pHeight)
Set the window dimensions of Window Object.
FGAPI fg_err fg_get_window_height(int *pHeight, const fg_window pWindow)
Get the height of Window.
FGAPI fg_err fg_set_window_font(fg_window pWindow, const fg_font pFont)
Set font object to be used by Window Object.
FGAPI fg_err fg_draw_image(const fg_window pWindow, const fg_image pImage, const bool pKeepAspectRatio)
Render given image to Window.