git commit -m "first commit"
This commit is contained in:
commit
8e9429f349
17
.clang-format
Normal file
17
.clang-format
Normal file
@ -0,0 +1,17 @@
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
||||
PointerAlignment: Left
|
||||
AccessModifierOffset: -4
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterFunction: true
|
||||
AfterClass: true
|
||||
Cpp11BracedListStyle: true
|
||||
ReflowComments: true
|
||||
SpacesBeforeTrailingComments: 3
|
||||
TabWidth: 4
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ColumnLimit: 80
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortEnumsOnASingleLine: false
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
build
|
||||
.vs
|
||||
.cache
|
||||
cmake-*
|
43
.vscode/settings.json
vendored
Normal file
43
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"files.autoSave": "onFocusChange",
|
||||
"editor.fontSize": 14,
|
||||
"editor.fontFamily": "'Monaspace Krypton Light', 'Monaspace Krypton Light', 'Monaspace Krypton Light'",
|
||||
"terminal.integrated.fontFamily": "Monaspace Krypton Light",
|
||||
"cmake.configureOnOpen": true,
|
||||
"cmake.debugConfig": {
|
||||
"console": "integratedTerminal",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "-gdb-set charset utf-8",
|
||||
"text": "-gdb-set charset UTF-8"
|
||||
},
|
||||
{
|
||||
"description": "Enable gdb pretty-printing",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
//"visualizerFile": "${workspaceRoot}/.vscode/qt6.natvis",
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
// "cmake.configureSettings": {
|
||||
// "CMAKE_TOOLCHAIN_FILE": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
// },
|
||||
"cmake.configureArgs": [
|
||||
"-Wno-dev",
|
||||
"-DCMAKE_PREFIX_PATH:STRING=C:/Dev/fltk",
|
||||
"-DTSCGUI=ON"
|
||||
],
|
||||
"cmake.options.statusBarVisibility": "visible",
|
||||
"cmake.generator": "Ninja",
|
||||
"C_Cpp.default.compileCommands": "${workspaceRoot}/build/compile_commands.json",
|
||||
"C_Cpp.default.cppStandard": "c++17",
|
||||
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
|
||||
"editor.inlayHints.enabled": "off",
|
||||
"editor.unicodeHighlight.allowedLocales": {
|
||||
"ja": true,
|
||||
"zh-hant": true,
|
||||
"zh-hans": true
|
||||
}
|
||||
}
|
32
CMakeLists.txt
Normal file
32
CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(fltk-demo LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options(/utf-8)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
MESSAGE(STATUS "Add MinGW Param.")
|
||||
add_compile_options(-finput-charset=utf-8)
|
||||
add_compile_options(-fexec-charset=gbk)
|
||||
endif()
|
||||
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
message(STATUS "System: ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS "Compiler CXX ID: ${CMAKE_CXX_COMPILER_ID}")
|
||||
|
||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/)
|
||||
|
||||
# 查找 FLTK 模块
|
||||
find_package(FLTK REQUIRED NO_MODULE)
|
||||
# 包含 FLTK 头文件
|
||||
include_directories(${FLTK_INCLUDE_DIRS})
|
||||
# 输出 FLTK 头文件路径
|
||||
message(STATUS "FLTK include: ${FLTK_INCLUDE_DIRS}")
|
||||
|
||||
add_executable(fltk-demo main.cpp)
|
||||
target_link_libraries(fltk-demo PRIVATE fltk::fltk)
|
46
main.cpp
Normal file
46
main.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <FL/Fl_Pack.H>
|
||||
#include <FL/Fl_Window.H>
|
||||
|
||||
int demo1(int argc, char** argv)
|
||||
{
|
||||
// 创建主窗口
|
||||
Fl_Window* window = new Fl_Window(800, 600, "FLTK 上下布局示例");
|
||||
window->color(FL_WHITE);
|
||||
|
||||
// 创建一个垂直排列的 Fl_Pack 容器
|
||||
Fl_Pack* vpack = new Fl_Pack(0, 0, 800, 600);
|
||||
vpack->type(Fl_Pack::VERTICAL); // 设置为垂直布局
|
||||
vpack->spacing(10); // 设置子部件之间的间距
|
||||
|
||||
// 上部分内容
|
||||
Fl_Box* top_box = new Fl_Box(0, 0, 800, 300, "上部分");
|
||||
top_box->box(FL_UP_BOX);
|
||||
top_box->color(FL_BLUE);
|
||||
top_box->labelsize(24);
|
||||
top_box->labelcolor(FL_WHITE);
|
||||
|
||||
// 下部分内容
|
||||
Fl_Box* bottom_box = new Fl_Box(0, 0, 800, 300, "下部分");
|
||||
bottom_box->box(FL_UP_BOX);
|
||||
bottom_box->color(FL_GREEN);
|
||||
bottom_box->labelsize(24);
|
||||
bottom_box->labelcolor(FL_WHITE);
|
||||
|
||||
// 结束 Fl_Pack 容器
|
||||
vpack->end();
|
||||
|
||||
// 设置窗口的布局容器
|
||||
window->end();
|
||||
window->resizable(vpack); // 使布局随窗口缩放
|
||||
window->show(argc, argv);
|
||||
|
||||
// 运行事件循环
|
||||
return Fl::run();
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
demo1(argc, argv);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user