Ticket #5480: StyledEdit.patch(2)

File StyledEdit.patch(2), 31.0 KB (added by mt, 14 years ago)

corrected patch (B_UTF8_ELLIPSIS)

Line 
1Index: StyledEditWindow.cpp
2===================================================================
3--- StyledEditWindow.cpp (revision 35655)
4+++ StyledEditWindow.cpp (working copy)
5@@ -19,12 +19,14 @@
6
7 #include <Alert.h>
8 #include <Autolock.h>
9+#include <Catalog.h>
10 #include <CharacterSet.h>
11 #include <CharacterSetRoster.h>
12 #include <Clipboard.h>
13 #include <Debug.h>
14 #include <File.h>
15 #include <FilePanel.h>
16+#include <Locale.h>
17 #include <Menu.h>
18 #include <MenuBar.h>
19 #include <MenuItem.h>
20@@ -42,12 +44,14 @@
21
22 const float kLineViewWidth = 30.0;
23
24+#undef TR_CONTEXT
25+#define TR_CONTEXT "StyledEditWindow"
26
27 StyledEditWindow::StyledEditWindow(BRect frame, int32 id, uint32 encoding)
28 : BWindow(frame, "untitled", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
29 {
30 InitWindow(encoding);
31- BString unTitled("Untitled ");
32+ BString unTitled(TR("Untitled "));
33 unTitled << id;
34 SetTitle(unTitled.String());
35 fSaveItem->SetEnabled(true);
36@@ -56,7 +60,7 @@
37 }
38
39
40-StyledEditWindow::StyledEditWindow(BRect frame, entry_ref *ref, uint32 encoding)
41+StyledEditWindow::StyledEditWindow(BRect frame, entry_ref* ref, uint32 encoding)
42 : BWindow(frame, "untitled", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
43 {
44 InitWindow(encoding);
45@@ -73,6 +77,9 @@
46 }
47
48
49+#undef TR_CONTEXT
50+#define TR_CONTEXT "Menus"
51+
52 void
53 StyledEditWindow::InitWindow(uint32 encoding)
54 {
55@@ -124,79 +131,97 @@
56 fTextView->MakeFocus(true);
57
58 // Add "File"-menu:
59- BMenu* menu = new BMenu("File");
60+ BMenu* menu = new BMenu(TR("File"));
61 fMenuBar->AddItem(menu);
62
63 BMenuItem* menuItem;
64- menu->AddItem(menuItem = new BMenuItem("New", new BMessage(MENU_NEW), 'N'));
65+ menu->AddItem(menuItem = new BMenuItem(TR("New"),
66+ new BMessage(MENU_NEW), 'N'));
67 menuItem->SetTarget(be_app);
68
69- menu->AddItem(menuItem = new BMenuItem(fRecentMenu = new BMenu("Open" B_UTF8_ELLIPSIS),
70- new BMessage(MENU_OPEN)));
71+ menu->AddItem(menuItem = new BMenuItem(fRecentMenu =
72+ new BMenu(TR("Open" B_UTF8_ELLIPSIS)), new BMessage(MENU_OPEN)));
73 menuItem->SetShortcut('O', 0);
74 menuItem->SetTarget(be_app);
75 menu->AddSeparatorItem();
76
77- menu->AddItem(fSaveItem = new BMenuItem("Save", new BMessage(MENU_SAVE), 'S'));
78+ menu->AddItem(fSaveItem = new BMenuItem(TR("Save"),
79+ new BMessage(MENU_SAVE), 'S'));
80 fSaveItem->SetEnabled(false);
81- menu->AddItem(menuItem = new BMenuItem("Save as" B_UTF8_ELLIPSIS, new BMessage(MENU_SAVEAS)));
82- menuItem->SetShortcut('S',B_SHIFT_KEY);
83+ menu->AddItem(menuItem = new BMenuItem(TR("Save as" B_UTF8_ELLIPSIS),
84+ new BMessage(MENU_SAVEAS)));
85+ menuItem->SetShortcut('S', B_SHIFT_KEY);
86 menuItem->SetEnabled(true);
87
88- menu->AddItem(fRevertItem = new BMenuItem("Revert to saved" B_UTF8_ELLIPSIS,
89+ menu->AddItem(fRevertItem =
90+ new BMenuItem(TR("Revert to saved" B_UTF8_ELLIPSIS),
91 new BMessage(MENU_REVERT)));
92 fRevertItem->SetEnabled(false);
93- menu->AddItem(menuItem = new BMenuItem("Close", new BMessage(MENU_CLOSE), 'W'));
94+ menu->AddItem(menuItem = new BMenuItem(TR("Close"),
95+ new BMessage(MENU_CLOSE), 'W'));
96
97 menu->AddSeparatorItem();
98- menu->AddItem(menuItem = new BMenuItem("Page setup" B_UTF8_ELLIPSIS, new BMessage(MENU_PAGESETUP)));
99- menu->AddItem(menuItem = new BMenuItem("Print" B_UTF8_ELLIPSIS, new BMessage(MENU_PRINT), 'P'));
100+ menu->AddItem(menuItem = new BMenuItem(TR("Page setup" B_UTF8_ELLIPSIS),
101+ new BMessage(MENU_PAGESETUP)));
102+ menu->AddItem(menuItem = new BMenuItem(TR("Print" B_UTF8_ELLIPSIS),
103+ new BMessage(MENU_PRINT), 'P'));
104
105 menu->AddSeparatorItem();
106- menu->AddItem(menuItem = new BMenuItem("Quit", new BMessage(MENU_QUIT), 'Q'));
107+ menu->AddItem(menuItem = new BMenuItem(TR("Quit"),
108+ new BMessage(MENU_QUIT), 'Q'));
109
110 // Add the "Edit"-menu:
111- menu = new BMenu("Edit");
112+ menu = new BMenu(TR("Edit"));
113 fMenuBar->AddItem(menu);
114
115- menu->AddItem(fUndoItem = new BMenuItem("Can't undo", new BMessage(B_UNDO), 'Z'));
116+ menu->AddItem(fUndoItem = new BMenuItem(TR("Can't undo"),
117+ new BMessage(B_UNDO), 'Z'));
118 fUndoItem->SetEnabled(false);
119
120 menu->AddSeparatorItem();
121- menu->AddItem(fCutItem = new BMenuItem("Cut", new BMessage(B_CUT), 'X'));
122+ menu->AddItem(fCutItem = new BMenuItem(TR("Cut"), new BMessage(B_CUT), 'X'));
123 fCutItem->SetEnabled(false);
124 fCutItem->SetTarget(fTextView);
125
126- menu->AddItem(fCopyItem = new BMenuItem("Copy", new BMessage(B_COPY), 'C'));
127+ menu->AddItem(fCopyItem = new BMenuItem(TR("Copy"),
128+ new BMessage(B_COPY), 'C'));
129 fCopyItem->SetEnabled(false);
130 fCopyItem->SetTarget(fTextView);
131
132- menu->AddItem(menuItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V'));
133+ menu->AddItem(menuItem = new BMenuItem(TR("Paste"),
134+ new BMessage(B_PASTE), 'V'));
135 menuItem->SetTarget(fTextView);
136- menu->AddItem(fClearItem = new BMenuItem("Clear", new BMessage(MENU_CLEAR)));
137+ menu->AddItem(fClearItem = new BMenuItem(TR("Clear"),
138+ new BMessage(MENU_CLEAR)));
139 fClearItem->SetEnabled(false);
140 fClearItem->SetTarget(fTextView);
141
142 menu->AddSeparatorItem();
143- menu->AddItem(menuItem = new BMenuItem("Select all", new BMessage(B_SELECT_ALL), 'A'));
144+ menu->AddItem(menuItem = new BMenuItem(TR("Select all"),
145+ new BMessage(B_SELECT_ALL), 'A'));
146 menuItem->SetTarget(fTextView);
147
148 menu->AddSeparatorItem();
149- menu->AddItem(menuItem = new BMenuItem("Find" B_UTF8_ELLIPSIS, new BMessage(MENU_FIND),'F'));
150- menu->AddItem(fFindAgainItem= new BMenuItem("Find again",new BMessage(MENU_FIND_AGAIN),'G'));
151+ menu->AddItem(menuItem = new BMenuItem(TR("Find" B_UTF8_ELLIPSIS),
152+ new BMessage(MENU_FIND), 'F'));
153+ menu->AddItem(fFindAgainItem= new BMenuItem(TR("Find again"),
154+ new BMessage(MENU_FIND_AGAIN), 'G'));
155 fFindAgainItem->SetEnabled(false);
156
157- menu->AddItem(menuItem = new BMenuItem("Find selection", new BMessage(MENU_FIND_SELECTION),'H'));
158- menu->AddItem(menuItem = new BMenuItem("Replace" B_UTF8_ELLIPSIS, new BMessage(MENU_REPLACE),'R'));
159- menu->AddItem(fReplaceSameItem = new BMenuItem("Replace same", new BMessage(MENU_REPLACE_SAME),'T'));
160+ menu->AddItem(menuItem = new BMenuItem(TR("Find selection"),
161+ new BMessage(MENU_FIND_SELECTION), 'H'));
162+ menu->AddItem(menuItem = new BMenuItem(TR("Replace" B_UTF8_ELLIPSIS),
163+ new BMessage(MENU_REPLACE), 'R'));
164+ menu->AddItem(fReplaceSameItem = new BMenuItem(TR("Replace same"),
165+ new BMessage(MENU_REPLACE_SAME), 'T'));
166 fReplaceSameItem->SetEnabled(false);
167
168 // Add the "Font"-menu:
169- fFontMenu = new BMenu("Font");
170+ fFontMenu = new BMenu(TR("Font"));
171 fMenuBar->AddItem(fFontMenu);
172
173 //"Size"-subMenu
174- fFontSizeMenu = new BMenu("Size");
175+ fFontSizeMenu = new BMenu(TR("Size"));
176 fFontSizeMenu->SetRadioMode(true);
177 fFontMenu->AddItem(fFontSizeMenu);
178
179@@ -214,18 +239,25 @@
180 }
181
182 // "Color"-subMenu
183- fFontColorMenu = new BMenu("Color");
184+ fFontColorMenu = new BMenu(TR("Color"));
185 fFontColorMenu->SetRadioMode(true);
186 fFontMenu->AddItem(fFontColorMenu);
187
188- fFontColorMenu->AddItem(fBlackItem = new BMenuItem("Black", new BMessage(FONT_COLOR)));
189+ fFontColorMenu->AddItem(fBlackItem = new BMenuItem(TR("Black"),
190+ new BMessage(FONT_COLOR)));
191 fBlackItem->SetMarked(true);
192- fFontColorMenu->AddItem(fRedItem = new ColorMenuItem("Red", RED, new BMessage(FONT_COLOR)));
193- fFontColorMenu->AddItem(fGreenItem = new ColorMenuItem("Green", GREEN, new BMessage(FONT_COLOR)));
194- fFontColorMenu->AddItem(fBlueItem = new ColorMenuItem("Blue", BLUE, new BMessage(FONT_COLOR)));
195- fFontColorMenu->AddItem(fCyanItem = new ColorMenuItem("Cyan", CYAN, new BMessage(FONT_COLOR)));
196- fFontColorMenu->AddItem(fMagentaItem = new ColorMenuItem("Magenta", MAGENTA, new BMessage(FONT_COLOR)));
197- fFontColorMenu->AddItem(fYellowItem = new ColorMenuItem("Yellow", YELLOW, new BMessage(FONT_COLOR)));
198+ fFontColorMenu->AddItem(fRedItem = new ColorMenuItem(TR("Red"), RED,
199+ new BMessage(FONT_COLOR)));
200+ fFontColorMenu->AddItem(fGreenItem = new ColorMenuItem(TR("Green"), GREEN,
201+ new BMessage(FONT_COLOR)));
202+ fFontColorMenu->AddItem(fBlueItem = new ColorMenuItem(TR("Blue"), BLUE,
203+ new BMessage(FONT_COLOR)));
204+ fFontColorMenu->AddItem(fCyanItem = new ColorMenuItem(TR("Cyan"), CYAN,
205+ new BMessage(FONT_COLOR)));
206+ fFontColorMenu->AddItem(fMagentaItem = new ColorMenuItem(TR("Magenta"), MAGENTA,
207+ new BMessage(FONT_COLOR)));
208+ fFontColorMenu->AddItem(fYellowItem = new ColorMenuItem(TR("Yellow"), YELLOW,
209+ new BMessage(FONT_COLOR)));
210 fFontMenu->AddSeparatorItem();
211
212 // Available fonts
213@@ -256,20 +288,24 @@
214 }
215
216 // Add the "Document"-menu:
217- menu = new BMenu("Document");
218+ menu = new BMenu(TR("Document"));
219 fMenuBar->AddItem(menu);
220
221 // "Align"-subMenu:
222- subMenu = new BMenu("Align");
223+ subMenu = new BMenu(TR("Align"));
224 subMenu->SetRadioMode(true);
225
226- subMenu->AddItem(fAlignLeft = new BMenuItem("Left", new BMessage(ALIGN_LEFT)));
227+ subMenu->AddItem(fAlignLeft = new BMenuItem(TR("Left"),
228+ new BMessage(ALIGN_LEFT)));
229 fAlignLeft->SetMarked(true);
230
231- subMenu->AddItem(fAlignCenter = new BMenuItem("Center", new BMessage(ALIGN_CENTER)));
232- subMenu->AddItem(fAlignRight = new BMenuItem("Right", new BMessage(ALIGN_RIGHT)));
233+ subMenu->AddItem(fAlignCenter = new BMenuItem(TR("Center"),
234+ new BMessage(ALIGN_CENTER)));
235+ subMenu->AddItem(fAlignRight = new BMenuItem(TR("Right"),
236+ new BMessage(ALIGN_RIGHT)));
237 menu->AddItem(subMenu);
238- menu->AddItem(fWrapItem = new BMenuItem("Wrap lines", new BMessage(WRAP_LINES)));
239+ menu->AddItem(fWrapItem = new BMenuItem(TR("Wrap lines"),
240+ new BMessage(WRAP_LINES)));
241 fWrapItem->SetMarked(true);
242
243 fSavePanel = NULL;
244@@ -279,7 +315,7 @@
245
246
247 void
248-StyledEditWindow::MessageReceived(BMessage *message)
249+StyledEditWindow::MessageReceived(BMessage* message)
250 {
251 if (message->WasDropped()) {
252 entry_ref ref;
253@@ -502,7 +538,7 @@
254 {
255 BRect textRect(fTextView->Bounds());
256 textRect.OffsetTo(B_ORIGIN);
257- textRect.InsetBy(TEXT_INSET,TEXT_INSET);
258+ textRect.InsetBy(TEXT_INSET, TEXT_INSET);
259 if (fTextView->DoesWordWrap()) {
260 fTextView->SetWordWrap(false);
261 fWrapItem->SetMarked(false);
262@@ -534,15 +570,15 @@
263 fClean = true;
264 fUndoCleans = false;
265 } else if (fClean) {
266- // if we were clean
267- // then a redo will make us clean again
268- fRedoCleans = true;
269- fClean = false;
270+ // if we were clean
271+ // then a redo will make us clean again
272+ fRedoCleans = true;
273+ fClean = false;
274 }
275 // set mode
276 fCanUndo = false;
277 fCanRedo = true;
278- fUndoItem->SetLabel("Redo typing");
279+ fUndoItem->SetLabel(TR("Redo typing"));
280 fUndoItem->SetEnabled(true);
281 fUndoFlag = false;
282 } else {
283@@ -562,7 +598,7 @@
284 // set mode
285 fCanUndo = true;
286 fCanRedo = false;
287- fUndoItem->SetLabel("Undo typing");
288+ fUndoItem->SetLabel(TR("Undo typing"));
289 fUndoItem->SetEnabled(true);
290 fRedoFlag = false;
291 }
292@@ -579,7 +615,8 @@
293 void* ptr;
294 if (message->FindPointer("source", &ptr) == B_OK
295 && fSavePanelEncodingMenu != NULL) {
296- fTextView->SetEncoding((uint32)fSavePanelEncodingMenu->IndexOf((BMenuItem*)ptr));
297+ fTextView->SetEncoding(
298+ (uint32)fSavePanelEncodingMenu->IndexOf((BMenuItem*)ptr));
299 }
300 break;
301
302@@ -736,15 +773,34 @@
303 }
304
305
306+// This is temporary solution for building BString with printf like format.
307+// will be removed in the future.
308+static void
309+bs_printf(BString* string, const char* format, ...)
310+{
311+ va_list ap;
312+ va_start(ap, format);
313+ char* buf;
314+ vasprintf(&buf, format, ap);
315+ string->SetTo(buf);
316+ free(buf);
317+ va_end(ap);
318+}
319+
320+
321+#undef TR_CONTEXT
322+#define TR_CONTEXT "QuitAlert"
323+
324 bool
325 StyledEditWindow::QuitRequested()
326 {
327 if (fClean)
328 return true;
329
330- BString alertText("Save changes to the document \"");
331- alertText<< Title() <<"\"? ";
332- int32 index = _ShowAlert(alertText, "Cancel", "Don't save", "Save",
333+ BString alertText;
334+ bs_printf(&alertText, TR("Save changes to the document \"%s\"? "), Title());
335+
336+ int32 index = _ShowAlert(alertText, TR("Cancel"), TR("Don't save"), TR("Save"),
337 B_WARNING_ALERT);
338
339 if (index == 0)
340@@ -762,8 +818,11 @@
341 }
342
343
344+#undef TR_CONTEXT
345+#define TR_CONTEXT "SaveAlert"
346+
347 status_t
348-StyledEditWindow::Save(BMessage *message)
349+StyledEditWindow::Save(BMessage* message)
350 {
351 if (!message)
352 message = fSaveMessage;
353@@ -788,10 +847,10 @@
354 }
355
356 if (status != B_OK) {
357- BString alertText("Error saving \"");
358- alertText << name << "\":\n" << strerror(status);
359+ BString alertText;
360+ bs_printf(&alertText, TR("Error saving \"%s\":\n%s"), name, strerror(status));
361
362- _ShowAlert(alertText, "OK", "", "", B_STOP_ALERT);
363+ _ShowAlert(alertText, TR("OK"), "", "", B_STOP_ALERT);
364 return status;
365 }
366
367@@ -816,8 +875,11 @@
368 }
369
370
371+#undef TR_CONTEXT
372+#define TR_CONTEXT "Open_and_SaveAsPanel"
373+
374 status_t
375-StyledEditWindow::SaveAs(BMessage *message)
376+StyledEditWindow::SaveAs(BMessage* message)
377 {
378 if (fSavePanel == NULL) {
379 entry_ref* directory = NULL;
380@@ -834,7 +896,7 @@
381 BMenuBar* menuBar = dynamic_cast<BMenuBar*>(
382 fSavePanel->Window()->FindView("MenuBar"));
383
384- fSavePanelEncodingMenu= new BMenu("Encoding");
385+ fSavePanelEncodingMenu= new BMenu(TR("Encoding"));
386 menuBar->AddItem(fSavePanelEncodingMenu);
387 fSavePanelEncodingMenu->SetRadioMode(true);
388
389@@ -848,7 +910,8 @@
390 name.Append(mime);
391 name.Append(")");
392 }
393- BMenuItem * item = new BMenuItem(name.String(), new BMessage(SAVE_AS_ENCODING));
394+ BMenuItem * item = new BMenuItem(name.String(),
395+ new BMessage(SAVE_AS_ENCODING));
396 item->SetTarget(this);
397 fSavePanelEncodingMenu->AddItem(item);
398 if (charset.GetFontID() == fTextView->GetEncoding())
399@@ -865,6 +928,9 @@
400 }
401
402
403+#undef TR_CONTEXT
404+#define TR_CONTEXT "LoadAlert"
405+
406 status_t
407 StyledEditWindow::_LoadFile(entry_ref* ref)
408 {
409@@ -892,16 +958,15 @@
410 BEntry entry(ref, true);
411 char name[B_FILE_NAME_LENGTH];
412 if (entry.GetName(name) != B_OK)
413- strcpy(name, "???");
414+ strcpy(name, TR("???"));
415
416- BString text("Error loading \"");
417- text << name << "\":\n\t";
418+ BString text;
419 if (status == B_BAD_TYPE)
420- text << "Unsupported format";
421+ bs_printf(&text, TR("Error loading \"%s\":\n\tUnsupported format"), name);
422 else
423- text << strerror(status);
424+ bs_printf(&text, TR("Error loading \"%s\":\n\t%s"), name, strerror(status));
425
426- _ShowAlert(text, "OK", "", "", B_STOP_ALERT);
427+ _ShowAlert(text, TR("OK"), "", "", B_STOP_ALERT);
428 return status;
429 }
430
431@@ -953,11 +1018,14 @@
432 }
433
434
435+#undef TR_CONTEXT
436+#define TR_CONTEXT "RevertToSavedAlert"
437+
438 void
439 StyledEditWindow::RevertToSaved()
440 {
441 entry_ref ref;
442- const char *name;
443+ const char* name;
444
445 fSaveMessage->FindRef("directory", &ref);
446 fSaveMessage->FindString("name", &name);
447@@ -972,23 +1040,26 @@
448 status = entry.GetRef(&ref);
449
450 if (status != B_OK || !entry.Exists()) {
451- BString alertText("Cannot revert, file not found: \"");
452- alertText << name << "\".";
453- _ShowAlert(alertText, "OK", "", "", B_STOP_ALERT);
454+ BString alertText;
455+ bs_printf(&alertText, TR("Cannot revert, file not found: \"%s\"."), name);
456+ _ShowAlert(alertText, TR("OK"), "", "", B_STOP_ALERT);
457 return;
458 }
459
460- BString alertText("Revert to the last version of \"");
461- alertText << Title() << "\"? ";
462- if (_ShowAlert(alertText, "Cancel", "OK", "", B_WARNING_ALERT) != 1)
463+ BString alertText;
464+ bs_printf(&alertText, TR("Revert to the last version of \"%s\"? "), Title());
465+ if (_ShowAlert(alertText, TR("Cancel"), TR("OK"), "", B_WARNING_ALERT) != 1)
466 return;
467
468 fTextView->Reset();
469 if (_LoadFile(&ref) != B_OK)
470 return;
471
472+#undef TR_CONTEXT
473+#define TR_CONTEXT "Menus"
474+
475 // clear undo modes
476- fUndoItem->SetLabel("Can't undo");
477+ fUndoItem->SetLabel(TR("Can't undo"));
478 fUndoItem->SetEnabled(false);
479 fUndoFlag = false;
480 fCanUndo = false;
481@@ -1089,7 +1160,8 @@
482 top = fTextView->TextHeight(0, firstLineOnPage - 1);
483
484 float bottom = fTextView->TextHeight(0, printLine - 1);
485- BRect textRect(0.0, top + TEXT_INSET, printableRect.Width(), bottom + TEXT_INSET);
486+ BRect textRect(0.0, top + TEXT_INSET,
487+ printableRect.Width(), bottom + TEXT_INSET);
488 printJob.DrawView(fTextView, textRect, B_ORIGIN);
489 printJob.SpoolPage();
490 }
491@@ -1213,7 +1285,7 @@
492 if (viewText.Length() < textFinish)
493 textFinish = viewText.Length();
494
495- fTextView->Select(textStart,textFinish);
496+ fTextView->Select(textStart, textFinish);
497 fTextView->ScrollToSelection();
498
499 _UpdateCleanUndoRedoSaveRevert();
500@@ -1226,14 +1298,14 @@
501 int32 numWindows;
502 numWindows = be_app->CountWindows();
503
504- BMessage *message;
505+ BMessage* message;
506 message= new BMessage(MSG_REPLACE_ALL);
507 message->AddString("FindText", find);
508 message->AddString("ReplaceText", replace);
509 message->AddBool("casesens", caseSensitive);
510
511 while (numWindows >= 0) {
512- StyledEditWindow *window = dynamic_cast<StyledEditWindow *>(
513+ StyledEditWindow* window = dynamic_cast<StyledEditWindow *>(
514 be_app->WindowAt(numWindows));
515
516 BMessenger messenger(window);
517@@ -1259,7 +1331,7 @@
518
519
520 void
521-StyledEditWindow::SetFontColor(const rgb_color *color)
522+StyledEditWindow::SetFontColor(const rgb_color* color)
523 {
524 uint32 sameProperties;
525 BFont font;
526@@ -1272,7 +1344,7 @@
527
528
529 void
530-StyledEditWindow::SetFontStyle(const char *fontFamily, const char *fontStyle)
531+StyledEditWindow::SetFontStyle(const char* fontFamily, const char* fontStyle)
532 {
533 BFont font;
534 uint32 sameProperties;
535@@ -1311,6 +1383,8 @@
536 }
537
538
539+#undef TR_CONTEXT
540+#define TR_CONTEXT "Menus"
541 void
542 StyledEditWindow::_UpdateCleanUndoRedoSaveRevert()
543 {
544@@ -1319,7 +1393,7 @@
545 fRedoCleans = false;
546 fRevertItem->SetEnabled(fSaveMessage != NULL);
547 fSaveItem->SetEnabled(true);
548- fUndoItem->SetLabel("Can't Undo");
549+ fUndoItem->SetLabel(TR("Can't Undo"));
550 fUndoItem->SetEnabled(false);
551 fCanUndo = false;
552 fCanRedo = false;
553Index: ReplaceWindow.cpp
554===================================================================
555--- ReplaceWindow.cpp (revision 35655)
556+++ ReplaceWindow.cpp (working copy)
557@@ -12,69 +12,72 @@
558 #include "ReplaceWindow.h"
559
560 #include <Button.h>
561+#include <Catalog.h>
562 #include <CheckBox.h>
563+#include <GroupLayoutBuilder.h>
564+#include <GridLayoutBuilder.h>
565 #include <Handler.h>
566+#include <Locale.h>
567+#include <LayoutBuilder.h>
568 #include <Message.h>
569 #include <Messenger.h>
570-#include <Rect.h>
571 #include <String.h>
572 #include <TextControl.h>
573-#include <View.h>
574
575
576-ReplaceWindow::ReplaceWindow(BRect frame, BHandler *_handler, BString *searchString,
577- BString *replaceString, bool caseState, bool wrapState, bool backState)
578+#undef TR_CONTEXT
579+#define TR_CONTEXT "FindandReplaceWindow"
580+
581+ReplaceWindow::ReplaceWindow(BRect frame, BHandler* _handler,
582+ BString* searchString, BString *replaceString,
583+ bool caseState, bool wrapState, bool backState)
584 : BWindow(frame, "ReplaceWindow", B_MODAL_WINDOW,
585- B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, B_CURRENT_WORKSPACE)
586+ B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS,
587+ B_CURRENT_WORKSPACE)
588 {
589 AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
590
591- fReplaceView = new BView(Bounds(), "ReplaceView", B_FOLLOW_ALL, B_WILL_DRAW);
592- fReplaceView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
593- AddChild(fReplaceView);
594+ fSearchString = new BTextControl("", TR("Find:"), NULL, NULL);
595+ fReplaceString = new BTextControl("", TR("Replace with:"), NULL, NULL);
596+ fCaseSensBox = new BCheckBox("", TR("Case-sensitive"), NULL);
597+ fWrapBox = new BCheckBox("", TR("Wrap-around search"), NULL);
598+ fBackSearchBox = new BCheckBox("", TR("Search backwards"), NULL);
599+ fAllWindowsBox = new BCheckBox("", TR("Replace in all windows"),
600+ new BMessage(CHANGE_WINDOW));
601+ fUIchange = false;
602
603- char* findLabel = "Find:";
604- float findWidth = fReplaceView->StringWidth(findLabel);
605- fReplaceView->AddChild(fSearchString = new BTextControl(BRect(5, 10, 290, 50), "",
606- findLabel, NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE));
607-
608- char* replaceWithLabel = "Replace with:";
609- float replaceWithWidth = fReplaceView->StringWidth(replaceWithLabel);
610- fReplaceView->AddChild(fReplaceString = new BTextControl(BRect(5, 35, 290, 50), "",
611- replaceWithLabel, NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP,
612- B_WILL_DRAW | B_NAVIGABLE));
613- float maxWidth = (replaceWithWidth > findWidth ? replaceWithWidth : findWidth) + TEXT_INSET;
614- fSearchString->SetDivider(maxWidth);
615- fReplaceString->SetDivider(maxWidth);
616+ fReplaceAllButton = new BButton("", TR("Replace all"),
617+ new BMessage(MSG_REPLACE_ALL));
618+ fCancelButton = new BButton("", TR("Cancel"), new BMessage(B_QUIT_REQUESTED));
619+ fReplaceButton = new BButton("", TR("Replace"), new BMessage(MSG_REPLACE));
620
621- fReplaceView->AddChild(fCaseSensBox = new BCheckBox(BRect(maxWidth + 8, 60, 290, 52),
622- "", "Case-sensitive", NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE));
623- fReplaceView->AddChild(fWrapBox = new BCheckBox(BRect(maxWidth + 8, 80, 290, 70),
624- "", "Wrap-around search", NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP,
625- B_WILL_DRAW | B_NAVIGABLE));
626- fReplaceView->AddChild(fBackSearchBox = new BCheckBox(BRect(maxWidth + 8, 100, 290, 95),
627- "", "Search backwards", NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP,
628- B_WILL_DRAW | B_NAVIGABLE));
629- fReplaceView->AddChild(fAllWindowsBox = new BCheckBox(BRect(maxWidth + 8, 120, 290, 95),
630- "", "Replace in all windows", new BMessage(CHANGE_WINDOW),
631- B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE));
632- fUIchange = false;
633+ SetLayout(new BGroupLayout(B_HORIZONTAL));
634+ AddChild(BGroupLayoutBuilder(B_VERTICAL, 4)
635+ .Add(BGridLayoutBuilder(6, 2)
636+ .Add(fSearchString->CreateLabelLayoutItem(), 0, 0)
637+ .Add(fSearchString->CreateTextViewLayoutItem(), 1, 0)
638+ .Add(fReplaceString->CreateLabelLayoutItem(), 0, 1)
639+ .Add(fReplaceString->CreateTextViewLayoutItem(), 1, 1)
640+ .Add(fCaseSensBox, 1, 2)
641+ .Add(fWrapBox, 1, 3)
642+ .Add(fBackSearchBox, 1, 4)
643+ .Add(fAllWindowsBox, 1, 5)
644+ )
645+ .AddGroup(B_HORIZONTAL, 10)
646+ .Add(fReplaceAllButton)
647+ .AddGlue()
648+ .Add(fCancelButton)
649+ .Add(fReplaceButton)
650+ .End()
651+ .SetInsets(10, 10, 10, 10)
652+ );
653
654- fReplaceView->AddChild(fReplaceAllButton = new BButton(BRect(10, 150, 98, 166),
655- "", "Replace all", new BMessage(MSG_REPLACE_ALL), B_FOLLOW_LEFT | B_FOLLOW_TOP,
656- B_WILL_DRAW | B_NAVIGABLE));
657- fReplaceView->AddChild(fCancelButton = new BButton(BRect(141, 150, 211, 166),
658- "", "Cancel", new BMessage(B_QUIT_REQUESTED), B_FOLLOW_LEFT | B_FOLLOW_TOP,
659- B_WILL_DRAW | B_NAVIGABLE));
660- fReplaceView->AddChild(fReplaceButton = new BButton(BRect(221, 150, 291, 166),
661- "", "Replace", new BMessage(MSG_REPLACE), B_FOLLOW_LEFT | B_FOLLOW_TOP,
662- B_WILL_DRAW | B_NAVIGABLE));
663 fReplaceButton->MakeDefault(true);
664
665 fHandler = _handler;
666
667- const char *searchtext = searchString->String();
668- const char *replacetext = replaceString->String();
669+ const char* searchtext = searchString->String();
670+ const char* replacetext = replaceString->String();
671
672 fSearchString->SetText(searchtext);
673 fReplaceString->SetText(replacetext);
674@@ -87,7 +90,7 @@
675
676
677 void
678-ReplaceWindow::MessageReceived(BMessage *msg)
679+ReplaceWindow::MessageReceived(BMessage* msg)
680 {
681 switch (msg->what) {
682 case MSG_REPLACE:
683@@ -126,7 +129,7 @@
684
685
686 void
687-ReplaceWindow::DispatchMessage(BMessage *message, BHandler *handler)
688+ReplaceWindow::DispatchMessage(BMessage* message, BHandler* handler)
689 {
690 if (message->what == B_KEY_DOWN) {
691 int8 key;
692Index: ReplaceWindow.h
693===================================================================
694--- ReplaceWindow.h (revision 35655)
695+++ ReplaceWindow.h (working copy)
696@@ -13,7 +13,6 @@
697 #include <Window.h>
698
699
700-class BView;
701 class BString;
702 class BButton;
703 class BHandler;
704@@ -35,7 +34,6 @@
705 void _SendMessage(uint32 what);
706 void _ChangeUI();
707
708- BView *fReplaceView;
709 BTextControl *fSearchString;
710 BTextControl *fReplaceString;
711 BCheckBox *fCaseSensBox;
712Index: FindWindow.cpp
713===================================================================
714--- FindWindow.cpp (revision 35655)
715+++ FindWindow.cpp (working copy)
716@@ -12,57 +12,55 @@
717 #include "FindWindow.h"
718
719 #include <Button.h>
720+#include <Catalog.h>
721 #include <CheckBox.h>
722+#include <GroupLayoutBuilder.h>
723+#include <GridLayoutBuilder.h>
724+#include <Locale.h>
725+#include <LayoutBuilder.h>
726 #include <String.h>
727 #include <TextControl.h>
728
729
730-FindWindow::FindWindow(BRect frame, BHandler *_handler, BString *searchString,
731+#undef TR_CONTEXT
732+#define TR_CONTEXT "FindandReplaceWindow"
733+
734+FindWindow::FindWindow(BRect frame, BHandler* _handler, BString* searchString,
735 bool caseState, bool wrapState, bool backState)
736 : BWindow(frame, "FindWindow", B_MODAL_WINDOW,
737- B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, B_CURRENT_WORKSPACE)
738+ B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS,
739+ B_CURRENT_WORKSPACE)
740 {
741 AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
742-
743- fFindView = new BView(Bounds(), "FindView", B_FOLLOW_ALL, B_WILL_DRAW);
744- fFindView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
745- AddChild(fFindView);
746
747- font_height height;
748- fFindView->GetFontHeight(&height);
749- float lineHeight = height.ascent + height.descent + height.leading;
750+ fSearchString = new BTextControl("", TR("Find:"), NULL, NULL);
751+ fCaseSensBox = new BCheckBox("", TR("Case-sensitive"), NULL);
752+ fWrapBox = new BCheckBox("", TR("Wrap-around search"), NULL);
753+ fBackSearchBox = new BCheckBox("", TR("Search backwards"), NULL);
754+ fCancelButton = new BButton("", TR("Cancel"), new BMessage(B_QUIT_REQUESTED));
755+ fSearchButton = new BButton("", TR("Find"), new BMessage(MSG_SEARCH));
756
757- float findWidth = fFindView->StringWidth("Find:") + 6;
758+ SetLayout(new BGroupLayout(B_HORIZONTAL));
759+ AddChild(BGroupLayoutBuilder(B_VERTICAL, 4)
760+ .Add(BGridLayoutBuilder(6, 2)
761+ .Add(fSearchString->CreateLabelLayoutItem(), 0, 0)
762+ .Add(fSearchString->CreateTextViewLayoutItem(), 1, 0)
763+ .Add(fCaseSensBox, 1, 1)
764+ .Add(fWrapBox, 1, 2)
765+ .Add(fBackSearchBox, 1, 3)
766+ )
767+ .AddGroup(B_HORIZONTAL, 10)
768+ .AddGlue()
769+ .Add(fCancelButton)
770+ .Add(fSearchButton)
771+ .End()
772+ .SetInsets(10, 10, 10, 10)
773+ );
774
775- float searchBottom = 12 + 2 + lineHeight + 2 + 1;
776- float buttonTop = frame.Height() - 19 - lineHeight;
777- float wrapBoxTop = (buttonTop + searchBottom - lineHeight) / 2;
778- float wrapBoxBottom = (buttonTop + searchBottom + lineHeight) / 2;
779- float caseBoxTop = (searchBottom + wrapBoxTop - lineHeight) / 2;
780- float caseBoxBottom = (searchBottom + wrapBoxTop + lineHeight) / 2;
781- float backBoxTop = (buttonTop + wrapBoxBottom - lineHeight) / 2;
782- float backBoxBottom = (buttonTop + wrapBoxBottom + lineHeight) / 2;
783-
784- fFindView->AddChild(fSearchString = new BTextControl(BRect(14, 12,
785- frame.Width() - 10, searchBottom), "", "Find:", NULL, NULL));
786- fSearchString->SetDivider(findWidth);
787-
788- fFindView->AddChild(fCaseSensBox = new BCheckBox(BRect(16 + findWidth, caseBoxTop,
789- frame.Width() - 12, caseBoxBottom), "", "Case-sensitive", NULL));
790- fFindView->AddChild(fWrapBox = new BCheckBox(BRect(16 + findWidth, wrapBoxTop,
791- frame.Width() - 12, wrapBoxBottom), "", "Wrap-around search", NULL));
792- fFindView->AddChild(fBackSearchBox = new BCheckBox(BRect(16 + findWidth,
793- backBoxTop, frame.Width() - 12, backBoxBottom), "", "Search backwards", NULL));
794-
795- fFindView->AddChild(fCancelButton = new BButton(BRect(142, buttonTop, 212,
796- frame.Height() - 7), "", "Cancel", new BMessage(B_QUIT_REQUESTED)));
797- fFindView->AddChild(fSearchButton = new BButton(BRect(221, buttonTop, 291,
798- frame.Height() - 7), "", "Find", new BMessage(MSG_SEARCH)));
799-
800 fSearchButton->MakeDefault(true);
801 fHandler = _handler;
802
803- const char *text = searchString->String();
804+ const char* text = searchString->String();
805
806 fSearchString->SetText(text);
807 fSearchString->MakeFocus(true);
808@@ -74,7 +72,7 @@
809
810
811 void
812-FindWindow::MessageReceived(BMessage *msg)
813+FindWindow::MessageReceived(BMessage* msg)
814 {
815 switch (msg->what) {
816 case B_QUIT_REQUESTED:
817@@ -92,7 +90,7 @@
818
819
820 void
821-FindWindow::DispatchMessage(BMessage *message, BHandler *handler)
822+FindWindow::DispatchMessage(BMessage* message, BHandler* handler)
823 {
824 if (message->what == B_KEY_DOWN) {
825 int8 key;
826Index: StyledEditApp.cpp
827===================================================================
828--- StyledEditApp.cpp (revision 35655)
829+++ StyledEditApp.cpp (working copy)
830@@ -15,6 +15,8 @@
831
832 #include <Alert.h>
833 #include <Autolock.h>
834+#include <Catalog.h>
835+#include <Locale.h>
836 #include <MenuBar.h>
837 #include <CharacterSet.h>
838 #include <CharacterSetRoster.h>
839@@ -49,7 +51,7 @@
840 if (top + gWindowRect.Height() > screenBorder.bottom)
841 top = 26;
842
843- gWindowRect.OffsetTo(BPoint(left,top));
844+ gWindowRect.OffsetTo(BPoint(left, top));
845 }
846
847
848@@ -71,24 +73,28 @@
849 top = top - ((int)left % 15) + 26;
850 }
851
852- gWindowRect.OffsetTo(BPoint(left,top));
853+ gWindowRect.OffsetTo(BPoint(left, top));
854 }
855 }
856
857
858 // #pragma mark -
859
860+#undef TR_CONTEXT
861+#define TR_CONTEXT "Open_and_SaveAsPanel"
862
863 StyledEditApp::StyledEditApp()
864 : BApplication(APP_SIGNATURE),
865 fOpenPanel(NULL)
866 {
867+ be_locale->GetAppCatalog(&fCatalog);
868+
869 fOpenPanel = new BFilePanel();
870- BMenuBar *menuBar =
871+ BMenuBar* menuBar =
872 dynamic_cast<BMenuBar*>(fOpenPanel->Window()->FindView("MenuBar"));
873
874 fOpenAsEncoding = 0;
875- fOpenPanelEncodingMenu= new BMenu("Encoding");
876+ fOpenPanelEncodingMenu= new BMenu(TR("Encoding"));
877 menuBar->AddItem(fOpenPanelEncodingMenu);
878 fOpenPanelEncodingMenu->SetRadioMode(true);
879
880@@ -97,7 +103,7 @@
881 while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) {
882 BString name;
883 if (charset.GetFontID() == B_UNICODE_UTF8)
884- name = "Default";
885+ name = TR("Default");
886 else
887 name = charset.GetPrintName();
888
889@@ -107,7 +113,8 @@
890 name.Append(mime);
891 name.Append(")");
892 }
893- BMenuItem* item = new BMenuItem(name.String(), new BMessage(OPEN_AS_ENCODING));
894+ BMenuItem* item =
895+ new BMenuItem(name.String(), new BMessage(OPEN_AS_ENCODING));
896 item->SetTarget(this);
897 fOpenPanelEncodingMenu->AddItem(item);
898 if (charset.GetFontID() == fOpenAsEncoding)
899@@ -129,7 +136,7 @@
900
901
902 void
903-StyledEditApp::MessageReceived(BMessage *message)
904+StyledEditApp::MessageReceived(BMessage* message)
905 {
906 switch (message->what) {
907 case MENU_NEW:
908@@ -231,7 +238,7 @@
909
910
911 void
912-StyledEditApp::RefsReceived(BMessage *message)
913+StyledEditApp::RefsReceived(BMessage* message)
914 {
915 int32 index = 0;
916 entry_ref ref;
917Index: FindWindow.h
918===================================================================
919--- FindWindow.h (revision 35655)
920+++ FindWindow.h (working copy)
921@@ -16,7 +16,6 @@
922 class BButton;
923 class BCheckBox;
924 class BTextControl;
925-class BView;
926
927
928 class FindWindow : public BWindow {
929@@ -30,7 +29,6 @@
930 private:
931 void _SendMessage();
932
933- BView *fFindView;
934 BTextControl *fSearchString;
935 BCheckBox *fCaseSensBox;
936 BCheckBox *fWrapBox;
937Index: StyledEditApp.h
938===================================================================
939--- StyledEditApp.h (revision 35655)
940+++ StyledEditApp.h (working copy)
941@@ -12,6 +12,7 @@
942
943
944 #include <Application.h>
945+#include <Catalog.h>
946
947
948 struct entry_ref;
949@@ -48,6 +49,7 @@
950 int32 fWindowCount;
951 int32 fNextUntitledWindow;
952 bool fBadArguments;
953+ BCatalog fCatalog;
954 };
955
956 extern StyledEditApp* styled_edit_app;
957Index: Jamfile
958===================================================================
959--- Jamfile (revision 35655)
960+++ Jamfile (working copy)
961@@ -16,6 +16,17 @@
962 StyledEditApp.cpp
963 StyledEditView.cpp
964 StyledEditWindow.cpp
965- : be translation tracker libtextencoding.so $(TARGET_LIBSUPC++)
966+ : be translation tracker libtextencoding.so liblocale.so $(TARGET_LIBSUPC++)
967 : $(styled_edit_rsrc)
968 ;
969+
970+DoCatalogs StyledEdit :
971+ x-vnd.Haiku-StyledEdit
972+ :
973+ FindWindow.cpp
974+ ReplaceWindow.cpp
975+ StyledEditApp.cpp
976+ StyledEditWindow.cpp
977+ : en.catalog
978+ :
979+;