mirror of
https://github.com/RGBCube/serenity
synced 2025-05-29 09:25:07 +00:00
Make the widgets code build on macOS.
Funny, I haven't looked at this code in a few weeks and there's so much to change!
This commit is contained in:
parent
85b886c2e0
commit
dd502bb54e
3 changed files with 19 additions and 13 deletions
|
@ -7,8 +7,8 @@ class AbstractScreen : public Object {
|
||||||
public:
|
public:
|
||||||
virtual ~AbstractScreen();
|
virtual ~AbstractScreen();
|
||||||
|
|
||||||
unsigned width() const { return m_width; }
|
int width() const { return m_width; }
|
||||||
unsigned height() const { return m_height; }
|
int height() const { return m_height; }
|
||||||
|
|
||||||
static AbstractScreen& the();
|
static AbstractScreen& the();
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ protected:
|
||||||
AbstractScreen(unsigned width, unsigned height);
|
AbstractScreen(unsigned width, unsigned height);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned m_width { 0 };
|
int m_width { 0 };
|
||||||
unsigned m_height { 0 };
|
int m_height { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@ void MsgBox(Window* owner, String&& text)
|
||||||
Font& font = Font::defaultFont();
|
Font& font = Font::defaultFont();
|
||||||
auto screenRect = AbstractScreen::the().rect();
|
auto screenRect = AbstractScreen::the().rect();
|
||||||
|
|
||||||
unsigned textWidth = text.length() * font.glyphWidth() + 8;
|
int textWidth = text.length() * font.glyphWidth() + 8;
|
||||||
unsigned textHeight = font.glyphHeight() + 8;
|
int textHeight = font.glyphHeight() + 8;
|
||||||
unsigned horizontalPadding = 16;
|
int horizontalPadding = 16;
|
||||||
unsigned verticalPadding = 16;
|
int verticalPadding = 16;
|
||||||
unsigned buttonWidth = 60;
|
int buttonWidth = 60;
|
||||||
unsigned buttonHeight = 20;
|
int buttonHeight = 20;
|
||||||
unsigned windowWidth = textWidth + horizontalPadding * 2;
|
int windowWidth = textWidth + horizontalPadding * 2;
|
||||||
unsigned windowHeight = textHeight + buttonHeight + verticalPadding * 3;
|
int windowHeight = textHeight + buttonHeight + verticalPadding * 3;
|
||||||
|
|
||||||
Rect windowRect(
|
Rect windowRect(
|
||||||
screenRect.center().x() - windowWidth / 2,
|
screenRect.center().x() - windowWidth / 2,
|
||||||
|
|
|
@ -14,7 +14,7 @@ TerminalWidget::TerminalWidget(Widget* parent)
|
||||||
{
|
{
|
||||||
g_tw = this;
|
g_tw = this;
|
||||||
|
|
||||||
setWindowRelativeRect({ 0, 0, (columns() * font().glyphWidth()) + 4, (rows() * font().glyphHeight()) + 4 });
|
setWindowRelativeRect({ 0, 0, int(columns() * font().glyphWidth()) + 4, int(rows() * font().glyphHeight()) + 4 });
|
||||||
|
|
||||||
printf("rekt: %d x %d\n", width(), height());
|
printf("rekt: %d x %d\n", width(), height());
|
||||||
m_screen = new CharacterWithAttributes[rows() * columns()];
|
m_screen = new CharacterWithAttributes[rows() * columns()];
|
||||||
|
@ -24,7 +24,13 @@ TerminalWidget::TerminalWidget(Widget* parent)
|
||||||
at(row, column).attribute = 0x07;
|
at(row, column).attribute = 0x07;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __APPLE__
|
||||||
|
g_fd = posix_openpt(O_RDWR);
|
||||||
|
#else
|
||||||
g_fd = getpt();
|
g_fd = getpt();
|
||||||
|
#endif
|
||||||
|
|
||||||
grantpt(g_fd);
|
grantpt(g_fd);
|
||||||
unlockpt(g_fd);
|
unlockpt(g_fd);
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue