本文整理汇总了C++中Label::SetAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ Label::SetAlignment方法的具体用法?C++ Label::SetAlignment怎么用?C++ Label::SetAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Label
的用法示例。
在下文中一共展示了Label::SetAlignment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Label
TimeMenu::TimeMenu()
{
Label *label;
LineSpacer *spacer;
label = new Label();
label->SetFont(&MetaWatch_Large_16pt);
label->SetText("Time & Date");
label->SetAlignment(caCentre);
AddControl(label);
spacer = new LineSpacer(5, 2);
spacer->SetLeftPadding(10);
spacer->SetRightPadding(10);
AddControl(spacer);
// Time editor
timeEntry = new NumberEntry();
timeEntry->SetFont(&MetaWatch_Large_8pt);
timeEntry->SetFormat("[0-2][0-9]:[0-5][0-9]:[0-5][0-9]"); // TODO: Change with time format?
timeEntry->SetAlignment(caCentre);
AddControl(timeEntry);
// Date editor
dateEntry = new NumberEntry();
dateEntry->SetFont(&MetaWatch_Large_8pt);
dateEntry->SetFormat("[0-3][0-9]:[0-1][0-9]:[0-2][0-9][0-9][0-9]"); // TODO: Change with date format?
dateEntry->SetAlignment(caCentre);
AddControl(dateEntry);
}
示例2: BuildUi
void LobbyState::BuildUi()
{
Label* serverName = new Label(800, 100, "StateHeader", mServerData.name);
serverName->SetAlignment(false, true);
mControlManager->AddControl(serverName);
Button* startButton = new Button(800, 600, "StartGameButton", "Start game");
startButton->AddPressedListener(&LobbyState::ButtonPressed, this);
startButton->SetDisabled(!mIsHost);
startButton->SetAlignment(false, true);
mControlManager->AddControl(startButton);
Button* leaveButton = new Button(800, 600, "LeaveLobbyButton", "Leave lobby");
leaveButton->AddPressedListener(&LobbyState::ButtonPressed, this);
leaveButton->SetAlignment(false, true);
mControlManager->AddControl(leaveButton);
leaveButton->SetPressedSound("data/sounds/button.wav");
startButton->SetPressedSound("data/sounds/button.wav");
mControlManager->LoadLuaProperties();
}
示例3: Window
/**
* Create an instance of class EditorWindow
*
* @param row the initial row
* @param col the initial column
* @param rows the number of rows
* @param cols the number of columns
*/
EditorWindow::EditorWindow(int row, int col, int rows, int cols)
: Window("Untitled", row, col, rows, cols, 4, 7)
{
editor = NULL;
inactiveFrameColor = 6;
// Add scroll bars
AddScrollBar(true, 16, 3);
AddScrollBar(false, 2, 2);
HorizScrollBar()->SetBGColor(6);
HorizScrollBar()->SetFGColor(4);
VertScrollBar()->SetBGColor(6);
VertScrollBar()->SetFGColor(4);
// Add the split pane
splitPane = new SplitPane(this, SPLITPANE_HORIZONTAL, 0, 0, ClientRows(),
ClientColumns());
splitPane->SetSplit(ClientRows() - 3);
splitPane->SetMainComponent(SPLITPANE_COMPONENT_FIRST);
splitPane->SetOneComponentMode(SPLITPANE_COMPONENT_FIRST);
// Add the editor
editor = new Editor(splitPane, true, 0, 0, splitPane->Rows(),
splitPane->Columns(), ANCHOR_ALL);
editor->SetBGColor(BGColor());
editor->SetFGColor(FGColor());
editor->SetScrollBars(HorizScrollBar(), VertScrollBar());
// Add the tools pane
toolContainer = new Container(splitPane);
toolContainer->SetCapturesFocus(true);
Label* findLabel = new Label(toolContainer, "Find:", 0, 1, 1, 8);
findLabel->SetAlignment(ALIGN_RIGHT);
int e = findLabel->Column() + findLabel->Columns() + 1;
int r = findLabel->Row();
patternEditor = new Editor(toolContainer, false, r, e, 1,
toolContainer->ClientColumns() - e - 1 - 3 * (3 + 1),
ANCHOR_LEFT | ANCHOR_TOP | ANCHOR_RIGHT);
patternEditor->RegisterEventHandler(this);
/*ignoreCaseCheckBox = new CheckBox(toolContainer, "Ignore Case", false,1,1);
regexCheckBox = new CheckBox(toolContainer, "Regular Expression", false, 1,
ignoreCaseCheckBox->Column() + ignoreCaseCheckBox->Columns() + 2);*/
e = patternEditor->Column() + patternEditor->Columns() + 1;
searchPrevButton = new Button(toolContainer, "<", r, e, -1,
ANCHOR_TOP | ANCHOR_RIGHT);
searchPrevButton->RegisterEventHandler(this);
e += searchPrevButton->Columns() + 1;
searchNextButton = new Button(toolContainer, ">", r, e, -1,
ANCHOR_TOP | ANCHOR_RIGHT);
searchNextButton->RegisterEventHandler(this);
e += searchNextButton->Columns() + 1;
searchCloseButton = new Button(toolContainer, "X", r, e, -1,
ANCHOR_TOP | ANCHOR_RIGHT);
searchCloseButton->RegisterEventHandler(this);
e += searchCloseButton->Columns() + 1;
toolContainer->SetMinSize(2, 60);
}
示例4: GetWindow
//.........这里部分代码省略.........
lab->Height = Height;
lab->ControlType = ControlType;
char* str = core->GetString( StrRef );
lab->SetText( str );
core->FreeString( str );
if (alignment & 1) {
lab->useRGB = true;
Color f, b;
f.r = fore.b;
f.g = fore.g;
f.b = fore.r;
f.a = 0;
b.r = back.b;
b.g = back.g;
b.b = back.r;
b.a = 0;
lab->SetColor( f, b );
}
int align = IE_FONT_ALIGN_CENTER;
if (( alignment & 0x10 ) != 0) {
align = IE_FONT_ALIGN_RIGHT;
goto endvertical;
}
if (( alignment & 0x04 ) != 0) {
goto endvertical;
}
if (( alignment & 0x08 ) != 0) {
align = IE_FONT_ALIGN_LEFT;
goto endvertical;
}
endvertical:
if (( alignment & 0x20 ) != 0) {
align |= IE_FONT_ALIGN_TOP;
goto endalign;
}
if (( alignment & 0x80 ) != 0) {
align |= IE_FONT_ALIGN_BOTTOM;
} else {
align |= IE_FONT_ALIGN_MIDDLE;
}
endalign:
lab->SetAlignment( align );
win->AddControl( lab );
}
break;
case IE_GUI_SCROLLBAR:
{
//ScrollBar
ieResRef BAMResRef;
ieWord Cycle, Trough, Slider, TAID;
ieWord UpUnPressed, UpPressed;
ieWord DownUnPressed, DownPressed;
str->ReadResRef( BAMResRef );
str->ReadWord( &Cycle );
str->ReadWord( &UpUnPressed );
str->ReadWord( &UpPressed );
str->ReadWord( &DownUnPressed );
str->ReadWord( &DownPressed );
str->ReadWord( &Trough );
str->ReadWord( &Slider );
str->ReadWord( &TAID );
ScrollBar* sbar = new ScrollBar();
sbar->ControlID = ControlID;
sbar->XPos = XPos;
sbar->YPos = YPos;
sbar->Width = Width;
sbar->Height = Height;
sbar->ControlType = ControlType;
AnimationFactory* bam = ( AnimationFactory* )
gamedata->GetFactoryResource( BAMResRef,
IE_BAM_CLASS_ID, IE_NORMAL );
if (bam) {
sbar->SetImage( IE_GUI_SCROLLBAR_UP_UNPRESSED,
bam->GetFrame( UpUnPressed, Cycle ) );
sbar->SetImage( IE_GUI_SCROLLBAR_UP_PRESSED,
bam->GetFrame( UpPressed, Cycle ) );
sbar->SetImage( IE_GUI_SCROLLBAR_DOWN_UNPRESSED,
bam->GetFrame( DownUnPressed, Cycle ) );
sbar->SetImage( IE_GUI_SCROLLBAR_DOWN_PRESSED,
bam->GetFrame( DownPressed, Cycle ) );
sbar->SetImage( IE_GUI_SCROLLBAR_TROUGH,
bam->GetFrame( Trough, Cycle ) );
sbar->SetImage( IE_GUI_SCROLLBAR_SLIDER,
bam->GetFrame( Slider, Cycle ) );
}
win->AddControl( sbar );
if (TAID != 0xffff)
win->Link( ( unsigned short ) ControlID, TAID );
}
break;
default:
printMessage( "CHUImporter","Control Not Supported\n",LIGHT_RED );
}
}
return win;
}
示例5: GetWindow
//.........这里部分代码省略.........
win->Link( SBID, ( unsigned short ) ControlID );
}
break;
case IE_GUI_LABEL:
{
//Label
ieResRef FontResRef;
ieStrRef StrRef;
RevColor fore, back;
ieWord alignment;
str->ReadDword( &StrRef );
str->ReadResRef( FontResRef );
Font* fnt = core->GetFont( FontResRef );
str->Read( &fore, 4 );
str->Read( &back, 4 );
str->ReadWord( &alignment );
char* str = core->GetString( StrRef );
Label* lab = new Label( ctrlFrame, fnt, str );
core->FreeString( str );
lab->ControlID = ControlID;
if (alignment & 1) {
lab->useRGB = true;
Color f, b;
f.r = fore.b;
f.g = fore.g;
f.b = fore.r;
f.a = 0;
b.r = back.b;
b.g = back.g;
b.b = back.r;
b.a = 0;
lab->SetColor( f, b );
}
int align = IE_FONT_ALIGN_CENTER;
if (( alignment & 0x10 ) != 0) {
align = IE_FONT_ALIGN_RIGHT;
goto endvertical;
}
if (( alignment & 0x04 ) != 0) {
goto endvertical;
}
if (( alignment & 0x08 ) != 0) {
align = IE_FONT_ALIGN_LEFT;
goto endvertical;
}
endvertical:
if (( alignment & 0x20 ) != 0) {
align |= IE_FONT_ALIGN_TOP;
goto endalign;
}
if (( alignment & 0x80 ) != 0) {
align |= IE_FONT_ALIGN_BOTTOM;
} else {
align |= IE_FONT_ALIGN_MIDDLE;
}
endalign:
lab->SetAlignment( align );
win->AddControl( lab );
}
break;
case IE_GUI_SCROLLBAR:
{
//ScrollBar
ieResRef BAMResRef;
ieWord Cycle, TAID, imgIdx;
str->ReadResRef( BAMResRef );
str->ReadWord( &Cycle );
AnimationFactory* bam = ( AnimationFactory* )
gamedata->GetFactoryResource( BAMResRef,
IE_BAM_CLASS_ID, IE_NORMAL );
if (!bam) {
Log(ERROR, "CHUImporter", "Unable to create scrollbar, no BAM: %s", BAMResRef);
break;
}
Sprite2D* images[IE_SCROLLBAR_IMAGE_COUNT];
for (int i=0; i < IE_SCROLLBAR_IMAGE_COUNT; i++) {
str->ReadWord( &imgIdx );
images[i] = bam->GetFrame( imgIdx, Cycle );
}
str->ReadWord( &TAID );
ScrollBar* sbar = new ScrollBar(ctrlFrame, images);
sbar->ControlID = ControlID;
win->AddControl( sbar );
if (TAID != 0xffff)
win->Link( ( unsigned short ) ControlID, TAID );
}
break;
default:
Log(ERROR, "CHUImporter", "Control Not Supported");
}
}
return win;
}