mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:27:42 +00:00
LibGUI: Add GMenu* and GApplication classes.
This commit is contained in:
parent
8d0bfa62fd
commit
9483b39227
9 changed files with 131 additions and 0 deletions
23
LibGUI/GApplication.cpp
Normal file
23
LibGUI/GApplication.cpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#include <LibGUI/GApplication.h>
|
||||||
|
#include <LibGUI/GEventLoop.h>
|
||||||
|
#include <LibGUI/GMenuBar.h>
|
||||||
|
|
||||||
|
GApplication::GApplication(int argc, char** argv)
|
||||||
|
{
|
||||||
|
m_event_loop = make<GEventLoop>();
|
||||||
|
}
|
||||||
|
|
||||||
|
GApplication::~GApplication()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int GApplication::exec()
|
||||||
|
{
|
||||||
|
return m_event_loop->exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GApplication::set_menubar(OwnPtr<GMenuBar>&& menubar)
|
||||||
|
{
|
||||||
|
m_menubar = move(menubar);
|
||||||
|
}
|
||||||
|
|
19
LibGUI/GApplication.h
Normal file
19
LibGUI/GApplication.h
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/OwnPtr.h>
|
||||||
|
|
||||||
|
class GEventLoop;
|
||||||
|
class GMenuBar;
|
||||||
|
|
||||||
|
class GApplication {
|
||||||
|
public:
|
||||||
|
GApplication(int argc, char** argv);
|
||||||
|
|
||||||
|
int exec();
|
||||||
|
|
||||||
|
void set_menubar(OwnPtr<GMenuBar>&&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
OwnPtr<GEventLoop> m_event_loop;
|
||||||
|
OwnPtr<GMenuBar> m_menubar;
|
||||||
|
};
|
11
LibGUI/GMenu.cpp
Normal file
11
LibGUI/GMenu.cpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#include <LibGUI/GMenu.h>
|
||||||
|
|
||||||
|
GMenu::GMenu()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GMenu::~GMenu()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
13
LibGUI/GMenu.h
Normal file
13
LibGUI/GMenu.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibGUI/GMenuItem.h>
|
||||||
|
#include <AK/Vector.h>
|
||||||
|
|
||||||
|
class GMenu {
|
||||||
|
public:
|
||||||
|
GMenu();
|
||||||
|
~GMenu();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Vector<GMenuItem> m_items;
|
||||||
|
};
|
9
LibGUI/GMenuBar.cpp
Normal file
9
LibGUI/GMenuBar.cpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#include <LibGUI/GMenuBar.h>
|
||||||
|
|
||||||
|
GMenuBar::GMenuBar()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GMenuBar::~GMenuBar()
|
||||||
|
{
|
||||||
|
}
|
13
LibGUI/GMenuBar.h
Normal file
13
LibGUI/GMenuBar.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibGUI/GMenu.h>
|
||||||
|
#include <AK/Vector.h>
|
||||||
|
|
||||||
|
class GMenuBar {
|
||||||
|
public:
|
||||||
|
GMenuBar();
|
||||||
|
~GMenuBar();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Vector<GMenu> m_menus;
|
||||||
|
};
|
18
LibGUI/GMenuItem.cpp
Normal file
18
LibGUI/GMenuItem.cpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#include <LibGUI/GMenuItem.h>
|
||||||
|
|
||||||
|
GMenuItem::GMenuItem(Type type)
|
||||||
|
: m_type(type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GMenuItem::GMenuItem(unsigned identifier, const String& text)
|
||||||
|
: m_type(Text)
|
||||||
|
, m_identifier(identifier)
|
||||||
|
, m_text(text)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GMenuItem::~GMenuItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
22
LibGUI/GMenuItem.h
Normal file
22
LibGUI/GMenuItem.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/AKString.h>
|
||||||
|
|
||||||
|
class GMenuItem {
|
||||||
|
public:
|
||||||
|
enum Type { Invalid, Text, Separator };
|
||||||
|
|
||||||
|
explicit GMenuItem(Type);
|
||||||
|
GMenuItem(unsigned identifier, const String& text);
|
||||||
|
~GMenuItem();
|
||||||
|
|
||||||
|
Type type() const { return m_type; }
|
||||||
|
String text() const { return m_text; }
|
||||||
|
unsigned identifier() const { return m_identifier; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type m_type { Invalid };
|
||||||
|
unsigned m_identifier { 0 };
|
||||||
|
String m_text;
|
||||||
|
};
|
||||||
|
|
|
@ -21,6 +21,9 @@ LIBGUI_OBJS = \
|
||||||
GStyle.o \
|
GStyle.o \
|
||||||
GLayout.o \
|
GLayout.o \
|
||||||
GBoxLayout.o \
|
GBoxLayout.o \
|
||||||
|
GMenuBar.o \
|
||||||
|
GMenu.o \
|
||||||
|
GMenuItem.o \
|
||||||
GWindow.o
|
GWindow.o
|
||||||
|
|
||||||
OBJS = $(SHAREDGRAPHICS_OBJS) $(LIBGUI_OBJS)
|
OBJS = $(SHAREDGRAPHICS_OBJS) $(LIBGUI_OBJS)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue