Ticket #16453: CenteringBug.cpp

File CenteringBug.cpp, 1.3 KB (added by AGMS, 4 years ago)

Code which creates the examples of centered BTextControls.

Line 
1/******************************************************************************
2 * Example code which tests BTextControl's centering ability.
3 */
4
5#include <Application.h>
6#include <TextControl.h>
7#include <Window.h>
8
9class CenteringBugApp : public BApplication
10{
11public:
12 CenteringBugApp ();
13
14 virtual void ReadyToRun ();
15};
16
17CenteringBugApp::CenteringBugApp ()
18: BApplication ("application/BTextControlTest")
19{
20}
21
22
23void CenteringBugApp::ReadyToRun ()
24{
25 BWindow *WindowPntr = new BWindow (BRect (40, 40, 250, 100),
26 "BTextControl Centering Test",
27 B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS);
28
29 BTextControl *TextCtrlPntr = new BTextControl (BRect (5, 5, 200, 25),
30 "Text1", "Label1", "Text 1", NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
31 TextCtrlPntr->SetAlignment (B_ALIGN_CENTER, B_ALIGN_CENTER);
32 WindowPntr->AddChild (TextCtrlPntr);
33
34 TextCtrlPntr = new BTextControl (BRect (5, 25, 200, 45),
35 "Text2", "Label2", "This is some longer text in box 2.",
36 NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
37 TextCtrlPntr->SetAlignment (B_ALIGN_CENTER, B_ALIGN_CENTER);
38 WindowPntr->AddChild (TextCtrlPntr);
39
40
41 WindowPntr->Show ();
42}
43
44
45int main (int argc, char **argv)
46{
47 CenteringBugApp MyApp;
48
49 if (MyApp.InitCheck () == B_OK)
50 MyApp.Run ();
51
52 return 0;
53}