Port DisplayDevice to C.

This commit is contained in:
UnknownShadow200 2017-08-08 09:52:11 +10:00
parent 04dfac3cbe
commit 0f720bfbe2
3 changed files with 70 additions and 10 deletions

View file

@ -0,0 +1,22 @@
#include "DisplayDevice.h"
DisplayResolution DisplayResolution_Make(Int32 width, Int32 height, Int32 bitsPerPixel, Real32 refreshRate) {
DisplayResolution res;
res.Width = width; res.Height = height;
res.BitsPerPixel = bitsPerPixel; res.RefreshRate = refreshRate;
return res;
}
DisplayDevice DisplayDevice_Make(DisplayResolution* curResolution) {
DisplayDevice device;
device.CurResolution = *curResolution;
device.Bounds = Rectangle_Make(0, 0, curResolution->Width, curResolution->Height);
device.Metadata = NULL;
return device;
}
void DisplayDevice_SetBounds(DisplayDevice* device, Rectangle* bounds) {
device->Bounds = *bounds;
device->CurResolution.Width = bounds.Width;
device->CurResolution.Height = bounds.Height;
}

View file

@ -29,4 +29,27 @@ typedef struct DisplayResolution_ {
/* Constructs a new display resolution instance. */
DisplayResolution DisplayResolution_Make(Int32 width, Int32 height, Int32 bitsPerPixel, Real32 refreshRate);
/* Defines a display device on the underlying system.*/
typedef struct DisplayDevice_ {
/* The current resolution of the display device.*/
DisplayResolution CurResolution;
/* The bounds of the display device.*/
Rectangle Bounds;
/* Metadata unique to this display device instance. */
void* Metadata;
} DisplayDevice;
/* Constructs a new display device instance. */
DisplayDevice DisplayDevice_Make(DisplayResolution* curResolution);
/* Updates the bounds of the display device to the given bounds. */
void DisplayDevice_SetBounds(DisplayDevice* device, Rectangle* bounds);
/* The primary / default / main display device. */
DisplayDevice Primary;
#endif

View file

@ -5,8 +5,32 @@
#include "Compiler.h"
#include "Bitmap.h"
/* Abstracts creating and managing a native window.
Copyright 2017 ClassicalSharp | Licensed under BSD-3
Copyright 2017 ClassicalSharp | Licensed under BSD-3 | Based on OpenTK code
*/
/*
The Open Toolkit Library License
Copyright (c) 2006 - 2009 the Open Toolkit library.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
/* Gets the current contents of the clipboard. */
void Window_GetClipboardText(STRING_TRANSIENT String* value);
@ -17,9 +41,6 @@ void Window_SetClipboardText(STRING_TRANSIENT String* value);
/* Sets the icon of this window. */
void Window_SetIcon(Bitmap* bmp);
/* Sets the title of the window. */
void Window_SetTitle(STRING_TRANSIENT String* title);
/* Gets whether this window has input focus. */
bool Window_GetFocused(void);
@ -95,12 +116,6 @@ bool Window_GetExists(void);
/// <summary> Occurs when the window is disposed. </summary>
event EventHandler<EventArgs> Disposed;
/// <summary> Occurs when the <see cref="Icon"/> property of the window changes. </summary>
event EventHandler<EventArgs> IconChanged;
/// <summary> Occurs when the <see cref="Title"/> property of the window changes. </summary>
event EventHandler<EventArgs> TitleChanged;
/// <summary> Occurs when the <see cref="Visible"/> property of the window changes. </summary>
event EventHandler<EventArgs> VisibleChanged;