Update of /cvsroot/cgui/cgui/src
In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv9843/src
Modified Files:
Tag: Branch_CGUI_1-6-7
browsbar.c obtext.c
Log Message:
added features 1990500 1990492 and 1990491
Index: browsbar.c
===================================================================
RCS file: /cvsroot/cgui/cgui/src/browsbar.c,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** browsbar.c 2 Mar 2003 17:45:16 -0000 1.1
--- browsbar.c 11 Jun 2008 07:18:29 -0000 1.1.4.1
***************
*** 221,224 ****
--- 221,225 ----
bb->handle_pos = MIN(*bb->pos * scale + 0.5, bb->sliding_area_length - bb->handle_length);
bb->b->inactive = 0;
+ bb->handle_length = MAX(bb->handle_length, 20);
}
return bb->b->inactive == 0;
Index: obtext.c
===================================================================
RCS file: /cvsroot/cgui/cgui/src/obtext.c,v
retrieving revision 1.1.2.3.2.6
retrieving revision 1.1.2.3.2.7
diff -C2 -d -r1.1.2.3.2.6 -r1.1.2.3.2.7
*** obtext.c 6 Sep 2007 18:57:24 -0000 1.1.2.3.2.6
--- obtext.c 11 Jun 2008 07:18:29 -0000 1.1.2.3.2.7
***************
*** 60,63 ****
--- 60,67 ----
int br;
int dirty;
+ int hilite;
+ int hrow;
+ int bgcolor;
+ int textcolor;
} t_textob;
***************
*** 238,242 ****
t_textob *to;
char **p;
! int y, clip_x2, clip_y2, fixw = 0;
BITMAP *bmp;
--- 242,246 ----
t_textob *to;
char **p;
! int y, clip_x2, clip_y2, fixw = 0, highlightcolor = -1, textcolor, row_index;
BITMAP *bmp;
***************
*** 257,266 ****
/* 3 pixels for the frame */
set_clip_rect(bmp, bmp->cl, bmp->ct, b->x2 - 3, b->y2 - 3);
for (y = b->y1 + 3, p = to->page + to->sti; *p && y < b->y2; p++, y += to->rh) {
if (to->fixfont) {
! FixTextOut(bmp, b->font, *p, b->x1 + 2, y, cgui_black, cgui_gray, fixw);
} else {
! textout_ex(bmp, b->font, *p, b->x1 + 2, y, cgui_black, -1);
}
}
set_clip_rect(bmp, bmp->cl, bmp->ct, clip_x2, clip_y2);
--- 261,282 ----
/* 3 pixels for the frame */
set_clip_rect(bmp, bmp->cl, bmp->ct, b->x2 - 3, b->y2 - 3);
+ textcolor = cgui_black;
+ if (to->hilite) {
+ rectfill(bmp, b->x1+1, b->y1+(to->hrow*to->rh)+3, b->x2, b->y1+(to->hrow*to->rh+to->rh)+2, to->bgcolor);
+ highlightcolor = to->textcolor;
+ }
+ row_index = 0;
for (y = b->y1 + 3, p = to->page + to->sti; *p && y < b->y2; p++, y += to->rh) {
+ if (row_index == to->hrow && highlightcolor != -1) {
+ textcolor = highlightcolor;
+ } else {
+ textcolor = cgui_black;
+ }
if (to->fixfont) {
! FixTextOut(bmp, b->font, *p, b->x1 + 2, y, textcolor, cgui_gray, fixw);
} else {
! textout_ex(bmp, b->font, *p, b->x1 + 2, y, textcolor, -1);
}
+ row_index++;
}
set_clip_rect(bmp, bmp->cl, bmp->ct, clip_x2, clip_y2);
***************
*** 379,411 ****
}
! static int FetchTextBoxText(t_object *b)
{
t_textob *to;
int h;
! if (fetching_in_progress) {
! fetching_in_progress = 0;
! to = b->appdata;
! DestroyPage(to->page);
! Release(to->s);
! if (to->preformat)
! CopyPreformattedText(to, new_string);
! else
! CopyText(to, new_string);
! to->page = MakePage(b->font, to->s, to->width + b->rex - 4,
! to->preformat, to->lf_, &to->n);
! h = b->y2 - b->y1 + 1;
! if (to->focus_end) {
! to->sti = to->n - h / text_height(b->font); /* start index */
! if (to->sti < 0)
! to->sti = 0;
} else {
! to->sti = 0;
! }
! to->pos = to->sti*to->rh;
! if (to->browsed) {
! SetBrowserSize(to->br, h-6, h);
! NotifyBrowser(to->br, to->rh, to->n*to->rh);
}
to->dirty = 1;
return 1;
--- 395,467 ----
}
! static void DelayedErrorMessage(void *data)
! {
! char *s = data;
!
! Req("", s);
! Release(s);
! }
!
! static void GenerateTextLayout(t_object *b, const char *new_string)
{
t_textob *to;
int h;
+ int size;
+ char *mem = NULL;
+ PACKFILE *fp;
! to = b->appdata;
! DestroyPage(to->page);
! Release(to->s);
!
! if (to->load) {
! fp = pack_fopen(new_string, "rt");
! if (fp) {
! size = file_size_ex(new_string);
! new_string = mem = GetMem(char, size + 1);
! pack_fread(mem, size, fp);
! pack_fclose(fp);
! mem[size] = 0;
} else {
! const char *const*txt;
! int nr;
! txt = LoadCompiledTexts(cgui_labels+CGUI_CGUILABL, "obtext", &nr);
! if (nr == SIZE_obtext) {
! char *tmp = GetMem(char, strlen(new_string) + strlen(txt[ERROR_OPENING_FILE_NN_OK]) + 1);
! sprintf(tmp, txt[ERROR_OPENING_FILE_NN_OK], new_string);
! _GenEventOfCgui(DelayedErrorMessage, tmp, 0, 0);
! }
}
+ }
+ if (to->preformat)
+ CopyPreformattedText(to, new_string);
+ else
+ CopyText(to, new_string);
+ if (mem)
+ Release(mem);
+ to->page = MakePage(b->font, to->s, to->width + b->rex - 4, to->preformat, to->lf_, &to->n);
+ h = b->y2 - b->y1 + 1;
+ if (to->focus_end) {
+ to->sti = to->n - h / text_height(b->font); /* start index */
+ if (to->sti < 0)
+ to->sti = 0;
+ } else {
+ to->sti = 0;
+ }
+ to->pos = to->sti*to->rh;
+ if (to->browsed) {
+ SetBrowserSize(to->br, h-6, h);
+ NotifyBrowser(to->br, to->rh, to->n*to->rh);
+ }
+ }
+
+ static int FetchTextBoxText(t_object *b)
+ {
+ t_textob *to;
+
+ to = b->appdata;
+ if (fetching_in_progress) {
+ fetching_in_progress = 0;
+ GenerateTextLayout(b, new_string);
to->dirty = 1;
return 1;
***************
*** 486,497 ****
}
- static void DelayedErrorMessage(void *data)
- {
- char *s = data;
-
- Req("", s);
- Release(s);
- }
-
/* Application interface: */
--- 542,545 ----
***************
*** 500,510 ****
t_textob *to;
t_object *b;
- char *mem = NULL;
struct t_node *nd = NULL;
static t_typefun tf;
static t_tcfun tc;
static int virgin = 1;
- int size;
- PACKFILE *fp;
if (virgin) {
--- 548,555 ----
***************
*** 547,583 ****
to->browsed = n;
to->b = b;
- if (to->load) {
- fp = pack_fopen(s, "rt");
- if (fp) {
- size = file_size_ex(s);
- s = mem = GetMem(char, size + 1);
- pack_fread(mem, size, fp);
- pack_fclose(fp);
- mem[size] = 0;
- } else {
- const char *const*txt;
- int nr;
- txt = LoadCompiledTexts(cgui_labels+CGUI_CGUILABL, "obtext", &nr);
- if (nr == SIZE_obtext) {
- char *tmp = GetMem(char, strlen(s) + strlen(txt[ERROR_OPENING_FILE_NN_OK]) + 1);
- sprintf(tmp, txt[ERROR_OPENING_FILE_NN_OK], s);
- _GenEventOfCgui(DelayedErrorMessage, tmp, 0, 0);
- }
- }
- }
- if (to->preformat)
- CopyPreformattedText(to, s);
- else
- CopyText(to, s);
- if (mem)
- Release(mem);
b->tf = &tf;
b->Action = Stub;
b->appdata = to;
if (to->browsed) {
to->br = MkVerticalBrowser(RIGHT|FILLSPACE|VERTICAL, BrCallBack, to, &to->pos);
nd->ob->tf->DoJoinTabChain(nd->ob);
nd->ob->tcfun = &tc;
! CloseNode();
}
return b->id;
--- 592,604 ----
to->browsed = n;
to->b = b;
b->tf = &tf;
b->Action = Stub;
b->appdata = to;
+ GenerateTextLayout(b, s);
if (to->browsed) {
to->br = MkVerticalBrowser(RIGHT|FILLSPACE|VERTICAL, BrCallBack, to, &to->pos);
nd->ob->tf->DoJoinTabChain(nd->ob);
nd->ob->tcfun = &tc;
! CloseNode();
}
return b->id;
***************
*** 601,604 ****
--- 622,672 ----
}
+ extern void TextboxHighlighting(int id, int bgcolor, int textcolor, int line_nr)
+ {
+ t_object *b;
+ t_textob *to;
+
+ b=GetObject(id);
+ if (b) {
+ to = b->appdata;
+ to->hilite = 1;
+ to->hrow = line_nr;
+ to->textcolor = textcolor;
+ to->bgcolor = bgcolor;
+ }
+ }
+
+ extern const char *TextboxGetHighlightedText(int id)
+ {
+ t_object *b;
+ t_textob *to;
+ int i;
+ b = GetObject(id);
+ if (b) {
+ to = b->appdata;
+ i = to->sti + to->hrow;
+ return to->page[i];
+ }
+ return NULL;
+ }
+
+ extern void TextboxScrollDownOneLine(int id)
+ {
+ t_object *b;
+ t_textob *to;
+
+ b = GetObject(id);
+ if (b) {
+ to = b->appdata;
+ if (to->sti < to->n - 1) {
+ to->sti++;
+ to->b->tf->Refresh(to->b);
+ to->pos = to->sti*to->rh;
+ NotifyBrowser(to->br, to->rh, to->n*to->rh);
+ Refresh(to->br);
+ }
+ }
+ }
+
/* Obsolete */
extern int MkTextObject(int x, int y, const char *s, int w,
|