本文整理汇总了C++中Style::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ Style::SetName方法的具体用法?C++ Style::SetName怎么用?C++ Style::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Style
的用法示例。
在下文中一共展示了Style::SetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new
// _AddStyle
status_t
StyledTextImporter::_AddStyle(Icon *icon, text_run *run)
{
CALLED();
if (!run)
return EINVAL;
rgb_color color = run->color;
Style* style = new (nothrow) Style(color);
if (!style) {
delete style;
return B_NO_MEMORY;
}
char name[30];
sprintf(name, "Color (#%02x%02x%02x)", color.red, color.green, color.blue);
style->SetName(name);
bool found = false;
for (int i = 0; i < fStyleCount; i++) {
if (*style == *(fStyleMap[i].style)) {
delete style;
style = fStyleMap[i].style;
found = true;
break;
}
}
if (!found && !icon->Styles()->AddStyle(style)) {
delete style;
return B_NO_MEMORY;
}
fStyleMap[fStyleCount].run = run;
fStyleMap[fStyleCount].style = style;
fStyleCount++;
return B_OK;
}
示例2: locker
void
MainWindow::MessageReceived(BMessage* message)
{
bool discard = false;
// Figure out if we need the write lock on the Document. For most
// messages we do, but exporting takes place in another thread and
// locking is taken care of there.
bool requiresWriteLock = true;
switch (message->what) {
case MSG_SAVE:
case MSG_EXPORT:
case MSG_SAVE_AS:
case MSG_EXPORT_AS:
requiresWriteLock = false;
break;
default:
break;
}
if (requiresWriteLock && !fDocument->WriteLock()) {
BWindow::MessageReceived(message);
return;
}
if (message->WasDropped()) {
const rgb_color* color;
ssize_t length;
// create styles from dropped colors
for (int32 i = 0; message->FindData("RGBColor", B_RGB_COLOR_TYPE, i,
(const void**)&color, &length) == B_OK; i++) {
if (length != sizeof(rgb_color))
continue;
char name[30];
sprintf(name,
B_TRANSLATE_CONTEXT("Color (#%02x%02x%02x)",
"Style name after dropping a color"),
color->red, color->green, color->blue);
Style* style = new (nothrow) Style(*color);
style->SetName(name);
Style* styles[1] = { style };
AddStylesCommand* styleCommand = new (nothrow) AddStylesCommand(
fDocument->Icon()->Styles(), styles, 1,
fDocument->Icon()->Styles()->CountStyles());
fDocument->CommandStack()->Perform(styleCommand);
// don't handle anything else,
// or we might paste the clipboard on B_PASTE
discard = true;
}
}
switch (message->what) {
case B_REFS_RECEIVED:
case B_SIMPLE_DATA:
// If our icon is empty, open the file in this window,
// otherwise forward to the application which will open
// it in another window, unless we append.
message->what = B_REFS_RECEIVED;
if (fDocument->Icon()->Styles()->CountStyles() == 0
&& fDocument->Icon()->Paths()->CountPaths() == 0
&& fDocument->Icon()->Shapes()->CountShapes() == 0) {
entry_ref ref;
if (message->FindRef("refs", &ref) == B_OK)
Open(ref);
break;
}
if (modifiers() & B_SHIFT_KEY) {
// We want the icon appended to this window.
message->AddBool("append", true);
message->AddPointer("window", this);
}
be_app->PostMessage(message);
break;
case B_PASTE:
case B_MIME_DATA:
{
BMessage* clip = message;
status_t err;
if (discard)
break;
if (message->what == B_PASTE) {
if (!be_clipboard->Lock())
break;
clip = be_clipboard->Data();
}
if (!clip || !clip->HasData("text/plain", B_MIME_TYPE)) {
if (message->what == B_PASTE)
be_clipboard->Unlock();
break;
}
Icon* icon = new (std::nothrow) Icon(*fDocument->Icon());
if (icon != NULL) {
StyledTextImporter importer;
err = importer.Import(icon, clip);
if (err >= B_OK) {
//.........这里部分代码省略.........