Ticket #4689: stylededit-shortcuts-2-v2.diff
File stylededit-shortcuts-2-v2.diff, 3.6 KB (added by , 13 years ago) |
---|
-
src/apps/stylededit/StyledEditWindow.cpp
311 311 BMenuItem* item = static_cast<BMenuItem*>(ptr); 312 312 fontFamily = item->Label(); 313 313 } 314 315 BFont font; 316 font.SetFamilyAndStyle(fontFamily, fontStyle); 317 fItalicItem->SetMarked(font.Face() & B_ITALIC_FACE); 318 fBoldItem->SetMarked(font.Face() & B_BOLD_FACE); 319 314 320 _SetFontStyle(fontFamily, fontStyle); 315 321 break; 316 322 } … … 329 335 fontFamily = super_item->Label(); 330 336 } 331 337 } 338 339 BFont font; 340 font.SetFamilyAndStyle(fontFamily, fontStyle); 341 fItalicItem->SetMarked(font.Face() & B_ITALIC_FACE); 342 fBoldItem->SetMarked(font.Face() & B_BOLD_FACE); 343 332 344 _SetFontStyle(fontFamily, fontStyle); 333 345 break; 334 346 } 347 case SET_ITALIC: 348 { 349 uint32 sameProperties; 350 BFont font; 351 352 fTextView->GetFontAndColor(&font, &sameProperties); 353 if(fItalicItem->IsMarked()) 354 font.SetFace(B_REGULAR_FACE); 355 fItalicItem->SetMarked(!fItalicItem->IsMarked()); 356 357 font_family family; 358 font_style style; 359 font.GetFamilyAndStyle(&family, &style); 360 361 _SetFontStyle(family, style); 362 break; 363 } 364 case SET_BOLD: 365 { 366 uint32 sameProperties; 367 BFont font; 368 369 fTextView->GetFontAndColor(&font, &sameProperties); 370 if(fBoldItem->IsMarked()) 371 font.SetFace(B_REGULAR_FACE); 372 fBoldItem->SetMarked(!fBoldItem->IsMarked()); 373 374 font_family family; 375 font_style style; 376 font.GetFamilyAndStyle(&family, &style); 377 378 _SetFontStyle(family, style); 379 break; 380 } 335 381 case FONT_COLOR: 336 382 { 337 383 void* ptr; … … 587 633 } 588 634 } 589 635 636 fBoldItem->SetMarked(font.Face() & B_BOLD_FACE); 637 fItalicItem->SetMarked(font.Face() & B_ITALIC_FACE); 638 590 639 switch (fTextView->Alignment()) { 591 640 case B_ALIGN_LEFT: 592 641 default: … … 1106 1155 YELLOW, new BMessage(FONT_COLOR))); 1107 1156 fFontMenu->AddSeparatorItem(); 1108 1157 1158 // "Bold" & "Italic" menu items 1159 fFontMenu->AddItem(fBoldItem = new BMenuItem(B_TRANSLATE("Bold"), 1160 new BMessage(SET_BOLD))); 1161 fFontMenu->AddItem(fItalicItem = new BMenuItem(B_TRANSLATE("Italic"), 1162 new BMessage(SET_ITALIC))); 1163 fBoldItem->SetShortcut('B', 0); 1164 fItalicItem->SetShortcut('I', 0); 1165 fFontMenu->AddSeparatorItem(); 1166 1109 1167 // Available fonts 1110 1168 1111 1169 fCurrentFontItem = 0; … … 1522 1580 } 1523 1581 1524 1582 font.SetFamilyAndStyle(fontFamily, fontStyle); 1583 1584 uint16 face = 0; 1585 1586 if (!(font.Face() & B_REGULAR_FACE)) 1587 face = font.Face(); 1588 1589 if (fBoldItem->IsMarked()) 1590 face |= B_BOLD_FACE; 1591 1592 if (fItalicItem->IsMarked()) 1593 face |= B_ITALIC_FACE; 1594 1595 font.SetFace(face); 1596 1525 1597 fTextView->SetFontAndColor(&font); 1526 1598 1527 1599 BMenuItem* superItem; -
src/apps/stylededit/StyledEditWindow.h
106 106 BMenuItem* fMagentaItem; 107 107 BMenuItem* fYellowItem; 108 108 109 BMenuItem* fBoldItem; 110 BMenuItem* fItalicItem; 111 109 112 BMenuItem* fWrapItem; 110 113 BMenuItem* fAlignLeft; 111 114 BMenuItem* fAlignCenter; -
src/apps/stylededit/Constants.h
48 48 const uint32 FONT_FAMILY = 'FFch'; 49 49 const uint32 FONT_STYLE = 'FSch'; 50 50 const uint32 FONT_COLOR = 'Fcol'; 51 const uint32 SET_ITALIC = 'Fita'; 52 const uint32 SET_BOLD = 'Fbld'; 51 53 52 54 // fontcolors 53 55 const rgb_color BLACK = {0, 0, 0, 255};