added encodings menu for save and open file panel (not functional yet)

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1864 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
shatty
2002-11-06 23:03:34 +00:00
parent fc8dfd798a
commit 844ea151d0
4 changed files with 32 additions and 13 deletions
+11 -3
View File
@@ -11,7 +11,15 @@ StyledEditApp * styled_edit_app;
StyledEditApp::StyledEditApp() StyledEditApp::StyledEditApp()
: BApplication(APP_SIGNATURE) : BApplication(APP_SIGNATURE)
{ {
fOpenPanel= new BFilePanel; fOpenPanel= new BFilePanel();
BMenuBar * menuBar =
dynamic_cast<BMenuBar*>(fOpenPanel->Window()->FindView("MenuBar"));
fOpenPanelEncodingMenu= new BMenu("Encoding");
menuBar->AddItem(fOpenPanelEncodingMenu);
// TODO: add encodings
fWindowCount= 0; fWindowCount= 0;
fNext_Untitled_Window= 1; fNext_Untitled_Window= 1;
styled_edit_app = this; styled_edit_app = this;
@@ -38,7 +46,7 @@ void
StyledEditApp::OpenDocument() StyledEditApp::OpenDocument()
{ {
new StyledEditWindow(windowRect,fNext_Untitled_Window++); new StyledEditWindow(windowRect,fNext_Untitled_Window++);
windowRect.OffsetBy(15,15); // todo: wrap around screen windowRect.OffsetBy(15,15); // TODO: wrap around screen
fWindowCount++; fWindowCount++;
} }
@@ -46,7 +54,7 @@ void
StyledEditApp::OpenDocument(entry_ref * ref) StyledEditApp::OpenDocument(entry_ref * ref)
{ {
new StyledEditWindow(windowRect,ref); new StyledEditWindow(windowRect,ref);
windowRect.OffsetBy(15,15); // todo: wrap around screen windowRect.OffsetBy(15,15); // TODO: wrap around screen
fWindowCount++; fWindowCount++;
} }
+1
View File
@@ -24,6 +24,7 @@ public:
private: private:
BFilePanel *fOpenPanel; BFilePanel *fOpenPanel;
BMenu *fOpenPanelEncodingMenu;
int32 fWindowCount; int32 fWindowCount;
int32 fNext_Untitled_Window; int32 fNext_Untitled_Window;
+17 -10
View File
@@ -12,6 +12,7 @@
#include <ScrollView.h> #include <ScrollView.h>
#include <stdlib.h> #include <stdlib.h>
#include <String.h> #include <String.h>
#include <TextControl.h>
#include <TranslationUtils.h> #include <TranslationUtils.h>
#include <Window.h> #include <Window.h>
@@ -274,7 +275,16 @@ StyledEditWindow::InitWindow()
/***************************MENUS ADDED***********************/ /***************************MENUS ADDED***********************/
fSavePanel= new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, B_FILE_NODE, false); fSavePanel= new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, B_FILE_NODE, false);
fSavePanelTextView =
dynamic_cast<BTextControl*>(fSavePanel->Window()->FindView("text view"));
BMenuBar * menuBar =
dynamic_cast<BMenuBar*>(fSavePanel->Window()->FindView("MenuBar"));
fSavePanelEncodingMenu= new BMenu("Encoding");
menuBar->AddItem(fSavePanelEncodingMenu);
// TODO: add encodings
} /***StyledEditWindow::Initwindow()***/ } /***StyledEditWindow::Initwindow()***/
void void
@@ -656,18 +666,15 @@ StyledEditWindow::Save(BMessage *message)
return err; return err;
} /***Save()***/ } /***Save()***/
#include <TextControl.h>
#include <Autolock.h>
status_t status_t
StyledEditWindow::SaveAs() StyledEditWindow::SaveAs()
{ {
BWindow * saveWindow = fSavePanel->Window(); // it's own scope allows the lock to be released before Show()
BTextControl * textView = {
dynamic_cast<BTextControl*>(saveWindow->FindView("text view")); BAutolock lock(fSavePanel->Window());
if (textView) { if (lock.IsLocked()) {
BAutolock lock(saveWindow); fSavePanelTextView->SetText(Title());
textView->SetText(Title()); }
} }
fSavePanel->Show(); fSavePanel->Show();
} }
+3
View File
@@ -73,7 +73,10 @@ private:
StyledEditView *fTextView; StyledEditView *fTextView;
BScrollView *fScrollView; BScrollView *fScrollView;
BFilePanel *fSavePanel; BFilePanel *fSavePanel;
BTextControl *fSavePanelTextView;
BMenu *fSavePanelEncodingMenu;
}; };