better example
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@52 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
979fb4f708
commit
149b49a81f
2 changed files with 12 additions and 20 deletions
16
GNUmakefile
16
GNUmakefile
|
|
@ -12,8 +12,8 @@ L_LDFLAGS = $(LDFLAGS)
|
||||||
L_LIBS = $(LIBS)
|
L_LIBS = $(LIBS)
|
||||||
|
|
||||||
E_CFLAGS = $(CFLAGS)
|
E_CFLAGS = $(CFLAGS)
|
||||||
E_LDFLAGS = $(LDFLAGS)
|
E_LDFLAGS = $(LDFLAGS) -Lsrc
|
||||||
E_LIBS = $(LIBS)
|
E_LIBS = $(LIBS) -lMw
|
||||||
|
|
||||||
L_OBJS = src/ds.o src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o
|
L_OBJS = src/ds.o src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o
|
||||||
L_OBJS += src/window.o src/button.o
|
L_OBJS += src/window.o src/button.o
|
||||||
|
|
@ -35,16 +35,14 @@ L_CFLAGS += -DUSE_X11
|
||||||
L_OBJS += src/x11.o
|
L_OBJS += src/x11.o
|
||||||
L_LIBS += -lX11
|
L_LIBS += -lX11
|
||||||
|
|
||||||
LIB = lib
|
|
||||||
SO = .so
|
SO = .so
|
||||||
EXEC =
|
EXEC =
|
||||||
else ifeq ($(WINDOWS),1)
|
else ifeq ($(WINDOWS),1)
|
||||||
L_CFLAGS += -DUSE_GDI
|
L_CFLAGS += -DUSE_GDI
|
||||||
L_LDFLAGS += -Wl,--out-implib,src/Mw.lib
|
L_LDFLAGS += -Wl,--out-implib,src/libMw.lib
|
||||||
L_OBJS += src/gdi.o
|
L_OBJS += src/gdi.o
|
||||||
L_LIBS += -lgdi32
|
L_LIBS += -lgdi32
|
||||||
|
|
||||||
LIB =
|
|
||||||
SO = .dll
|
SO = .dll
|
||||||
EXEC = .exe
|
EXEC = .exe
|
||||||
endif
|
endif
|
||||||
|
|
@ -52,17 +50,17 @@ endif
|
||||||
.PHONY: all format clean lib examples
|
.PHONY: all format clean lib examples
|
||||||
|
|
||||||
all: lib examples
|
all: lib examples
|
||||||
lib: src/$(LIB)Mw$(SO)
|
lib: src/libMw$(SO)
|
||||||
examples: examples/example$(EXEC)
|
examples: examples/example$(EXEC)
|
||||||
|
|
||||||
format:
|
format:
|
||||||
clang-format --verbose -i $(shell find src include -name "*.c" -or -name "*.h")
|
clang-format --verbose -i $(shell find src include -name "*.c" -or -name "*.h")
|
||||||
|
|
||||||
src/$(LIB)Mw$(SO): $(L_OBJS)
|
src/libMw$(SO): $(L_OBJS)
|
||||||
$(CC) $(L_LDFLAGS) -shared -o $@ $(L_OBJS) $(L_LIBS)
|
$(CC) $(L_LDFLAGS) -shared -o $@ $(L_OBJS) $(L_LIBS)
|
||||||
|
|
||||||
examples/%$(EXEC): examples/%.o src/$(LIB)Mw$(SO)
|
examples/%$(EXEC): examples/%.o src/libMw$(SO)
|
||||||
$(CC) $(E_LDFLAGS) -o $@ $< src/$(LIB)Mw$(SO) $(E_LIBS)
|
$(CC) $(E_LDFLAGS) -o $@ $< $(E_LIBS)
|
||||||
|
|
||||||
src/%.o: src/%.c
|
src/%.o: src/%.c
|
||||||
$(CC) $(L_CFLAGS) -c -o $@ $<
|
$(CC) $(L_CFLAGS) -c -o $@ $<
|
||||||
|
|
|
||||||
|
|
@ -11,20 +11,14 @@ void handler(MwWidget handle, void* user_data, void* call_data){
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
int y, x;
|
MwWidget window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400,
|
||||||
MwWidget window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 260,
|
|
||||||
MwNtitle, "hello world",
|
MwNtitle, "hello world",
|
||||||
NULL);
|
NULL);
|
||||||
|
MwWidget button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 300, 300,
|
||||||
for(y = 0; y < 5; y++){
|
|
||||||
for(x = 0; x < 2; x++){
|
|
||||||
MwWidget button = MwVaCreateWidget(MwButtonClass, "button", window, 5 + 195 * x, 5 + 50 * y, 195, 50,
|
|
||||||
MwNtext, "lorem ipsum",
|
MwNtext, "lorem ipsum",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
MwAddUserHandler(button, MwNactivateHandler, handler, NULL);
|
MwAddUserHandler(button, MwNactivateHandler, handler, NULL);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MwLoop(window);
|
MwLoop(window);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue