mirror of
https://github.com/LHY0125/Gobang-Game.git
synced 2026-05-09 18:09:46 +08:00
feat(gui): 迁移图形界面库从SDL3到IUP
- 移除SDL3依赖,引入IUP图形界面库 - 更新Makefile以支持IUP编译配置 - 重构GUI模块,移除SDL相关代码 - 更新全局变量和类型定义,移除SDL依赖 - 添加IUP头文件到项目库目录 - 删除手动帧率控制(SDL_Delay),依赖IUP事件循环 - 更新编译脚本和文档说明
This commit is contained in:
@@ -1,54 +1,69 @@
|
||||
# 五子棋游戏 Makefile
|
||||
# 支持编译控制台版本和GUI版本
|
||||
# 支持编译控制台版本和GUI版本 (IUP)
|
||||
|
||||
# 编译器设置
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wextra -std=c17 -O2 -Iinclude
|
||||
CFLAGS = -Wall -Wextra -std=c17 -O2 -Iinclude -finput-charset=UTF-8 -fexec-charset=UTF-8
|
||||
LDFLAGS = -lws2_32
|
||||
|
||||
# SDL3路径设置
|
||||
SDL3_PATH = D:/settings/SDL/SDL3-3.2.22/x86_64-w64-mingw32
|
||||
SDL3_INCLUDE = -I$(SDL3_PATH)/include
|
||||
SDL3_LIBS = -L$(SDL3_PATH)/lib -lSDL3 -lmingw32
|
||||
# IUP路径设置
|
||||
IUP_PATH = libs/iup-3.31_Win64_dllw6_lib
|
||||
IUP_INCLUDE = -I$(IUP_PATH)/include
|
||||
# IUP链接库: iup, gdi32, comdlg32, comctl32, uuid, ole32
|
||||
IUP_LIBS = -L$(IUP_PATH) -liup -lgdi32 -lcomdlg32 -lcomctl32 -luuid -lole32
|
||||
|
||||
# 目录设置
|
||||
SRC_DIR = src
|
||||
OBJ_DIR = obj
|
||||
BIN_DIR = bin
|
||||
|
||||
# 源文件
|
||||
COMMON_SOURCES = src/main.c src/gobang.c src/ai.c src/config.c src/game_mode.c src/globals.c \
|
||||
src/init_board.c src/network.c src/record.c src/ui.c src/gui.c
|
||||
COMMON_SOURCES = $(SRC_DIR)/main.c $(SRC_DIR)/gobang.c $(SRC_DIR)/ai.c $(SRC_DIR)/config.c \
|
||||
$(SRC_DIR)/game_mode.c $(SRC_DIR)/globals.c $(SRC_DIR)/init_board.c \
|
||||
$(SRC_DIR)/network.c $(SRC_DIR)/record.c $(SRC_DIR)/ui.c $(SRC_DIR)/gui.c
|
||||
|
||||
GUI_SOURCES = $(COMMON_SOURCES)
|
||||
CONSOLE_SOURCES = $(COMMON_SOURCES)
|
||||
|
||||
# 目标文件
|
||||
COMMON_OBJECTS = $(patsubst src/%.c,src/%.o,$(filter %.c,$(COMMON_SOURCES)))
|
||||
# 目标文件 (src/xxx.c -> obj/xxx.o)
|
||||
COMMON_OBJECTS = $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(COMMON_SOURCES))
|
||||
|
||||
# 可执行文件
|
||||
CONSOLE_TARGET = gobang_console.exe
|
||||
GUI_TARGET = gobang_gui.exe
|
||||
CONSOLE_TARGET = $(BIN_DIR)/gobang_console.exe
|
||||
GUI_TARGET = $(BIN_DIR)/gobang_gui.exe
|
||||
|
||||
# 默认目标
|
||||
all: $(CONSOLE_TARGET) $(GUI_TARGET)
|
||||
all: directories $(CONSOLE_TARGET) $(GUI_TARGET)
|
||||
|
||||
# 创建目录
|
||||
directories:
|
||||
-mkdir $(OBJ_DIR)
|
||||
-mkdir $(BIN_DIR)
|
||||
|
||||
# 控制台版本
|
||||
$(CONSOLE_TARGET): $(COMMON_OBJECTS)
|
||||
$(CC) $(CFLAGS) $(SDL3_INCLUDE) -o $@ $^ $(SDL3_LIBS) $(LDFLAGS)
|
||||
$(CC) $(CFLAGS) $(IUP_INCLUDE) -o $@ $^ $(IUP_LIBS) $(LDFLAGS)
|
||||
|
||||
# GUI版本
|
||||
$(GUI_TARGET): $(COMMON_OBJECTS)
|
||||
$(CC) $(CFLAGS) $(SDL3_INCLUDE) -o $@ $^ $(SDL3_LIBS) $(LDFLAGS)
|
||||
$(CC) $(CFLAGS) $(IUP_INCLUDE) -o $@ $^ $(IUP_LIBS) $(LDFLAGS)
|
||||
copy $(subst /,\,$(IUP_PATH))\iup.dll $(BIN_DIR) 2>nul || echo Warning: Could not copy iup.dll
|
||||
|
||||
# 通用目标文件编译规则(包含SDL3头文件路径,因为多个文件包含gui.h)
|
||||
src/%.o: src/%.c
|
||||
$(CC) $(CFLAGS) $(SDL3_INCLUDE) -c -o $@ $<
|
||||
# 通用目标文件编译规则
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
$(CC) $(CFLAGS) $(IUP_INCLUDE) -c -o $@ $<
|
||||
|
||||
# 清理规则
|
||||
clean:
|
||||
del /Q src\*.o *.exe 2>nul || true
|
||||
|
||||
-del /Q $(OBJ_DIR)\*.o $(BIN_DIR)\*.exe $(BIN_DIR)\*.dll
|
||||
-rmdir $(OBJ_DIR)
|
||||
-rmdir $(BIN_DIR)
|
||||
|
||||
# 只编译控制台版本
|
||||
console: $(CONSOLE_TARGET)
|
||||
console: directories $(CONSOLE_TARGET)
|
||||
|
||||
# 只编译GUI版本
|
||||
gui: $(GUI_TARGET)
|
||||
gui: directories $(GUI_TARGET)
|
||||
|
||||
# 安装规则(可选)
|
||||
install: all
|
||||
@@ -77,4 +92,4 @@ help:
|
||||
@echo help - Show this help message
|
||||
|
||||
# 声明伪目标
|
||||
.PHONY: all clean console gui install run-console run-gui help
|
||||
.PHONY: all clean console gui install run-console run-gui help directories
|
||||
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
@echo off
|
||||
echo ===== Gobang Game Compile Script =====
|
||||
echo.
|
||||
echo Please select compile version:
|
||||
echo 1. Console version (gobang_console.exe)
|
||||
echo 2. GUI version (gobang_gui.exe)
|
||||
echo 3. Compile all versions
|
||||
echo 0. Exit
|
||||
echo.
|
||||
set /p choice="Please enter your choice (0-3): "
|
||||
|
||||
if "%choice%"=="0" goto :exit
|
||||
if "%choice%"=="1" goto :console
|
||||
if "%choice%"=="2" goto :gui
|
||||
if "%choice%"=="3" goto :all
|
||||
echo Invalid choice!
|
||||
pause
|
||||
exit /b 1
|
||||
|
||||
:console
|
||||
echo.
|
||||
echo Compiling console version...
|
||||
echo.
|
||||
gcc -std=c17 -o gobang_console.exe src/*.c -Iinclude -ID:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\include -LD:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\lib -lSDL3 -lws2_32
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo.
|
||||
echo Compilation successful! Generated: gobang_console.exe
|
||||
echo Run command: .\gobang_console.exe
|
||||
echo.
|
||||
) else (
|
||||
echo.
|
||||
echo Compilation failed! Please check source files and compiler installation
|
||||
echo.
|
||||
)
|
||||
goto :end
|
||||
|
||||
:gui
|
||||
echo.
|
||||
echo Compiling GUI version...
|
||||
echo.
|
||||
REM Check if SDL3 library exists
|
||||
if not exist "D:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\include" (
|
||||
echo Error: SDL3 library not found!
|
||||
echo Please ensure SDL3 is extracted to: D:\settings\SDL\SDL3-3.2.22\
|
||||
goto :end
|
||||
)
|
||||
gcc -std=c17 -o gobang_gui.exe src/*.c -Iinclude -ID:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\include -LD:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\lib -lSDL3 -lws2_32
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo.
|
||||
echo Compilation successful! Generated: gobang_gui.exe
|
||||
echo.
|
||||
echo Copying SDL3.dll to current directory...
|
||||
copy "D:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\bin\SDL3.dll" . >nul 2>&1
|
||||
echo Run command: .\gobang_gui.exe
|
||||
echo.
|
||||
) else (
|
||||
echo.
|
||||
echo Compilation failed! Please check:
|
||||
echo 1. SDL3 library path is correct
|
||||
echo 2. All source files exist
|
||||
echo 3. gcc compiler is installed
|
||||
echo.
|
||||
)
|
||||
goto :end
|
||||
|
||||
:all
|
||||
echo.
|
||||
echo Compiling all versions...
|
||||
echo.
|
||||
echo [1/2] Compiling console version...
|
||||
gcc -std=c17 -o gobang_console.exe src/*.c -Iinclude -ID:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\include -LD:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\lib -lSDL3 -lws2_32
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo Console version compilation successful!
|
||||
) else (
|
||||
echo Console version compilation failed!
|
||||
)
|
||||
echo.
|
||||
echo [2/2] Compiling GUI version...
|
||||
if not exist "D:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\include" (
|
||||
echo Error: SDL3 library not found! Skipping GUI version compilation
|
||||
goto :end
|
||||
)
|
||||
gcc -std=c17 -o gobang_gui.exe src/*.c -Iinclude -ID:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\include -LD:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\lib -lSDL3 -lws2_32
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo GUI version compilation successful!
|
||||
copy "D:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\bin\SDL3.dll" . >nul 2>&1
|
||||
) else (
|
||||
echo GUI version compilation failed!
|
||||
)
|
||||
echo.
|
||||
echo Compilation complete! Generated files:
|
||||
dir *.exe 2>nul
|
||||
echo.
|
||||
goto :end
|
||||
|
||||
:end
|
||||
pause
|
||||
|
||||
:exit
|
||||
+21
-24
@@ -9,42 +9,39 @@
|
||||
|
||||
#include "type.h"
|
||||
#include "gobang.h"
|
||||
#include "network.h"
|
||||
#include <stdbool.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
// ==================== 游戏核心变量 ====================
|
||||
extern int BOARD_SIZE; // 当前实际使用的棋盘尺寸
|
||||
extern int board[MAX_BOARD_SIZE][MAX_BOARD_SIZE]; // 棋盘状态存储数组
|
||||
extern Step steps[MAX_STEPS]; // 存储所有落子步骤的数组
|
||||
extern const int direction[4][2]; // 四个方向:向下、向右、右下、左下
|
||||
extern int step_count; // 当前步数计数器
|
||||
extern int BOARD_SIZE; // 当前实际使用的棋盘尺寸
|
||||
extern int board[MAX_BOARD_SIZE][MAX_BOARD_SIZE]; // 棋盘状态存储数组
|
||||
extern Step steps[MAX_STEPS]; // 存储所有落子步骤的数组
|
||||
extern const int direction[4][2]; // 四个方向:向下、向右、右下、左下
|
||||
extern int step_count; // 当前步数计数器
|
||||
|
||||
// ==================== 游戏配置变量 ====================
|
||||
extern bool use_forbidden_moves; // 是否启用禁手规则的标志
|
||||
extern int use_timer; // 是否启用计时器的标志
|
||||
extern int time_limit; // 每回合的时间限制(秒,内部存储)
|
||||
extern int network_port; // 网络端口
|
||||
extern int network_timeout; // 网络超时时间
|
||||
extern bool use_forbidden_moves; // 是否启用禁手规则的标志
|
||||
extern int use_timer; // 是否启用计时器的标志
|
||||
extern int time_limit; // 每回合的时间限制(秒,内部存储)
|
||||
extern int network_port; // 网络端口
|
||||
extern int network_timeout; // 网络超时时间
|
||||
|
||||
// ==================== AI相关变量 ====================
|
||||
extern double defense_coefficient; // 防守系数
|
||||
extern double defense_coefficient; // 防守系数
|
||||
|
||||
// ==================== 网络相关变量 ====================
|
||||
extern NetworkGameState network_state; // 网络游戏状态
|
||||
extern NetworkGameState network_state; // 网络游戏状态
|
||||
|
||||
// ==================== GUI相关变量 ====================
|
||||
extern SDL_Window* window; // SDL窗口指针
|
||||
extern SDL_Renderer* renderer; // SDL渲染器指针
|
||||
extern int gui_running; // GUI运行状态标志
|
||||
extern int current_player_gui; // GUI当前玩家
|
||||
extern int game_over; // 游戏结束标志
|
||||
extern char status_message[256]; // 状态消息
|
||||
// Raylib 不需要暴露窗口和渲染器指针
|
||||
extern int gui_running; // GUI运行状态标志
|
||||
extern int current_player_gui; // GUI当前玩家
|
||||
extern int game_over; // 游戏结束标志
|
||||
extern char status_message[256]; // 状态消息
|
||||
|
||||
// ==================== 记录相关变量 ====================
|
||||
extern int player1_final_score; // 玩家1最终得分
|
||||
extern int player2_final_score; // 玩家2最终得分
|
||||
extern int scores_calculated; // 评分计算标志
|
||||
extern char winner_info[50]; // 存储胜负信息
|
||||
extern int player1_final_score; // 玩家1最终得分
|
||||
extern int player2_final_score; // 玩家2最终得分
|
||||
extern int scores_calculated; // 评分计算标志
|
||||
extern char winner_info[50]; // 存储胜负信息
|
||||
|
||||
#endif // GLOBALS_H
|
||||
+5
-90
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file gui.h
|
||||
* @brief 图形化用户界面头文件
|
||||
* @note 使用SDL3库实现五子棋的图形化界面
|
||||
* @note 使用Raylib库实现五子棋的图形化界面
|
||||
* @author 刘航宇
|
||||
* @date 2025-01-15
|
||||
*/
|
||||
@@ -9,7 +9,6 @@
|
||||
#ifndef GUI_H
|
||||
#define GUI_H
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include "gobang.h"
|
||||
#include "config.h"
|
||||
#include "globals.h"
|
||||
@@ -18,136 +17,52 @@
|
||||
|
||||
/**
|
||||
* @brief 初始化GUI
|
||||
* @details 初始化SDL3图形库和游戏界面组件:
|
||||
* - 初始化SDL视频子系统
|
||||
* - 创建游戏窗口(可调整大小)
|
||||
* - 创建SDL渲染器
|
||||
* - 初始化游戏状态和棋盘数据
|
||||
* @details 初始化Raylib图形库和游戏界面组件
|
||||
* @return 成功返回0,失败返回-1
|
||||
* @note 窗口标题为"五子棋游戏 - SDL3版本"
|
||||
* 窗口尺寸由WINDOW_WIDTH和WINDOW_HEIGHT定义
|
||||
* 失败时会自动清理已创建的资源
|
||||
*/
|
||||
int init_gui();
|
||||
|
||||
/**
|
||||
* @brief 清理GUI资源
|
||||
* @details 按顺序释放所有SDL相关资源:
|
||||
* - 销毁SDL渲染器
|
||||
* - 销毁SDL窗口
|
||||
* - 退出SDL子系统
|
||||
* @note 函数会检查资源是否存在再进行释放
|
||||
* 释放后将指针设置为NULL防止重复释放
|
||||
* 程序退出时必须调用此函数避免内存泄漏
|
||||
* @details 关闭窗口
|
||||
*/
|
||||
void cleanup_gui();
|
||||
|
||||
/**
|
||||
* @brief 渲染游戏画面
|
||||
* @details 完整的游戏画面渲染流程:
|
||||
* - 清空屏幕并设置背景色
|
||||
* - 绘制棋盘网格和标记点
|
||||
* - 绘制所有棋子
|
||||
* - 绘制UI界面元素
|
||||
* - 将渲染结果显示到屏幕
|
||||
* @note 使用双缓冲技术,通过SDL_RenderPresent显示最终结果
|
||||
* 背景色由GUI_COLOR_BACKGROUND定义
|
||||
* 每帧都会完全重绘整个画面
|
||||
* @details 完整的游戏画面渲染流程
|
||||
*/
|
||||
void render_game();
|
||||
|
||||
/**
|
||||
* @brief 处理事件
|
||||
* @details 处理所有SDL事件并执行相应操作:
|
||||
* - SDL_EVENT_QUIT:用户关闭窗口
|
||||
* - SDL_EVENT_KEY_DOWN:键盘按键(ESC退出)
|
||||
* - SDL_EVENT_MOUSE_BUTTON_DOWN:鼠标点击落子
|
||||
* @details 处理所有Raylib事件并执行相应操作
|
||||
* @return 继续运行返回1,退出返回0
|
||||
* @note 鼠标左键点击会转换为棋盘坐标并尝试落子
|
||||
* 落子后会检查胜负并切换玩家
|
||||
* 游戏结束后不再响应落子操作
|
||||
*/
|
||||
int handle_events();
|
||||
|
||||
/**
|
||||
* @brief 绘制棋盘
|
||||
* @details 绘制15x15的五子棋棋盘,包括:
|
||||
* - 横竖交叉的网格线
|
||||
* - 天元点(棋盘中心的标记点)
|
||||
* - 四个星位(棋盘上的定位点)
|
||||
* @note 使用SDL3渲染器绘制线条和填充矩形
|
||||
* 棋盘线条颜色由GUI_COLOR_BOARD_LINE定义
|
||||
* 天元点和星位用黑色小矩形标记
|
||||
*/
|
||||
void draw_board();
|
||||
|
||||
/**
|
||||
* @brief 绘制棋子
|
||||
* @details 遍历整个棋盘数组,绘制所有已落下的棋子:
|
||||
* - 黑子:使用GUI_COLOR_BLACK_STONE颜色
|
||||
* - 白子:使用GUI_COLOR_WHITE_STONE颜色
|
||||
* - 每个棋子都有边框:使用GUI_COLOR_STONE_BORDER颜色
|
||||
* @note 棋子绘制为圆形,半径由STONE_RADIUS定义
|
||||
* 通过draw_circle函数实现圆形绘制
|
||||
* 棋子位置根据棋盘坐标和CELL_SIZE计算屏幕坐标
|
||||
*/
|
||||
void draw_stones();
|
||||
|
||||
/**
|
||||
* @brief 绘制UI元素
|
||||
* @details 绘制游戏界面的用户交互元素:
|
||||
* - 状态信息区域背景和边框
|
||||
* - 当前玩家指示器(黑子或白子圆形)
|
||||
* - 游戏状态显示区域
|
||||
* @note 暂时使用简单图形代替文字显示
|
||||
* 需要额外字体库支持文字渲染
|
||||
* 指示器位置在棋盘右侧固定区域
|
||||
*/
|
||||
void draw_ui_elements();
|
||||
|
||||
/**
|
||||
* @brief 绘制圆形
|
||||
* @param center_x 圆心X坐标
|
||||
* @param center_y 圆心Y坐标
|
||||
* @param radius 半径
|
||||
* @param color 颜色
|
||||
* @details 使用像素级绘制实现圆形:
|
||||
* - 遍历圆形外接矩形内的所有像素点
|
||||
* - 计算每个像素到圆心的距离
|
||||
* - 距离小于等于半径的像素点进行着色
|
||||
* @note 采用暴力算法,性能较低但实现简单
|
||||
* 适用于绘制棋子等小尺寸圆形
|
||||
* SDL3没有内置圆形绘制函数,需要自实现
|
||||
*/
|
||||
void draw_circle(int center_x, int center_y, int radius, SDL_Color color);
|
||||
|
||||
/**
|
||||
* @brief 屏幕坐标转棋盘坐标
|
||||
* @param screen_x 屏幕X坐标
|
||||
* @param screen_y 屏幕Y坐标
|
||||
* @param board_x 输出棋盘X坐标
|
||||
* @param board_y 输出棋盘Y坐标
|
||||
* @return 转换成功返回1,失败返回0
|
||||
* @details 坐标转换算法:
|
||||
* - 减去棋盘偏移量得到相对坐标
|
||||
* - 加上半个格子尺寸实现就近取整
|
||||
* - 除以格子尺寸得到棋盘坐标
|
||||
* - 检查坐标是否在有效范围内
|
||||
* @note 使用就近取整算法,点击格子中心附近都会定位到该格子
|
||||
* 坐标范围检查确保不会越界访问棋盘数组
|
||||
*/
|
||||
int screen_to_board(int screen_x, int screen_y, int *board_x, int *board_y);
|
||||
|
||||
/**
|
||||
* @brief 显示消息
|
||||
* @param message 要显示的消息
|
||||
* @details 消息显示功能:
|
||||
* - 将消息复制到全局状态消息缓冲区
|
||||
* - 同时在控制台输出消息内容
|
||||
* - 确保字符串安全复制,防止缓冲区溢出
|
||||
* @note 消息会存储在status_message全局变量中
|
||||
* 字符串长度限制为缓冲区大小减1
|
||||
* 消息可用于游戏状态提示和错误信息显示
|
||||
*/
|
||||
void show_message(const char *message);
|
||||
|
||||
|
||||
+39
-38
@@ -10,32 +10,29 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#define SOCKET int
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
// ==================== 游戏核心数据结构 ====================
|
||||
|
||||
/**
|
||||
* @brief 记录一步棋的详细信息
|
||||
*/
|
||||
typedef struct {
|
||||
int player; // 执行该步的玩家标识
|
||||
int x; // 落子的行坐标 (0-based)
|
||||
int y; // 落子的列坐标 (0-based)
|
||||
typedef struct
|
||||
{
|
||||
int player; // 执行该步的玩家标识
|
||||
int x; // 落子的行坐标 (0-based)
|
||||
int y; // 落子的列坐标 (0-based)
|
||||
} Step;
|
||||
|
||||
/**
|
||||
* @brief 存储在特定方向上棋子连续性的信息
|
||||
* @details 用于评估棋形,例如判断活三、冲四等关键形态
|
||||
*/
|
||||
typedef struct {
|
||||
int continuous_chess; // 连续同色棋子的数量
|
||||
bool check_start; // 棋子序列的起始端是否为空位(即是否开放)
|
||||
bool check_end; // 棋子序列的末尾端是否为空位(即是否开放)
|
||||
typedef struct
|
||||
{
|
||||
int continuous_chess; // 连续同色棋子的数量
|
||||
bool check_start; // 棋子序列的起始端是否为空位(即是否开放)
|
||||
bool check_end; // 棋子序列的末尾端是否为空位(即是否开放)
|
||||
} DirInfo;
|
||||
|
||||
// ==================== AI相关数据结构 ====================
|
||||
@@ -44,22 +41,24 @@ typedef struct {
|
||||
* @brief 移动排序结构体
|
||||
* @details 用于AI移动排序,存储候选移动及其评估分数
|
||||
*/
|
||||
typedef struct {
|
||||
int x, y; // 位置坐标
|
||||
int score; // 评估分数
|
||||
typedef struct
|
||||
{
|
||||
int x, y; // 位置坐标
|
||||
int score; // 评估分数
|
||||
} ScoredMove;
|
||||
|
||||
/**
|
||||
* @brief 威胁类型枚举
|
||||
* @details 用于AI威胁检测系统
|
||||
*/
|
||||
typedef enum {
|
||||
THREAT_NONE = 0, // 无威胁
|
||||
THREAT_WIN = 5, // 直接获胜
|
||||
THREAT_FOUR = 4, // 活四/冲四
|
||||
THREAT_THREE = 3, // 活三
|
||||
THREAT_DOUBLE = 2, // 双威胁
|
||||
THREAT_POTENTIAL = 1 // 潜在威胁
|
||||
typedef enum
|
||||
{
|
||||
THREAT_NONE = 0, // 无威胁
|
||||
THREAT_WIN = 5, // 直接获胜
|
||||
THREAT_FOUR = 4, // 活四/冲四
|
||||
THREAT_THREE = 3, // 活三
|
||||
THREAT_DOUBLE = 2, // 双威胁
|
||||
THREAT_POTENTIAL = 1 // 潜在威胁
|
||||
} ThreatLevel;
|
||||
|
||||
// ==================== 网络相关数据结构 ====================
|
||||
@@ -68,26 +67,28 @@ typedef enum {
|
||||
* @brief 网络消息结构
|
||||
* @details 用于网络对战中的消息传输
|
||||
*/
|
||||
typedef struct {
|
||||
int type; // 消息类型
|
||||
int player_id; // 玩家ID
|
||||
int x, y; // 坐标(用于落子)
|
||||
char message[256]; // 消息内容(用于聊天等)
|
||||
time_t timestamp; // 时间戳
|
||||
typedef struct
|
||||
{
|
||||
int type; // 消息类型
|
||||
int player_id; // 玩家ID
|
||||
int x, y; // 坐标(用于落子)
|
||||
char message[256]; // 消息内容(用于聊天等)
|
||||
time_t timestamp; // 时间戳
|
||||
} NetworkMessage;
|
||||
|
||||
/**
|
||||
* @brief 网络游戏状态结构
|
||||
* @details 用于管理网络游戏状态
|
||||
*/
|
||||
typedef struct {
|
||||
SOCKET socket; // 套接字
|
||||
bool is_server; // 是否为服务器
|
||||
bool is_connected; // 是否已连接
|
||||
int local_player_id; // 本地玩家ID
|
||||
int remote_player_id; // 远程玩家ID
|
||||
char remote_ip[16]; // 远程IP地址(MAX_IP_LENGTH = 16)
|
||||
int port; // 端口号
|
||||
typedef struct
|
||||
{
|
||||
uintptr_t socket; // 套接字 (使用uintptr_t代替SOCKET以避免引入winsock2.h)
|
||||
bool is_server; // 是否为服务器
|
||||
bool is_connected; // 是否已连接
|
||||
int local_player_id; // 本地玩家ID
|
||||
int remote_player_id; // 远程玩家ID
|
||||
char remote_ip[16]; // 远程IP地址(MAX_IP_LENGTH = 16)
|
||||
int port; // 端口号
|
||||
} NetworkGameState;
|
||||
|
||||
#endif // TYPE_H
|
||||
@@ -0,0 +1,516 @@
|
||||
/** \file
|
||||
* \brief User API
|
||||
* IUP - A Portable User Interface Toolkit
|
||||
* Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
|
||||
* http://www.tecgraf.puc-rio.br/iup mailto:iup@tecgraf.puc-rio.br
|
||||
*
|
||||
* See Copyright Notice at the end of this file
|
||||
*/
|
||||
|
||||
#ifndef __IUP_H
|
||||
#define __IUP_H
|
||||
|
||||
#include "iupkey.h"
|
||||
#include "iupdef.h"
|
||||
#include "iup_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define IUP_NAME "IUP - Portable User Interface"
|
||||
#define IUP_DESCRIPTION "Multi-platform Toolkit for Building Graphical User Interfaces"
|
||||
#define IUP_COPYRIGHT "Copyright (C) 1994-2023 Tecgraf/PUC-Rio"
|
||||
#define IUP_VERSION "3.31" /* bug fixes are reported only by IupVersion functions */
|
||||
#define IUP_VERSION_NUMBER 331000
|
||||
#define IUP_VERSION_DATE "2023/10/13" /* does not include bug fix releases */
|
||||
|
||||
typedef struct Ihandle_ Ihandle;
|
||||
typedef int (*Icallback)(Ihandle*);
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* Main API */
|
||||
/************************************************************************/
|
||||
|
||||
IUP_API int IupOpen (int *argc, char ***argv);
|
||||
IUP_API void IupClose (void);
|
||||
IUP_API int IupIsOpened (void);
|
||||
|
||||
IUPIMGLIB_API void IupImageLibOpen(void);
|
||||
|
||||
IUP_API int IupMainLoop (void);
|
||||
IUP_API int IupLoopStep (void);
|
||||
IUP_API int IupLoopStepWait (void);
|
||||
IUP_API int IupMainLoopLevel (void);
|
||||
IUP_API void IupFlush (void);
|
||||
IUP_API void IupExitLoop (void);
|
||||
IUP_API void IupPostMessage (Ihandle* ih, const char* s, int i, double d, void* p);
|
||||
|
||||
IUP_API int IupRecordInput(const char* filename, int mode);
|
||||
IUP_API int IupPlayInput(const char* filename);
|
||||
|
||||
IUP_API void IupUpdate (Ihandle* ih);
|
||||
IUP_API void IupUpdateChildren(Ihandle* ih);
|
||||
IUP_API void IupRedraw (Ihandle* ih, int children);
|
||||
IUP_API void IupRefresh (Ihandle* ih);
|
||||
IUP_API void IupRefreshChildren(Ihandle* ih);
|
||||
|
||||
IUP_API int IupExecute(const char *filename, const char* parameters);
|
||||
IUP_API int IupExecuteWait(const char *filename, const char* parameters);
|
||||
IUP_API int IupHelp(const char* url);
|
||||
IUP_API void IupLog(const char* type, const char* format, ...);
|
||||
|
||||
IUP_API char* IupLoad (const char *filename);
|
||||
IUP_API char* IupLoadBuffer (const char *buffer);
|
||||
|
||||
IUP_API char* IupVersion (void);
|
||||
IUP_API char* IupVersionDate (void);
|
||||
IUP_API int IupVersionNumber (void);
|
||||
IUP_API void IupVersionShow (void);
|
||||
|
||||
IUP_API void IupSetLanguage (const char *lng);
|
||||
IUP_API char* IupGetLanguage (void);
|
||||
IUP_API void IupSetLanguageString(const char* name, const char* str);
|
||||
IUP_API void IupStoreLanguageString(const char* name, const char* str);
|
||||
IUP_API char* IupGetLanguageString(const char* name);
|
||||
IUP_API void IupSetLanguagePack(Ihandle* ih);
|
||||
|
||||
IUP_API void IupDestroy (Ihandle* ih);
|
||||
IUP_API void IupDetach (Ihandle* child);
|
||||
IUP_API Ihandle* IupAppend (Ihandle* ih, Ihandle* child);
|
||||
IUP_API Ihandle* IupInsert (Ihandle* ih, Ihandle* ref_child, Ihandle* child);
|
||||
IUP_API Ihandle* IupGetChild (Ihandle* ih, int pos);
|
||||
IUP_API int IupGetChildPos (Ihandle* ih, Ihandle* child);
|
||||
IUP_API int IupGetChildCount(Ihandle* ih);
|
||||
IUP_API Ihandle* IupGetNextChild (Ihandle* ih, Ihandle* child);
|
||||
IUP_API Ihandle* IupGetBrother (Ihandle* ih);
|
||||
IUP_API Ihandle* IupGetParent (Ihandle* ih);
|
||||
IUP_API Ihandle* IupGetDialog (Ihandle* ih);
|
||||
IUP_API Ihandle* IupGetDialogChild(Ihandle* ih, const char* name);
|
||||
IUP_API int IupReparent (Ihandle* ih, Ihandle* new_parent, Ihandle* ref_child);
|
||||
|
||||
IUP_API int IupPopup (Ihandle* ih, int x, int y);
|
||||
IUP_API int IupShow (Ihandle* ih);
|
||||
IUP_API int IupShowXY (Ihandle* ih, int x, int y);
|
||||
IUP_API int IupHide (Ihandle* ih);
|
||||
IUP_API int IupMap (Ihandle* ih);
|
||||
IUP_API void IupUnmap (Ihandle* ih);
|
||||
|
||||
IUP_API void IupResetAttribute(Ihandle* ih, const char* name);
|
||||
IUP_API int IupGetAllAttributes(Ihandle* ih, char** names, int n);
|
||||
IUP_API void IupCopyAttributes(Ihandle* src_ih, Ihandle* dst_ih);
|
||||
IUP_API Ihandle* IupSetAtt(const char* handle_name, Ihandle* ih, const char* name, ...);
|
||||
IUP_API Ihandle* IupSetAttributes (Ihandle* ih, const char *str);
|
||||
IUP_API char* IupGetAttributes (Ihandle* ih);
|
||||
|
||||
IUP_API void IupSetAttribute (Ihandle* ih, const char* name, const char* value);
|
||||
IUP_API void IupSetStrAttribute(Ihandle* ih, const char* name, const char* value);
|
||||
IUP_API void IupSetStrf (Ihandle* ih, const char* name, const char* format, ...);
|
||||
IUP_API void IupSetInt (Ihandle* ih, const char* name, int value);
|
||||
IUP_API void IupSetFloat (Ihandle* ih, const char* name, float value);
|
||||
IUP_API void IupSetDouble (Ihandle* ih, const char* name, double value);
|
||||
IUP_API void IupSetRGB (Ihandle* ih, const char* name, unsigned char r, unsigned char g, unsigned char b);
|
||||
IUP_API void IupSetRGBA (Ihandle* ih, const char* name, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
||||
|
||||
IUP_API char* IupGetAttribute(Ihandle* ih, const char* name);
|
||||
IUP_API int IupGetInt (Ihandle* ih, const char* name);
|
||||
IUP_API int IupGetInt2 (Ihandle* ih, const char* name);
|
||||
IUP_API int IupGetIntInt (Ihandle* ih, const char* name, int *i1, int *i2);
|
||||
IUP_API float IupGetFloat (Ihandle* ih, const char* name);
|
||||
IUP_API double IupGetDouble(Ihandle* ih, const char* name);
|
||||
IUP_API void IupGetRGB (Ihandle* ih, const char* name, unsigned char *r, unsigned char *g, unsigned char *b);
|
||||
IUP_API void IupGetRGBA (Ihandle* ih, const char* name, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a);
|
||||
|
||||
IUP_API void IupSetAttributeId(Ihandle* ih, const char* name, int id, const char *value);
|
||||
IUP_API void IupSetStrAttributeId(Ihandle* ih, const char* name, int id, const char *value);
|
||||
IUP_API void IupSetStrfId(Ihandle* ih, const char* name, int id, const char* format, ...);
|
||||
IUP_API void IupSetIntId(Ihandle* ih, const char* name, int id, int value);
|
||||
IUP_API void IupSetFloatId(Ihandle* ih, const char* name, int id, float value);
|
||||
IUP_API void IupSetDoubleId(Ihandle* ih, const char* name, int id, double value);
|
||||
IUP_API void IupSetRGBId(Ihandle* ih, const char* name, int id, unsigned char r, unsigned char g, unsigned char b);
|
||||
|
||||
IUP_API char* IupGetAttributeId(Ihandle* ih, const char* name, int id);
|
||||
IUP_API int IupGetIntId(Ihandle* ih, const char* name, int id);
|
||||
IUP_API float IupGetFloatId(Ihandle* ih, const char* name, int id);
|
||||
IUP_API double IupGetDoubleId(Ihandle* ih, const char* name, int id);
|
||||
IUP_API void IupGetRGBId(Ihandle* ih, const char* name, int id, unsigned char *r, unsigned char *g, unsigned char *b);
|
||||
|
||||
IUP_API void IupSetAttributeId2(Ihandle* ih, const char* name, int lin, int col, const char* value);
|
||||
IUP_API void IupSetStrAttributeId2(Ihandle* ih, const char* name, int lin, int col, const char* value);
|
||||
IUP_API void IupSetStrfId2(Ihandle* ih, const char* name, int lin, int col, const char* format, ...);
|
||||
IUP_API void IupSetIntId2(Ihandle* ih, const char* name, int lin, int col, int value);
|
||||
IUP_API void IupSetFloatId2(Ihandle* ih, const char* name, int lin, int col, float value);
|
||||
IUP_API void IupSetDoubleId2(Ihandle* ih, const char* name, int lin, int col, double value);
|
||||
IUP_API void IupSetRGBId2(Ihandle* ih, const char* name, int lin, int col, unsigned char r, unsigned char g, unsigned char b);
|
||||
|
||||
IUP_API char* IupGetAttributeId2(Ihandle* ih, const char* name, int lin, int col);
|
||||
IUP_API int IupGetIntId2(Ihandle* ih, const char* name, int lin, int col);
|
||||
IUP_API float IupGetFloatId2(Ihandle* ih, const char* name, int lin, int col);
|
||||
IUP_API double IupGetDoubleId2(Ihandle* ih, const char* name, int lin, int col);
|
||||
IUP_API void IupGetRGBId2(Ihandle* ih, const char* name, int lin, int col, unsigned char *r, unsigned char *g, unsigned char *b);
|
||||
|
||||
IUP_API void IupSetGlobal (const char* name, const char* value);
|
||||
IUP_API void IupSetStrGlobal(const char* name, const char* value);
|
||||
IUP_API char* IupGetGlobal (const char* name);
|
||||
|
||||
IUP_API Ihandle* IupSetFocus (Ihandle* ih);
|
||||
IUP_API Ihandle* IupGetFocus (void);
|
||||
IUP_API Ihandle* IupPreviousField(Ihandle* ih);
|
||||
IUP_API Ihandle* IupNextField (Ihandle* ih);
|
||||
|
||||
IUP_API Icallback IupGetCallback (Ihandle* ih, const char *name);
|
||||
IUP_API Icallback IupSetCallback (Ihandle* ih, const char *name, Icallback func);
|
||||
IUP_API Ihandle* IupSetCallbacks(Ihandle* ih, const char *name, Icallback func, ...);
|
||||
|
||||
IUP_API Icallback IupGetFunction(const char *name);
|
||||
IUP_API Icallback IupSetFunction(const char *name, Icallback func);
|
||||
|
||||
IUP_API Ihandle* IupGetHandle (const char *name);
|
||||
IUP_API Ihandle* IupSetHandle (const char *name, Ihandle* ih);
|
||||
IUP_API int IupGetAllNames (char** names, int n);
|
||||
IUP_API int IupGetAllDialogs(char** names, int n);
|
||||
IUP_API char* IupGetName (Ihandle* ih);
|
||||
|
||||
IUP_API void IupSetAttributeHandle(Ihandle* ih, const char* name, Ihandle* ih_named);
|
||||
IUP_API Ihandle* IupGetAttributeHandle(Ihandle* ih, const char* name);
|
||||
IUP_API void IupSetAttributeHandleId(Ihandle* ih, const char* name, int id, Ihandle* ih_named);
|
||||
IUP_API Ihandle* IupGetAttributeHandleId(Ihandle* ih, const char* name, int id);
|
||||
IUP_API void IupSetAttributeHandleId2(Ihandle* ih, const char* name, int lin, int col, Ihandle* ih_named);
|
||||
IUP_API Ihandle* IupGetAttributeHandleId2(Ihandle* ih, const char* name, int lin, int col);
|
||||
|
||||
IUP_API char* IupGetClassName(Ihandle* ih);
|
||||
IUP_API char* IupGetClassType(Ihandle* ih);
|
||||
IUP_API int IupGetAllClasses(char** names, int n);
|
||||
IUP_API int IupGetClassAttributes(const char* classname, char** names, int n);
|
||||
IUP_API int IupGetClassCallbacks(const char* classname, char** names, int n);
|
||||
IUP_API void IupSaveClassAttributes(Ihandle* ih);
|
||||
IUP_API void IupCopyClassAttributes(Ihandle* src_ih, Ihandle* dst_ih);
|
||||
IUP_API void IupSetClassDefaultAttribute(const char* classname, const char *name, const char* value);
|
||||
IUP_API int IupClassMatch(Ihandle* ih, const char* classname);
|
||||
|
||||
IUP_API Ihandle* IupCreate (const char *classname);
|
||||
IUP_API Ihandle* IupCreatev(const char *classname, void* *params);
|
||||
IUP_API Ihandle* IupCreatep(const char *classname, void* first, ...);
|
||||
|
||||
/************************************************************************/
|
||||
/* Elements */
|
||||
/************************************************************************/
|
||||
|
||||
IUP_API Ihandle* IupFill (void);
|
||||
IUP_API Ihandle* IupSpace(void);
|
||||
|
||||
IUP_API Ihandle* IupRadio (Ihandle* child);
|
||||
IUP_API Ihandle* IupVbox (Ihandle* child, ...);
|
||||
IUP_API Ihandle* IupVboxv (Ihandle* *children);
|
||||
IUP_API Ihandle* IupZbox (Ihandle* child, ...);
|
||||
IUP_API Ihandle* IupZboxv (Ihandle* *children);
|
||||
IUP_API Ihandle* IupHbox (Ihandle* child, ...);
|
||||
IUP_API Ihandle* IupHboxv (Ihandle* *children);
|
||||
|
||||
IUP_API Ihandle* IupNormalizer (Ihandle* ih_first, ...);
|
||||
IUP_API Ihandle* IupNormalizerv(Ihandle* *ih_list);
|
||||
|
||||
IUP_API Ihandle* IupCbox (Ihandle* child, ...);
|
||||
IUP_API Ihandle* IupCboxv (Ihandle* *children);
|
||||
IUP_API Ihandle* IupSbox (Ihandle* child);
|
||||
IUP_API Ihandle* IupSplit (Ihandle* child1, Ihandle* child2);
|
||||
IUP_API Ihandle* IupScrollBox (Ihandle* child);
|
||||
IUP_API Ihandle* IupFlatScrollBox(Ihandle* child);
|
||||
IUP_API Ihandle* IupGridBox (Ihandle* child, ...);
|
||||
IUP_API Ihandle* IupGridBoxv (Ihandle* *children);
|
||||
IUP_API Ihandle* IupMultiBox (Ihandle* child, ...);
|
||||
IUP_API Ihandle* IupMultiBoxv (Ihandle **children);
|
||||
IUP_API Ihandle* IupExpander(Ihandle* child);
|
||||
IUP_API Ihandle* IupDetachBox (Ihandle* child);
|
||||
IUP_API Ihandle* IupBackgroundBox(Ihandle* child);
|
||||
|
||||
IUP_API Ihandle* IupFrame (Ihandle* child);
|
||||
IUP_API Ihandle* IupFlatFrame (Ihandle* child);
|
||||
|
||||
IUP_API Ihandle* IupImage (int width, int height, const unsigned char* pixels);
|
||||
IUP_API Ihandle* IupImageRGB (int width, int height, const unsigned char* pixels);
|
||||
IUP_API Ihandle* IupImageRGBA (int width, int height, const unsigned char* pixels);
|
||||
|
||||
IUP_API Ihandle* IupItem (const char* title, const char* action);
|
||||
IUP_API Ihandle* IupSubmenu (const char* title, Ihandle* child);
|
||||
IUP_API Ihandle* IupSeparator (void);
|
||||
IUP_API Ihandle* IupMenu (Ihandle* child, ...);
|
||||
IUP_API Ihandle* IupMenuv (Ihandle* *children);
|
||||
|
||||
IUP_API Ihandle* IupButton (const char* title, const char* action);
|
||||
IUP_API Ihandle* IupFlatButton (const char* title);
|
||||
IUP_API Ihandle* IupFlatToggle (const char* title);
|
||||
IUP_API Ihandle* IupDropButton (Ihandle* dropchild);
|
||||
IUP_API Ihandle* IupFlatLabel (const char* title);
|
||||
IUP_API Ihandle* IupFlatSeparator(void);
|
||||
IUP_API Ihandle* IupCanvas (const char* action);
|
||||
IUP_API Ihandle* IupDialog (Ihandle* child);
|
||||
IUP_API Ihandle* IupUser (void);
|
||||
IUP_API Ihandle* IupThread (void);
|
||||
IUP_API Ihandle* IupLabel (const char* title);
|
||||
IUP_API Ihandle* IupList (const char* action);
|
||||
IUP_API Ihandle* IupFlatList (void);
|
||||
IUP_API Ihandle* IupText (const char* action);
|
||||
IUP_API Ihandle* IupMultiLine (const char* action);
|
||||
IUP_API Ihandle* IupToggle (const char* title, const char* action);
|
||||
IUP_API Ihandle* IupTimer (void);
|
||||
IUP_API Ihandle* IupClipboard (void);
|
||||
IUP_API Ihandle* IupProgressBar(void);
|
||||
IUP_API Ihandle* IupVal (const char *type);
|
||||
IUP_API Ihandle* IupFlatVal (const char *type);
|
||||
IUP_API Ihandle* IupFlatTree (void);
|
||||
IUP_API Ihandle* IupTabs (Ihandle* child, ...);
|
||||
IUP_API Ihandle* IupTabsv (Ihandle* *children);
|
||||
IUP_API Ihandle* IupFlatTabs (Ihandle* first, ...);
|
||||
IUP_API Ihandle* IupFlatTabsv (Ihandle* *children);
|
||||
IUP_API Ihandle* IupTree (void);
|
||||
IUP_API Ihandle* IupLink (const char* url, const char* title);
|
||||
IUP_API Ihandle* IupAnimatedLabel(Ihandle* animation);
|
||||
IUP_API Ihandle* IupDatePick (void);
|
||||
IUP_API Ihandle* IupCalendar (void);
|
||||
IUP_API Ihandle* IupColorbar (void);
|
||||
IUP_API Ihandle* IupGauge (void);
|
||||
IUP_API Ihandle* IupDial (const char* type);
|
||||
IUP_API Ihandle* IupColorBrowser(void);
|
||||
|
||||
/* Old controls, use SPIN attribute of IupText */
|
||||
IUP_API Ihandle* IupSpin (void);
|
||||
IUP_API Ihandle* IupSpinbox (Ihandle* child);
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* Utilities */
|
||||
/************************************************************************/
|
||||
|
||||
/* String compare utility */
|
||||
IUP_API int IupStringCompare(const char* str1, const char* str2, int casesensitive, int lexicographic);
|
||||
|
||||
/* IupImage utilities */
|
||||
IUP_API int IupSaveImageAsText(Ihandle* ih, const char* filename, const char* format, const char* name);
|
||||
IUP_API Ihandle* IupImageGetHandle(const char* name);
|
||||
|
||||
/* IupText and IupScintilla utilities */
|
||||
IUP_API void IupTextConvertLinColToPos(Ihandle* ih, int lin, int col, int *pos);
|
||||
IUP_API void IupTextConvertPosToLinCol(Ihandle* ih, int pos, int *lin, int *col);
|
||||
|
||||
/* IupText, IupList, IupTree, IupMatrix and IupScintilla utility */
|
||||
IUP_API int IupConvertXYToPos(Ihandle* ih, int x, int y);
|
||||
|
||||
/* OLD names, kept for backward compatibility, will never be removed. */
|
||||
IUP_API void IupStoreGlobal(const char* name, const char* value);
|
||||
IUP_API void IupStoreAttribute(Ihandle* ih, const char* name, const char* value);
|
||||
IUP_API void IupSetfAttribute(Ihandle* ih, const char* name, const char* format, ...);
|
||||
IUP_API void IupStoreAttributeId(Ihandle* ih, const char* name, int id, const char *value);
|
||||
IUP_API void IupSetfAttributeId(Ihandle* ih, const char* name, int id, const char* f, ...);
|
||||
IUP_API void IupStoreAttributeId2(Ihandle* ih, const char* name, int lin, int col, const char* value);
|
||||
IUP_API void IupSetfAttributeId2(Ihandle* ih, const char* name, int lin, int col, const char* format, ...);
|
||||
|
||||
/* IupTree and IupFlatTree utilities (work for both) */
|
||||
IUP_API int IupTreeSetUserId(Ihandle* ih, int id, void* userid);
|
||||
IUP_API void* IupTreeGetUserId(Ihandle* ih, int id);
|
||||
IUP_API int IupTreeGetId(Ihandle* ih, void *userid);
|
||||
IUP_API void IupTreeSetAttributeHandle(Ihandle* ih, const char* name, int id, Ihandle* ih_named); /* deprecated, use IupSetAttributeHandleId */
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* Pre-defined dialogs */
|
||||
/************************************************************************/
|
||||
|
||||
IUP_API Ihandle* IupFileDlg(void);
|
||||
IUP_API Ihandle* IupMessageDlg(void);
|
||||
IUP_API Ihandle* IupColorDlg(void);
|
||||
IUP_API Ihandle* IupFontDlg(void);
|
||||
IUP_API Ihandle* IupProgressDlg(void);
|
||||
|
||||
IUP_API int IupGetFile(char *arq);
|
||||
IUP_API void IupMessage(const char *title, const char *msg);
|
||||
IUP_API void IupMessagef(const char *title, const char *format, ...);
|
||||
IUP_API void IupMessageError(Ihandle* parent, const char* message);
|
||||
IUP_API int IupMessageAlarm(Ihandle* parent, const char* title, const char *message, const char *buttons);
|
||||
IUP_API int IupAlarm(const char *title, const char *msg, const char *b1, const char *b2, const char *b3);
|
||||
IUP_API int IupScanf(const char *format, ...);
|
||||
IUP_API int IupListDialog(int type, const char *title, int size, const char** list,
|
||||
int op, int max_col, int max_lin, int* marks);
|
||||
IUP_API int IupGetText(const char* title, char* text, int maxsize);
|
||||
IUP_API int IupGetColor(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b);
|
||||
|
||||
typedef int (*Iparamcb)(Ihandle* dialog, int param_index, void* user_data);
|
||||
IUP_API int IupGetParam(const char* title, Iparamcb action, void* user_data, const char* format,...);
|
||||
IUP_API int IupGetParamv(const char* title, Iparamcb action, void* user_data, const char* format, int param_count, int param_extra, void** param_data);
|
||||
IUP_API Ihandle* IupParam(const char* format);
|
||||
IUP_API Ihandle* IupParamBox(Ihandle* param, ...);
|
||||
IUP_API Ihandle* IupParamBoxv(Ihandle* *param_array);
|
||||
|
||||
IUP_API Ihandle* IupLayoutDialog(Ihandle* dialog);
|
||||
IUP_API Ihandle* IupElementPropertiesDialog(Ihandle* parent, Ihandle* elem);
|
||||
IUP_API Ihandle* IupGlobalsDialog(void);
|
||||
IUP_API Ihandle* IupClassInfoDialog(Ihandle* parent);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************/
|
||||
/* Common Flags and Return Values */
|
||||
/************************************************************************/
|
||||
#define IUP_ERROR 1
|
||||
#define IUP_NOERROR 0
|
||||
#define IUP_OPENED -1
|
||||
#define IUP_INVALID -1
|
||||
#define IUP_INVALID_ID -10
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* Callback Return Values */
|
||||
/************************************************************************/
|
||||
#define IUP_IGNORE -1
|
||||
#define IUP_DEFAULT -2
|
||||
#define IUP_CLOSE -3
|
||||
#define IUP_CONTINUE -4
|
||||
|
||||
/************************************************************************/
|
||||
/* IupPopup and IupShowXY Parameter Values */
|
||||
/************************************************************************/
|
||||
#define IUP_CENTER 0xFFFF /* 65535 */
|
||||
#define IUP_LEFT 0xFFFE /* 65534 */
|
||||
#define IUP_RIGHT 0xFFFD /* 65533 */
|
||||
#define IUP_MOUSEPOS 0xFFFC /* 65532 */
|
||||
#define IUP_CURRENT 0xFFFB /* 65531 */
|
||||
#define IUP_CENTERPARENT 0xFFFA /* 65530 */
|
||||
#define IUP_LEFTPARENT 0xFFF9 /* 65529 */
|
||||
#define IUP_RIGHTPARENT 0xFFF8 /* 65528 */
|
||||
#define IUP_TOP IUP_LEFT
|
||||
#define IUP_BOTTOM IUP_RIGHT
|
||||
#define IUP_TOPPARENT IUP_LEFTPARENT
|
||||
#define IUP_BOTTOMPARENT IUP_RIGHTPARENT
|
||||
|
||||
/************************************************************************/
|
||||
/* SHOW_CB Callback Values */
|
||||
/************************************************************************/
|
||||
enum{IUP_SHOW, IUP_RESTORE, IUP_MINIMIZE, IUP_MAXIMIZE, IUP_HIDE};
|
||||
|
||||
/************************************************************************/
|
||||
/* SCROLL_CB Callback Values */
|
||||
/************************************************************************/
|
||||
enum{IUP_SBUP, IUP_SBDN, IUP_SBPGUP, IUP_SBPGDN, IUP_SBPOSV, IUP_SBDRAGV,
|
||||
IUP_SBLEFT, IUP_SBRIGHT, IUP_SBPGLEFT, IUP_SBPGRIGHT, IUP_SBPOSH, IUP_SBDRAGH};
|
||||
|
||||
/************************************************************************/
|
||||
/* Mouse Button Values and Macros */
|
||||
/************************************************************************/
|
||||
#define IUP_BUTTON1 '1'
|
||||
#define IUP_BUTTON2 '2'
|
||||
#define IUP_BUTTON3 '3'
|
||||
#define IUP_BUTTON4 '4'
|
||||
#define IUP_BUTTON5 '5'
|
||||
|
||||
#define iup_isshift(_s) (_s[0]=='S')
|
||||
#define iup_iscontrol(_s) (_s[1]=='C')
|
||||
#define iup_isbutton1(_s) (_s[2]=='1')
|
||||
#define iup_isbutton2(_s) (_s[3]=='2')
|
||||
#define iup_isbutton3(_s) (_s[4]=='3')
|
||||
#define iup_isdouble(_s) (_s[5]=='D')
|
||||
#define iup_isalt(_s) (_s[6]=='A')
|
||||
#define iup_issys(_s) (_s[7]=='Y')
|
||||
#define iup_isbutton4(_s) (_s[8]=='4')
|
||||
#define iup_isbutton5(_s) (_s[9]=='5')
|
||||
|
||||
/* Old definitions for backward compatibility */
|
||||
#define isshift iup_isshift
|
||||
#define iscontrol iup_iscontrol
|
||||
#define isbutton1 iup_isbutton1
|
||||
#define isbutton2 iup_isbutton2
|
||||
#define isbutton3 iup_isbutton3
|
||||
#define isdouble iup_isdouble
|
||||
#define isalt iup_isalt
|
||||
#define issys iup_issys
|
||||
#define isbutton4 iup_isbutton4
|
||||
#define isbutton5 iup_isbutton5
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* Pre-Defined Masks */
|
||||
/************************************************************************/
|
||||
#define IUP_MASK_FLOAT "[+/-]?(/d+/.?/d*|/./d+)"
|
||||
#define IUP_MASK_UFLOAT "(/d+/.?/d*|/./d+)"
|
||||
#define IUP_MASK_EFLOAT "[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?"
|
||||
#define IUP_MASK_UEFLOAT "(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?"
|
||||
#define IUP_MASK_FLOATCOMMA "[+/-]?(/d+/,?/d*|/,/d+)"
|
||||
#define IUP_MASK_UFLOATCOMMA "(/d+/,?/d*|/,/d+)"
|
||||
#define IUP_MASK_INT "[+/-]?/d+"
|
||||
#define IUP_MASK_UINT "/d+"
|
||||
|
||||
/* Old definitions for backward compatibility */
|
||||
#define IUPMASK_FLOAT IUP_MASK_FLOAT
|
||||
#define IUPMASK_UFLOAT IUP_MASK_UFLOAT
|
||||
#define IUPMASK_EFLOAT IUP_MASK_EFLOAT
|
||||
#define IUPMASK_INT IUP_MASK_INT
|
||||
#define IUPMASK_UINT IUP_MASK_UINT
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* IupGetParam Callback situations */
|
||||
/************************************************************************/
|
||||
#define IUP_GETPARAM_BUTTON1 -1
|
||||
#define IUP_GETPARAM_INIT -2
|
||||
#define IUP_GETPARAM_BUTTON2 -3
|
||||
#define IUP_GETPARAM_BUTTON3 -4
|
||||
#define IUP_GETPARAM_CLOSE -5
|
||||
#define IUP_GETPARAM_MAP -6
|
||||
#define IUP_GETPARAM_OK IUP_GETPARAM_BUTTON1
|
||||
#define IUP_GETPARAM_CANCEL IUP_GETPARAM_BUTTON2
|
||||
#define IUP_GETPARAM_HELP IUP_GETPARAM_BUTTON3
|
||||
|
||||
/************************************************************************/
|
||||
/* Used by IupColorbar */
|
||||
/************************************************************************/
|
||||
#define IUP_PRIMARY -1
|
||||
#define IUP_SECONDARY -2
|
||||
|
||||
/************************************************************************/
|
||||
/* Record Input Modes */
|
||||
/************************************************************************/
|
||||
enum {IUP_RECBINARY, IUP_RECTEXT};
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* Replacement for the WinMain in Windows, */
|
||||
/* this allows the application to start from "main". */
|
||||
/* Used only for Watcom. */
|
||||
/************************************************************************/
|
||||
#if defined (__WATCOMC__)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
int IupMain (int argc, char** argv); /* In C++ we have to declare the prototype */
|
||||
}
|
||||
#endif
|
||||
#define main IupMain /* this is the trick for Watcom and MetroWerks */
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright (C) 1994-2019 Tecgraf/PUC-Rio.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,464 @@
|
||||
/** \file
|
||||
* \brief Class Callback Utilities.
|
||||
*/
|
||||
|
||||
#ifndef __IUP_CLASS_CBS_HPP
|
||||
#define __IUP_CLASS_CBS_HPP
|
||||
|
||||
|
||||
#define IUP_CLASS_GET_OBJECT(__ih, __class) dynamic_cast<__class*>((__class*)IupGetAttribute(__ih, #__class "->this"))
|
||||
|
||||
|
||||
#define IUP_CLASS_INITCALLBACK(__ih, __class) \
|
||||
IupSetAttribute(__ih, #__class "->this", (char*)this)
|
||||
|
||||
#define IUP_CLASS_SETCALLBACK(__ih, __name, __cb) \
|
||||
IupSetCallback(__ih, __name, (Icallback)CB_##__cb)
|
||||
|
||||
|
||||
|
||||
#ifdef __IUP_PLUS_H
|
||||
|
||||
#define IUP_PLUS_GET_OBJECT(__elem, __class) dynamic_cast<__class*>((__class*)IupGetAttribute(__elem.GetHandle(), #__class "->this"))
|
||||
|
||||
#define IUP_PLUS_INITCALLBACK(__elem, __class) \
|
||||
IupSetAttribute(__elem.GetHandle(), #__class "->this", (char*)this)
|
||||
|
||||
#define IUP_PLUS_SETCALLBACK(__elem, __name, __cb) \
|
||||
IupSetCallback(__elem.GetHandle(), __name, (Icallback)CB_##__cb)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFn(__class, __cb) \
|
||||
int __cb(Ihandle* ih); \
|
||||
static int CB_##__cb(Ihandle* ih) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFni(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnii(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniii(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, int i3); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, int i3) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, i3); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniiii(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, int i3, int i4); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, int i3, int i4) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, i3, i4); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniiiii(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, int i3, int i4, int i5); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, int i3, int i4, int i5) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, i3, i4, i5); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniiiiii(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, int i3, int i4, int i5, int i6); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, int i3, int i4, int i5, int i6) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, i3, i4, i5, i6); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniiiiiiC(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, int i3, int i4, int i5, int i6, struct _cdCanvas* canvas); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, int i3, int i4, int i5, int i6, struct _cdCanvas* canvas) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, i3, i4, i5, i6, canvas); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnC(__class, __cb) \
|
||||
int __cb(Ihandle* ih, struct _cdCanvas* canvas); \
|
||||
static int CB_##__cb(Ihandle* ih, struct _cdCanvas* canvas) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, canvas); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_dIFnii(__class, __cb) \
|
||||
double __cb(Ihandle* ih, int i1, int i2); \
|
||||
static double CB_##__cb(Ihandle* ih, int i1, int i2) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_sIFni(__class, __cb) \
|
||||
char* __cb(Ihandle* ih, int i1); \
|
||||
static char* CB_##__cb(Ihandle* ih, int i1) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_sIFnii(__class, __cb) \
|
||||
char* __cb(Ihandle* ih, int i1, int i2); \
|
||||
static char* CB_##__cb(Ihandle* ih, int i1, int i2) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_sIFniis(__class, __cb) \
|
||||
char* __cb(Ihandle* ih, int i1, int i2, char* s); \
|
||||
static char* CB_##__cb(Ihandle* ih, int i1, int i2, char* s) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, s); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnff(__class, __cb) \
|
||||
int __cb(Ihandle* ih, float f1, float f2); \
|
||||
static int CB_##__cb(Ihandle* ih, float f1, float f2) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, f1, f2); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniff(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, float f1, float f2); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, float f1, float f2) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, f1, f2); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnfiis(__class, __cb) \
|
||||
int __cb(Ihandle* ih, float f1, int i1, int i2, char* s); \
|
||||
static int CB_##__cb(Ihandle* ih, float f1, int i1, int i2, char* s) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, f1, i1, i2, s); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnd(__class, __cb) \
|
||||
int __cb(Ihandle* ih, double d1); \
|
||||
static int CB_##__cb(Ihandle* ih, double d1) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, d1); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFndds(__class, __cb) \
|
||||
int __cb(Ihandle* ih, double d1, double d2, char* s); \
|
||||
static int CB_##__cb(Ihandle* ih, double d1, double d2, char* s) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, d1, d2, s); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniid(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, double d1); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, double d1) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, d1); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniidd(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, double d1, double d2); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, double d1, double d2) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, d1, d2); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniiddi(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, double d1, double d2, int i3); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, double d1, double d2, int i3) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, d1, d2, i3); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniidds(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, double d1, double d2, char* s); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, double d1, double d2, char* s) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, d1, d2, s); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniiIII(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, int *I1, int *I2, int *I3); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, int *I1, int *I2, int *I3) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, I1, I2, I3); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniIIII(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int *I1, int *I2, int *I3, int *I4); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int *I1, int *I2, int *I3, int *I4) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, I1, I2, I3, I4); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnIi(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int *I1, int i1); \
|
||||
static int CB_##__cb(Ihandle* ih, int *I1, int i1) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, I1, i1); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnccc(__class, __cb) \
|
||||
int __cb(Ihandle* ih, char c1, char c2, char c3); \
|
||||
static int CB_##__cb(Ihandle* ih, char c1, char c2, char c3) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, c1, c2, c3); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnis(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, char* s); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, char* s) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, s); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniis(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, char* s); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, char* s) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, s); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniiis(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, int i3, char* s); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, int i3, char* s) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, i3, s); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniiiis(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, int i3, int i4, char* s); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, int i3, int i4, char* s) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, i3, i4, s); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniiiiis(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, int i3, int i4, int i5, char* s); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, int i3, int i4, int i5, char* s) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, i3, i4, i5, s); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniiiiiis(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, int i3, int i4, int i5, int i6, char* s); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, int i3, int i4, int i5, int i6, char* s) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, i3, i4, i5, i6, s); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnss(__class, __cb) \
|
||||
int __cb(Ihandle* ih, char* s1, char* s2); \
|
||||
static int CB_##__cb(Ihandle* ih, char* s1, char* s2) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, s1, s2); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFns(__class, __cb) \
|
||||
int __cb(Ihandle* ih, char* s1); \
|
||||
static int CB_##__cb(Ihandle* ih, char* s1) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, s1); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnsi(__class, __cb) \
|
||||
int __cb(Ihandle* ih, char* s1, int i1); \
|
||||
static int CB_##__cb(Ihandle* ih, char* s1, int i1) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, s1, i1); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnsii(__class, __cb) \
|
||||
int __cb(Ihandle* ih, char* s1, int i1, int i2); \
|
||||
static int CB_##__cb(Ihandle* ih, char* s1, int i1, int i2) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, s1, i1, i2); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnsiii(__class, __cb) \
|
||||
int __cb(Ihandle* ih, char* s1, int i1, int i2, int i3); \
|
||||
static int CB_##__cb(Ihandle* ih, char* s1, int i1, int i2, int i3) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, s1, i1, i2, i3); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnnii(__class, __cb) \
|
||||
int __cb(Ihandle* ih, Ihandle* ih1, int i1, int i2); \
|
||||
static int CB_##__cb(Ihandle* ih, Ihandle* ih1, int i1, int i2) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, ih1, i1, i2); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnnn(__class, __cb) \
|
||||
int __cb(Ihandle* ih, Ihandle* ih1, Ihandle *ih2); \
|
||||
static int CB_##__cb(Ihandle* ih, Ihandle* ih1, Ihandle *ih2) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, ih1, ih2); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFniinsii(__class, __cb) \
|
||||
int __cb(Ihandle* ih, int i1, int i2, Ihandle* ih1, char* s, int i3, int i4); \
|
||||
static int CB_##__cb(Ihandle* ih, int i1, int i2, Ihandle* ih1, char* s, int i3, int i4) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, i1, i2, ih1, s, i3, i4); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnsVi(__class, __cb) \
|
||||
int __cb(Ihandle* ih, char* s1, void* V1, int i1); \
|
||||
static int CB_##__cb(Ihandle* ih, char* s1, void* V1, int i1) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, s1, V1, i1); \
|
||||
}
|
||||
|
||||
#define IUP_CLASS_DECLARECALLBACK_IFnsViii(__class, __cb) \
|
||||
int __cb(Ihandle* ih, char* s1, void* V1, int i1, int i2, int i3); \
|
||||
static int CB_##__cb(Ihandle* ih, char* s1, void* V1, int i1, int i2, int i3) \
|
||||
{ \
|
||||
__class* obj = IUP_CLASS_GET_OBJECT(ih, __class); \
|
||||
return obj->__cb(ih, s1, V1, i1, i2, i3); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* #define IUP_CLASS_DEBUG */
|
||||
#ifdef IUP_CLASS_DEBUG
|
||||
class IUP_CLASS_DUMMY
|
||||
{
|
||||
// Used to check for errors in the definitions
|
||||
IUP_CLASS_DECLARECALLBACK_IFn(IUP_CLASS_DUMMY, IFn);
|
||||
IUP_CLASS_DECLARECALLBACK_IFni(IUP_CLASS_DUMMY, IFni);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnii(IUP_CLASS_DUMMY, IFnii);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniii(IUP_CLASS_DUMMY, IFniii);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniiii(IUP_CLASS_DUMMY, IFniiii);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniiiii(IUP_CLASS_DUMMY, IFniiiii);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniiiiii(IUP_CLASS_DUMMY, IFniiiiii);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniiiiiiC(IUP_CLASS_DUMMY, IFniiiiiiC);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnC(IUP_CLASS_DUMMY, IFnC);
|
||||
IUP_CLASS_DECLARECALLBACK_dIFnii(IUP_CLASS_DUMMY, dIFnii);
|
||||
IUP_CLASS_DECLARECALLBACK_sIFni(IUP_CLASS_DUMMY, sIFni);
|
||||
IUP_CLASS_DECLARECALLBACK_sIFnii(IUP_CLASS_DUMMY, sIFnii);
|
||||
IUP_CLASS_DECLARECALLBACK_sIFniis(IUP_CLASS_DUMMY, sIFniis);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnff(IUP_CLASS_DUMMY, IFnff);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniff(IUP_CLASS_DUMMY, IFniff);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnfiis(IUP_CLASS_DUMMY, IFnfiis);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnd(IUP_CLASS_DUMMY, IFnd);
|
||||
IUP_CLASS_DECLARECALLBACK_IFndds(IUP_CLASS_DUMMY, IFndds);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniid(IUP_CLASS_DUMMY, IFniid);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniidd(IUP_CLASS_DUMMY, IFniidd);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniiddi(IUP_CLASS_DUMMY, IFniiddi);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniidds(IUP_CLASS_DUMMY, IFniidds);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniiIII(IUP_CLASS_DUMMY, IFniiIII);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniIIII(IUP_CLASS_DUMMY, IFniIIII);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnIi(IUP_CLASS_DUMMY, IFnIi);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnccc(IUP_CLASS_DUMMY, IFnccc);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnis(IUP_CLASS_DUMMY, IFnis);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniis(IUP_CLASS_DUMMY, IFniis);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniiis(IUP_CLASS_DUMMY, IFniiis);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniiiis(IUP_CLASS_DUMMY, IFniiiis);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniiiiis(IUP_CLASS_DUMMY, IFniiiiis);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniiiiiis(IUP_CLASS_DUMMY, IFniiiiiis);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnss(IUP_CLASS_DUMMY, IFnss);
|
||||
IUP_CLASS_DECLARECALLBACK_IFns(IUP_CLASS_DUMMY, IFns);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnsi(IUP_CLASS_DUMMY, IFnsi);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnsii(IUP_CLASS_DUMMY, IFnsii);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnsiii(IUP_CLASS_DUMMY, IFnsiii);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnnii(IUP_CLASS_DUMMY, IFnnii);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnnn(IUP_CLASS_DUMMY, IFnnn);
|
||||
IUP_CLASS_DECLARECALLBACK_IFniinsii(IUP_CLASS_DUMMY, IFniinsii);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnsVi(IUP_CLASS_DUMMY, IFnsVi);
|
||||
IUP_CLASS_DECLARECALLBACK_IFnsViii(IUP_CLASS_DUMMY, IFnsViii);
|
||||
};
|
||||
|
||||
class SampleClass
|
||||
{
|
||||
int sample_count;
|
||||
|
||||
public:
|
||||
SampleClass()
|
||||
{
|
||||
sample_count = 0;
|
||||
|
||||
Ihandle* button1 = IupButton("Inc", NULL);
|
||||
Ihandle* button2 = IupButton("Dec", NULL);
|
||||
Ihandle* dialog = IupDialog(IupHbox(button1, button2, NULL));
|
||||
|
||||
// 1) Register "this" object as a callback receiver (need only once)
|
||||
IUP_CLASS_INITCALLBACK(dialog, SampleClass);
|
||||
|
||||
// 2) Associate the callback with the button
|
||||
IUP_CLASS_SETCALLBACK(button1, "ACTION", ButtonAction1);
|
||||
IUP_CLASS_SETCALLBACK(button2, "ACTION", ButtonAction2);
|
||||
|
||||
IupShow(dialog);
|
||||
};
|
||||
|
||||
protected:
|
||||
// 3) Declare the callback as a member function
|
||||
IUP_CLASS_DECLARECALLBACK_IFn(SampleClass, ButtonAction1);
|
||||
IUP_CLASS_DECLARECALLBACK_IFn(SampleClass, ButtonAction2);
|
||||
};
|
||||
|
||||
// 4) Define the callback as a member function
|
||||
int SampleClass::ButtonAction1(Ihandle*)
|
||||
{
|
||||
sample_count++;
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
int SampleClass::ButtonAction2(Ihandle*)
|
||||
{
|
||||
sample_count--;
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
#endif // IUP_CLASS_DEBUG
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
/** \file
|
||||
* \brief Configuration file Utilities
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef IUP_CONFIG_H
|
||||
#define IUP_CONFIG_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
IUP_API Ihandle* IupConfig(void);
|
||||
|
||||
IUP_API int IupConfigLoad(Ihandle* ih);
|
||||
IUP_API int IupConfigSave(Ihandle* ih);
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
IUP_API void IupConfigSetVariableStr(Ihandle* ih, const char* group, const char* key, const char* value);
|
||||
IUP_API void IupConfigSetVariableStrId(Ihandle* ih, const char* group, const char* key, int id, const char* value);
|
||||
IUP_API void IupConfigSetVariableInt(Ihandle* ih, const char* group, const char* key, int value);
|
||||
IUP_API void IupConfigSetVariableIntId(Ihandle* ih, const char* group, const char* key, int id, int value);
|
||||
IUP_API void IupConfigSetVariableDouble(Ihandle* ih, const char* group, const char* key, double value);
|
||||
IUP_API void IupConfigSetVariableDoubleId(Ihandle* ih, const char* group, const char* key, int id, double value);
|
||||
|
||||
IUP_API const char* IupConfigGetVariableStr(Ihandle* ih, const char* group, const char* key);
|
||||
IUP_API const char* IupConfigGetVariableStrId(Ihandle* ih, const char* group, const char* key, int id);
|
||||
IUP_API int IupConfigGetVariableInt(Ihandle* ih, const char* group, const char* key);
|
||||
IUP_API int IupConfigGetVariableIntId(Ihandle* ih, const char* group, const char* key, int id);
|
||||
IUP_API double IupConfigGetVariableDouble(Ihandle* ih, const char* group, const char* key);
|
||||
IUP_API double IupConfigGetVariableDoubleId(Ihandle* ih, const char* group, const char* key, int id);
|
||||
|
||||
IUP_API const char* IupConfigGetVariableStrDef(Ihandle* ih, const char* group, const char* key, const char* def);
|
||||
IUP_API const char* IupConfigGetVariableStrIdDef(Ihandle* ih, const char* group, const char* key, int id, const char* def);
|
||||
IUP_API int IupConfigGetVariableIntDef(Ihandle* ih, const char* group, const char* key, int def);
|
||||
IUP_API int IupConfigGetVariableIntIdDef(Ihandle* ih, const char* group, const char* key, int id, int def);
|
||||
IUP_API double IupConfigGetVariableDoubleDef(Ihandle* ih, const char* group, const char* key, double def);
|
||||
IUP_API double IupConfigGetVariableDoubleIdDef(Ihandle* ih, const char* group, const char* key, int id, double def);
|
||||
|
||||
IUP_API void IupConfigCopy(Ihandle* ih1, Ihandle* ih2, const char* exclude_prefix);
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
IUP_API void IupConfigSetListVariable(Ihandle* ih, const char *group, const char* key, const char* value, int add);
|
||||
|
||||
IUP_API void IupConfigRecentInit(Ihandle* ih, Ihandle* menu, Icallback recent_cb, int max_recent);
|
||||
IUP_API void IupConfigRecentUpdate(Ihandle* ih, const char* filename);
|
||||
|
||||
IUP_API void IupConfigDialogShow(Ihandle* ih, Ihandle* dialog, const char* name);
|
||||
IUP_API void IupConfigDialogClosed(Ihandle* ih, Ihandle* dialog, const char* name);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
#ifndef __IUP_EXPORT_H
|
||||
#define __IUP_EXPORT_H
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
/** @cond DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
/* Mark the official functions */
|
||||
#ifndef IUP_API
|
||||
#ifdef IUP_BUILD_LIBRARY
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#define IUP_API EMSCRIPTEN_KEEPALIVE
|
||||
#elif WIN32
|
||||
#define IUP_API __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define IUP_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define IUP_API
|
||||
#endif
|
||||
#else
|
||||
#define IUP_API
|
||||
#endif /* IUP_BUILD_LIBRARY */
|
||||
#endif /* IUP_API */
|
||||
|
||||
/* Mark the internal SDK functions (some not official but need to be exported) */
|
||||
#ifndef IUP_SDK_API
|
||||
#ifdef IUP_BUILD_LIBRARY
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#define IUP_SDK_API EMSCRIPTEN_KEEPALIVE
|
||||
#elif WIN32
|
||||
#define IUP_SDK_API __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define IUP_SDK_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define IUP_SDK_API
|
||||
#endif
|
||||
#else
|
||||
#define IUP_SDK_API
|
||||
#endif /* IUP_BUILD_LIBRARY */
|
||||
#endif /* IUP_SDK_API */
|
||||
|
||||
/* Mark the driver functions that need to be exported */
|
||||
#ifndef IUP_DRV_API
|
||||
#ifdef IUP_BUILD_LIBRARY
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#define IUP_DRV_API EMSCRIPTEN_KEEPALIVE
|
||||
#elif WIN32
|
||||
#define IUP_DRV_API __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define IUP_DRV_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define IUP_DRV_API
|
||||
#endif
|
||||
#else
|
||||
#define IUP_DRV_API
|
||||
#endif /* IUP_BUILD_LIBRARY */
|
||||
#endif /* IUP_DRV_API */
|
||||
|
||||
/* Mark the IupImageLib function, it does not have a header of its own */
|
||||
#ifndef IUPIMGLIB_API
|
||||
#ifdef IUPIMGLIB_BUILD_LIBRARY
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#define IUPIMGLIB_API EMSCRIPTEN_KEEPALIVE
|
||||
#elif WIN32
|
||||
#define IUPIMGLIB_API __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define IUPIMGLIB_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define IUPIMGLIB_API
|
||||
#endif
|
||||
#else
|
||||
#define IUPIMGLIB_API
|
||||
#endif /* IUPIMGLIB_BUILD_LIBRARY */
|
||||
#endif /* IUPIMGLIB_API */
|
||||
|
||||
/** @endcond DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
|
||||
#endif /* __IUP_EXPORT_H */
|
||||
@@ -0,0 +1,70 @@
|
||||
/** \file
|
||||
* \brief Plot component for Iup.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUP_MGLPLOT_H
|
||||
#define __IUP_MGLPLOT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Initialize IupMglPlot widget class */
|
||||
void IupMglPlotOpen(void);
|
||||
|
||||
/* Create an IupMglPlot widget instance */
|
||||
Ihandle* IupMglPlot(void);
|
||||
|
||||
/***********************************************/
|
||||
/* Additional API */
|
||||
|
||||
/* Linear Data Only */
|
||||
void IupMglPlotBegin(Ihandle *ih, int dim);
|
||||
void IupMglPlotAdd1D(Ihandle *ih, const char* name, double y);
|
||||
void IupMglPlotAdd2D(Ihandle *ih, double x, double y);
|
||||
void IupMglPlotAdd3D(Ihandle *ih, double x, double y, double z);
|
||||
int IupMglPlotEnd(Ihandle *ih);
|
||||
|
||||
/* Linear (dim=1,2,3), Planar (dim=1), Volumetric (dim=1) */
|
||||
int IupMglPlotNewDataSet(Ihandle *ih, int dim);
|
||||
|
||||
/* Linear Data Only */
|
||||
void IupMglPlotInsert1D(Ihandle* ih, int ds_index, int sample_index, const char** names, const double* y, int count);
|
||||
void IupMglPlotInsert2D(Ihandle* ih, int ds_index, int sample_index, const double* x, const double* y, int count);
|
||||
void IupMglPlotInsert3D(Ihandle* ih, int ds_index, int sample_index, const double* x, const double* y, const double* z, int count);
|
||||
|
||||
/* Linear Data Only */
|
||||
void IupMglPlotSet1D(Ihandle* ih, int ds_index, const char** names, const double* y, int count);
|
||||
void IupMglPlotSet2D(Ihandle* ih, int ds_index, const double* x, const double* y, int count);
|
||||
void IupMglPlotSet3D(Ihandle* ih, int ds_index, const double* x, const double* y, const double* z, int count);
|
||||
void IupMglPlotSetFormula(Ihandle* ih, int ds_index, const char* formulaX, const char* formulaY, const char* formulaZ, int count);
|
||||
|
||||
/* Linear (dim=1), Planar (dim=1), Volumetric (dim=1) */
|
||||
void IupMglPlotSetData(Ihandle* ih, int ds_index, const double* data, int count_x, int count_y, int count_z);
|
||||
void IupMglPlotLoadData(Ihandle* ih, int ds_index, const char* filename, int count_x, int count_y, int count_z);
|
||||
void IupMglPlotSetFromFormula(Ihandle* ih, int ds_index, const char* formula, int count_x, int count_y, int count_z);
|
||||
|
||||
/* Only inside callbacks */
|
||||
void IupMglPlotTransform(Ihandle* ih, double x, double y, double z, int *ix, int *iy);
|
||||
void IupMglPlotTransformTo(Ihandle* ih, int ix, int iy, double *x, double *y, double *z);
|
||||
|
||||
/* Only inside callbacks */
|
||||
void IupMglPlotDrawMark(Ihandle* ih, double x, double y, double z);
|
||||
void IupMglPlotDrawLine(Ihandle* ih, double x1, double y1, double z1, double x2, double y2, double z2);
|
||||
void IupMglPlotDrawText(Ihandle* ih, const char* text, double x, double y, double z);
|
||||
|
||||
void IupMglPlotPaintTo(Ihandle *ih, const char* format, int w, int h, double dpi, void *data);
|
||||
|
||||
/***********************************************/
|
||||
|
||||
/* Utility label for showing TeX labels */
|
||||
Ihandle* IupMglLabel(const char* title);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
/** \file
|
||||
* \brief Plot component for Iup.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUP_PLOT_H
|
||||
#define __IUP_PLOT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Initialize IupPlot widget class */
|
||||
void IupPlotOpen(void);
|
||||
|
||||
/* Create an IupPlot widget instance */
|
||||
Ihandle* IupPlot(void);
|
||||
|
||||
/***********************************************/
|
||||
/* Additional API */
|
||||
|
||||
void IupPlotBegin(Ihandle *ih, int strXdata);
|
||||
void IupPlotAdd(Ihandle *ih, double x, double y);
|
||||
void IupPlotAddStr(Ihandle *ih, const char* x, double y);
|
||||
void IupPlotAddSegment(Ihandle *ih, double x, double y);
|
||||
int IupPlotEnd(Ihandle *ih);
|
||||
|
||||
int IupPlotLoadData(Ihandle* ih, const char* filename, int strXdata);
|
||||
|
||||
/* available only when linking with "iupluaplot" */
|
||||
int IupPlotSetFormula(Ihandle* ih, int sample_count, const char* formula, const char* init);
|
||||
|
||||
void IupPlotInsert(Ihandle *ih, int ds_index, int sample_index, double x, double y);
|
||||
void IupPlotInsertStr(Ihandle *ih, int ds_index, int sample_index, const char* x, double y);
|
||||
void IupPlotInsertSegment(Ihandle *ih, int ds_index, int sample_index, double x, double y);
|
||||
|
||||
void IupPlotInsertStrSamples(Ihandle* ih, int ds_index, int sample_index, const char** x, double* y, int count);
|
||||
void IupPlotInsertSamples(Ihandle* ih, int ds_index, int sample_index, double *x, double *y, int count);
|
||||
|
||||
void IupPlotAddSamples(Ihandle* ih, int ds_index, double *x, double *y, int count);
|
||||
void IupPlotAddStrSamples(Ihandle* ih, int ds_index, const char** x, double* y, int count);
|
||||
|
||||
void IupPlotGetSample(Ihandle* ih, int ds_index, int sample_index, double *x, double *y);
|
||||
void IupPlotGetSampleStr(Ihandle* ih, int ds_index, int sample_index, const char* *x, double *y);
|
||||
int IupPlotGetSampleSelection(Ihandle* ih, int ds_index, int sample_index);
|
||||
double IupPlotGetSampleExtra(Ihandle* ih, int ds_index, int sample_index);
|
||||
void IupPlotSetSample(Ihandle* ih, int ds_index, int sample_index, double x, double y);
|
||||
void IupPlotSetSampleStr(Ihandle* ih, int ds_index, int sample_index, const char* x, double y);
|
||||
void IupPlotSetSampleSelection(Ihandle* ih, int ds_index, int sample_index, int selected);
|
||||
void IupPlotSetSampleExtra(Ihandle* ih, int ds_index, int sample_index, double extra);
|
||||
|
||||
void IupPlotTransform(Ihandle* ih, double x, double y, double *cnv_x, double *cnv_y);
|
||||
void IupPlotTransformTo(Ihandle* ih, double cnv_x, double cnv_y, double *x, double *y);
|
||||
|
||||
int IupPlotFindSample(Ihandle* ih, double cnv_x, double cnv_y, int *ds_index, int *sample_index);
|
||||
int IupPlotFindSegment(Ihandle* ih, double cnv_x, double cnv_y, int *ds_index, int *sample_index1, int *sample_index2);
|
||||
|
||||
struct _cdCanvas;
|
||||
|
||||
void IupPlotPaintTo(Ihandle *ih, struct _cdCanvas* cnv);
|
||||
|
||||
/***********************************************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
/** \file
|
||||
* \brief Scintilla control.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUP_SCINTILLA_H
|
||||
#define __IUP_SCINTILLA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
void IupScintillaOpen(void);
|
||||
|
||||
Ihandle *IupScintilla(void);
|
||||
Ihandle *IupScintillaDlg(void);
|
||||
|
||||
#ifdef SCINTILLA_H
|
||||
sptr_t IupScintillaSendMessage(Ihandle* ih, unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
/** \file
|
||||
* \brief IUP API with explicit variable argument parameters.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUP_VARG_H
|
||||
#define __IUP_VARG_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "iup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
IUP_API void IupLogV(const char* type, const char* format, va_list arglist);
|
||||
|
||||
IUP_API Ihandle* IupSetAttV(const char* handle_name, Ihandle* ih, const char* name, va_list arglist);
|
||||
|
||||
IUP_API void IupSetStrfV(Ihandle* ih, const char* name, const char* format, va_list arglist);
|
||||
IUP_API void IupSetStrfIdV(Ihandle* ih, const char* name, int id, const char* format, va_list arglist);
|
||||
IUP_API void IupSetStrfId2V(Ihandle* ih, const char* name, int lin, int col, const char* format, va_list arglist);
|
||||
|
||||
IUP_API Ihandle* IupSetCallbacksV(Ihandle* ih, const char *name, Icallback func, va_list arglist);
|
||||
|
||||
IUP_API Ihandle* IupCreateV(const char *classname, void* first, va_list arglist);
|
||||
IUP_API Ihandle* IupVboxV(Ihandle* child, va_list arglist);
|
||||
IUP_API Ihandle* IupZboxV(Ihandle* child, va_list arglist);
|
||||
IUP_API Ihandle* IupHboxV(Ihandle* child,va_list arglist);
|
||||
IUP_API Ihandle* IupNormalizerV(Ihandle* ih_first, va_list arglist);
|
||||
IUP_API Ihandle* IupCboxV(Ihandle* child, va_list arglist);
|
||||
IUP_API Ihandle* IupGridBoxV(Ihandle* child, va_list arglist);
|
||||
IUP_API Ihandle* IupMultiBoxV(Ihandle* child, va_list arglist);
|
||||
IUP_API Ihandle* IupMenuV(Ihandle* child,va_list arglist);
|
||||
IUP_API Ihandle* IupTabsV(Ihandle* child, va_list arglist);
|
||||
IUP_API Ihandle* IupFlatTabsV(Ihandle* child, va_list arglist);
|
||||
|
||||
IUP_API void IupMessageV(const char *title, const char *format, va_list arglist);
|
||||
IUP_API Ihandle* IupParamBoxV(Ihandle* param, va_list arglist);
|
||||
IUP_API int IupGetParamV(const char* title, Iparamcb action, void* user_data, const char* format, va_list arglist);
|
||||
|
||||
/* must include iupglcontrols before this file to enable this declaration */
|
||||
#ifdef __IUPGLCONTROLS_H
|
||||
#ifndef IUP_GLCONTROLS_API
|
||||
#define IUP_GLCONTROLS_API
|
||||
#endif
|
||||
IUP_GLCONTROLS_API Ihandle* IupGLCanvasBoxV(Ihandle* child, va_list arglist);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
/** \file
|
||||
* \brief Contains all function pointer typedefs.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPCBS_H
|
||||
#define __IUPCBS_H
|
||||
|
||||
struct _cdCanvas;
|
||||
|
||||
typedef int (*IFidle)(void); /* idle */
|
||||
typedef void (*IFentry)(void); /* entry */
|
||||
|
||||
typedef void (*IFi)(int); /* globalentermodal_cb, globalleavemodal_cb, */
|
||||
typedef void (*IFs)(char*); /* openurl_cb */
|
||||
typedef void (*IFii)(int, int); /* globalkeypress_cb */
|
||||
typedef void (*IFiis)(int, int, char*); /* globalmotion_cb, openfiles_cb */
|
||||
typedef void (*IFiiiis)(int, int, int, int, char*); /* globalbutton_cb */
|
||||
typedef void (*IFfiis)(float,int,int,char*); /* globalwheel_cb */
|
||||
typedef void (*IFvs)(void*, char*); /* handleadd_cb, handleremove_cb, imagecreate_cb, imagedestroy_cb */
|
||||
|
||||
typedef int (*IFn)(Ihandle*); /* default definition, same as Icallback */
|
||||
typedef int (*IFni)(Ihandle*, int); /* k_any, show_cb, toggle_action, spin_cb, branchopen_cb, branchclose_cb, executeleaf_cb, showrename_cb, rightclick_cb, extended_cb, height_cb, width_cb */
|
||||
typedef int (*IFnii)(Ihandle*, int, int); /* resize_cb, caret_cb, matrix_mousemove_cb, enteritem_cb, leaveitem_cb, scrolltop_cb, dropcheck_cb, selection_cb, select_cb, switch_cb, scrolling_cb, vspan_cb, hspan_cb */
|
||||
typedef int (*IFniii)(Ihandle*, int, int, int); /* trayclick_cb, edition_cb */
|
||||
typedef int (*IFniiii)(Ihandle*, int, int, int, int); /* dragdrop_cb */
|
||||
typedef int (*IFniiiiiiC)(Ihandle*, int, int, int, int, int, int, struct _cdCanvas*); /* draw_cb */
|
||||
typedef int (*IFniiiiii)(Ihandle*, int, int, int, int, int, int); /* OLD draw_cb */
|
||||
typedef int (*IFnsidv)(Ihandle*, char*, int, double, void*); /* postmessage_cb */
|
||||
|
||||
typedef int (*IFnff)(Ihandle*, float, float); /* canvas_action */
|
||||
typedef int (*IFniff)(Ihandle*,int,float,float); /* scroll_cb */
|
||||
typedef int (*IFnfiis)(Ihandle*,float,int,int,char*); /* wheel_cb */
|
||||
|
||||
typedef int (*IFnsVi)(Ihandle*, char*, void*, int); /* dragdata_cb */
|
||||
typedef int (*IFnsViii)(Ihandle*, char*, void*, int, int, int); /* dropdata_cb */
|
||||
typedef int (*IFnsiii)(Ihandle*, char*, int, int, int); /* dropfiles_cb */
|
||||
typedef int (*IFnssi)(Ihandle*, char*, char*, int); /* dragfilecreatename_cb */
|
||||
|
||||
typedef int (*IFnnii)(Ihandle*, Ihandle*, int, int); /* drop_cb */
|
||||
typedef int (*IFnn)(Ihandle*, Ihandle*); /* savemarkers_cb, restoremarkers_cb */
|
||||
typedef int (*IFnnn)(Ihandle*, Ihandle*, Ihandle*); /* tabchange_cb */
|
||||
typedef int (*IFnss)(Ihandle*, char *, char *); /* file_cb */
|
||||
typedef int (*IFns)(Ihandle*, char *); /* multiselect_cb */
|
||||
typedef int (*IFnsi)(Ihandle*, char *, int); /* copydata_cb */
|
||||
typedef int (*IFnis)(Ihandle*, int, char *); /* text_action, multiline_action, edit_cb, rename_cb */
|
||||
typedef int (*IFnsii)(Ihandle*, char*, int, int); /* list_action */
|
||||
typedef int (*IFniis)(Ihandle*, int, int, char*); /* motion_cb, click_cb, value_edit_cb */
|
||||
typedef int (*IFniiis)(Ihandle*, int, int, int, char*); /* touch_cb, dblclick_cb */
|
||||
typedef int (*IFniiiis)(Ihandle*, int, int, int, int, char*); /* button_cb, matrix_action, mousemotion_cb */
|
||||
typedef int (*IFniiiiiis)(Ihandle*, int, int, int, int, int, int, char*); /* mouseclick_cb */
|
||||
|
||||
typedef int (*IFnIi)(Ihandle*, int*, int); /* multiselection_cb, multiunselection_cb */
|
||||
typedef int (*IFnd)(Ihandle*, double); /* mousemove_cb, button_press_cb, button_release_cb */
|
||||
typedef int (*IFniiIII)(Ihandle*, int, int, int*, int*, int*); /* fgcolor_cb, bgcolor_cb */
|
||||
typedef int (*IFniinsii)(Ihandle*, int, int, Ihandle*, char*, int, int); /* dropselect_cb */
|
||||
typedef int (*IFnccc)(Ihandle*, unsigned char, unsigned char, unsigned char); /* drag_cb, change_cb */
|
||||
typedef int (*IFniIIII)(Ihandle*, int, int*, int*, int*, int*); /* multitouch_cb */
|
||||
|
||||
typedef int (*IFnC)(Ihandle*, struct _cdCanvas*); /* postdraw_cb, predraw_cb */
|
||||
typedef int (*IFniidd)(Ihandle*, int, int, double, double); /* delete_cb */
|
||||
typedef int (*IFniiddi)(Ihandle*, int, int, double, double, int); /* select_cb */
|
||||
typedef int (*IFniiddiddi)(Ihandle*, int, int, double, double, int, double, double, int); /* clicksegment_cb */
|
||||
typedef int (*IFniidds)(Ihandle*, int, int, double, double, char*); /* plotbutton_cb */
|
||||
typedef int (*IFndds)(Ihandle*, double, double, char*); /* plotmotion_cb */
|
||||
typedef int (*IFnssds)(Ihandle*, char*, char*, double, char*); /* plottickformat_cb */
|
||||
typedef int (*IFnni)(Ihandle*, Ihandle*, int);
|
||||
|
||||
typedef char* (*sIFnii)(Ihandle*, int, int); /* value_cb, font_cb */
|
||||
typedef char* (*sIFni)(Ihandle*, int); /* cell_cb */
|
||||
typedef char* (*sIFniis)(Ihandle*, int, int, char*); /* translatevalue_cb */
|
||||
|
||||
typedef double (*dIFnii)(Ihandle*, int, int); /* numericgetvalue_cb */
|
||||
typedef int (*IFniid)(Ihandle*, int, int, double); /* numericsetvalue_cb */
|
||||
|
||||
typedef void (*IFniiv)(Ihandle*, int, int, void*); /* android_onactivityresult_cb */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
/** \file
|
||||
* \brief initializes dial, gauge, colorbrowser, colorbar controls.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPCONTROLS_H
|
||||
#define __IUPCONTROLS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
int IupControlsOpen(void);
|
||||
|
||||
Ihandle* IupCells(void);
|
||||
Ihandle* IupMatrix(const char *action);
|
||||
Ihandle* IupMatrixList(void);
|
||||
Ihandle* IupMatrixEx(void);
|
||||
|
||||
/* available only when linking with "iupluamatrix" */
|
||||
void IupMatrixSetFormula(Ihandle* ih, int col, const char* formula, const char* init);
|
||||
void IupMatrixSetDynamic(Ihandle* ih, const char* init);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,683 @@
|
||||
/** \file
|
||||
* \brief Callbacks, Attributes and Attribute Values definitions.
|
||||
* Avoid using these definitions. Use the strings instead.
|
||||
*
|
||||
* See Copyright Notice in iup.h
|
||||
*/
|
||||
|
||||
#ifndef __IUPDEF_H
|
||||
#define __IUPDEF_H
|
||||
|
||||
/* ATTENTION: these are OLD definitions and they are NOT updated anymore since IUP 3.0 */
|
||||
/* Avoid using them, directly use the strings instead. */
|
||||
/* Define __IUPDEF_H to avoid the inclusion of this header */
|
||||
|
||||
#define IUP_RUN "RUN"
|
||||
#define IUP_ENGLISH "ENGLISH"
|
||||
#define IUP_PORTUGUESE "PORTUGUESE"
|
||||
#define IUP_SBH "SBH"
|
||||
#define IUP_SBV "SBV"
|
||||
|
||||
/************************************************************************/
|
||||
/* Callbacks */
|
||||
/************************************************************************/
|
||||
|
||||
#define IUP_IDLE_ACTION "IDLE_ACTION"
|
||||
|
||||
#define IUP_ACTION "ACTION"
|
||||
#define IUP_GETFOCUS_CB "GETFOCUS_CB"
|
||||
#define IUP_KILLFOCUS_CB "KILLFOCUS_CB"
|
||||
#define IUP_K_ANY "K_ANY"
|
||||
#define IUP_KEYPRESS_CB "KEYPRESS_CB"
|
||||
#define IUP_HELP_CB "HELP_CB"
|
||||
|
||||
#define IUP_SCROLL_CB "SCROLL_CB"
|
||||
#define IUP_RESIZE_CB "RESIZE_CB"
|
||||
#define IUP_MOTION_CB "MOTION_CB"
|
||||
#define IUP_BUTTON_CB "BUTTON_CB"
|
||||
#define IUP_ENTERWINDOW_CB "ENTERWINDOW_CB"
|
||||
#define IUP_LEAVEWINDOW_CB "LEAVEWINDOW_CB"
|
||||
#define IUP_WHEEL_CB "WHEEL_CB"
|
||||
|
||||
#define IUP_MASK_CB "MASK_CB"
|
||||
#define IUP_OPEN_CB "OPEN_CB"
|
||||
#define IUP_HIGHLIGHT_CB "HIGHLIGHT_CB"
|
||||
#define IUP_MENUCLOSE_CB "MENUCLOSE_CB"
|
||||
|
||||
#define IUP_MAP_CB "MAP_CB"
|
||||
#define IUP_CLOSE_CB "CLOSE_CB"
|
||||
#define IUP_SHOW_CB "SHOW_CB"
|
||||
|
||||
#define IUP_DROPFILES_CB "DROPFILES_CB"
|
||||
#define IUP_WOM_CB "WOM_CB"
|
||||
|
||||
/************************************************************************/
|
||||
/* Attributes */
|
||||
/************************************************************************/
|
||||
|
||||
#define IUP_DIRECTION "DIRECTION"
|
||||
#define IUP_ACTIVE "ACTIVE"
|
||||
#define IUP_BGCOLOR "BGCOLOR"
|
||||
#define IUP_FRAMECOLOR "FRAMECOLOR"
|
||||
#define IUP_FGCOLOR "FGCOLOR"
|
||||
#define IUP_COLOR "COLOR"
|
||||
#define IUP_WID "WID"
|
||||
#define IUP_SIZE "SIZE"
|
||||
#define IUP_RASTERSIZE "RASTERSIZE"
|
||||
#define IUP_TITLE "TITLE"
|
||||
#define IUP_VALUE "VALUE"
|
||||
#define IUP_VISIBLE "VISIBLE"
|
||||
#define IUP_FONT "FONT"
|
||||
#define IUP_TIP "TIP"
|
||||
#define IUP_EXPAND "EXPAND"
|
||||
#define IUP_SEPARATOR "SEPARATOR"
|
||||
|
||||
#define IUP_HOTSPOT "HOTSPOT"
|
||||
#define IUP_HEIGHT "HEIGHT"
|
||||
#define IUP_WIDTH "WIDTH"
|
||||
|
||||
#define IUP_KEY "KEY"
|
||||
|
||||
#define IUP_MULTIPLE "MULTIPLE"
|
||||
#define IUP_DROPDOWN "DROPDOWN"
|
||||
#define IUP_VISIBLE_ITEMS "VISIBLE_ITEMS"
|
||||
|
||||
#define IUP_MARGIN "MARGIN"
|
||||
#define IUP_GAP "GAP"
|
||||
#define IUP_ALIGNMENT "ALIGNMENT"
|
||||
|
||||
#define IUP_IMAGE "IMAGE"
|
||||
#define IUP_IMINACTIVE "IMINACTIVE"
|
||||
#define IUP_IMPRESS "IMPRESS"
|
||||
#define IUP_WIN_SAVEBITS "WIN_SAVEBITS"
|
||||
|
||||
#define IUP_NC "NC"
|
||||
#define IUP_MASK "MASK"
|
||||
|
||||
#define IUP_APPEND "APPEND"
|
||||
#define IUP_BORDER "BORDER"
|
||||
|
||||
#define IUP_CARET "CARET"
|
||||
#define IUP_SELECTION "SELECTION"
|
||||
#define IUP_SELECTEDTEXT "SELECTEDTEXT"
|
||||
#define IUP_INSERT "INSERT"
|
||||
|
||||
#define IUP_CONID "CONID"
|
||||
#define IUP_CURSOR "CURSOR"
|
||||
|
||||
#define IUP_ICON "ICON"
|
||||
#define IUP_MENUBOX "MENUBOX"
|
||||
#define IUP_MINBOX "MINBOX"
|
||||
#define IUP_MAXBOX "MAXBOX"
|
||||
#define IUP_RESIZE "RESIZE"
|
||||
#define IUP_MENU "MENU"
|
||||
#define IUP_STARTFOCUS "STARTFOCUS"
|
||||
#define IUP_PARENTDIALOG "PARENTDIALOG"
|
||||
#define IUP_SHRINK "SHRINK"
|
||||
#define IUP_DEFAULTENTER "DEFAULTENTER"
|
||||
#define IUP_DEFAULTESC "DEFAULTESC"
|
||||
#define IUP_X "X"
|
||||
#define IUP_Y "Y"
|
||||
#define IUP_TOOLBOX "TOOLBOX"
|
||||
#define IUP_CONTROL "CONTROL"
|
||||
#define IUP_READONLY "READONLY"
|
||||
|
||||
#define IUP_SCROLLBAR "SCROLLBAR"
|
||||
#define IUP_POSY "POSY"
|
||||
#define IUP_POSX "POSX"
|
||||
#define IUP_DX "DX"
|
||||
#define IUP_DY "DY"
|
||||
#define IUP_XMAX "XMAX"
|
||||
#define IUP_XMIN "XMIN"
|
||||
#define IUP_YMAX "YMAX"
|
||||
#define IUP_YMIN "YMIN"
|
||||
|
||||
#define IUP_RED "255 0 0"
|
||||
#define IUP_GREEN "0 255 0"
|
||||
#define IUP_BLUE "0 0 255"
|
||||
|
||||
#define IUP_MIN "MIN"
|
||||
#define IUP_MAX "MAX"
|
||||
|
||||
#define IUP_TIME "TIME"
|
||||
#define IUP_DRAG "DRAG"
|
||||
#define IUP_DROP "DROP"
|
||||
#define IUP_REPAINT "REPAINT"
|
||||
#define IUP_TOPMOST "TOPMOST"
|
||||
#define IUP_CLIPCHILDREN "CLIPCHILDREN"
|
||||
|
||||
#define IUP_DIALOGTYPE "DIALOGTYPE"
|
||||
#define IUP_FILE "FILE"
|
||||
#define IUP_MULTIPLEFILES "MULTIPLEFILES"
|
||||
#define IUP_FILTER "FILTER"
|
||||
#define IUP_FILTERUSED "FILTERUSED"
|
||||
#define IUP_FILTERINFO "FILTERINFO"
|
||||
#define IUP_EXTFILTER "EXTFILTER"
|
||||
#define IUP_DIRECTORY "DIRECTORY"
|
||||
#define IUP_ALLOWNEW "ALLOWNEW"
|
||||
#define IUP_NOOVERWRITEPROMPT "NOOVERWRITEPROMPT"
|
||||
#define IUP_NOCHANGEDIR "NOCHANGEDIR"
|
||||
#define IUP_FILEEXIST "FILEEXIST"
|
||||
#define IUP_STATUS "STATUS"
|
||||
|
||||
#define IUP_LOCKLOOP "LOCKLOOP"
|
||||
#define IUP_SYSTEM "SYSTEM"
|
||||
#define IUP_DRIVER "DRIVER"
|
||||
#define IUP_SCREENSIZE "SCREENSIZE"
|
||||
#define IUP_SYSTEMLANGUAGE "SYSTEMLANGUAGE"
|
||||
#define IUP_COMPUTERNAME "COMPUTERNAME"
|
||||
#define IUP_USERNAME "USERNAME"
|
||||
|
||||
#define IUP_OPEN "OPEN"
|
||||
#define IUP_SAVE "SAVE"
|
||||
#define IUP_DIR "DIR"
|
||||
|
||||
#define IUP_HORIZONTAL "HORIZONTAL"
|
||||
#define IUP_VERTICAL "VERTICAL"
|
||||
|
||||
/************************************************************************/
|
||||
/* Attribute Values */
|
||||
/************************************************************************/
|
||||
|
||||
#define IUP_YES "YES"
|
||||
#define IUP_NO "NO"
|
||||
#define IUP_ON "ON"
|
||||
#define IUP_OFF "OFF"
|
||||
|
||||
#define IUP_ACENTER "ACENTER"
|
||||
#define IUP_ALEFT "ALEFT"
|
||||
#define IUP_ARIGHT "ARIGHT"
|
||||
#define IUP_ATOP "ATOP"
|
||||
#define IUP_ABOTTOM "ABOTTOM"
|
||||
|
||||
#define IUP_NORTH "NORTH"
|
||||
#define IUP_SOUTH "SOUTH"
|
||||
#define IUP_WEST "WEST"
|
||||
#define IUP_EAST "EAST"
|
||||
#define IUP_NE "NE"
|
||||
#define IUP_SE "SE"
|
||||
#define IUP_NW "NW"
|
||||
#define IUP_SW "SW"
|
||||
|
||||
#define IUP_FULLSCREEN "FULLSCREEN"
|
||||
#define IUP_FULL "FULL"
|
||||
#define IUP_HALF "HALF"
|
||||
#define IUP_THIRD "THIRD"
|
||||
#define IUP_QUARTER "QUARTER"
|
||||
#define IUP_EIGHTH "EIGHTH"
|
||||
|
||||
#define IUP_ARROW "ARROW"
|
||||
#define IUP_BUSY "BUSY"
|
||||
#define IUP_RESIZE_N "RESIZE_N"
|
||||
#define IUP_RESIZE_S "RESIZE_S"
|
||||
#define IUP_RESIZE_E "RESIZE_E"
|
||||
#define IUP_RESIZE_W "RESIZE_W"
|
||||
#define IUP_RESIZE_NE "RESIZE_NE"
|
||||
#define IUP_RESIZE_NW "RESIZE_NW"
|
||||
#define IUP_RESIZE_SE "RESIZE_SE"
|
||||
#define IUP_RESIZE_SW "RESIZE_SW"
|
||||
#define IUP_MOVE "MOVE"
|
||||
#define IUP_HAND "HAND"
|
||||
#define IUP_NONE "NONE"
|
||||
#define IUP_IUP "IUP"
|
||||
#define IUP_CROSS "CROSS"
|
||||
#define IUP_PEN "PEN"
|
||||
#define IUP_TEXT "TEXT"
|
||||
#define IUP_RESIZE_C "RESIZE_C"
|
||||
#define IUP_OPENHAND "OPENHAND"
|
||||
|
||||
/************************************************************************/
|
||||
/* Keys */
|
||||
/************************************************************************/
|
||||
|
||||
#define IUP_K_exclam "K_exclam"
|
||||
#define IUP_K_quotedbl "K_quotedbl"
|
||||
#define IUP_K_numbersign "K_numbersign"
|
||||
#define IUP_K_dollar "K_dollar"
|
||||
#define IUP_K_percent "K_percent"
|
||||
#define IUP_K_ampersand "K_ampersand"
|
||||
#define IUP_K_quoteright "K_quoteright"
|
||||
#define IUP_K_parentleft "K_parentleft"
|
||||
#define IUP_K_parentright "K_parentright"
|
||||
#define IUP_K_asterisk "K_asterisk"
|
||||
#define IUP_K_plus "K_plus"
|
||||
#define IUP_K_comma "K_comma"
|
||||
#define IUP_K_minus "K_minus"
|
||||
#define IUP_K_period "K_period"
|
||||
#define IUP_K_slash "K_slash"
|
||||
#define IUP_K_0 "K_0"
|
||||
#define IUP_K_1 "K_1"
|
||||
#define IUP_K_2 "K_2"
|
||||
#define IUP_K_3 "K_3"
|
||||
#define IUP_K_4 "K_4"
|
||||
#define IUP_K_5 "K_5"
|
||||
#define IUP_K_6 "K_6"
|
||||
#define IUP_K_7 "K_7"
|
||||
#define IUP_K_8 "K_8"
|
||||
#define IUP_K_9 "K_9"
|
||||
#define IUP_K_colon "K_colon"
|
||||
#define IUP_K_semicolon "K_semicolon "
|
||||
#define IUP_K_less "K_less"
|
||||
#define IUP_K_equal "K_equal"
|
||||
#define IUP_K_greater "K_greater"
|
||||
#define IUP_K_question "K_question"
|
||||
#define IUP_K_at "K_at"
|
||||
#define IUP_K_A "K_A"
|
||||
#define IUP_K_B "K_B"
|
||||
#define IUP_K_C "K_C"
|
||||
#define IUP_K_D "K_D"
|
||||
#define IUP_K_E "K_E"
|
||||
#define IUP_K_F "K_F"
|
||||
#define IUP_K_G "K_G"
|
||||
#define IUP_K_H "K_H"
|
||||
#define IUP_K_I "K_I"
|
||||
#define IUP_K_J "K_J"
|
||||
#define IUP_K_K "K_K"
|
||||
#define IUP_K_L "K_L"
|
||||
#define IUP_K_M "K_M"
|
||||
#define IUP_K_N "K_N"
|
||||
#define IUP_K_O "K_O"
|
||||
#define IUP_K_P "K_P"
|
||||
#define IUP_K_Q "K_Q"
|
||||
#define IUP_K_R "K_R"
|
||||
#define IUP_K_S "K_S"
|
||||
#define IUP_K_T "K_T"
|
||||
#define IUP_K_U "K_U"
|
||||
#define IUP_K_V "K_V"
|
||||
#define IUP_K_W "K_W"
|
||||
#define IUP_K_X "K_X"
|
||||
#define IUP_K_Y "K_Y"
|
||||
#define IUP_K_Z "K_Z"
|
||||
#define IUP_K_bracketleft "K_bracketleft"
|
||||
#define IUP_K_backslash "K_backslash"
|
||||
#define IUP_K_bracketright "K_bracketright"
|
||||
#define IUP_K_circum "K_circum"
|
||||
#define IUP_K_underscore "K_underscore"
|
||||
#define IUP_K_quoteleft "K_quoteleft"
|
||||
#define IUP_K_a "K_a"
|
||||
#define IUP_K_b "K_b"
|
||||
#define IUP_K_c "K_c"
|
||||
#define IUP_K_d "K_d"
|
||||
#define IUP_K_e "K_e"
|
||||
#define IUP_K_f "K_f"
|
||||
#define IUP_K_g "K_g"
|
||||
#define IUP_K_h "K_h"
|
||||
#define IUP_K_i "K_i"
|
||||
#define IUP_K_j "K_j"
|
||||
#define IUP_K_k "K_k"
|
||||
#define IUP_K_l "K_l"
|
||||
#define IUP_K_m "K_m"
|
||||
#define IUP_K_n "K_n"
|
||||
#define IUP_K_o "K_o"
|
||||
#define IUP_K_p "K_p"
|
||||
#define IUP_K_q "K_q"
|
||||
#define IUP_K_r "K_r"
|
||||
#define IUP_K_s "K_s"
|
||||
#define IUP_K_t "K_t"
|
||||
#define IUP_K_u "K_u"
|
||||
#define IUP_K_v "K_v"
|
||||
#define IUP_K_w "K_w"
|
||||
#define IUP_K_x "K_x"
|
||||
#define IUP_K_y "K_y"
|
||||
#define IUP_K_z "K_z"
|
||||
#define IUP_K_braceleft "K_braceleft"
|
||||
#define IUP_K_bar "K_bar"
|
||||
#define IUP_K_braceright "K_braceright"
|
||||
#define IUP_K_tilde "K_tilde"
|
||||
|
||||
#define IUP_K_cA "K_cA"
|
||||
#define IUP_K_cB "K_cB"
|
||||
#define IUP_K_cC "K_cC"
|
||||
#define IUP_K_cD "K_cD"
|
||||
#define IUP_K_cE "K_cE"
|
||||
#define IUP_K_cF "K_cF"
|
||||
#define IUP_K_cG "K_cG"
|
||||
#define IUP_K_cJ "K_cJ"
|
||||
#define IUP_K_cK "K_cK"
|
||||
#define IUP_K_cL "K_cL"
|
||||
#define IUP_K_cN "K_cN"
|
||||
#define IUP_K_cO "K_cO"
|
||||
#define IUP_K_cP "K_cP"
|
||||
#define IUP_K_cQ "K_cQ"
|
||||
#define IUP_K_cR "K_cR"
|
||||
#define IUP_K_cS "K_cS"
|
||||
#define IUP_K_cT "K_cT"
|
||||
#define IUP_K_cU "K_cU"
|
||||
#define IUP_K_cV "K_cV"
|
||||
#define IUP_K_cW "K_cW"
|
||||
#define IUP_K_cX "K_cX"
|
||||
#define IUP_K_cY "K_cY"
|
||||
#define IUP_K_cZ "K_cZ"
|
||||
#define IUP_K_mA "K_mA"
|
||||
#define IUP_K_mB "K_mB"
|
||||
#define IUP_K_mC "K_mC"
|
||||
#define IUP_K_mD "K_mD"
|
||||
#define IUP_K_mE "K_mE"
|
||||
#define IUP_K_mF "K_mF"
|
||||
#define IUP_K_mG "K_mG"
|
||||
#define IUP_K_mH "K_mH"
|
||||
#define IUP_K_mI "K_mI"
|
||||
#define IUP_K_mJ "K_mJ"
|
||||
#define IUP_K_mK "K_mK"
|
||||
#define IUP_K_mL "K_mL"
|
||||
#define IUP_K_mM "K_mM"
|
||||
#define IUP_K_mN "K_mN"
|
||||
#define IUP_K_mO "K_mO"
|
||||
#define IUP_K_mP "K_mP"
|
||||
#define IUP_K_mQ "K_mQ"
|
||||
#define IUP_K_mR "K_mR"
|
||||
#define IUP_K_mS "K_mS"
|
||||
#define IUP_K_mT "K_mT"
|
||||
#define IUP_K_mU "K_mU"
|
||||
#define IUP_K_mV "K_mV"
|
||||
#define IUP_K_mW "K_mW"
|
||||
#define IUP_K_mX "K_mX"
|
||||
#define IUP_K_mY "K_mY"
|
||||
#define IUP_K_mZ "K_mZ"
|
||||
#define IUP_K_BS "K_BS"
|
||||
#define IUP_K_TAB "K_TAB"
|
||||
#define IUP_K_CR "K_CR"
|
||||
#define IUP_K_SP "K_SP"
|
||||
#define IUP_K_ESC "K_ESC"
|
||||
#define IUP_K_sCR "K_sCR"
|
||||
#define IUP_K_sTAB "K_sTAB"
|
||||
#define IUP_K_cTAB "K_cTAB"
|
||||
#define IUP_K_mTAB "K_mTAB"
|
||||
#define IUP_K_HOME "K_HOME"
|
||||
#define IUP_K_UP "K_UP"
|
||||
#define IUP_K_PGUP "K_PGUP"
|
||||
#define IUP_K_LEFT "K_LEFT"
|
||||
#define IUP_K_RIGHT "K_RIGHT"
|
||||
#define IUP_K_END "K_END"
|
||||
#define IUP_K_DOWN "K_DOWN"
|
||||
#define IUP_K_PGDN "K_PGDN"
|
||||
#define IUP_K_MIDDLE "K_MIDDLE"
|
||||
#define IUP_K_INS "K_INS"
|
||||
#define IUP_K_DEL "K_DEL"
|
||||
#define IUP_K_sHOME "K_sHOME"
|
||||
#define IUP_K_sUP "K_sUP"
|
||||
#define IUP_K_sPGUP "K_sPGUP"
|
||||
#define IUP_K_sLEFT "K_sLEFT"
|
||||
#define IUP_K_sRIGHT "K_sRIGHT"
|
||||
#define IUP_K_sEND "K_sEND"
|
||||
#define IUP_K_sDOWN "K_sDOWN"
|
||||
#define IUP_K_sPGDN "K_sPGDN"
|
||||
#define IUP_K_cHOME "K_cHOME"
|
||||
#define IUP_K_cPGUP "K_cPGUP"
|
||||
#define IUP_K_cLEFT "K_cLEFT"
|
||||
#define IUP_K_cRIGHT "K_cRIGHT"
|
||||
#define IUP_K_cEND "K_cEND"
|
||||
#define IUP_K_cPGDN "K_cPGDN"
|
||||
#define IUP_K_cUP "K_cUP"
|
||||
#define IUP_K_cDOWN "K_cDOWN"
|
||||
#define IUP_K_cMIDDLE "K_cMIDDLE"
|
||||
#define IUP_K_cINS "K_cINS"
|
||||
#define IUP_K_cDEL "K_cDEL"
|
||||
#define IUP_K_mHOME "K_mHOME"
|
||||
#define IUP_K_mPGUP "K_mPGUP"
|
||||
#define IUP_K_mLEFT "K_mLEFT"
|
||||
#define IUP_K_mRIGHT "K_mRIGHT"
|
||||
#define IUP_K_mEND "K_mEND"
|
||||
#define IUP_K_mPGDN "K_mPGDN"
|
||||
#define IUP_K_mUP "K_mUP"
|
||||
#define IUP_K_mDOWN "K_mDOWN"
|
||||
#define IUP_K_mINS "K_mINS"
|
||||
#define IUP_K_mDEL "K_mDEL"
|
||||
#define IUP_K_F1 "K_F1"
|
||||
#define IUP_K_F2 "K_F2"
|
||||
#define IUP_K_F3 "K_F3"
|
||||
#define IUP_K_F4 "K_F4"
|
||||
#define IUP_K_F5 "K_F5"
|
||||
#define IUP_K_F6 "K_F6"
|
||||
#define IUP_K_F7 "K_F7"
|
||||
#define IUP_K_F8 "K_F8"
|
||||
#define IUP_K_F9 "K_F9"
|
||||
#define IUP_K_F10 "K_F10"
|
||||
#define IUP_K_F11 "K_F11"
|
||||
#define IUP_K_F12 "K_F12"
|
||||
#define IUP_K_sF1 "K_sF1"
|
||||
#define IUP_K_sF2 "K_sF2"
|
||||
#define IUP_K_sF3 "K_sF3"
|
||||
#define IUP_K_sF4 "K_sF4"
|
||||
#define IUP_K_sF5 "K_sF5"
|
||||
#define IUP_K_sF6 "K_sF6"
|
||||
#define IUP_K_sF7 "K_sF7"
|
||||
#define IUP_K_sF8 "K_sF8"
|
||||
#define IUP_K_sF9 "K_sF9"
|
||||
#define IUP_K_sF10 "K_sF10"
|
||||
#define IUP_K_sF11 "K_sF11"
|
||||
#define IUP_K_sF12 "K_sF12"
|
||||
#define IUP_K_cF1 "K_cF1"
|
||||
#define IUP_K_cF2 "K_cF2"
|
||||
#define IUP_K_cF3 "K_cF3"
|
||||
#define IUP_K_cF4 "K_cF4"
|
||||
#define IUP_K_cF5 "K_cF5"
|
||||
#define IUP_K_cF6 "K_cF6"
|
||||
#define IUP_K_cF7 "K_cF7"
|
||||
#define IUP_K_cF8 "K_cF8"
|
||||
#define IUP_K_cF9 "K_cF9"
|
||||
#define IUP_K_cF10 "K_cF10"
|
||||
#define IUP_K_cF11 "K_cF11"
|
||||
#define IUP_K_cF12 "K_cF12"
|
||||
#define IUP_K_mF1 "K_mF1"
|
||||
#define IUP_K_mF2 "K_mF2"
|
||||
#define IUP_K_mF3 "K_mF3"
|
||||
#define IUP_K_mF4 "K_mF4"
|
||||
#define IUP_K_mF5 "K_mF5"
|
||||
#define IUP_K_mF6 "K_mF6"
|
||||
#define IUP_K_mF7 "K_mF7"
|
||||
#define IUP_K_mF8 "K_mF8"
|
||||
#define IUP_K_mF9 "K_mF9"
|
||||
#define IUP_K_mF10 "K_mF10"
|
||||
#define IUP_K_m1 "K_m1"
|
||||
#define IUP_K_m2 "K_m2"
|
||||
#define IUP_K_m3 "K_m3"
|
||||
#define IUP_K_m4 "K_m4"
|
||||
#define IUP_K_m5 "K_m5"
|
||||
#define IUP_K_m6 "K_m6"
|
||||
#define IUP_K_m7 "K_m7"
|
||||
#define IUP_K_m8 "K_m8"
|
||||
#define IUP_K_m9 "K_m9"
|
||||
#define IUP_K_m0 "K_m0"
|
||||
|
||||
/************/
|
||||
/* Colorbar */
|
||||
/************/
|
||||
|
||||
#define IUP_NUM_PARTS "NUM_PARTS"
|
||||
#define IUP_NUM_CELLS "NUM_CELLS"
|
||||
#define IUP_CELL "CELL"
|
||||
#define IUP_PREVIEW_SIZE "PREVIEW_SIZE"
|
||||
#define IUP_SHOW_PREVIEW "SHOW_PREVIEW"
|
||||
#define IUP_SHOW_SECONDARY "SHOW_SECONDARY"
|
||||
#define IUP_PRIMARY_CELL "PRIMARY_CELL"
|
||||
#define IUP_SECONDARY_CELL "SECONDARY_CELL"
|
||||
#define IUP_ORIENTATION "ORIENTATION"
|
||||
#define IUP_SQUARED "SQUARED"
|
||||
#define IUP_SHADOWED "SHADOWED"
|
||||
#define IUP_BUFFERIZE "BUFFERIZE"
|
||||
#define IUP_TRANSPARENCY "TRANSPARENCY"
|
||||
#define IUP_CELL_CB "CELL_CB"
|
||||
#define IUP_EXTENDED_CB "EXTENDED_CB"
|
||||
#define IUP_SELECT_CB "SELECT_CB"
|
||||
#define IUP_SWITCH_CB "SWITCH_CB"
|
||||
#define IUP_VERTICAL "VERTICAL"
|
||||
#define IUP_HORIZONTAL "HORIZONTAL"
|
||||
|
||||
/************/
|
||||
/* Cells */
|
||||
/************/
|
||||
|
||||
#define IUP_ALL "ALL"
|
||||
#define IUP_BOXED "BOXED"
|
||||
#define IUP_CLIPPED "CLIPPED"
|
||||
#define IUP_TRANSPARENT "TRANSPARENT"
|
||||
#define IUP_NON_SCROLLABLE_LINES "NON_SCROLLABLE_LINES"
|
||||
#define IUP_NON_SCROLLABLE_COLS "NON_SCROLLABLE_COLS"
|
||||
#define IUP_ORIGIN "ORIGIN"
|
||||
#define IUP_NO_COLOR "NO_COLOR"
|
||||
#define IUP_FIRST_LINE "FIRST_LINE"
|
||||
#define IUP_FIRST_COL "FIRST_COL"
|
||||
#define IUP_DOUBLE_BUFFER "DOUBLE_BUFFER"
|
||||
#define IUP_LIMITS "LIMITS"
|
||||
#define IUP_CANVAS "CANVAS"
|
||||
#define IUP_IMAGE_CANVAS "IMAGE_CANVAS"
|
||||
#define IUP_FULL_VISIBLE "FULL_VISIBLE"
|
||||
#define IUP_MOUSECLICK_CB "MOUSECLICK_CB"
|
||||
#define IUP_MOUSEMOTION_CB "MOUSEMOTION_CB"
|
||||
#define IUP_DRAW_CB "DRAW_CB"
|
||||
#define IUP_WIDTH_CB "WIDTH_CB"
|
||||
#define IUP_HEIGHT_CB "HEIGHT_CB"
|
||||
#define IUP_NLINES_CB "NLINES_CB"
|
||||
#define IUP_NCOLS_CB "NCOLS_CB"
|
||||
#define IUP_HSPAN_CB "HSPAN_CB"
|
||||
#define IUP_VSPAN_CB "VSPAN_CB"
|
||||
#define IUP_SCROLLING_CB "SCROLLING_CB"
|
||||
|
||||
/*****************/
|
||||
/* ColorBrowser */
|
||||
/*****************/
|
||||
|
||||
#define IUP_RGB "RGB"
|
||||
#define IUP_CHANGE_CB "CHANGE_CB"
|
||||
#define IUP_DRAG_CB "DRAG_CB"
|
||||
|
||||
/*****************/
|
||||
/* Val */
|
||||
/*****************/
|
||||
|
||||
#define ICTL_MOUSEMOVE_CB "MOUSEMOVE_CB"
|
||||
#define ICTL_BUTTON_PRESS_CB "BUTTON_PRESS_CB"
|
||||
#define ICTL_BUTTON_RELEASE_CB "BUTTON_RELEASE_CB"
|
||||
#define ICTL_HORIZONTAL "HORIZONTAL"
|
||||
#define ICTL_VERTICAL "VERTICAL"
|
||||
#define ICTL_SHOWTICKS "SHOWTICKS"
|
||||
|
||||
/*****************/
|
||||
/* Tabs */
|
||||
/*****************/
|
||||
|
||||
#define ICTL_TOP "TOP"
|
||||
#define ICTL_BOTTOM "BOTTOM"
|
||||
#define ICTL_LEFT "LEFT"
|
||||
#define ICTL_RIGHT "RIGHT"
|
||||
#define ICTL_TABTYPE "TABTYPE"
|
||||
#define ICTL_TABTITLE "TABTITLE"
|
||||
#define ICTL_TABSIZE "TABSIZE"
|
||||
#define ICTL_TABCHANGE_CB "TABCHANGE_CB"
|
||||
#define ICTL_FONT "FONT"
|
||||
#define ICTL_FONT_ACTIVE "FONT_ACTIVE"
|
||||
#define ICTL_FONT_INACTIVE "FONT_INACTIVE"
|
||||
|
||||
/*****************/
|
||||
/* Gauge */
|
||||
/*****************/
|
||||
|
||||
#define ICTL_SHOW_TEXT "SHOW_TEXT"
|
||||
#define ICTL_DASHED "DASHED"
|
||||
#define ICTL_MARGIN "MARGIN"
|
||||
#define ICTL_TEXT "TEXT"
|
||||
|
||||
/*****************/
|
||||
/* Dial */
|
||||
/*****************/
|
||||
|
||||
#define ICTL_DENSITY "DENSITY"
|
||||
#define ICTL_HORIZONTAL "HORIZONTAL"
|
||||
#define ICTL_VERTICAL "VERTICAL"
|
||||
#define ICTL_CIRCULAR "CIRCULAR"
|
||||
#define ICTL_UNIT "UNIT"
|
||||
|
||||
/*****************/
|
||||
/* Matrix */
|
||||
/*****************/
|
||||
|
||||
#define IUP_ENTERITEM_CB "ENTERITEM_CB"
|
||||
#define IUP_LEAVEITEM_CB "LEAVEITEM_CB"
|
||||
#define IUP_EDITION_CB "EDITION_CB"
|
||||
#define IUP_CLICK_CB "CLICK_CB"
|
||||
#define IUP_DROP_CB "DROP_CB"
|
||||
#define IUP_DROPSELECT_CB "DROPSELECT_CB"
|
||||
#define IUP_DROPCHECK_CB "DROPCHECK_CB"
|
||||
#define IUP_SCROLL_CB "SCROLL_CB"
|
||||
#define IUP_VALUE_CB "VALUE_CB"
|
||||
#define IUP_VALUE_EDIT_CB "VALUE_EDIT_CB"
|
||||
#define IUP_FIELD_CB "FIELD_CB"
|
||||
#define IUP_RESIZEMATRIX "RESIZEMATRIX"
|
||||
#define IUP_ADDLIN "ADDLIN"
|
||||
#define IUP_ADDCOL "ADDCOL"
|
||||
#define IUP_DELLIN "DELLIN"
|
||||
#define IUP_DELCOL "DELCOL"
|
||||
#define IUP_NUMLIN "NUMLIN"
|
||||
#define IUP_NUMCOL "NUMCOL"
|
||||
#define IUP_NUMLIN_VISIBLE "NUMLIN_VISIBLE"
|
||||
#define IUP_NUMCOL_VISIBLE "NUMCOL_VISIBLE"
|
||||
#define IUP_MARKED "MARKED"
|
||||
#define IUP_WIDTHDEF "WIDTHDEF"
|
||||
#define IUP_HEIGHTDEF "HEIGHTDEF"
|
||||
#define IUP_AREA "AREA"
|
||||
#define IUP_MARK_MODE "MARK_MODE"
|
||||
#define IUP_LIN "LIN"
|
||||
#define IUP_COL "COL"
|
||||
#define IUP_LINCOL "LINCOL"
|
||||
#define IUP_CELL "CELL"
|
||||
#define IUP_EDIT_MODE "EDIT_MODE"
|
||||
#define IUP_FOCUS_CELL "FOCUS_CELL"
|
||||
#define IUP_ORIGIN "ORIGIN"
|
||||
#define IUP_REDRAW "REDRAW"
|
||||
#define IUP_PREVIOUSVALUE "PREVIOUSVALUE"
|
||||
#define IUP_MOUSEMOVE_CB "MOUSEMOVE_CB"
|
||||
|
||||
/*****************/
|
||||
/* Tree */
|
||||
/*****************/
|
||||
|
||||
#define IUP_ADDLEAF "ADDLEAF"
|
||||
#define IUP_ADDBRANCH "ADDBRANCH"
|
||||
#define IUP_DELNODE "DELNODE"
|
||||
#define IUP_IMAGELEAF "IMAGELEAF"
|
||||
#define IUP_IMAGEBRANCHCOLLAPSED "IMAGEBRANCHCOLLAPSED"
|
||||
#define IUP_IMAGEBRANCHEXPANDED "IMAGEBRANCHEXPANDED"
|
||||
#define IUP_IMAGEEXPANDED "IMAGEEXPANDED"
|
||||
#define IUP_KIND "KIND"
|
||||
#define IUP_PARENT "PARENT"
|
||||
#define IUP_DEPTH "DEPTH"
|
||||
#define IUP_MARKED "MARKED"
|
||||
#define IUP_ADDEXPANDED "ADDEXPANDED"
|
||||
#define IUP_CTRL "CTRL"
|
||||
#define IUP_SHIFT "SHIFT"
|
||||
#define IUP_STATE "STATE"
|
||||
#define IUP_STARTING "STARTING"
|
||||
#define IUP_LEAF "LEAF"
|
||||
#define IUP_BRANCH "BRANCH"
|
||||
#define IUP_SELECTED "SELECTED"
|
||||
#define IUP_CHILDREN "CHILDREN"
|
||||
#define IUP_MARKED "MARKED"
|
||||
#define IUP_ROOT "ROOT"
|
||||
#define IUP_LAST "LAST"
|
||||
#define IUP_PGUP "PGUP"
|
||||
#define IUP_PGDN "PGDN"
|
||||
#define IUP_NEXT "NEXT"
|
||||
#define IUP_PREVIOUS "PREVIOUS"
|
||||
#define IUP_INVERT "INVERT"
|
||||
#define IUP_BLOCK "BLOCK"
|
||||
#define IUP_CLEARALL "CLEARALL"
|
||||
#define IUP_MARKALL "MARKALL"
|
||||
#define IUP_INVERTALL "INVERTALL"
|
||||
#define IUP_REDRAW "REDRAW"
|
||||
#define IUP_COLLAPSED "COLLAPSED"
|
||||
#define IUP_EXPANDED "EXPANDED"
|
||||
#define IUP_SELECTION_CB "SELECTION_CB"
|
||||
#define IUP_BRANCHOPEN_CB "BRANCHOPEN_CB"
|
||||
#define IUP_BRANCHCLOSE_CB "BRANCHCLOSE_CB"
|
||||
#define IUP_RIGHTCLICK_CB "RIGHTCLICK_CB"
|
||||
#define IUP_EXECUTELEAF_CB "EXECUTELEAF_CB"
|
||||
#define IUP_RENAMENODE_CB "RENAMENODE_CB"
|
||||
#define IUP_IMGLEAF "IMGLEAF"
|
||||
#define IUP_IMGCOLLAPSED "IMGCOLLAPSED"
|
||||
#define IUP_IMGEXPANDED "IMGEXPANDED"
|
||||
#define IUP_IMGBLANK "IMGBLANK"
|
||||
#define IUP_IMGPAPER "IMGPAPER"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/** \file
|
||||
* \brief Canvas Draw API
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPDRAW_H
|
||||
#define __IUPDRAW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* all functions can be used only in IUP canvas and inside the ACTION callback */
|
||||
|
||||
IUP_API void IupDrawBegin(Ihandle* ih);
|
||||
IUP_API void IupDrawEnd(Ihandle* ih);
|
||||
|
||||
/* all functions can be called only between calls to Begin and End */
|
||||
|
||||
IUP_API void IupDrawSetClipRect(Ihandle* ih, int x1, int y1, int x2, int y2);
|
||||
IUP_API void IupDrawGetClipRect(Ihandle* ih, int *x1, int *y1, int *x2, int *y2);
|
||||
IUP_API void IupDrawResetClip(Ihandle* ih);
|
||||
|
||||
/* color controlled by the attribute DRAWCOLOR */
|
||||
/* line style or fill controlled by the attribute DRAWSTYLE */
|
||||
|
||||
IUP_API void IupDrawParentBackground(Ihandle* ih);
|
||||
IUP_API void IupDrawLine(Ihandle* ih, int x1, int y1, int x2, int y2);
|
||||
IUP_API void IupDrawRectangle(Ihandle* ih, int x1, int y1, int x2, int y2);
|
||||
IUP_API void IupDrawArc(Ihandle* ih, int x1, int y1, int x2, int y2, double a1, double a2);
|
||||
IUP_API void IupDrawPolygon(Ihandle* ih, int* points, int count);
|
||||
IUP_API void IupDrawText(Ihandle* ih, const char* text, int len, int x, int y, int w, int h);
|
||||
IUP_API void IupDrawImage(Ihandle* ih, const char* name, int x, int y, int w, int h);
|
||||
IUP_API void IupDrawSelectRect(Ihandle* ih, int x1, int y1, int x2, int y2);
|
||||
IUP_API void IupDrawFocusRect(Ihandle* ih, int x1, int y1, int x2, int y2);
|
||||
|
||||
IUP_API void IupDrawGetSize(Ihandle* ih, int *w, int *h);
|
||||
IUP_API void IupDrawGetTextSize(Ihandle* ih, const char* text, int len, int *w, int *h);
|
||||
IUP_API void IupDrawGetImageInfo(const char* name, int *w, int *h, int *bpp);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
/** \file
|
||||
* \brief IupDraw CD driver
|
||||
*
|
||||
* See Copyright Notice in iup.h
|
||||
*/
|
||||
|
||||
#ifndef __CD_IUPDRAW_H
|
||||
#define __CD_IUPDRAW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
cdContext* cdContextIupDraw(void);
|
||||
#define CD_IUPDRAW cdContextIupDraw()
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ifndef __CD_IUPDRAW_ */
|
||||
@@ -0,0 +1,24 @@
|
||||
/** \file
|
||||
* \brief New FileDlg (Windows Only).
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPFILEDLG_H
|
||||
#define __IUPFILEDLG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* the only exported function,
|
||||
once called it will replace regular IupFileDlg */
|
||||
|
||||
int IupNewFileDlgOpen(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,97 @@
|
||||
/** \file
|
||||
* \brief OpenGL canvas for Iup.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPGL_H
|
||||
#define __IUPGL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Attributes
|
||||
** To set the appropriate visual (pixel format) the following
|
||||
** attributes may be specified. Their values should be set
|
||||
** before the canvas is mapped to the scrren.
|
||||
** After mapping, changing their values has no effect.
|
||||
*/
|
||||
#ifndef IUP_BUFFER /* IUP_SINGLE (defaut) or IUP_DOUBLE */
|
||||
#define IUP_BUFFER "BUFFER"
|
||||
#endif
|
||||
#ifndef IUP_STEREO /* IUP_NO (defaut) or IUP_YES */
|
||||
#define IUP_STEREO "STEREO"
|
||||
#endif
|
||||
#ifndef IUP_BUFFER_SIZE /* Number of bits if index mode */
|
||||
#define IUP_BUFFER_SIZE "BUFFER_SIZE"
|
||||
#endif
|
||||
#ifndef IUP_RED_SIZE /* Number of red bits */
|
||||
#define IUP_RED_SIZE "RED_SIZE"
|
||||
#endif
|
||||
#ifndef IUP_GREEN_SIZE /* Number of green bits */
|
||||
#define IUP_GREEN_SIZE "GREEN_SIZE"
|
||||
#endif
|
||||
#ifndef IUP_BLUE_SIZE /* Number of blue bits */
|
||||
#define IUP_BLUE_SIZE "BLUE_SIZE"
|
||||
#endif
|
||||
#ifndef IUP_ALPHA_SIZE /* Number of alpha bits */
|
||||
#define IUP_ALPHA_SIZE "ALPHA_SIZE"
|
||||
#endif
|
||||
#ifndef IUP_DEPTH_SIZE /* Number of bits in depth buffer */
|
||||
#define IUP_DEPTH_SIZE "DEPTH_SIZE"
|
||||
#endif
|
||||
#ifndef IUP_STENCIL_SIZE /* Number of bits in stencil buffer */
|
||||
#define IUP_STENCIL_SIZE "STENCIL_SIZE"
|
||||
#endif
|
||||
#ifndef IUP_ACCUM_RED_SIZE /* Number of red bits in accum. buffer */
|
||||
#define IUP_ACCUM_RED_SIZE "ACCUM_RED_SIZE"
|
||||
#endif
|
||||
#ifndef IUP_ACCUM_GREEN_SIZE /* Number of green bits in accum. buffer */
|
||||
#define IUP_ACCUM_GREEN_SIZE "ACCUM_GREEN_SIZE"
|
||||
#endif
|
||||
#ifndef IUP_ACCUM_BLUE_SIZE /* Number of blue bits in accum. buffer */
|
||||
#define IUP_ACCUM_BLUE_SIZE "ACCUM_BLUE_SIZE"
|
||||
#endif
|
||||
#ifndef IUP_ACCUM_ALPHA_SIZE /* Number of alpha bits in accum. buffer */
|
||||
#define IUP_ACCUM_ALPHA_SIZE "ACCUM_ALPHA_SIZE"
|
||||
#endif
|
||||
|
||||
|
||||
/* Attribute values */
|
||||
#ifndef IUP_DOUBLE
|
||||
#define IUP_DOUBLE "DOUBLE"
|
||||
#endif
|
||||
#ifndef IUP_SINGLE
|
||||
#define IUP_SINGLE "SINGLE"
|
||||
#endif
|
||||
#ifndef IUP_INDEX
|
||||
#define IUP_INDEX "INDEX"
|
||||
#endif
|
||||
#ifndef IUP_RGBA
|
||||
#define IUP_RGBA "RGBA"
|
||||
#endif
|
||||
#ifndef IUP_YES
|
||||
#define IUP_YES "YES"
|
||||
#endif
|
||||
#ifndef IUP_NO
|
||||
#define IUP_NO "NO"
|
||||
#endif
|
||||
|
||||
void IupGLCanvasOpen(void);
|
||||
|
||||
Ihandle *IupGLCanvas(const char *action);
|
||||
Ihandle* IupGLBackgroundBox(Ihandle* child);
|
||||
|
||||
void IupGLMakeCurrent(Ihandle* ih);
|
||||
int IupGLIsCurrent(Ihandle* ih);
|
||||
void IupGLSwapBuffers(Ihandle* ih);
|
||||
void IupGLPalette(Ihandle* ih, int index, float r, float g, float b);
|
||||
void IupGLUseFont(Ihandle* ih, int first, int count, int list_base);
|
||||
void IupGLWait(int gl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
/** \file
|
||||
* \brief GL Controls.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPGLCONTROLS_H
|
||||
#define __IUPGLCONTROLS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
int IupGLControlsOpen(void);
|
||||
|
||||
Ihandle* IupGLCanvasBoxv(Ihandle** children);
|
||||
Ihandle* IupGLCanvasBox(Ihandle* child, ...);
|
||||
|
||||
Ihandle* IupGLSubCanvas(void);
|
||||
|
||||
Ihandle* IupGLLabel(const char* title);
|
||||
Ihandle* IupGLSeparator(void);
|
||||
Ihandle* IupGLButton(const char* title);
|
||||
Ihandle* IupGLToggle(const char* title);
|
||||
Ihandle* IupGLLink(const char *url, const char * title);
|
||||
Ihandle* IupGLProgressBar(void);
|
||||
Ihandle* IupGLVal(void);
|
||||
Ihandle* IupGLFrame(Ihandle* child);
|
||||
Ihandle* IupGLExpander(Ihandle* child);
|
||||
Ihandle* IupGLScrollBox(Ihandle* child);
|
||||
Ihandle* IupGLSizeBox(Ihandle* child);
|
||||
Ihandle* IupGLText(void);
|
||||
|
||||
|
||||
/* Utilities */
|
||||
void IupGLDrawImage(Ihandle* ih, const char* name, int x, int y, int active);
|
||||
void IupGLDrawText(Ihandle* ih, const char* str, int len, int x, int y);
|
||||
void IupGLDrawGetTextSize(Ihandle* ih, const char* str, int *w, int *h);
|
||||
void IupGLDrawGetImageInfo(const char* name, int *w, int *h, int *bpp);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
/** \file
|
||||
* \brief Utilities using IM
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPIM_H
|
||||
#define __IUPIM_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
void IupImOpen(void); /* optional */
|
||||
|
||||
Ihandle* IupLoadImage(const char* filename);
|
||||
int IupSaveImage(Ihandle* ih, const char* filename, const char* format);
|
||||
|
||||
Ihandle* IupLoadAnimation(const char* filename);
|
||||
Ihandle* IupLoadAnimationFrames(const char** filename_list, int file_count);
|
||||
|
||||
#ifdef __IM_IMAGE_H
|
||||
imImage* IupGetNativeHandleImage(void* handle);
|
||||
void* IupGetImageNativeHandle(const imImage* image);
|
||||
|
||||
Ihandle* IupImageFromImImage(const imImage* image);
|
||||
imImage* IupImageToImImage(Ihandle* iup_image);
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,533 @@
|
||||
/** \file
|
||||
* \brief Keyboard Keys definitions.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPKEY_H
|
||||
#define __IUPKEY_H
|
||||
|
||||
/* from 32 to 126, all character sets are equal,
|
||||
the key code is the same as the ASCii character code. */
|
||||
|
||||
#define K_SP ' ' /* 32 (0x20) */
|
||||
#define K_exclam '!' /* 33 */
|
||||
#define K_quotedbl '\"' /* 34 */
|
||||
#define K_numbersign '#' /* 35 */
|
||||
#define K_dollar '$' /* 36 */
|
||||
#define K_percent '%' /* 37 */
|
||||
#define K_ampersand '&' /* 38 */
|
||||
#define K_apostrophe '\'' /* 39 */
|
||||
#define K_parentleft '(' /* 40 */
|
||||
#define K_parentright ')' /* 41 */
|
||||
#define K_asterisk '*' /* 42 */
|
||||
#define K_plus '+' /* 43 */
|
||||
#define K_comma ',' /* 44 */
|
||||
#define K_minus '-' /* 45 */
|
||||
#define K_period '.' /* 46 */
|
||||
#define K_slash '/' /* 47 */
|
||||
#define K_0 '0' /* 48 (0x30) */
|
||||
#define K_1 '1' /* 49 */
|
||||
#define K_2 '2' /* 50 */
|
||||
#define K_3 '3' /* 51 */
|
||||
#define K_4 '4' /* 52 */
|
||||
#define K_5 '5' /* 53 */
|
||||
#define K_6 '6' /* 54 */
|
||||
#define K_7 '7' /* 55 */
|
||||
#define K_8 '8' /* 56 */
|
||||
#define K_9 '9' /* 57 */
|
||||
#define K_colon ':' /* 58 */
|
||||
#define K_semicolon ';' /* 59 */
|
||||
#define K_less '<' /* 60 */
|
||||
#define K_equal '=' /* 61 */
|
||||
#define K_greater '>' /* 62 */
|
||||
#define K_question '?' /* 63 */
|
||||
#define K_at '@' /* 64 */
|
||||
#define K_A 'A' /* 65 (0x41) */
|
||||
#define K_B 'B' /* 66 */
|
||||
#define K_C 'C' /* 67 */
|
||||
#define K_D 'D' /* 68 */
|
||||
#define K_E 'E' /* 69 */
|
||||
#define K_F 'F' /* 70 */
|
||||
#define K_G 'G' /* 71 */
|
||||
#define K_H 'H' /* 72 */
|
||||
#define K_I 'I' /* 73 */
|
||||
#define K_J 'J' /* 74 */
|
||||
#define K_K 'K' /* 75 */
|
||||
#define K_L 'L' /* 76 */
|
||||
#define K_M 'M' /* 77 */
|
||||
#define K_N 'N' /* 78 */
|
||||
#define K_O 'O' /* 79 */
|
||||
#define K_P 'P' /* 80 */
|
||||
#define K_Q 'Q' /* 81 */
|
||||
#define K_R 'R' /* 82 */
|
||||
#define K_S 'S' /* 83 */
|
||||
#define K_T 'T' /* 84 */
|
||||
#define K_U 'U' /* 85 */
|
||||
#define K_V 'V' /* 86 */
|
||||
#define K_W 'W' /* 87 */
|
||||
#define K_X 'X' /* 88 */
|
||||
#define K_Y 'Y' /* 89 */
|
||||
#define K_Z 'Z' /* 90 */
|
||||
#define K_bracketleft '[' /* 91 */
|
||||
#define K_backslash '\\' /* 92 */
|
||||
#define K_bracketright ']' /* 93 */
|
||||
#define K_circum '^' /* 94 */
|
||||
#define K_underscore '_' /* 95 */
|
||||
#define K_grave '`' /* 96 */
|
||||
#define K_a 'a' /* 97 (0x61) */
|
||||
#define K_b 'b' /* 98 */
|
||||
#define K_c 'c' /* 99 */
|
||||
#define K_d 'd' /* 100 */
|
||||
#define K_e 'e' /* 101 */
|
||||
#define K_f 'f' /* 102 */
|
||||
#define K_g 'g' /* 103 */
|
||||
#define K_h 'h' /* 104 */
|
||||
#define K_i 'i' /* 105 */
|
||||
#define K_j 'j' /* 106 */
|
||||
#define K_k 'k' /* 107 */
|
||||
#define K_l 'l' /* 108 */
|
||||
#define K_m 'm' /* 109 */
|
||||
#define K_n 'n' /* 110 */
|
||||
#define K_o 'o' /* 111 */
|
||||
#define K_p 'p' /* 112 */
|
||||
#define K_q 'q' /* 113 */
|
||||
#define K_r 'r' /* 114 */
|
||||
#define K_s 's' /* 115 */
|
||||
#define K_t 't' /* 116 */
|
||||
#define K_u 'u' /* 117 */
|
||||
#define K_v 'v' /* 118 */
|
||||
#define K_w 'w' /* 119 */
|
||||
#define K_x 'x' /* 120 */
|
||||
#define K_y 'y' /* 121 */
|
||||
#define K_z 'z' /* 122 */
|
||||
#define K_braceleft '{' /* 123 */
|
||||
#define K_bar '|' /* 124 */
|
||||
#define K_braceright '}' /* 125 */
|
||||
#define K_tilde '~' /* 126 (0x7E) */
|
||||
|
||||
/* Printable ASCii keys */
|
||||
|
||||
#define iup_isprint(_c) ((_c) > 31 && (_c) < 127)
|
||||
|
||||
/* also define the escape sequences that have keys associated */
|
||||
|
||||
#define K_BS '\b' /* 8 */
|
||||
#define K_TAB '\t' /* 9 */
|
||||
#define K_LF '\n' /* 10 (0x0A) not a real key, is a combination of CR with a modifier, just to document */
|
||||
#define K_CR '\r' /* 13 (0x0D) */
|
||||
|
||||
/* backward compatible definitions */
|
||||
|
||||
#define K_quoteleft K_grave
|
||||
#define K_quoteright K_apostrophe
|
||||
#define isxkey iup_isXkey
|
||||
|
||||
/* IUP Extended Key Codes, range start at 128 */
|
||||
|
||||
#define iup_isXkey(_c) ((_c) >= 128)
|
||||
|
||||
/* These use the same definition as X11 and GDK.
|
||||
This also means that any X11 or GDK definition can also be used. */
|
||||
|
||||
#define K_PAUSE 0xFF13
|
||||
#define K_ESC 0xFF1B
|
||||
#define K_HOME 0xFF50
|
||||
#define K_LEFT 0xFF51
|
||||
#define K_UP 0xFF52
|
||||
#define K_RIGHT 0xFF53
|
||||
#define K_DOWN 0xFF54
|
||||
#define K_PGUP 0xFF55
|
||||
#define K_PGDN 0xFF56
|
||||
#define K_END 0xFF57
|
||||
#define K_MIDDLE 0xFF0B
|
||||
#define K_Print 0xFF61
|
||||
#define K_INS 0xFF63
|
||||
#define K_Menu 0xFF67
|
||||
#define K_DEL 0xFFFF
|
||||
#define K_F1 0xFFBE
|
||||
#define K_F2 0xFFBF
|
||||
#define K_F3 0xFFC0
|
||||
#define K_F4 0xFFC1
|
||||
#define K_F5 0xFFC2
|
||||
#define K_F6 0xFFC3
|
||||
#define K_F7 0xFFC4
|
||||
#define K_F8 0xFFC5
|
||||
#define K_F9 0xFFC6
|
||||
#define K_F10 0xFFC7
|
||||
#define K_F11 0xFFC8
|
||||
#define K_F12 0xFFC9
|
||||
#define K_F13 0xFFCA
|
||||
#define K_F14 0xFFCB
|
||||
#define K_F15 0xFFCC
|
||||
#define K_F16 0xFFCD
|
||||
#define K_F17 0xFFCE
|
||||
#define K_F18 0xFFCF
|
||||
#define K_F19 0xFFD0
|
||||
#define K_F20 0xFFD1
|
||||
|
||||
/* no Shift/Ctrl/Alt */
|
||||
#define K_LSHIFT 0xFFE1
|
||||
#define K_RSHIFT 0xFFE2
|
||||
#define K_LCTRL 0xFFE3
|
||||
#define K_RCTRL 0xFFE4
|
||||
#define K_LALT 0xFFE9
|
||||
#define K_RALT 0xFFEA
|
||||
|
||||
#define K_NUM 0xFF7F
|
||||
#define K_SCROLL 0xFF14
|
||||
#define K_CAPS 0xFFE5
|
||||
|
||||
/* Mac clear button. Value randomly picked trying to avoid clashing with an existing value. */
|
||||
#define K_CLEAR 0xFFD2
|
||||
/* Help button if anybody has it. Value randomly picked trying to avoid clashing with an existing value. */
|
||||
#define K_HELP 0xFFD3
|
||||
|
||||
/* Also, these are the same as the Latin-1 definition */
|
||||
|
||||
#define K_ccedilla 0x00E7
|
||||
#define K_Ccedilla 0x00C7
|
||||
#define K_acute 0x00B4 /* no Shift/Ctrl/Alt */
|
||||
#define K_diaeresis 0x00A8
|
||||
|
||||
/******************************************************/
|
||||
/* Modifiers use last 4 bits. Since IUP 3.9 */
|
||||
/* These modifiers definitions are specific to IUP */
|
||||
/******************************************************/
|
||||
|
||||
#define iup_isShiftXkey(_c) (((_c) & 0x10000000) != 0)
|
||||
#define iup_isCtrlXkey(_c) (((_c) & 0x20000000) != 0)
|
||||
#define iup_isAltXkey(_c) (((_c) & 0x40000000) != 0)
|
||||
#define iup_isSysXkey(_c) (((_c) & 0x80000000) != 0)
|
||||
|
||||
#define iup_XkeyBase(_c) ((_c) & 0x0FFFFFFF)
|
||||
#define iup_XkeyShift(_c) ((_c) | 0x10000000) /* Shift */
|
||||
#define iup_XkeyCtrl(_c) ((_c) | 0x20000000) /* Ctrl */
|
||||
#define iup_XkeyAlt(_c) ((_c) | 0x40000000) /* Alt */
|
||||
#define iup_XkeySys(_c) ((_c) | 0x80000000) /* Sys (Win or Apple) - notice that using "int" will display a negative value */
|
||||
|
||||
/* These definitions are here for backward compatibility
|
||||
and to simplify some key combination usage.
|
||||
But since IUP 3.9, modifiers can be combined with any key
|
||||
and they can be mixed together. */
|
||||
|
||||
#define K_sHOME iup_XkeyShift(K_HOME )
|
||||
#define K_sUP iup_XkeyShift(K_UP )
|
||||
#define K_sPGUP iup_XkeyShift(K_PGUP )
|
||||
#define K_sLEFT iup_XkeyShift(K_LEFT )
|
||||
#define K_sMIDDLE iup_XkeyShift(K_MIDDLE )
|
||||
#define K_sRIGHT iup_XkeyShift(K_RIGHT )
|
||||
#define K_sEND iup_XkeyShift(K_END )
|
||||
#define K_sDOWN iup_XkeyShift(K_DOWN )
|
||||
#define K_sPGDN iup_XkeyShift(K_PGDN )
|
||||
#define K_sINS iup_XkeyShift(K_INS )
|
||||
#define K_sDEL iup_XkeyShift(K_DEL )
|
||||
#define K_sSP iup_XkeyShift(K_SP )
|
||||
#define K_sTAB iup_XkeyShift(K_TAB )
|
||||
#define K_sCR iup_XkeyShift(K_CR )
|
||||
#define K_sBS iup_XkeyShift(K_BS )
|
||||
#define K_sPAUSE iup_XkeyShift(K_PAUSE )
|
||||
#define K_sESC iup_XkeyShift(K_ESC )
|
||||
#define K_sCLEAR iup_XkeyShift(K_CLEAR )
|
||||
#define K_sF1 iup_XkeyShift(K_F1 )
|
||||
#define K_sF2 iup_XkeyShift(K_F2 )
|
||||
#define K_sF3 iup_XkeyShift(K_F3 )
|
||||
#define K_sF4 iup_XkeyShift(K_F4 )
|
||||
#define K_sF5 iup_XkeyShift(K_F5 )
|
||||
#define K_sF6 iup_XkeyShift(K_F6 )
|
||||
#define K_sF7 iup_XkeyShift(K_F7 )
|
||||
#define K_sF8 iup_XkeyShift(K_F8 )
|
||||
#define K_sF9 iup_XkeyShift(K_F9 )
|
||||
#define K_sF10 iup_XkeyShift(K_F10 )
|
||||
#define K_sF11 iup_XkeyShift(K_F11 )
|
||||
#define K_sF12 iup_XkeyShift(K_F12 )
|
||||
#define K_sF13 iup_XkeyShift(K_F13 )
|
||||
#define K_sF14 iup_XkeyShift(K_F14 )
|
||||
#define K_sF15 iup_XkeyShift(K_F15 )
|
||||
#define K_sF16 iup_XkeyShift(K_F16 )
|
||||
#define K_sF17 iup_XkeyShift(K_F17 )
|
||||
#define K_sF18 iup_XkeyShift(K_F18 )
|
||||
#define K_sF19 iup_XkeyShift(K_F19 )
|
||||
#define K_sF20 iup_XkeyShift(K_F20 )
|
||||
#define K_sPrint iup_XkeyShift(K_Print )
|
||||
#define K_sMenu iup_XkeyShift(K_Menu )
|
||||
|
||||
#define K_cHOME iup_XkeyCtrl(K_HOME )
|
||||
#define K_cUP iup_XkeyCtrl(K_UP )
|
||||
#define K_cPGUP iup_XkeyCtrl(K_PGUP )
|
||||
#define K_cLEFT iup_XkeyCtrl(K_LEFT )
|
||||
#define K_cMIDDLE iup_XkeyCtrl(K_MIDDLE )
|
||||
#define K_cRIGHT iup_XkeyCtrl(K_RIGHT )
|
||||
#define K_cEND iup_XkeyCtrl(K_END )
|
||||
#define K_cDOWN iup_XkeyCtrl(K_DOWN )
|
||||
#define K_cPGDN iup_XkeyCtrl(K_PGDN )
|
||||
#define K_cINS iup_XkeyCtrl(K_INS )
|
||||
#define K_cDEL iup_XkeyCtrl(K_DEL )
|
||||
#define K_cSP iup_XkeyCtrl(K_SP )
|
||||
#define K_cTAB iup_XkeyCtrl(K_TAB )
|
||||
#define K_cCR iup_XkeyCtrl(K_CR )
|
||||
#define K_cBS iup_XkeyCtrl(K_BS )
|
||||
#define K_cPAUSE iup_XkeyCtrl(K_PAUSE )
|
||||
#define K_cESC iup_XkeyCtrl(K_ESC )
|
||||
#define K_cCLEAR iup_XkeyCtrl(K_CLEAR )
|
||||
#define K_cCcedilla iup_XkeyCtrl(K_Ccedilla)
|
||||
#define K_cF1 iup_XkeyCtrl(K_F1 )
|
||||
#define K_cF2 iup_XkeyCtrl(K_F2 )
|
||||
#define K_cF3 iup_XkeyCtrl(K_F3 )
|
||||
#define K_cF4 iup_XkeyCtrl(K_F4 )
|
||||
#define K_cF5 iup_XkeyCtrl(K_F5 )
|
||||
#define K_cF6 iup_XkeyCtrl(K_F6 )
|
||||
#define K_cF7 iup_XkeyCtrl(K_F7 )
|
||||
#define K_cF8 iup_XkeyCtrl(K_F8 )
|
||||
#define K_cF9 iup_XkeyCtrl(K_F9 )
|
||||
#define K_cF10 iup_XkeyCtrl(K_F10 )
|
||||
#define K_cF11 iup_XkeyCtrl(K_F11 )
|
||||
#define K_cF12 iup_XkeyCtrl(K_F12 )
|
||||
#define K_cF13 iup_XkeyCtrl(K_F13 )
|
||||
#define K_cF14 iup_XkeyCtrl(K_F14 )
|
||||
#define K_cF15 iup_XkeyCtrl(K_F15 )
|
||||
#define K_cF16 iup_XkeyCtrl(K_F16 )
|
||||
#define K_cF17 iup_XkeyCtrl(K_F17 )
|
||||
#define K_cF18 iup_XkeyCtrl(K_F18 )
|
||||
#define K_cF19 iup_XkeyCtrl(K_F19 )
|
||||
#define K_cF20 iup_XkeyCtrl(K_F20 )
|
||||
#define K_cPrint iup_XkeyCtrl(K_Print )
|
||||
#define K_cMenu iup_XkeyCtrl(K_Menu )
|
||||
|
||||
#define K_mHOME iup_XkeyAlt(K_HOME )
|
||||
#define K_mUP iup_XkeyAlt(K_UP )
|
||||
#define K_mPGUP iup_XkeyAlt(K_PGUP )
|
||||
#define K_mLEFT iup_XkeyAlt(K_LEFT )
|
||||
#define K_mMIDDLE iup_XkeyAlt(K_MIDDLE )
|
||||
#define K_mRIGHT iup_XkeyAlt(K_RIGHT )
|
||||
#define K_mEND iup_XkeyAlt(K_END )
|
||||
#define K_mDOWN iup_XkeyAlt(K_DOWN )
|
||||
#define K_mPGDN iup_XkeyAlt(K_PGDN )
|
||||
#define K_mINS iup_XkeyAlt(K_INS )
|
||||
#define K_mDEL iup_XkeyAlt(K_DEL )
|
||||
#define K_mSP iup_XkeyAlt(K_SP )
|
||||
#define K_mTAB iup_XkeyAlt(K_TAB )
|
||||
#define K_mCR iup_XkeyAlt(K_CR )
|
||||
#define K_mBS iup_XkeyAlt(K_BS )
|
||||
#define K_mPAUSE iup_XkeyAlt(K_PAUSE )
|
||||
#define K_mESC iup_XkeyAlt(K_ESC )
|
||||
#define K_mCLEAR iup_XkeyAlt(K_CLEAR )
|
||||
#define K_mCcedilla iup_XkeyAlt(K_Ccedilla)
|
||||
#define K_mF1 iup_XkeyAlt(K_F1 )
|
||||
#define K_mF2 iup_XkeyAlt(K_F2 )
|
||||
#define K_mF3 iup_XkeyAlt(K_F3 )
|
||||
#define K_mF4 iup_XkeyAlt(K_F4 )
|
||||
#define K_mF5 iup_XkeyAlt(K_F5 )
|
||||
#define K_mF6 iup_XkeyAlt(K_F6 )
|
||||
#define K_mF7 iup_XkeyAlt(K_F7 )
|
||||
#define K_mF8 iup_XkeyAlt(K_F8 )
|
||||
#define K_mF9 iup_XkeyAlt(K_F9 )
|
||||
#define K_mF10 iup_XkeyAlt(K_F10 )
|
||||
#define K_mF11 iup_XkeyAlt(K_F11 )
|
||||
#define K_mF12 iup_XkeyAlt(K_F12 )
|
||||
#define K_mF13 iup_XkeyAlt(K_F13 )
|
||||
#define K_mF14 iup_XkeyAlt(K_F14 )
|
||||
#define K_mF15 iup_XkeyAlt(K_F15 )
|
||||
#define K_mF16 iup_XkeyAlt(K_F16 )
|
||||
#define K_mF17 iup_XkeyAlt(K_F17 )
|
||||
#define K_mF18 iup_XkeyAlt(K_F18 )
|
||||
#define K_mF19 iup_XkeyAlt(K_F19 )
|
||||
#define K_mF20 iup_XkeyAlt(K_F20 )
|
||||
#define K_mPrint iup_XkeyAlt(K_Print )
|
||||
#define K_mMenu iup_XkeyAlt(K_Menu )
|
||||
|
||||
#define K_yHOME iup_XkeySys(K_HOME )
|
||||
#define K_yUP iup_XkeySys(K_UP )
|
||||
#define K_yPGUP iup_XkeySys(K_PGUP )
|
||||
#define K_yLEFT iup_XkeySys(K_LEFT )
|
||||
#define K_yMIDDLE iup_XkeySys(K_MIDDLE )
|
||||
#define K_yRIGHT iup_XkeySys(K_RIGHT )
|
||||
#define K_yEND iup_XkeySys(K_END )
|
||||
#define K_yDOWN iup_XkeySys(K_DOWN )
|
||||
#define K_yPGDN iup_XkeySys(K_PGDN )
|
||||
#define K_yINS iup_XkeySys(K_INS )
|
||||
#define K_yDEL iup_XkeySys(K_DEL )
|
||||
#define K_ySP iup_XkeySys(K_SP )
|
||||
#define K_yTAB iup_XkeySys(K_TAB )
|
||||
#define K_yCR iup_XkeySys(K_CR )
|
||||
#define K_yBS iup_XkeySys(K_BS )
|
||||
#define K_yPAUSE iup_XkeySys(K_PAUSE )
|
||||
#define K_yESC iup_XkeySys(K_ESC )
|
||||
#define K_yCLEAR iup_XkeySys(K_CLEAR )
|
||||
#define K_yCcedilla iup_XkeySys(K_Ccedilla)
|
||||
#define K_yF1 iup_XkeySys(K_F1 )
|
||||
#define K_yF2 iup_XkeySys(K_F2 )
|
||||
#define K_yF3 iup_XkeySys(K_F3 )
|
||||
#define K_yF4 iup_XkeySys(K_F4 )
|
||||
#define K_yF5 iup_XkeySys(K_F5 )
|
||||
#define K_yF6 iup_XkeySys(K_F6 )
|
||||
#define K_yF7 iup_XkeySys(K_F7 )
|
||||
#define K_yF8 iup_XkeySys(K_F8 )
|
||||
#define K_yF9 iup_XkeySys(K_F9 )
|
||||
#define K_yF10 iup_XkeySys(K_F10 )
|
||||
#define K_yF11 iup_XkeySys(K_F11 )
|
||||
#define K_yF12 iup_XkeySys(K_F12 )
|
||||
#define K_yF13 iup_XkeySys(K_F13 )
|
||||
#define K_yF14 iup_XkeySys(K_F14 )
|
||||
#define K_yF15 iup_XkeySys(K_F15 )
|
||||
#define K_yF16 iup_XkeySys(K_F16 )
|
||||
#define K_yF17 iup_XkeySys(K_F17 )
|
||||
#define K_yF18 iup_XkeySys(K_F18 )
|
||||
#define K_yF19 iup_XkeySys(K_F19 )
|
||||
#define K_yF20 iup_XkeySys(K_F20 )
|
||||
#define K_yPrint iup_XkeySys(K_Print )
|
||||
#define K_yMenu iup_XkeySys(K_Menu )
|
||||
|
||||
#define K_sPlus iup_XkeyShift(K_plus )
|
||||
#define K_sComma iup_XkeyShift(K_comma )
|
||||
#define K_sMinus iup_XkeyShift(K_minus )
|
||||
#define K_sPeriod iup_XkeyShift(K_period )
|
||||
#define K_sSlash iup_XkeyShift(K_slash )
|
||||
#define K_sAsterisk iup_XkeyShift(K_asterisk)
|
||||
|
||||
#define K_cA iup_XkeyCtrl(K_A)
|
||||
#define K_cB iup_XkeyCtrl(K_B)
|
||||
#define K_cC iup_XkeyCtrl(K_C)
|
||||
#define K_cD iup_XkeyCtrl(K_D)
|
||||
#define K_cE iup_XkeyCtrl(K_E)
|
||||
#define K_cF iup_XkeyCtrl(K_F)
|
||||
#define K_cG iup_XkeyCtrl(K_G)
|
||||
#define K_cH iup_XkeyCtrl(K_H)
|
||||
#define K_cI iup_XkeyCtrl(K_I)
|
||||
#define K_cJ iup_XkeyCtrl(K_J)
|
||||
#define K_cK iup_XkeyCtrl(K_K)
|
||||
#define K_cL iup_XkeyCtrl(K_L)
|
||||
#define K_cM iup_XkeyCtrl(K_M)
|
||||
#define K_cN iup_XkeyCtrl(K_N)
|
||||
#define K_cO iup_XkeyCtrl(K_O)
|
||||
#define K_cP iup_XkeyCtrl(K_P)
|
||||
#define K_cQ iup_XkeyCtrl(K_Q)
|
||||
#define K_cR iup_XkeyCtrl(K_R)
|
||||
#define K_cS iup_XkeyCtrl(K_S)
|
||||
#define K_cT iup_XkeyCtrl(K_T)
|
||||
#define K_cU iup_XkeyCtrl(K_U)
|
||||
#define K_cV iup_XkeyCtrl(K_V)
|
||||
#define K_cW iup_XkeyCtrl(K_W)
|
||||
#define K_cX iup_XkeyCtrl(K_X)
|
||||
#define K_cY iup_XkeyCtrl(K_Y)
|
||||
#define K_cZ iup_XkeyCtrl(K_Z)
|
||||
#define K_c1 iup_XkeyCtrl(K_1)
|
||||
#define K_c2 iup_XkeyCtrl(K_2)
|
||||
#define K_c3 iup_XkeyCtrl(K_3)
|
||||
#define K_c4 iup_XkeyCtrl(K_4)
|
||||
#define K_c5 iup_XkeyCtrl(K_5)
|
||||
#define K_c6 iup_XkeyCtrl(K_6)
|
||||
#define K_c7 iup_XkeyCtrl(K_7)
|
||||
#define K_c8 iup_XkeyCtrl(K_8)
|
||||
#define K_c9 iup_XkeyCtrl(K_9)
|
||||
#define K_c0 iup_XkeyCtrl(K_0)
|
||||
#define K_cPlus iup_XkeyCtrl(K_plus )
|
||||
#define K_cComma iup_XkeyCtrl(K_comma )
|
||||
#define K_cMinus iup_XkeyCtrl(K_minus )
|
||||
#define K_cPeriod iup_XkeyCtrl(K_period )
|
||||
#define K_cSlash iup_XkeyCtrl(K_slash )
|
||||
#define K_cSemicolon iup_XkeyCtrl(K_semicolon )
|
||||
#define K_cEqual iup_XkeyCtrl(K_equal )
|
||||
#define K_cBracketleft iup_XkeyCtrl(K_bracketleft )
|
||||
#define K_cBracketright iup_XkeyCtrl(K_bracketright)
|
||||
#define K_cBackslash iup_XkeyCtrl(K_backslash )
|
||||
#define K_cAsterisk iup_XkeyCtrl(K_asterisk )
|
||||
|
||||
#define K_mA iup_XkeyAlt(K_A)
|
||||
#define K_mB iup_XkeyAlt(K_B)
|
||||
#define K_mC iup_XkeyAlt(K_C)
|
||||
#define K_mD iup_XkeyAlt(K_D)
|
||||
#define K_mE iup_XkeyAlt(K_E)
|
||||
#define K_mF iup_XkeyAlt(K_F)
|
||||
#define K_mG iup_XkeyAlt(K_G)
|
||||
#define K_mH iup_XkeyAlt(K_H)
|
||||
#define K_mI iup_XkeyAlt(K_I)
|
||||
#define K_mJ iup_XkeyAlt(K_J)
|
||||
#define K_mK iup_XkeyAlt(K_K)
|
||||
#define K_mL iup_XkeyAlt(K_L)
|
||||
#define K_mM iup_XkeyAlt(K_M)
|
||||
#define K_mN iup_XkeyAlt(K_N)
|
||||
#define K_mO iup_XkeyAlt(K_O)
|
||||
#define K_mP iup_XkeyAlt(K_P)
|
||||
#define K_mQ iup_XkeyAlt(K_Q)
|
||||
#define K_mR iup_XkeyAlt(K_R)
|
||||
#define K_mS iup_XkeyAlt(K_S)
|
||||
#define K_mT iup_XkeyAlt(K_T)
|
||||
#define K_mU iup_XkeyAlt(K_U)
|
||||
#define K_mV iup_XkeyAlt(K_V)
|
||||
#define K_mW iup_XkeyAlt(K_W)
|
||||
#define K_mX iup_XkeyAlt(K_X)
|
||||
#define K_mY iup_XkeyAlt(K_Y)
|
||||
#define K_mZ iup_XkeyAlt(K_Z)
|
||||
#define K_m1 iup_XkeyAlt(K_1)
|
||||
#define K_m2 iup_XkeyAlt(K_2)
|
||||
#define K_m3 iup_XkeyAlt(K_3)
|
||||
#define K_m4 iup_XkeyAlt(K_4)
|
||||
#define K_m5 iup_XkeyAlt(K_5)
|
||||
#define K_m6 iup_XkeyAlt(K_6)
|
||||
#define K_m7 iup_XkeyAlt(K_7)
|
||||
#define K_m8 iup_XkeyAlt(K_8)
|
||||
#define K_m9 iup_XkeyAlt(K_9)
|
||||
#define K_m0 iup_XkeyAlt(K_0)
|
||||
#define K_mPlus iup_XkeyAlt(K_plus )
|
||||
#define K_mComma iup_XkeyAlt(K_comma )
|
||||
#define K_mMinus iup_XkeyAlt(K_minus )
|
||||
#define K_mPeriod iup_XkeyAlt(K_period )
|
||||
#define K_mSlash iup_XkeyAlt(K_slash )
|
||||
#define K_mSemicolon iup_XkeyAlt(K_semicolon )
|
||||
#define K_mEqual iup_XkeyAlt(K_equal )
|
||||
#define K_mBracketleft iup_XkeyAlt(K_bracketleft )
|
||||
#define K_mBracketright iup_XkeyAlt(K_bracketright)
|
||||
#define K_mBackslash iup_XkeyAlt(K_backslash )
|
||||
#define K_mAsterisk iup_XkeyAlt(K_asterisk )
|
||||
|
||||
#define K_yA iup_XkeySys(K_A)
|
||||
#define K_yB iup_XkeySys(K_B)
|
||||
#define K_yC iup_XkeySys(K_C)
|
||||
#define K_yD iup_XkeySys(K_D)
|
||||
#define K_yE iup_XkeySys(K_E)
|
||||
#define K_yF iup_XkeySys(K_F)
|
||||
#define K_yG iup_XkeySys(K_G)
|
||||
#define K_yH iup_XkeySys(K_H)
|
||||
#define K_yI iup_XkeySys(K_I)
|
||||
#define K_yJ iup_XkeySys(K_J)
|
||||
#define K_yK iup_XkeySys(K_K)
|
||||
#define K_yL iup_XkeySys(K_L)
|
||||
#define K_yM iup_XkeySys(K_M)
|
||||
#define K_yN iup_XkeySys(K_N)
|
||||
#define K_yO iup_XkeySys(K_O)
|
||||
#define K_yP iup_XkeySys(K_P)
|
||||
#define K_yQ iup_XkeySys(K_Q)
|
||||
#define K_yR iup_XkeySys(K_R)
|
||||
#define K_yS iup_XkeySys(K_S)
|
||||
#define K_yT iup_XkeySys(K_T)
|
||||
#define K_yU iup_XkeySys(K_U)
|
||||
#define K_yV iup_XkeySys(K_V)
|
||||
#define K_yW iup_XkeySys(K_W)
|
||||
#define K_yX iup_XkeySys(K_X)
|
||||
#define K_yY iup_XkeySys(K_Y)
|
||||
#define K_yZ iup_XkeySys(K_Z)
|
||||
#define K_y1 iup_XkeySys(K_1)
|
||||
#define K_y2 iup_XkeySys(K_2)
|
||||
#define K_y3 iup_XkeySys(K_3)
|
||||
#define K_y4 iup_XkeySys(K_4)
|
||||
#define K_y5 iup_XkeySys(K_5)
|
||||
#define K_y6 iup_XkeySys(K_6)
|
||||
#define K_y7 iup_XkeySys(K_7)
|
||||
#define K_y8 iup_XkeySys(K_8)
|
||||
#define K_y9 iup_XkeySys(K_9)
|
||||
#define K_y0 iup_XkeySys(K_0)
|
||||
#define K_yPlus iup_XkeySys(K_plus )
|
||||
#define K_yComma iup_XkeySys(K_comma )
|
||||
#define K_yMinus iup_XkeySys(K_minus )
|
||||
#define K_yPeriod iup_XkeySys(K_period )
|
||||
#define K_ySlash iup_XkeySys(K_slash )
|
||||
#define K_ySemicolon iup_XkeySys(K_semicolon )
|
||||
#define K_yEqual iup_XkeySys(K_equal )
|
||||
#define K_yBracketleft iup_XkeySys(K_bracketleft )
|
||||
#define K_yBracketright iup_XkeySys(K_bracketright)
|
||||
#define K_yBackslash iup_XkeySys(K_backslash )
|
||||
#define K_yAsterisk iup_XkeySys(K_asterisk )
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
/** \file
|
||||
* \brief IUP Binding for Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUA_H
|
||||
#define __IUPLUA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
/** @cond DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
#ifndef IUPLUA_API
|
||||
#ifdef IUPLUA_BUILD_LIBRARY
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#define IUPLUA_API EMSCRIPTEN_KEEPALIVE
|
||||
#elif WIN32
|
||||
#define IUPLUA_API __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define IUPLUA_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define IUPLUA_API
|
||||
#endif
|
||||
#else
|
||||
#define IUPLUA_API
|
||||
#endif /* IUPLUA_BUILD_LIBRARY */
|
||||
#endif /* IUPLUA_API */
|
||||
/** @endcond DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
|
||||
IUPLUA_API int iuplua_open(lua_State *L);
|
||||
IUPLUA_API int iupkey_open(lua_State *L); /* does nothing, kept for backward compatibility */
|
||||
IUPLUA_API int iuplua_close(lua_State * L);
|
||||
|
||||
/* utilities */
|
||||
IUPLUA_API int iuplua_isihandle(lua_State *L, int pos);
|
||||
IUPLUA_API Ihandle* iuplua_checkihandle(lua_State *L, int pos);
|
||||
IUPLUA_API void iuplua_pushihandle(lua_State *L, Ihandle *n);
|
||||
IUPLUA_API int iuplua_dofile(lua_State *L, const char *filename);
|
||||
IUPLUA_API int iuplua_dostring(lua_State *L, const char *string, const char *chunk_name);
|
||||
IUPLUA_API int iuplua_dobuffer(lua_State *L, const char *buffer, int len, const char *chunk_name);
|
||||
IUPLUA_API void iuplua_show_error_message(const char *pname, const char* msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/** \file
|
||||
* \brief IupMglPlot Binding for Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUA_MGLPLOT_H
|
||||
#define __IUPLUA_MGLPLOT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int iup_mglplotlua_open (lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/** \file
|
||||
* \brief iup_plot Binding for Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUA_PLOT_H
|
||||
#define __IUPLUA_PLOT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int iup_plotlua_open (lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/** \file
|
||||
* \brief IupScintilla Binding for Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUA_SCINTILLA_H
|
||||
#define __IUPLUA_SCINTILLA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int iup_scintillalua_open (lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/** \file
|
||||
* \brief iupcontrols Binding for Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUACONTROLS_H
|
||||
#define __IUPLUACONTROLS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int iupcontrolslua_open (lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/** \file
|
||||
* \brief Binding of new iupfiledlg to Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUAFILEDLG_H
|
||||
#define __IUPLUAFILEDLG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int iupfiledlglua_open (lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/** \file
|
||||
* \brief Binding of iupglcanvas to Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUAGL_H
|
||||
#define __IUPLUAGL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int iupgllua_open (lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/** \file
|
||||
* \brief iupglcontrols Binding for Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUAGLCONTROLS_H
|
||||
#define __IUPLUAGLCONTROLS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int iupglcontrolslua_open (lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/** \file
|
||||
* \brief Bindig of iupim functions to Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUAIM_H
|
||||
#define __IUPLUAIM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int iupimlua_open(lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/** \file
|
||||
* \brief Binding of iupolecontrol to Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUAOLE_H
|
||||
#define __IUPLUAOLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int iupolelua_open (lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
/** \file
|
||||
* \brief IupLuaScripterDlg dialog and Lua binding
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUASCRIPTERDLG_H
|
||||
#define __IUPLUASCRIPTERDLG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void IupLuaScripterDlgOpen(lua_State * L);
|
||||
|
||||
Ihandle* IupLuaScripterDlg(void);
|
||||
|
||||
/* Lua binding */
|
||||
int iupluascripterdlglua_open(lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/** \file
|
||||
* \brief Binding of iuptuio to Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUATUIO_H
|
||||
#define __IUPLUATUIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int iuptuiolua_open (lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/** \file
|
||||
* \brief Binding of iupwebbrowser to Lua.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPLUAWEB_H
|
||||
#define __IUPLUAWEB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
/** @cond DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
#ifndef IUPLUAWEB_API
|
||||
#ifdef IUPLUAWEB_BUILD_LIBRARY
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#define IUPLUAWEB_API EMSCRIPTEN_KEEPALIVE
|
||||
#elif WIN32
|
||||
#define IUPLUAWEB_API __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define IUPLUAWEB_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define IUPLUAWEB_API
|
||||
#endif
|
||||
#else
|
||||
#define IUPLUAWEB_API
|
||||
#endif /* IUPLUAWEB_BUILD_LIBRARY */
|
||||
#endif /* IUPLUAWEB_API */
|
||||
/** @endcond DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
|
||||
IUPLUAWEB_API int iupweblua_open (lua_State * L);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
/** \file
|
||||
* \brief Ole control.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPOLE_H
|
||||
#define __IUPOLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
/** @cond DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
#ifndef IUPOLE_API
|
||||
#ifdef IUPOLE_BUILD_LIBRARY
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#define IUPOLE_API EMSCRIPTEN_KEEPALIVE
|
||||
#elif WIN32
|
||||
#define IUPOLE_API __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define IUPOLE_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define IUPOLE_API
|
||||
#endif
|
||||
#else
|
||||
#define IUPOLE_API
|
||||
#endif /* IUP_BUILD_LIBRARY */
|
||||
#endif /* IUPOLE_API */
|
||||
/** @endcond DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
|
||||
IUPOLE_API Ihandle *IupOleControl(const char* progid);
|
||||
|
||||
IUPOLE_API int IupOleControlOpen(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
/** \file
|
||||
* \brief IupTuioClient control
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPTUIO_H
|
||||
#define __IUPTUIO_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int IupTuioOpen(void);
|
||||
Ihandle* IupTuioClient(int port);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
/** \file
|
||||
* \brief Web control.
|
||||
*
|
||||
* See Copyright Notice in "iup.h"
|
||||
*/
|
||||
|
||||
#ifndef __IUPWEB_H
|
||||
#define __IUPWEB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
/** @cond DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
#ifndef IUPWEB_API
|
||||
#ifdef IUPWEB_BUILD_LIBRARY
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#define IUPWEB_API EMSCRIPTEN_KEEPALIVE
|
||||
#elif WIN32
|
||||
#define IUPWEB_API __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define IUPWEB_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define IUPWEB_API
|
||||
#endif
|
||||
#else
|
||||
#define IUPWEB_API
|
||||
#endif /* IUP_BUILD_LIBRARY */
|
||||
#endif /* IUPWEB_API */
|
||||
/** @endcond DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
|
||||
IUPWEB_API int IupWebBrowserOpen(void);
|
||||
|
||||
IUPWEB_API Ihandle *IupWebBrowser(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -744,7 +744,6 @@ void run_gui_mode()
|
||||
while (gui_running && handle_events())
|
||||
{
|
||||
render_game();
|
||||
SDL_Delay(16); // 约60FPS
|
||||
}
|
||||
printf("退出图形化界面\n");
|
||||
cleanup_gui();
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "globals.h"
|
||||
#include "config.h"
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
// ==================== 游戏核心变量定义 ====================
|
||||
int BOARD_SIZE = DEFAULT_BOARD_SIZE; // 实际使用的棋盘尺寸
|
||||
@@ -30,8 +29,6 @@ double defense_coefficient = DEFAULT_DEFENSE_COEFFICIENT; // 防守系数
|
||||
NetworkGameState network_state = {0}; // 网络游戏状态
|
||||
|
||||
// ==================== GUI相关变量定义 ====================
|
||||
SDL_Window *window = NULL; // SDL窗口指针
|
||||
SDL_Renderer *renderer = NULL; // SDL渲染器指针
|
||||
int gui_running = 1; // GUI运行状态标志
|
||||
int current_player_gui = PLAYER; // GUI当前玩家
|
||||
int game_over = 0; // 游戏结束标志
|
||||
|
||||
@@ -1,69 +1,305 @@
|
||||
/**
|
||||
* @file gui.c
|
||||
* @brief 图形化用户界面实现文件
|
||||
* @note 使用SDL3库实现五子棋的图形化界面
|
||||
* @note 使用IUP库实现五子棋的图形化界面
|
||||
* @author 刘航宇
|
||||
* @date 2025-01-15
|
||||
*/
|
||||
|
||||
#include "gui.h"
|
||||
#include <iup.h>
|
||||
#include <iupdraw.h>
|
||||
#include "ui.h"
|
||||
#include "globals.h"
|
||||
#include "game_mode.h"
|
||||
#include "init_board.h"
|
||||
#include "gobang.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
static Ihandle *dlg = NULL;
|
||||
static Ihandle *canvas = NULL;
|
||||
static int gui_loop_running = 0;
|
||||
|
||||
// 辅助函数:设置绘图颜色
|
||||
static void set_draw_color(Ihandle *ih, unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
char color[32];
|
||||
sprintf(color, "%d %d %d", r, g, b);
|
||||
IupSetAttribute(ih, "DRAWCOLOR", color);
|
||||
}
|
||||
|
||||
// 绘制棋盘
|
||||
static void draw_board_iup(Ihandle *ih)
|
||||
{
|
||||
set_draw_color(ih, 0, 0, 0); // Black
|
||||
IupSetAttribute(ih, "DRAWSTYLE", "STROKE");
|
||||
|
||||
for (int i = 0; i < BOARD_SIZE; i++)
|
||||
{
|
||||
// 横线
|
||||
IupDrawLine(ih,
|
||||
BOARD_OFFSET_X,
|
||||
BOARD_OFFSET_Y + i * CELL_SIZE,
|
||||
BOARD_OFFSET_X + (BOARD_SIZE - 1) * CELL_SIZE,
|
||||
BOARD_OFFSET_Y + i * CELL_SIZE);
|
||||
// 竖线
|
||||
IupDrawLine(ih,
|
||||
BOARD_OFFSET_X + i * CELL_SIZE,
|
||||
BOARD_OFFSET_Y,
|
||||
BOARD_OFFSET_X + i * CELL_SIZE,
|
||||
BOARD_OFFSET_Y + (BOARD_SIZE - 1) * CELL_SIZE);
|
||||
}
|
||||
|
||||
// 星位/天元
|
||||
IupSetAttribute(ih, "DRAWSTYLE", "FILL");
|
||||
int stars[] = {3, 7, 11}; // 15路棋盘的星位坐标
|
||||
if (BOARD_SIZE == 15)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
int cx = BOARD_OFFSET_X + stars[i] * CELL_SIZE;
|
||||
int cy = BOARD_OFFSET_Y + stars[j] * CELL_SIZE;
|
||||
IupDrawRectangle(ih, cx - 3, cy - 3, cx + 3, cy + 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int center = BOARD_SIZE / 2;
|
||||
int cx = BOARD_OFFSET_X + center * CELL_SIZE;
|
||||
int cy = BOARD_OFFSET_Y + center * CELL_SIZE;
|
||||
IupDrawRectangle(ih, cx - 3, cy - 3, cx + 3, cy + 3);
|
||||
}
|
||||
}
|
||||
|
||||
// 绘制棋子
|
||||
static void draw_stones_iup(Ihandle *ih)
|
||||
{
|
||||
for (int i = 0; i < BOARD_SIZE; i++)
|
||||
{
|
||||
for (int j = 0; j < BOARD_SIZE; j++)
|
||||
{
|
||||
if (board[i][j] != EMPTY)
|
||||
{
|
||||
int cx = BOARD_OFFSET_X + j * CELL_SIZE; // j是x坐标(列)
|
||||
int cy = BOARD_OFFSET_Y + i * CELL_SIZE; // i是y坐标(行)
|
||||
|
||||
if (board[i][j] == PLAYER)
|
||||
{ // 黑子
|
||||
set_draw_color(ih, 0, 0, 0);
|
||||
IupSetAttribute(ih, "DRAWSTYLE", "FILL");
|
||||
IupDrawArc(ih, cx - STONE_RADIUS, cy - STONE_RADIUS, cx + STONE_RADIUS, cy + STONE_RADIUS, 0.0, 360.0);
|
||||
}
|
||||
else
|
||||
{ // 白子
|
||||
set_draw_color(ih, 255, 255, 255);
|
||||
IupSetAttribute(ih, "DRAWSTYLE", "FILL");
|
||||
IupDrawArc(ih, cx - STONE_RADIUS, cy - STONE_RADIUS, cx + STONE_RADIUS, cy + STONE_RADIUS, 0.0, 360.0);
|
||||
|
||||
set_draw_color(ih, 0, 0, 0);
|
||||
IupSetAttribute(ih, "DRAWSTYLE", "STROKE");
|
||||
IupDrawArc(ih, cx - STONE_RADIUS, cy - STONE_RADIUS, cx + STONE_RADIUS, cy + STONE_RADIUS, 0.0, 360.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 绘制UI元素
|
||||
static void draw_ui_iup(Ihandle *ih)
|
||||
{
|
||||
int infoX = BOARD_OFFSET_X + BOARD_SIZE * CELL_SIZE + 20;
|
||||
int infoY = BOARD_OFFSET_Y;
|
||||
int infoW = 220;
|
||||
int infoH = 120;
|
||||
|
||||
// 背景
|
||||
set_draw_color(ih, 200, 200, 200); // Light Gray
|
||||
IupSetAttribute(ih, "DRAWSTYLE", "FILL");
|
||||
IupDrawRectangle(ih, infoX, infoY, infoX + infoW, infoY + infoH);
|
||||
|
||||
// 边框
|
||||
set_draw_color(ih, 0, 0, 0);
|
||||
IupSetAttribute(ih, "DRAWSTYLE", "STROKE");
|
||||
IupDrawRectangle(ih, infoX, infoY, infoX + infoW, infoY + infoH);
|
||||
|
||||
// 文本
|
||||
// 注意:IUP使用系统字体,不支持直接加载TTF文件像Raylib那样方便
|
||||
// 我们可以尝试设置字体属性
|
||||
IupSetAttribute(ih, "DRAWFONT", "SimHei, 14");
|
||||
|
||||
IupDrawText(ih, "当前玩家:", -1, infoX + 20, infoY + 20, -1, -1);
|
||||
|
||||
int indicatorX = infoX + 30;
|
||||
int indicatorY = infoY + 30;
|
||||
|
||||
if (!game_over)
|
||||
{
|
||||
if (current_player_gui == PLAYER)
|
||||
{
|
||||
IupDrawText(ih, "黑子", -1, indicatorX + 20, indicatorY + 10, -1, -1);
|
||||
set_draw_color(ih, 0, 0, 0);
|
||||
IupSetAttribute(ih, "DRAWSTYLE", "FILL");
|
||||
IupDrawArc(ih, indicatorX, indicatorY + 20 - 5, indicatorX + 10, indicatorY + 20 + 5, 0, 360);
|
||||
}
|
||||
else
|
||||
{
|
||||
IupDrawText(ih, "白子", -1, indicatorX + 20, indicatorY + 10, -1, -1);
|
||||
set_draw_color(ih, 255, 255, 255);
|
||||
IupSetAttribute(ih, "DRAWSTYLE", "FILL");
|
||||
IupDrawArc(ih, indicatorX, indicatorY + 20 - 5, indicatorX + 10, indicatorY + 20 + 5, 0, 360);
|
||||
set_draw_color(ih, 0, 0, 0);
|
||||
IupSetAttribute(ih, "DRAWSTYLE", "STROKE");
|
||||
IupDrawArc(ih, indicatorX, indicatorY + 20 - 5, indicatorX + 10, indicatorY + 20 + 5, 0, 360);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
set_draw_color(ih, 255, 0, 0);
|
||||
IupDrawText(ih, "游戏结束", -1, indicatorX, indicatorY + 10, -1, -1);
|
||||
}
|
||||
|
||||
set_draw_color(ih, 0, 0, 0);
|
||||
IupDrawText(ih, status_message, -1, infoX + 10, infoY + 60, -1, -1);
|
||||
}
|
||||
|
||||
// 屏幕坐标转棋盘坐标
|
||||
int screen_to_board(int screen_x, int screen_y, int *board_x, int *board_y)
|
||||
{
|
||||
int rel_x = screen_x - BOARD_OFFSET_X;
|
||||
int rel_y = screen_y - BOARD_OFFSET_Y;
|
||||
|
||||
*board_x = (rel_y + CELL_SIZE / 2) / CELL_SIZE; // 注意:行号对应y
|
||||
*board_y = (rel_x + CELL_SIZE / 2) / CELL_SIZE; // 列号对应x
|
||||
|
||||
return (*board_x >= 0 && *board_x < BOARD_SIZE &&
|
||||
*board_y >= 0 && *board_y < BOARD_SIZE);
|
||||
}
|
||||
|
||||
// ACTION 回调:负责重绘
|
||||
static int action_cb(Ihandle *ih)
|
||||
{
|
||||
IupDrawBegin(ih);
|
||||
|
||||
int w, h;
|
||||
IupGetIntInt(ih, "DRAWSIZE", &w, &h);
|
||||
|
||||
set_draw_color(ih, 245, 245, 245); // Background (Raylib RAYWHITE approx)
|
||||
IupSetAttribute(ih, "DRAWSTYLE", "FILL");
|
||||
IupDrawRectangle(ih, 0, 0, w, h);
|
||||
|
||||
draw_board_iup(ih);
|
||||
draw_stones_iup(ih);
|
||||
draw_ui_iup(ih);
|
||||
|
||||
IupDrawEnd(ih);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
// 鼠标点击回调
|
||||
static int button_cb(Ihandle *ih, int button, int pressed, int x, int y, char *status)
|
||||
{
|
||||
if (button == IUP_BUTTON1 && pressed)
|
||||
{ // 左键按下
|
||||
if (game_over)
|
||||
return IUP_DEFAULT;
|
||||
|
||||
int board_x, board_y;
|
||||
if (screen_to_board(x, y, &board_x, &board_y))
|
||||
{
|
||||
if (have_space(board_x, board_y))
|
||||
{
|
||||
// 执行落子操作
|
||||
if (player_move(board_x, board_y, current_player_gui))
|
||||
{
|
||||
// 检查是否获胜
|
||||
if (check_win(board_x, board_y, current_player_gui))
|
||||
{
|
||||
game_over = 1;
|
||||
if (current_player_gui == PLAYER)
|
||||
{
|
||||
sprintf(status_message, "黑子获胜!");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(status_message, "白子获胜!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 切换玩家
|
||||
current_player_gui = (current_player_gui == PLAYER) ? AI : PLAYER;
|
||||
if (current_player_gui == PLAYER)
|
||||
{
|
||||
sprintf(status_message, "轮到黑子");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(status_message, "轮到白子");
|
||||
}
|
||||
}
|
||||
IupUpdate(ih); // 请求重绘
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(status_message, "无效位置!");
|
||||
IupUpdate(ih);
|
||||
}
|
||||
}
|
||||
}
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
// 键盘回调
|
||||
static int k_any_cb(Ihandle *ih, int c)
|
||||
{
|
||||
if (c == K_ESC)
|
||||
{
|
||||
gui_loop_running = 0;
|
||||
return IUP_CLOSE;
|
||||
}
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 初始化GUI
|
||||
* @details 初始化SDL3图形库和游戏界面组件:
|
||||
* - 初始化SDL视频子系统
|
||||
* - 创建游戏窗口(可调整大小)
|
||||
* - 创建SDL渲染器
|
||||
* - 初始化游戏状态和棋盘数据
|
||||
* @return 成功返回0,失败返回-1
|
||||
* @note 窗口标题为"五子棋游戏 - SDL3版本"
|
||||
* 窗口尺寸由WINDOW_WIDTH和WINDOW_HEIGHT定义
|
||||
* 失败时会自动清理已创建的资源
|
||||
*/
|
||||
int init_gui()
|
||||
{
|
||||
if (!SDL_Init(SDL_INIT_VIDEO))
|
||||
if (IupOpen(NULL, NULL) == IUP_ERROR)
|
||||
{
|
||||
printf("SDL初始化失败: %s\n", SDL_GetError());
|
||||
printf("IupOpen failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
window = SDL_CreateWindow(
|
||||
"五子棋游戏 - SDL3版本",
|
||||
WINDOW_WIDTH, WINDOW_HEIGHT,
|
||||
SDL_WINDOW_RESIZABLE);
|
||||
// 启用UTF-8模式,确保中文正常显示
|
||||
IupSetGlobal("UTF8MODE", "YES");
|
||||
|
||||
// 设置窗口位置到屏幕中央
|
||||
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
// 创建Canvas
|
||||
canvas = IupCanvas(NULL);
|
||||
IupSetAttribute(canvas, "ACTION", "action_cb");
|
||||
IupSetCallback(canvas, "ACTION", (Icallback)action_cb);
|
||||
IupSetCallback(canvas, "BUTTON_CB", (Icallback)button_cb);
|
||||
IupSetCallback(canvas, "K_ANY", (Icallback)k_any_cb);
|
||||
|
||||
if (!window)
|
||||
{
|
||||
printf("窗口创建失败: %s\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
return -1;
|
||||
}
|
||||
// 设置Canvas大小
|
||||
char size[32];
|
||||
sprintf(size, "%dx%d", WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
IupSetAttribute(canvas, "RASTERSIZE", size);
|
||||
IupSetAttribute(canvas, "EXPAND", "NO");
|
||||
|
||||
// 显示窗口
|
||||
SDL_ShowWindow(window);
|
||||
// 创建Dialog
|
||||
dlg = IupDialog(canvas);
|
||||
IupSetAttribute(dlg, "TITLE", "五子棋 - IUP版本");
|
||||
IupSetAttribute(dlg, "RESIZE", "NO");
|
||||
|
||||
renderer = SDL_CreateRenderer(window, NULL);
|
||||
if (!renderer)
|
||||
{
|
||||
printf("渲染器创建失败: %s\n", SDL_GetError());
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
return -1;
|
||||
}
|
||||
IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
|
||||
|
||||
// 初始化游戏状态
|
||||
// 初始化棋盘
|
||||
for (int i = 0; i < BOARD_SIZE; i++)
|
||||
{
|
||||
for (int j = 0; j < BOARD_SIZE; j++)
|
||||
@@ -73,8 +309,10 @@ int init_gui()
|
||||
}
|
||||
current_player_gui = PLAYER;
|
||||
game_over = 0;
|
||||
gui_loop_running = 1;
|
||||
sprintf(status_message, "游戏开始");
|
||||
|
||||
printf("图形化界面初始化成功!\n");
|
||||
printf("图形化界面初始化成功!(IUP)\n");
|
||||
printf("使用鼠标点击棋盘进行落子\n");
|
||||
printf("按ESC键退出游戏\n");
|
||||
|
||||
@@ -83,359 +321,89 @@ int init_gui()
|
||||
|
||||
/**
|
||||
* @brief 清理GUI资源
|
||||
* @details 按顺序释放所有SDL相关资源:
|
||||
* - 销毁SDL渲染器
|
||||
* - 销毁SDL窗口
|
||||
* - 退出SDL子系统
|
||||
* @note 函数会检查资源是否存在再进行释放
|
||||
* 释放后将指针设置为NULL防止重复释放
|
||||
* 程序退出时必须调用此函数避免内存泄漏
|
||||
*/
|
||||
void cleanup_gui()
|
||||
{
|
||||
if (renderer)
|
||||
if (dlg)
|
||||
{
|
||||
SDL_DestroyRenderer(renderer);
|
||||
renderer = NULL;
|
||||
IupDestroy(dlg);
|
||||
dlg = NULL;
|
||||
}
|
||||
if (window)
|
||||
{
|
||||
SDL_DestroyWindow(window);
|
||||
window = NULL;
|
||||
}
|
||||
SDL_Quit();
|
||||
IupClose();
|
||||
printf("图形化界面已关闭\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 渲染游戏画面
|
||||
* @details 完整的游戏画面渲染流程:
|
||||
* - 清空屏幕并设置背景色
|
||||
* - 绘制棋盘网格和标记点
|
||||
* - 绘制所有棋子
|
||||
* - 绘制UI界面元素
|
||||
* - 将渲染结果显示到屏幕
|
||||
* @note 使用双缓冲技术,通过SDL_RenderPresent显示最终结果
|
||||
* 背景色由GUI_COLOR_BACKGROUND定义
|
||||
* 每帧都会完全重绘整个画面
|
||||
*/
|
||||
void render_game()
|
||||
{
|
||||
// 清空屏幕 - 设置背景色
|
||||
SDL_Color bg_color = GUI_COLOR_BACKGROUND;
|
||||
SDL_SetRenderDrawColor(renderer, bg_color.r, bg_color.g, bg_color.b, bg_color.a);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// 绘制棋盘
|
||||
draw_board();
|
||||
|
||||
// 绘制棋子
|
||||
draw_stones();
|
||||
|
||||
// 绘制UI元素
|
||||
draw_ui_elements();
|
||||
|
||||
// 显示渲染结果
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 处理事件
|
||||
* @details 处理所有SDL事件并执行相应操作:
|
||||
* - SDL_EVENT_QUIT:用户关闭窗口
|
||||
* - SDL_EVENT_KEY_DOWN:键盘按键(ESC退出)
|
||||
* - SDL_EVENT_MOUSE_BUTTON_DOWN:鼠标点击落子
|
||||
* @return 继续运行返回1,退出返回0
|
||||
* @note 鼠标左键点击会转换为棋盘坐标并尝试落子
|
||||
* 落子后会检查胜负并切换玩家
|
||||
* 游戏结束后不再响应落子操作
|
||||
*/
|
||||
int handle_events()
|
||||
{
|
||||
SDL_Event event;
|
||||
if (!gui_loop_running)
|
||||
return 0;
|
||||
|
||||
while (SDL_PollEvent(&event))
|
||||
// 执行一次IUP循环迭代
|
||||
int ret = IupLoopStep();
|
||||
if (ret == IUP_CLOSE)
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_EVENT_QUIT:
|
||||
gui_running = 0;
|
||||
return 0;
|
||||
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
if (event.key.key == SDLK_ESCAPE)
|
||||
{
|
||||
gui_running = 0;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
if (event.button.button == SDL_BUTTON_LEFT && !game_over)
|
||||
{
|
||||
int board_x, board_y;
|
||||
if (screen_to_board(event.button.x, event.button.y, &board_x, &board_y))
|
||||
{
|
||||
if (have_space(board_x, board_y))
|
||||
{
|
||||
// 执行落子操作
|
||||
if (player_move(board_x, board_y, current_player_gui))
|
||||
{
|
||||
// 检查是否获胜
|
||||
if (check_win(board_x, board_y, current_player_gui))
|
||||
{
|
||||
game_over = 1;
|
||||
if (current_player_gui == PLAYER)
|
||||
{
|
||||
sprintf(status_message, "游戏结束 - 黑子获胜!");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(status_message, "游戏结束 - 白子获胜!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 切换玩家
|
||||
current_player_gui = (current_player_gui == PLAYER) ? AI : PLAYER;
|
||||
if (current_player_gui == PLAYER)
|
||||
{
|
||||
sprintf(status_message, "轮到黑子下棋");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(status_message, "轮到白子下棋");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(status_message, "该位置已有棋子,请选择其他位置");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
gui_loop_running = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 如果窗口被关闭(点X)
|
||||
// 注意:IupLoopStep会自动处理窗口关闭并返回IUP_CLOSE,除非定义了CLOSE_CB
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 绘制棋盘
|
||||
* @details 绘制15x15的五子棋棋盘,包括:
|
||||
* - 横竖交叉的网格线
|
||||
* - 天元点(棋盘中心的标记点)
|
||||
* - 四个星位(棋盘上的定位点)
|
||||
* @note 使用SDL3渲染器绘制线条和填充矩形
|
||||
* 棋盘线条颜色由GUI_COLOR_BOARD_LINE定义
|
||||
* 天元点和星位用黑色小矩形标记
|
||||
* @brief 渲染游戏画面
|
||||
*/
|
||||
void render_game()
|
||||
{
|
||||
// 主动刷新Canvas
|
||||
// 注意:频繁调用IupUpdate可能会导致闪烁或高CPU占用,但在单线程循环模型中通常是必要的
|
||||
// 以确保动画或状态更新能及时反映。
|
||||
// 在我们的例子中,主要依靠 button_cb 触发 IupUpdate。
|
||||
// 但为了兼容原来的循环结构,我们可以保持这个函数。
|
||||
// IupUpdate(canvas);
|
||||
// 实际上不需要每一帧都 Update,只有状态变了才需要。
|
||||
// 原来的Raylib代码是每帧都重绘。为了性能,这里我们什么都不做,让事件驱动。
|
||||
// 除非有外部事件改变了游戏状态(比如网络消息),那时应该调用 IupUpdate。
|
||||
// 鉴于目前是本地PVP/AI,所有状态改变都在 button_cb 里,那里已经调用了 IupUpdate。
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 绘制棋盘 (保留空函数以兼容接口,实际绘图在 action_cb 中)
|
||||
*/
|
||||
void draw_board()
|
||||
{
|
||||
SDL_Color line_color = GUI_COLOR_BOARD_LINE;
|
||||
SDL_SetRenderDrawColor(renderer, line_color.r, line_color.g, line_color.b, line_color.a);
|
||||
|
||||
// 绘制横线
|
||||
for (int i = 0; i < BOARD_SIZE; i++)
|
||||
{
|
||||
int y = BOARD_OFFSET_Y + i * CELL_SIZE;
|
||||
SDL_RenderLine(renderer,
|
||||
BOARD_OFFSET_X, y,
|
||||
BOARD_OFFSET_X + (BOARD_SIZE - 1) * CELL_SIZE, y);
|
||||
}
|
||||
|
||||
// 绘制竖线
|
||||
for (int j = 0; j < BOARD_SIZE; j++)
|
||||
{
|
||||
int x = BOARD_OFFSET_X + j * CELL_SIZE;
|
||||
SDL_RenderLine(renderer,
|
||||
x, BOARD_OFFSET_Y,
|
||||
x, BOARD_OFFSET_Y + (BOARD_SIZE - 1) * CELL_SIZE);
|
||||
}
|
||||
|
||||
// 绘制天元点和星位
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
int center = BOARD_SIZE / 2;
|
||||
|
||||
// 天元点
|
||||
int center_x = BOARD_OFFSET_X + center * CELL_SIZE;
|
||||
int center_y = BOARD_OFFSET_Y + center * CELL_SIZE;
|
||||
SDL_FRect center_rect = {center_x - 2, center_y - 2, 4, 4};
|
||||
SDL_RenderFillRect(renderer, ¢er_rect);
|
||||
|
||||
// 四个星位
|
||||
int star_offset = 3;
|
||||
int positions[][2] = {
|
||||
{center - star_offset, center - star_offset},
|
||||
{center + star_offset, center - star_offset},
|
||||
{center - star_offset, center + star_offset},
|
||||
{center + star_offset, center + star_offset}};
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int x = BOARD_OFFSET_X + positions[i][1] * CELL_SIZE;
|
||||
int y = BOARD_OFFSET_Y + positions[i][0] * CELL_SIZE;
|
||||
SDL_FRect star_rect = {x - 1, y - 1, 2, 2};
|
||||
SDL_RenderFillRect(renderer, &star_rect);
|
||||
}
|
||||
// Implemented in action_cb
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 绘制棋子
|
||||
* @details 遍历整个棋盘数组,绘制所有已落下的棋子:
|
||||
* - 黑子:使用GUI_COLOR_BLACK_STONE颜色
|
||||
* - 白子:使用GUI_COLOR_WHITE_STONE颜色
|
||||
* - 每个棋子都有边框:使用GUI_COLOR_STONE_BORDER颜色
|
||||
* @note 棋子绘制为圆形,半径由STONE_RADIUS定义
|
||||
* 通过draw_circle函数实现圆形绘制
|
||||
* 棋子位置根据棋盘坐标和CELL_SIZE计算屏幕坐标
|
||||
* @brief 绘制棋子 (保留空函数以兼容接口)
|
||||
*/
|
||||
void draw_stones()
|
||||
{
|
||||
for (int i = 0; i < BOARD_SIZE; i++)
|
||||
{
|
||||
for (int j = 0; j < BOARD_SIZE; j++)
|
||||
{
|
||||
if (board[i][j] != EMPTY)
|
||||
{
|
||||
int x = BOARD_OFFSET_X + j * CELL_SIZE;
|
||||
int y = BOARD_OFFSET_Y + i * CELL_SIZE;
|
||||
|
||||
// 设置棋子颜色
|
||||
SDL_Color stone_color, border_color;
|
||||
if (board[i][j] == PLAYER || board[i][j] == PLAYER1)
|
||||
{
|
||||
stone_color = (SDL_Color)GUI_COLOR_BLACK_STONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
stone_color = (SDL_Color)GUI_COLOR_WHITE_STONE;
|
||||
}
|
||||
border_color = (SDL_Color)GUI_COLOR_STONE_BORDER;
|
||||
|
||||
// 绘制圆形棋子
|
||||
draw_circle(x, y, STONE_RADIUS, stone_color);
|
||||
draw_circle(x, y, STONE_RADIUS, border_color);
|
||||
|
||||
// 重新绘制内部
|
||||
draw_circle(x, y, STONE_RADIUS - 1, stone_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Implemented in action_cb
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 绘制圆形
|
||||
* @param center_x 圆心X坐标
|
||||
* @param center_y 圆心Y坐标
|
||||
* @param radius 半径
|
||||
* @param color 颜色
|
||||
* @details 使用像素级绘制实现圆形:
|
||||
* - 遍历圆形外接矩形内的所有像素点
|
||||
* - 计算每个像素到圆心的距离
|
||||
* - 距离小于等于半径的像素点进行着色
|
||||
* @note 采用暴力算法,性能较低但实现简单
|
||||
* 适用于绘制棋子等小尺寸圆形
|
||||
* SDL3没有内置圆形绘制函数,需要自实现
|
||||
*/
|
||||
void draw_circle(int center_x, int center_y, int radius, SDL_Color color)
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
|
||||
|
||||
for (int w = 0; w < radius * 2; w++)
|
||||
{
|
||||
for (int h = 0; h < radius * 2; h++)
|
||||
{
|
||||
int dx = radius - w;
|
||||
int dy = radius - h;
|
||||
if ((dx * dx + dy * dy) <= (radius * radius))
|
||||
{
|
||||
SDL_RenderPoint(renderer, center_x + dx, center_y + dy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 绘制UI元素
|
||||
* @brief 绘制UI元素 (保留空函数以兼容接口)
|
||||
*/
|
||||
void draw_ui_elements()
|
||||
{
|
||||
// 绘制状态信息区域背景
|
||||
SDL_SetRenderDrawColor(renderer, 200, 200, 200, 255);
|
||||
SDL_FRect info_rect = {BOARD_OFFSET_X + BOARD_SIZE * CELL_SIZE + 20, BOARD_OFFSET_Y, 200, 100};
|
||||
SDL_RenderFillRect(renderer, &info_rect);
|
||||
|
||||
// 绘制边框
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_RenderRect(renderer, &info_rect);
|
||||
|
||||
// 这里可以添加文字渲染,但SDL3需要额外的字体库
|
||||
// 暂时用简单的图形表示当前玩家
|
||||
int indicator_x = info_rect.x + 20;
|
||||
int indicator_y = info_rect.y + 20;
|
||||
|
||||
if (!game_over)
|
||||
{
|
||||
if (current_player_gui == PLAYER)
|
||||
{
|
||||
// 黑子回合
|
||||
draw_circle(indicator_x, indicator_y, 10, (SDL_Color){0, 0, 0, 255});
|
||||
}
|
||||
else
|
||||
{
|
||||
// 白子回合
|
||||
draw_circle(indicator_x, indicator_y, 10, (SDL_Color){255, 255, 255, 255});
|
||||
// 绘制当前玩家指示器(简单的矩形代替圆形)
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_FRect indicator_rect = {indicator_x - 10, indicator_y - 10, 20, 20};
|
||||
SDL_RenderFillRect(renderer, &indicator_rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 屏幕坐标转棋盘坐标
|
||||
* @param screen_x 屏幕X坐标
|
||||
* @param screen_y 屏幕Y坐标
|
||||
* @param board_x 输出棋盘X坐标
|
||||
* @param board_y 输出棋盘Y坐标
|
||||
* @return 转换成功返回1,失败返回0
|
||||
* @details 坐标转换算法:
|
||||
* - 减去棋盘偏移量得到相对坐标
|
||||
* - 加上半个格子尺寸实现就近取整
|
||||
* - 除以格子尺寸得到棋盘坐标
|
||||
* - 检查坐标是否在有效范围内
|
||||
* @note 使用就近取整算法,点击格子中心附近都会定位到该格子
|
||||
* 坐标范围检查确保不会越界访问棋盘数组
|
||||
*/
|
||||
int screen_to_board(int screen_x, int screen_y, int *board_x, int *board_y)
|
||||
{
|
||||
int rel_x = screen_x - BOARD_OFFSET_X;
|
||||
int rel_y = screen_y - BOARD_OFFSET_Y;
|
||||
|
||||
*board_x = (rel_x + CELL_SIZE / 2) / CELL_SIZE;
|
||||
*board_y = (rel_y + CELL_SIZE / 2) / CELL_SIZE;
|
||||
|
||||
return (*board_x >= 0 && *board_x < BOARD_SIZE &&
|
||||
*board_y >= 0 && *board_y < BOARD_SIZE);
|
||||
// Implemented in action_cb
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 显示消息
|
||||
* @param message 要显示的消息
|
||||
* @details 消息显示功能:
|
||||
* - 将消息复制到全局状态消息缓冲区
|
||||
* - 同时在控制台输出消息内容
|
||||
* - 确保字符串安全复制,防止缓冲区溢出
|
||||
* @note 消息会存储在status_message全局变量中
|
||||
* 字符串长度限制为缓冲区大小减1
|
||||
* 消息可用于游戏状态提示和错误信息显示
|
||||
*/
|
||||
void show_message(const char *message)
|
||||
{
|
||||
strncpy(status_message, message, sizeof(status_message) - 1);
|
||||
status_message[sizeof(status_message) - 1] = '\0';
|
||||
if (canvas)
|
||||
IupUpdate(canvas);
|
||||
printf("%s\n", message);
|
||||
}
|
||||
+4
-4
@@ -8,13 +8,13 @@
|
||||
* gcc -std=c17 -o gobang_console.exe *.c -lws2_32
|
||||
.\gobang_console.exe
|
||||
*
|
||||
* !图形化版本编译(需要SDL3):
|
||||
* gcc -std=c17 -o gobang_gui.exe *.c -ID:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\include -LD:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\lib -lSDL3 -lws2_32
|
||||
copy "D:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32\bin\SDL3.dll" .
|
||||
* !图形化版本编译(需要IUP库):
|
||||
* gcc -std=c17 -o gobang_gui.exe *.c -ID:\settings\settings\libs\iup-3.31_Win64_dllw6_lib\include -LD:\settings\settings\libs\iup-3.31_Win64_dllw6_lib -liup -lws2_32
|
||||
copy "D:\settings\settings\libs\iup-3.31_Win64_dllw6_lib\iup.dll" .
|
||||
.\gobang_gui.exe
|
||||
*
|
||||
* @note gcc 为编译器,添加了-lws2_32链接Windows网络库
|
||||
* @note SDL3 的路径:D:\settings\SDL\SDL3-3.2.22\x86_64-w64-mingw32
|
||||
* @note IUP 的路径:D:\settings\settings\libs\iup-3.31_Win64_dllw6_lib
|
||||
* @brief & "D:\Program Files (x86)\NSIS\makensis.exe" "installer\\installer.nsi"
|
||||
* @brief & "D:\Program Files (x86)\Inno Setup 6\iscc.exe" installer\\installer.iss
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user