mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-11 20:03:29 +00:00
done
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@761 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -18,7 +18,7 @@ extern "C" {
|
||||
* @param str String
|
||||
* @return String
|
||||
*/
|
||||
MWDECL char* MwStringDupliacte(const char* str);
|
||||
MWDECL char* MwStringDuplicate(const char* str);
|
||||
|
||||
/*!
|
||||
* @brief Concatenates 2 strings
|
||||
|
||||
@@ -72,7 +72,7 @@ MwInline void MwListBoxInsert(MwWidget handle, int index, void* packet) {
|
||||
* @param index Index
|
||||
*/
|
||||
MwInline void MwListBoxDelete(MwWidget handle, int index) {
|
||||
MwVaWidgetExecute(handle, "mwListboxDelete", NULL, index);
|
||||
MwVaWidgetExecute(handle, "mwListBoxDelete", NULL, index);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -19,6 +19,36 @@ extern "C" {
|
||||
*/
|
||||
MWDECL MwClass MwTreeViewClass;
|
||||
|
||||
/*!
|
||||
* @brief Adds item to the treeview
|
||||
* @param handle Widget
|
||||
* @parma parent Parent
|
||||
* @parma pixmap Pixmap
|
||||
* @param item Item
|
||||
*/
|
||||
MwInline void* MwTreeViewAdd(MwWidget handle, void* parent, MwLLPixmap pixmap, const char* item) {
|
||||
void* out;
|
||||
MwVaWidgetExecute(handle, "mwTreeViewAdd", &out, parent, pixmap, item);
|
||||
return out;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Deletes item from the treeview
|
||||
* @param handle Widget
|
||||
* @param item Item
|
||||
*/
|
||||
MwInline void MwTreeViewDelete(MwWidget handle, void* item) {
|
||||
MwVaWidgetExecute(handle, "mwTreeViewDelete", NULL, item);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Resets the treeview
|
||||
* @param handle Widget
|
||||
*/
|
||||
MwInline void MwTreeViewReset(MwWidget handle) {
|
||||
MwVaWidgetExecute(handle, "mwTreeViewReset", NULL);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -60,7 +60,7 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) {
|
||||
free(entry);
|
||||
return NULL;
|
||||
}
|
||||
entry->name = MwStringDupliacte(dir->ffd.cFileName);
|
||||
entry->name = MwStringDuplicate(dir->ffd.cFileName);
|
||||
|
||||
if(dir->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
entry->type = MwDIRECTORY_DIRECTORY;
|
||||
@@ -81,7 +81,7 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) {
|
||||
free(entry);
|
||||
return NULL;
|
||||
}
|
||||
entry->name = MwStringDupliacte(d->d_name);
|
||||
entry->name = MwStringDuplicate(d->d_name);
|
||||
|
||||
p = malloc(strlen(dir->base) + 1 + strlen(d->d_name) + 1);
|
||||
strcpy(p, dir->base);
|
||||
@@ -174,7 +174,7 @@ static void MwDirectoryJoinSingle(char* target, char* p) {
|
||||
|
||||
char* MwDirectoryJoin(char* a, char* b) {
|
||||
char* p = malloc(strlen(a) + 1 + strlen(b) + 1);
|
||||
char* bdup = MwStringDupliacte(b);
|
||||
char* bdup = MwStringDuplicate(b);
|
||||
char* b2 = bdup;
|
||||
int i;
|
||||
|
||||
|
||||
@@ -943,7 +943,7 @@ static char* MwLLGetClipboardImpl(MwLL handle) {
|
||||
|
||||
XGetWindowProperty(ev.xselection.display, ev.xselection.requestor, ev.xselection.property, 0, (~0L), 0, AnyPropertyType, &t, &format, &size, &N, (unsigned char**)&data);
|
||||
if(t == target) {
|
||||
r = MwStringDupliacte(data);
|
||||
r = MwStringDuplicate(data);
|
||||
XFree(data);
|
||||
}
|
||||
XDeleteProperty(ev.xselection.display, ev.xselection.requestor, ev.xselection.property);
|
||||
|
||||
@@ -106,7 +106,7 @@ static void llfocusouthandler(MwLL handle, void* data) {
|
||||
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
||||
MwWidget h = malloc(sizeof(*h));
|
||||
|
||||
h->name = MwStringDupliacte(name);
|
||||
h->name = MwStringDuplicate(name);
|
||||
|
||||
h->parent = parent;
|
||||
h->children = NULL;
|
||||
@@ -361,7 +361,7 @@ void MwSetText(MwWidget handle, const char* key, const char* value) {
|
||||
if(strcmp(key, MwNtitle) == 0) {
|
||||
MwLLSetTitle(handle->lowlevel, value);
|
||||
} else {
|
||||
char* v = MwStringDupliacte(value);
|
||||
char* v = MwStringDuplicate(value);
|
||||
|
||||
if(shgeti(handle->text, key) != -1) free(shget(handle->text, key));
|
||||
|
||||
|
||||
@@ -385,7 +385,7 @@ static void scan(MwWidget handle, const char* path, int record) {
|
||||
qsort(fc->entries, arrlen(fc->entries), sizeof(MwDirectoryEntry*), qsort_files);
|
||||
|
||||
if(record) {
|
||||
char* str = MwStringDupliacte(path);
|
||||
char* str = MwStringDuplicate(path);
|
||||
|
||||
while(arrlen(fc->history) > fc->history_seek) {
|
||||
free(fc->history[fc->history_seek]);
|
||||
@@ -403,7 +403,7 @@ static void scan(MwWidget handle, const char* path, int record) {
|
||||
}
|
||||
|
||||
if(fc->path != NULL) free(fc->path);
|
||||
fc->path = MwStringDupliacte(path);
|
||||
fc->path = MwStringDuplicate(path);
|
||||
|
||||
MwVaApply(fc->addr,
|
||||
MwNtext, path,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
char* MwStringDupliacte(const char* str) {
|
||||
char* MwStringDuplicate(const char* str) {
|
||||
char* r = malloc(strlen(str) + 1);
|
||||
strcpy(r, str);
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ static void prop_change(MwWidget handle, const char* prop) {
|
||||
|
||||
static void mwComboBoxAddImpl(MwWidget handle, int index, const char* text) {
|
||||
MwComboBox cb = handle->internal;
|
||||
char* t = MwStringDupliacte(text);
|
||||
char* t = MwStringDuplicate(text);
|
||||
|
||||
if(index == -1) index = arrlen(cb->list);
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ int MwListBoxPacketInsert(MwListBoxPacket* packet, int index) {
|
||||
}
|
||||
|
||||
void MwListBoxPacketSet(MwListBoxPacket* packet, int index, int col, const char* text) {
|
||||
char* t = text == NULL ? NULL : MwStringDupliacte(text);
|
||||
char* t = text == NULL ? NULL : MwStringDuplicate(text);
|
||||
int i;
|
||||
|
||||
if(col == -1) col = arrlen(packet->names[index]);
|
||||
@@ -410,7 +410,7 @@ static void mwListBoxInsertImpl(MwWidget handle, int index, MwListBoxPacket* pac
|
||||
entry.name = NULL;
|
||||
for(j = 0; j < max; j++) {
|
||||
if(arrlen(packet->names[i]) > j && packet->names[i][j] != NULL) {
|
||||
name = MwStringDupliacte(packet->names[i][j]);
|
||||
name = MwStringDuplicate(packet->names[i][j]);
|
||||
arrput(entry.name, name);
|
||||
} else {
|
||||
arrput(entry.name, NULL);
|
||||
@@ -494,8 +494,6 @@ static void mwListBoxSetWidthImpl(MwWidget handle, int index, int width) {
|
||||
}
|
||||
|
||||
static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {
|
||||
(void)out;
|
||||
|
||||
if(strcmp(name, "mwListBoxDelete") == 0) {
|
||||
int index = va_arg(va, int);
|
||||
mwListBoxDeleteImpl(handle, index);
|
||||
|
||||
@@ -179,7 +179,7 @@ static void mouse_up(MwWidget handle, void* ptr) {
|
||||
static MwMenu mwMenuAddImpl(MwWidget handle, MwMenu menu, const char* name) {
|
||||
MwMenu m = menu == NULL ? handle->internal : menu;
|
||||
MwMenu new = malloc(sizeof(*new));
|
||||
new->name = MwStringDupliacte(name);
|
||||
new->name = MwStringDuplicate(name);
|
||||
new->sub = NULL;
|
||||
new->wsub = NULL;
|
||||
new->keep = 0;
|
||||
|
||||
@@ -282,37 +282,12 @@ static void resize(MwWidget handle) {
|
||||
|
||||
static int create(MwWidget handle) {
|
||||
MwTreeView tv = malloc(sizeof(*tv));
|
||||
MwTreeViewEntry e, e2, e3;
|
||||
memset(tv, 0, sizeof(*tv));
|
||||
|
||||
handle->internal = tv;
|
||||
|
||||
MwSetDefault(handle);
|
||||
|
||||
e3.label = MwStringDupliacte("hello");
|
||||
e3.pixmap = NULL;
|
||||
e3.tree = NULL;
|
||||
e3.opened = 1;
|
||||
e3.selected = 0;
|
||||
e3.click_time = 0;
|
||||
|
||||
e2.label = MwStringDupliacte("hello");
|
||||
e2.pixmap = NULL;
|
||||
e2.tree = NULL;
|
||||
e2.opened = 1;
|
||||
e2.selected = 0;
|
||||
e2.click_time = 0;
|
||||
arrput(e2.tree, e3);
|
||||
|
||||
e.label = MwStringDupliacte("hello");
|
||||
e.pixmap = NULL;
|
||||
e.tree = NULL;
|
||||
e.opened = 1;
|
||||
e.selected = 0;
|
||||
e.click_time = 0;
|
||||
arrput(e.tree, e2);
|
||||
arrput(tv->tree, e);
|
||||
|
||||
MwSetInteger(handle, MwNsingleClickSelectable, 0);
|
||||
MwSetInteger(handle, MwNleftPadding, 0);
|
||||
|
||||
@@ -343,6 +318,44 @@ static void prop_change(MwWidget handle, const char* prop) {
|
||||
if(strcmp(prop, MwNwidth) == 0 || strcmp(prop, MwNheight) == 0) resize(handle);
|
||||
}
|
||||
|
||||
static void* mwTreeViewAddImpl(MwWidget handle, void* parent, MwLLPixmap pixmap, const char* item){
|
||||
MwTreeView tv = handle->internal;
|
||||
MwTreeViewEntry t;
|
||||
|
||||
t.label = MwStringDuplicate(item);
|
||||
t.pixmap = pixmap;
|
||||
t.selected = 0;
|
||||
t.opened = 1;
|
||||
t.click_time = 0;
|
||||
|
||||
if(parent == NULL){
|
||||
arrput(tv->tree, t);
|
||||
}
|
||||
resize(handle);
|
||||
}
|
||||
|
||||
static void mwTreeViewDeleteImpl(MwWidget handle, void* item){
|
||||
}
|
||||
|
||||
static void mwTreeViewResetImpl(MwWidget handle){
|
||||
}
|
||||
|
||||
static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {
|
||||
if(strcmp(name, "mwTreeViewAdd") == 0){
|
||||
void* parent = va_arg(va, void*);
|
||||
MwLLPixmap pixmap = va_arg(va, MwLLPixmap);
|
||||
const char* item = va_arg(va, const char*);
|
||||
*(void**)out = mwTreeViewAddImpl(handle, parent, pixmap, item);
|
||||
}
|
||||
if(strcmp(name, "mwTreeViewDelete") == 0){
|
||||
void* item = va_arg(va, void*);
|
||||
mwTreeViewDeleteImpl(handle, item);
|
||||
}
|
||||
if(strcmp(name, "mwTreeViewReset") == 0){
|
||||
mwTreeViewResetImpl(handle);
|
||||
}
|
||||
}
|
||||
|
||||
static void tick(MwWidget handle) {
|
||||
MwTreeView tv = handle->internal;
|
||||
|
||||
@@ -363,7 +376,7 @@ MwClassRec MwTreeViewClassRec = {
|
||||
NULL, /* mouse_up */
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
NULL, /* execute */
|
||||
func_handler, /* execute */
|
||||
tick, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
|
||||
Reference in New Issue
Block a user