Usermode/AxWin3 - resources and bugfixes
authorJohn Hodge <[email protected]>
Mon, 18 Feb 2013 15:49:44 +0000 (23:49 +0800)
committerJohn Hodge <[email protected]>
Mon, 18 Feb 2013 15:49:44 +0000 (23:49 +0800)
Usermode/Applications/axwin3_src/WM/Makefile
Usermode/Applications/axwin3_src/WM/renderers/richtext.c
Usermode/Applications/axwin3_src/WM/resources/toolbar_new.png [new file with mode: 0755]
Usermode/Applications/gui_ate_src/main.c
Usermode/Applications/gui_ate_src/strings.c

index 1112ffe..4150e94 100644 (file)
@@ -23,13 +23,31 @@ OBJ += renderers/widget/textinput.o
 OBJ += renderers/widget/spacer.o
 OBJ += renderers/widget/subwin.o
 
+PNGIMAGES := toolbar_new.png
+
 LDFLAGS += -limage_sif -luri -lnet -lunicode
 
+IMG2SIF = ../../../../Tools/img2sif
+
 -include ../../Makefile.tpl
 
+.PHONY: install_resources
+
+install: install_resources
+
 #all: resources/LogoSmall.sif.res.h
 
 %.res.h: % Makefile
        echo "#define RESOURCE_$(notdir $<) \\"| sed -e 's/\./_/g' > $@
        base64 $< | sed -e 's/.*/"&"\\/' >> $@
        echo "" >> $@
+
+$(IMG2SIF):
+       $(MAKE) -C $(dir $(IMG2SIF)) img2sif
+
+install_%.sif: resources/%.png
+       @echo img2sif resources/$*.png
+       @$(IMG2SIF) resources/$*.png resources/.$*.sif
+       @$(xCP) resources/.$*.sif $(DISTROOT)/$(DIR)/$*.sif
+
+install_resources: $(IMG2SIF) $(addprefix install_,$(PNGIMAGES:%.png=%.sif))
index a72cac3..8f69c9c 100644 (file)
@@ -87,7 +87,7 @@ tWindow *Renderer_RichText_Create(int Flags)
 
 void Renderer_RichText_Destroy(tWindow *Window)
 {
-       tRichText_Window        *info = ret->RendererInfo;
+       tRichText_Window        *info = Window->RendererInfo;
 
        // TODO: Is locking needed? WM_Destroy should have taken us off the render tree
        while( info->FirstLine )
diff --git a/Usermode/Applications/axwin3_src/WM/resources/toolbar_new.png b/Usermode/Applications/axwin3_src/WM/resources/toolbar_new.png
new file mode 100755 (executable)
index 0000000..8644344
Binary files /dev/null and b/Usermode/Applications/axwin3_src/WM/resources/toolbar_new.png differ
index 3a929c2..a6bbee6 100644 (file)
@@ -108,9 +108,18 @@ int TextArea_MouseHandler(tHWND Window, int bPress, int Button, int Row, int Col
 void add_toolbar_button(tAxWin3_Widget *Toolbar, const char *Ident, tAxWin3_Widget_FireCb Callback)
 {
        tAxWin3_Widget *btn = AxWin3_Widget_AddWidget(Toolbar, ELETYPE_BUTTON, ELEFLAG_NOSTRETCH, Ident);
-       tAxWin3_Widget *txt = AxWin3_Widget_AddWidget(btn, ELETYPE_TEXT, 0, Ident);
-       // TODO: Get image / text using `Ident` as a lookup key
-       AxWin3_Widget_SetText(txt, getstr(Ident));
+       const char *img = getimg(Ident);
+       if( img )
+       {
+               tAxWin3_Widget *txt = AxWin3_Widget_AddWidget(btn, ELETYPE_IMAGE, 0, Ident);
+               AxWin3_Widget_SetText(txt, img);
+               // TODO: tooltip?
+       }
+       else
+       {
+               tAxWin3_Widget *txt = AxWin3_Widget_AddWidget(btn, ELETYPE_TEXT, 0, Ident);
+               AxWin3_Widget_SetText(txt, getstr(Ident));
+       }
        AxWin3_Widget_SetFireHandler(btn, Callback);
 }
 
index a699993..96b6c0e 100644 (file)
@@ -28,6 +28,10 @@ const struct keyval_str      gaDisplayStrings[] = {
        {"BtnReplace", "Replace"},
        };
 const int      ciNumDisplayStrings = sizeof(gaDisplayStrings)/sizeof(gaDisplayStrings[0]);
+const struct keyval_str        gaImageStrings[] = {
+       {"BtnNew", "file:///Acess/Apps/AxWin/3.0/toolbar_new.sif"}
+       };
+const int      ciNumImageStrings = sizeof(gaImageStrings)/sizeof(gaImageStrings[0]);
 
 const char *getstr(const char *key)
 {
@@ -42,5 +46,11 @@ const char *getstr(const char *key)
 
 const char *getimg(const char *key)
 {
-       return "";
+        int    i;
+       for(i = 0; i < ciNumImageStrings; i ++)
+       {
+               if( strcmp(key, gaImageStrings[i].key) == 0 )
+                       return gaImageStrings[i].val;
+       }
+       return NULL;
 }

UCC git Repository :: git.ucc.asn.au