-
Notifications
You must be signed in to change notification settings - Fork 0
/
LWindow.cpp
79 lines (63 loc) · 2.14 KB
/
LWindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright 2010 Your Name <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "App.h"
#include "LWindow.h"
const BRect rect(150,150,500,400);
LWindow::LWindow(void)
: BWindow(rect, "Saisie Latex",B_TITLED_WINDOW,B_ASYNCHRONOUS_CONTROLS)
{
LView *view = NULL;
BString chaine = BString("\\[\\oint_{\\partial A}\\vec H\\;\\cdot\\mathrm{d}\\vec s=\\iint_A\\vec J\\;\\cdot\\mathrm{d}\\vec A+\\frac{\\mathrm{d}}{\\mathrm{d} t}\\iint_A\\vec D\\;\\cdot\\mathrm{d}\\vec A\\]");
BGridView *grille = new BGridView(2,26);
grille->GetLayout()->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER,B_ALIGN_BOTTOM));
for (int i=0; i < 26;i++) {
BString s;
s.Append((char)('a'+i), 1);
// BBitmap* image = ((App*)be_app)->latexToPNG(s);
view = new LView(s);
grille->GridLayout()->AddView(view,i,1);
}
for (int i=0; i < 26;i++) {
BString s;
s.Append((char)('A'+i), 1);
// BBitmap* image = ((App*)be_app)->latexToPNG(s);
view = new LView(s);
grille->GridLayout()->AddView(view,i,0);
}
view = new LView(chaine);
BTextControl *saisie = new BTextControl("label","text", new BMessage(kLatexPreview));
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.AddGroup(B_VERTICAL)
.SetInsets(5, 5, 5, 5)
.Add(grille)
.Add(view)
.AddGroup(B_HORIZONTAL)
.Add(saisie);
float height1, width1, height2, width2;
view->GetPreferredSize(&width1,&height1);
saisie->GetPreferredSize(&width2,&height2);
ResizeTo(10+std::max(width1, width2),20+height1+height2);
Show();
}
void LWindow::MessageReceived(BMessage* message) {
switch (message->what) {
case(kLatexPreview): {
BTextControl *textControl = NULL;
message->FindPointer("source", (void **)&textControl);
BString texte = BString(textControl->Text());
BWindow *preview = new BWindow(BRect(50,50,200,200), "preview", B_FLOATING_WINDOW, B_ASYNCHRONOUS_CONTROLS);
LView *view = new LView(texte);
preview->AddChild(view);
float width;
float height;
view->GetPreferredSize(&width, &height);
preview->ResizeTo(width,height);
preview->Show();
break;
}
default :
BWindow::MessageReceived(message);
}
}