Index: ide/NewFile.cpp =================================================================== --- ide/NewFile.cpp (nonexistent) +++ ide/NewFile.cpp (kopia robocza) @@ -0,0 +1,144 @@ +#include "ide.h" + +class NewFileBasicInformationsWindow : public WithNewFileBasicInformationsLayout { + typedef NewFileBasicInformationsWindow CLASSNAME; + +public: + NewFileBasicInformationsWindow(const Vector& packages); +}; + +NewFileBasicInformationsWindow::NewFileBasicInformationsWindow(const Vector& packages) +{ + CtrlLayout(*this); + + for (const String& currentPackage : packages) + package.Add(currentPackage); + + Zoomable(); +} + +class NewFileSummaryWindow : public WithNewFileSummaryLayout { + typedef NewFileSummaryWindow CLASSNAME; + +public: + NewFileSummaryWindow(); +}; + +NewFileSummaryWindow::NewFileSummaryWindow() +{ + CtrlLayout(*this); + + Zoomable(); +} + +class NewFileWindow : public WithNewFileLayout { + typedef NewFileWindow CLASSNAME; + enum class State; + +public: + NewFileWindow(const Vector& packages); + + String GetFilePath(); + +private: + void SetState(State newState); + void ResetStateComponents(); + + void OnNext(); + void OnBack(); + +private: + enum class State { + BasicInformations, + Summary, + Unknown + }; + + State state; + + NewFileBasicInformationsWindow basicInformations; + NewFileSummaryWindow summary; +}; + +NewFileWindow::NewFileWindow(const Vector& packages) + : state(State::Unknown) + , basicInformations(packages) +{ + CtrlLayoutOKCancel(*this, "New file"); + Zoomable(); + + parent.Add(basicInformations.SizePos()); + parent.Add(summary.SizePos()); + + next <<= THISBACK(OnNext); + back <<= THISBACK(OnBack); + + SetState(State::BasicInformations); +} + +String NewFileWindow::GetFilePath() +{ + // TODO: This should be generated better + return summary.fileName; +} + +void NewFileWindow::SetState(State newState) +{ + if(state == newState) + return; + + ResetStateComponents(); + + state = newState; + switch (state) { + case State::BasicInformations: + basicInformations.Show(); + next.Enable(); + break; + case State::Summary: + summary.Show(); + ok.Enable(); + back.Enable(); + break; + default: + ASSERT(0); + } +} + +void NewFileWindow::ResetStateComponents() +{ + basicInformations.Hide(); + summary.Hide(); + + ok.Disable(); + + next.Disable(); + back.Disable(); +} + +void NewFileWindow::OnNext() +{ + SetState(State::Summary); +} + +void NewFileWindow::OnBack() +{ + SetState(State::BasicInformations); +} + +void Ide::NewFile() +{ + Vector packages; + + const Workspace& wspc = IdeWorkspace(); + for(int i = 0; i < wspc.GetCount(); i++){ + packages.Add(wspc[i]); + } + + NewFileWindow newFileWindow(packages); + if (newFileWindow.ExecuteOK()) { + String file = newFileWindow.GetFilePath(); + + Cout() << "File: " << file << "\n"; + } +} Index: ide/icon.ico =================================================================== Nie można wyświetlić: plik binarny. svn:mime-type = application/octet-stream Index: ide/ide.h =================================================================== --- ide/ide.h (wersja 9829) +++ ide/ide.h (kopia robocza) @@ -753,6 +753,7 @@ void File(Bar& menu); void EditWorkspace(); + void NewFile(); void EditAnyFile(); bool IsProjectFile(const String& f) const; void SaveEditorFile(Stream& out); Index: ide/ide.lay =================================================================== --- ide/ide.lay (wersja 9829) +++ ide/ide.lay (kopia robocza) @@ -800,3 +800,29 @@ ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(8, 24)) END_LAYOUT +LAYOUT(NewFileLayout, 480, 404) + ITEM(Button, back, SetLabel(t_("Back")).RightPosZ(212, 64).BottomPosZ(8, 24)) + ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(8, 24)) + ITEM(Button, next, SetLabel(t_("Next")).RightPosZ(144, 64).BottomPosZ(8, 24)) + ITEM(Button, ok, SetLabel(t_("OK")).RightPosZ(76, 64).BottomPosZ(8, 24)) + ITEM(ParentCtrl, parent, HSizePosZ(0, 0).VSizePosZ(0, 40)) +END_LAYOUT + +LAYOUT(NewFileBasicInformationsLayout, 480, 384) + ITEM(Label, dv___0, SetLabel(t_("Package:")).LeftPosZ(8, 56).TopPosZ(4, 20)) + ITEM(DropList, package, HSizePosZ(72, 8).TopPosZ(4, 20)) + ITEM(Label, dv___2, SetLabel(t_("Category:")).LeftPosZ(8, 120).TopPosZ(28, 19)) + ITEM(Label, dv___3, SetLabel(t_("File type:")).HSizePosZ(232, 128).TopPosZ(28, 19)) + ITEM(ArrayCtrl, categories, Header(false).AutoHideSb(true).LeftPosZ(8, 216).VSizePosZ(52, 8)) + ITEM(ArrayCtrl, types, Header(false).AutoHideSb(true).HSizePosZ(232, 12).VSizePosZ(52, 8)) +END_LAYOUT + +LAYOUT(NewFileSummaryLayout, 480, 392) + ITEM(Label, dv___0, SetLabel(t_("File name:")).LeftPosZ(8, 116).TopPosZ(8, 24)) + ITEM(EditString, fileName, HSizePosZ(132, 8).TopPosZ(8, 24)) + ITEM(Label, dv___2, SetLabel(t_("File path in package:")).LeftPosZ(8, 116).TopPosZ(40, 24)) + ITEM(EditString, filePathInProject, SetEditable(false).HSizePosZ(132, 8).TopPosZ(40, 24)) + ITEM(Label, dv___4, SetLabel(t_("Absolute file path:")).LeftPosZ(8, 116).TopPosZ(72, 24)) + ITEM(EditString, absoluteFilePath, SetEditable(false).HSizePosZ(132, 8).TopPosZ(72, 24)) +END_LAYOUT + Index: ide/ide.upp =================================================================== --- ide/ide.upp (wersja 9829) +++ ide/ide.upp (kopia robocza) @@ -41,6 +41,7 @@ Config.cpp, ide.cpp, idefile.cpp charset "iso8859-1", + NewFile.cpp, EditorTabBar.cpp, Bottom.cpp, t.cpp, Index: ide/idebar.cpp =================================================================== --- ide/idebar.cpp (wersja 9829) +++ ide/idebar.cpp (kopia robocza) @@ -46,7 +46,10 @@ { menu.Add(AK_SETMAIN, THISBACK(NewMainPackage)) .Help("Select global configuration (var), select / add main project package"); - + menu.Separator(); + + menu.Add("New file", CtrlImg::new_doc(), THISBACK(NewFile)) + .Help("Create new file"); menu.AddMenu(AK_EDITFILE, CtrlImg::open(), THISBACK(EditAnyFile)) .Help("Select any file in file selector and open it in editor"); menu.AddMenu(!IsNull(GetOpposite()), AK_OPPOSITE, IdeImg::opposite(), THISBACK(GoOpposite))