MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / DisplayMessageBox

Function DisplayMessageBox

LibLemon/src/gui/messagebox.cpp:20–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 }
19
20 int DisplayMessageBox(const char* title, const char* message, MsgBoxButtons buttons){
21 int width = Graphics::GetTextLength(message) + 10;
22 if(width < 220) width = 220;
23
24 Window* win = new Window(title, {width, 80}, 0, WindowType::GUI);
25
26 Label* label = new Label(message, {10, 10, 180, 12});
27 win->AddWidget(label);
28
29 if(buttons == MsgButtonsOKCancel){
30 Button* okBtn = new Button("OK", {-52, 2, 100, 24});
31 win->AddWidget(okBtn);
32 okBtn->SetLayout(LayoutSize::Fixed, LayoutSize::Fixed, WAlignCentre, WAlignBottom);
33 okBtn->OnPress = OnMessageBoxOKPressed;
34
35 Button* cancelBtn = new Button("Cancel", {52, 2, 100, 24});
36 win->AddWidget(cancelBtn);
37 cancelBtn->SetLayout(LayoutSize::Fixed, LayoutSize::Fixed, WAlignCentre, WAlignBottom);
38 cancelBtn->OnPress = OnMessageBoxCancelPressed;
39 } else {
40 Button* okBtn = new Button("OK", {0, 5, 100, 24});
41 win->AddWidget(okBtn);
42 okBtn->SetLayout(LayoutSize::Fixed, LayoutSize::Fixed, WAlignCentre, WAlignBottom);
43 okBtn->OnPress = OnMessageBoxOKPressed;
44 }
45
46 bool paint = true;
47
48 while(!win->closed){
49 LemonEvent ev;
50 while(win->PollEvent(ev)){
51 win->GUIHandleEvent(ev);
52 paint = true;
53 }
54
55 if(paint){
56 win->Paint();
57 paint = false;
58 }
59 }
60
61 delete win;
62
63 return pressed;
64 }
65}

Callers 14

OnOKPressFunction · 0.85
OnSubmitMethod · 0.85
FileDialogOnFileOpenedFunction · 0.85
LoadImageFunction · 0.85
SaveImageFunction · 0.85
LoadImageFunction · 0.85
LoadFileFunction · 0.85
SaveFileFunction · 0.85
OpenFileFunction · 0.85
SaveFileAsFunction · 0.85
GameOverMethod · 0.85

Calls 6

GetTextLengthFunction · 0.85
SetLayoutMethod · 0.80
PollEventMethod · 0.80
GUIHandleEventMethod · 0.80
AddWidgetMethod · 0.45
PaintMethod · 0.45

Tested by

no test coverage detected