A lot of changes with CrossBench. Created CUI, one fix in crossgen.hpp
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
#include <wx/wx.h>
|
#include "wx/wx.h"
|
||||||
|
|
||||||
|
#include <wx/app.h>
|
||||||
|
#include <wx/cmdline.h>
|
||||||
|
|
||||||
#include "crossbasetypes.hpp"
|
#include "crossbasetypes.hpp"
|
||||||
|
#include "crossgen.hpp"
|
||||||
|
|
||||||
/* To-Do:
|
/* To-Do:
|
||||||
* Console app that runs generating of crosswords
|
* Console app that runs generating of crosswords
|
||||||
@@ -11,35 +15,42 @@
|
|||||||
* 3. Dispersion
|
* 3. Dispersion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// application class
|
static const wxCmdLineEntryDesc cmdLineDesc[] = {
|
||||||
class wxMiniApp : public wxApp
|
{ wxCMD_LINE_PARAM , wxT(""), wxT(""), wxT("cross_path"),
|
||||||
{
|
wxCMD_LINE_VAL_STRING },
|
||||||
public:
|
{ wxCMD_LINE_PARAM, wxT(""), wxT(""), wxT("dict_path"),
|
||||||
// function called at the application initialization
|
wxCMD_LINE_VAL_STRING },
|
||||||
virtual bool OnInit();
|
{ wxCMD_LINE_OPTION, wxT("c"), wxT("count"), wxT("times to run generation, default = 10") ,
|
||||||
|
wxCMD_LINE_VAL_NUMBER },
|
||||||
// event handler for button click
|
{ wxCMD_LINE_SWITCH, wxT("h"), wxT("help"), wxT("show this help message"),
|
||||||
void OnClick(wxCommandEvent& event) {
|
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
|
||||||
GetTopWindow()->Close();
|
{ wxCMD_LINE_NONE }
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_APP(wxMiniApp);
|
int main(int argc, char **argv) {
|
||||||
|
wxInitializer wx_initializer;
|
||||||
bool wxMiniApp::OnInit()
|
if ( !wx_initializer ) {
|
||||||
{
|
fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
|
||||||
// create a new frame and set it as the top most application window
|
return -1;
|
||||||
SetTopWindow( new wxFrame( NULL, -1, wxT(""), wxDefaultPosition, wxSize( 100, 50) ) );
|
}
|
||||||
|
wxCmdLineParser cmd_parser(cmdLineDesc, argc, argv);
|
||||||
// create new button and assign it to the main frame
|
long run_count = 10;
|
||||||
new wxButton( GetTopWindow(), wxID_EXIT, wxT("Click!") );
|
wxString cross_path, dict_path;
|
||||||
|
switch ( cmd_parser.Parse() ) {
|
||||||
// connect button click event with event handler
|
case -1:
|
||||||
Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxMiniApp::OnClick) );
|
return 0;
|
||||||
|
case 0:
|
||||||
// show main frame
|
cmd_parser.Found(wxT("count"), &run_count);
|
||||||
GetTopWindow()->Show();
|
cross_path = cmd_parser.GetParam(0);
|
||||||
|
dict_path = cmd_parser.GetParam(1);
|
||||||
// enter the application's main loop
|
wxPrintf(wxT("cross_path = ") + cross_path + wxT("\n"));
|
||||||
return true;
|
wxPrintf(wxT("dict_path = ") + dict_path + wxT("\n"));
|
||||||
|
wxPrintf(wxT("run_count = %d\n"), run_count);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CodeLite_Workspace Name="CrossGen" Database="">
|
<CodeLite_Workspace Name="CrossGen" Database="">
|
||||||
<Project Name="wxCrossGen" Path="wxCrossGen/wxCrossGen.project" Active="Yes"/>
|
<Project Name="wxCrossGen" Path="wxCrossGen/wxCrossGen.project" Active="No"/>
|
||||||
<Project Name="CrossBench" Path="CrossBench/CrossBench.project" Active="No"/>
|
<Project Name="CrossBench" Path="CrossBench/CrossBench.project" Active="Yes"/>
|
||||||
<BuildMatrix>
|
<BuildMatrix>
|
||||||
<WorkspaceConfiguration Name="Debug" Selected="no">
|
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
||||||
<Project Name="wxCrossGen" ConfigName="Debug"/>
|
<Project Name="wxCrossGen" ConfigName="Debug"/>
|
||||||
<Project Name="CrossBench" ConfigName="Debug"/>
|
<Project Name="CrossBench" ConfigName="Debug"/>
|
||||||
</WorkspaceConfiguration>
|
</WorkspaceConfiguration>
|
||||||
<WorkspaceConfiguration Name="Release" Selected="yes">
|
<WorkspaceConfiguration Name="Release" Selected="no">
|
||||||
<Project Name="wxCrossGen" ConfigName="Release"/>
|
<Project Name="wxCrossGen" ConfigName="Release"/>
|
||||||
<Project Name="CrossBench" ConfigName="Release"/>
|
<Project Name="CrossBench" ConfigName="Release"/>
|
||||||
</WorkspaceConfiguration>
|
</WorkspaceConfiguration>
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -1,8 +1,8 @@
|
|||||||
.PHONY: clean All
|
.PHONY: clean All
|
||||||
|
|
||||||
All:
|
All:
|
||||||
@echo "----------Building project:[ wxCrossGen - Release ]----------"
|
@echo "----------Building project:[ CrossBench - Debug ]----------"
|
||||||
@cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk"
|
@cd "CrossBench" && $(MAKE) -f "CrossBench.mk"
|
||||||
clean:
|
clean:
|
||||||
@echo "----------Cleaning project:[ wxCrossGen - Release ]----------"
|
@echo "----------Cleaning project:[ CrossBench - Debug ]----------"
|
||||||
@cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk" clean
|
@cd "CrossBench" && $(MAKE) -f "CrossBench.mk" clean
|
||||||
|
|||||||
@@ -3,8 +3,11 @@
|
|||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
|
#include <wx/textfile.h>
|
||||||
|
|
||||||
#include "crossbasetypes.hpp"
|
#include "crossbasetypes.hpp"
|
||||||
|
|
||||||
@@ -175,7 +178,7 @@ bool procCross(UsedWords used, AllWordsType &words, CurGridType grid,
|
|||||||
|
|
||||||
void generateCross(GridType &grid, const DictType &dict, std::vector<wxString> &words_out){
|
void generateCross(GridType &grid, const DictType &dict, std::vector<wxString> &words_out){
|
||||||
AllWordsType words;
|
AllWordsType words;
|
||||||
for (DictType::iterator it = dict.begin(); it != dict.end(); ++it){
|
for (auto it = dict.begin(); it != dict.end(); ++it){
|
||||||
if (words.size() <= it->first.size())
|
if (words.size() <= it->first.size())
|
||||||
words.resize(it->first.size() + 2);
|
words.resize(it->first.size() + 2);
|
||||||
words.at(it->first.size()).push_back(it->first);
|
words.at(it->first.size()).push_back(it->first);
|
||||||
|
|||||||
@@ -2,18 +2,18 @@
|
|||||||
## Auto Generated makefile by CodeLite IDE
|
## Auto Generated makefile by CodeLite IDE
|
||||||
## any manual changes will be erased
|
## any manual changes will be erased
|
||||||
##
|
##
|
||||||
## Release
|
## Debug
|
||||||
ProjectName :=wxCrossGen
|
ProjectName :=wxCrossGen
|
||||||
ConfigurationName :=Release
|
ConfigurationName :=Debug
|
||||||
WorkspacePath := "/data/Sync/SyncProjects/CrossGen"
|
WorkspacePath := "/data/Sync/SyncProjects/CrossGen"
|
||||||
ProjectPath := "/data/Sync/SyncProjects/CrossGen/wxCrossGen"
|
ProjectPath := "/data/Sync/SyncProjects/CrossGen/wxCrossGen"
|
||||||
IntermediateDirectory :=../Release
|
IntermediateDirectory :=./Debug
|
||||||
OutDir := $(IntermediateDirectory)
|
OutDir := $(IntermediateDirectory)
|
||||||
CurrentFileName :=
|
CurrentFileName :=
|
||||||
CurrentFilePath :=
|
CurrentFilePath :=
|
||||||
CurrentFileFullPath :=
|
CurrentFileFullPath :=
|
||||||
User :=Aleksey Lobanov
|
User :=Aleksey Lobanov
|
||||||
Date :=11/06/15
|
Date :=12/06/15
|
||||||
CodeLitePath :="/home/alex/.codelite"
|
CodeLitePath :="/home/alex/.codelite"
|
||||||
LinkerName :=/usr/bin/g++-4.8
|
LinkerName :=/usr/bin/g++-4.8
|
||||||
SharedObjectLinkerName :=/usr/bin/g++-4.8 -shared -fPIC
|
SharedObjectLinkerName :=/usr/bin/g++-4.8 -shared -fPIC
|
||||||
@@ -28,14 +28,14 @@ LibraryPathSwitch :=-L
|
|||||||
PreprocessorSwitch :=-D
|
PreprocessorSwitch :=-D
|
||||||
SourceSwitch :=-c
|
SourceSwitch :=-c
|
||||||
OutputFile :=$(IntermediateDirectory)/$(ProjectName).out
|
OutputFile :=$(IntermediateDirectory)/$(ProjectName).out
|
||||||
Preprocessors :=$(PreprocessorSwitch)NDEBUG
|
Preprocessors :=
|
||||||
ObjectSwitch :=-o
|
ObjectSwitch :=-o
|
||||||
ArchiveOutputSwitch :=
|
ArchiveOutputSwitch :=
|
||||||
PreprocessOnlySwitch :=-E
|
PreprocessOnlySwitch :=-E
|
||||||
ObjectsFileList :="wxCrossGen.txt"
|
ObjectsFileList :="wxCrossGen.txt"
|
||||||
PCHCompileFlags :=
|
PCHCompileFlags :=
|
||||||
MakeDirCommand :=mkdir -p
|
MakeDirCommand :=mkdir -p
|
||||||
LinkOptions := -s $(shell wx-config --debug=no --libs --unicode=yes)
|
LinkOptions := $(shell wx-config --debug=yes --libs --unicode=yes)
|
||||||
IncludePath := $(IncludeSwitch). $(IncludeSwitch)../src
|
IncludePath := $(IncludeSwitch). $(IncludeSwitch)../src
|
||||||
IncludePCH :=
|
IncludePCH :=
|
||||||
RcIncludePath :=
|
RcIncludePath :=
|
||||||
@@ -50,8 +50,8 @@ LibPath := $(LibraryPathSwitch).
|
|||||||
AR := /usr/bin/ar rcu
|
AR := /usr/bin/ar rcu
|
||||||
CXX := /usr/bin/g++-4.8
|
CXX := /usr/bin/g++-4.8
|
||||||
CC := /usr/bin/gcc-4.8
|
CC := /usr/bin/gcc-4.8
|
||||||
CXXFLAGS := -std=c++11 -O2 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=no) $(Preprocessors)
|
CXXFLAGS := -std=c++11 -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes) $(Preprocessors)
|
||||||
CFLAGS := -O2 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=no) $(Preprocessors)
|
CFLAGS := -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes) $(Preprocessors)
|
||||||
ASFLAGS :=
|
ASFLAGS :=
|
||||||
AS := /usr/bin/as
|
AS := /usr/bin/as
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ $(OutputFile): $(IntermediateDirectory)/.d $(Objects)
|
|||||||
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
|
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
|
||||||
|
|
||||||
$(IntermediateDirectory)/.d:
|
$(IntermediateDirectory)/.d:
|
||||||
@test -d ../Release || $(MakeDirCommand) ../Release
|
@test -d ./Debug || $(MakeDirCommand) ./Debug
|
||||||
|
|
||||||
PreBuild:
|
PreBuild:
|
||||||
|
|
||||||
@@ -101,6 +101,6 @@ $(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp
|
|||||||
## Clean
|
## Clean
|
||||||
##
|
##
|
||||||
clean:
|
clean:
|
||||||
$(RM) -r ../Release/
|
$(RM) -r ./Debug/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
../Release/main.cpp.o
|
./Debug/main.cpp.o
|
||||||
|
|||||||
Reference in New Issue
Block a user