start
This commit is contained in:
commit
5cfc4e3bd8
17
.clang-format
Normal file
17
.clang-format
Normal file
@ -0,0 +1,17 @@
|
||||
# .clang-format
|
||||
|
||||
# 风格格式化
|
||||
BasedOnStyle: Google
|
||||
# 4 空格缩进
|
||||
IndentWidth: 4
|
||||
# 连续对齐变量的声明
|
||||
AlignConsecutiveDeclarations: true
|
||||
# 指针左侧对齐
|
||||
PointerAlignment: Left
|
||||
# 访问说明符(public、private等)的偏移
|
||||
AccessModifierOffset: -4
|
||||
# 大括号
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
# 函数定义后面大括号在新行
|
||||
AfterFunction: true
|
12
.clangd
Normal file
12
.clangd
Normal file
@ -0,0 +1,12 @@
|
||||
Hover:
|
||||
ShowAKA: Yes
|
||||
Diagnostics:
|
||||
UnusedIncludes: None # 禁用未使用头文件提示
|
||||
Suppress: [
|
||||
anon_type_definition, # 禁用匿名的typedef提示
|
||||
unused-variable, # 禁用未使用变量提示
|
||||
unused-function, # 禁用未使用函数提示
|
||||
unused-includes, # 禁用未使用的头文件提示
|
||||
]
|
||||
ClangTidy:
|
||||
Remove: misc-unused-alias-decls
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
build
|
34
.vscode/settings.json
vendored
Normal file
34
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"files.autoSave": "onFocusChange",
|
||||
"editor.fontSize": 14,
|
||||
"editor.fontFamily": "'FiraCode Nerd Font Mono', 'FiraCode Nerd Font Mono', 'FiraCode Nerd Font Mono'",
|
||||
"cmake.configureOnOpen": true,
|
||||
"cmake.debugConfig": {
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
"cmake.environment": {
|
||||
"PATH": "${env:PATH};C:\\binary\\wxWidgets-3.2.4\\lib\\vc_x64_dll"
|
||||
},
|
||||
"cmake.options.statusBarVisibility": "visible",
|
||||
"cmake.generator": "Ninja",
|
||||
"C_Cpp.intelliSenseEngine": "disabled",
|
||||
"clangd.arguments": [
|
||||
"--header-insertion=never",
|
||||
"--all-scopes-completion",
|
||||
"--completion-style=detailed",
|
||||
"--clang-tidy",
|
||||
"-j=4",
|
||||
"--pch-storage=memory",
|
||||
"--compile-commands-dir=build",
|
||||
"--background-index",
|
||||
"--ranking-model=heuristics",
|
||||
"--function-arg-placeholders=false",
|
||||
"--query-driver=repaceE"
|
||||
],
|
||||
"editor.inlayHints.enabled": "off",
|
||||
"editor.unicodeHighlight.allowedLocales": {
|
||||
"ja": true,
|
||||
"zh-hant": true,
|
||||
"zh-hans": true
|
||||
}
|
||||
}
|
24
CMakeLists.txt
Normal file
24
CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
cmake_minimum_required (VERSION 3.8)
|
||||
project (wxWidgetStudy)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
set(CMAKE_PREFIX_PATH "C:\\binary\\wxWidgets-3.2.4")
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
if (MSVC)
|
||||
add_compile_options(/source-charset:utf-8)
|
||||
add_compile_options(/EHsc)
|
||||
add_compile_options(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
find_package(wxWidgets REQUIRED COMPONENTS core base)
|
||||
include(${wxWidgets_USE_FILE})
|
||||
|
||||
add_executable(wxWidgetStudy main.cpp)
|
||||
target_link_libraries(wxWidgetStudy PRIVATE ${wxWidgets_LIBRARIES})
|
||||
|
||||
set_target_properties(wxWidgetStudy
|
||||
PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
)
|
50
CMakeSettings.json
Normal file
50
CMakeSettings.json
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug-x64",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||
"buildRoot": "${projectDir}\\out\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": ""
|
||||
},
|
||||
{
|
||||
"name": "Debug-x86",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"buildRoot": "${projectDir}\\out\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x86" ]
|
||||
},
|
||||
{
|
||||
"name": "Release-x86",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Release",
|
||||
"buildRoot": "${projectDir}\\out\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x86" ],
|
||||
"variables": []
|
||||
},
|
||||
{
|
||||
"name": "Release-x64",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Release",
|
||||
"buildRoot": "${projectDir}\\out\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||
"variables": []
|
||||
}
|
||||
]
|
||||
}
|
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# 注意
|
||||
|
||||
如果是手动在 visual studio 中使用 dll 形式的动态库,需要添加一个定义:WXUSINGDLL
|
79
main.cpp
Normal file
79
main.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
// Name: minimal.cpp
|
||||
// Purpose: Minimal wxWidgets sample
|
||||
// Author: Julian Smart
|
||||
#include "wx/wx.h"
|
||||
|
||||
// 定义应用程序类
|
||||
class MyApp : public wxApp {
|
||||
public:
|
||||
// 这个函数将会在程序启动的时候被调用
|
||||
virtual bool OnInit();
|
||||
};
|
||||
// 定义主窗口类
|
||||
class MyFrame : public wxFrame {
|
||||
public:
|
||||
// 主窗口类的构造函数
|
||||
MyFrame(const wxString& title);
|
||||
// 事件处理函数
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
|
||||
private:
|
||||
// 声明事件表
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// 有了这一行就可以使用 MyApp& wxGetApp()了
|
||||
DECLARE_APP(MyApp)
|
||||
// 告诉wxWidgets主应用程序是哪个类
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
// 初始化程序
|
||||
bool MyApp::OnInit()
|
||||
{
|
||||
// 创建主窗口
|
||||
MyFrame* frame = new MyFrame(wxT("Minimal wxWidgets App"));
|
||||
// 显示主窗口
|
||||
frame->Show(true);
|
||||
// 开始事件处理循环
|
||||
return true;
|
||||
}
|
||||
// MyFrame类的事件表
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
|
||||
EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void MyFrame::OnAbout(wxCommandEvent& event)
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf(wxT("Hello and welcome to %s"), wxVERSION_STRING);
|
||||
wxMessageBox(msg, wxT("About Minimal"), wxOK | wxICON_INFORMATION, this);
|
||||
}
|
||||
void MyFrame::OnQuit(wxCommandEvent& event)
|
||||
{
|
||||
// 释放主窗口
|
||||
Close();
|
||||
}
|
||||
|
||||
MyFrame::MyFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title)
|
||||
{
|
||||
// 设置窗口图标
|
||||
// SetIcon(wxIcon(mondrian_xpm));
|
||||
// 创建菜单条
|
||||
wxMenu* fileMenu = new wxMenu;
|
||||
// 添加“关于”菜单项
|
||||
wxMenu* helpMenu = new wxMenu;
|
||||
helpMenu->Append(wxID_ABOUT, wxT("&About...\tF1"),
|
||||
wxT("Show about dialog"));
|
||||
fileMenu->Append(wxID_EXIT, wxT("E&xit\tAlt-X"), wxT("Quit this program"));
|
||||
// 将菜单项添加到菜单条中
|
||||
wxMenuBar* menuBar = new wxMenuBar();
|
||||
menuBar->Append(fileMenu, wxT("&File"));
|
||||
menuBar->Append(helpMenu, wxT("&Help"));
|
||||
// ...然后将菜单条放置在主窗口上
|
||||
SetMenuBar(menuBar);
|
||||
// 创建一个状态条来让一切更有趣些。
|
||||
CreateStatusBar(2);
|
||||
SetStatusText(wxT("Welcome to wxWidgets!"));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user