forked from KolibriOS/kolibrios
Controls ScrolledWindow and ProgressBar render in buffer befor screen output.
Some size and speed optimizations and some bugfixes. git-svn-id: svn://kolibrios.org@1163 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
8f20fe84d3
commit
cbfb59ad64
2
programs/develop/new libGUI_C/SRC/compilation/MinGW/Makefile → programs/develop/new libGUI_C/SRC/compilation/cygwin/Makefile
Executable file → Normal file
2
programs/develop/new libGUI_C/SRC/compilation/MinGW/Makefile → programs/develop/new libGUI_C/SRC/compilation/cygwin/Makefile
Executable file → Normal file
@ -2,10 +2,10 @@ SRC = libGUI.c
|
||||
TARGET = libGUI.obj
|
||||
CFLAGS = -O2 -nostdinc -nostdlib -march=pentium -fomit-frame-pointer -fno-builtin
|
||||
CC = gcc
|
||||
AR=ar
|
||||
|
||||
all:
|
||||
$(CC) -c $(SRC) $(CFLAGS) -o $(TARGET)
|
||||
strip -X --strip-unneeded $(TARGET)
|
||||
clean:
|
||||
rm *.obj
|
||||
rm $(TARGET)
|
@ -276,6 +276,9 @@ void ButtonProc(struct ControlButton *button,struct MESSAGE *message)
|
||||
{
|
||||
if (message->arg3==MOUSE_LEFT_BUTTON_DOWN)
|
||||
{
|
||||
if ((button->btn_flags & FLAG_PRESSED_BUTTON_ON)==FALSE)
|
||||
{if (button->flags & FLAG_SHOW_CONTROL)
|
||||
DrawPressedButton(button);}
|
||||
button->btn_flags=button->btn_flags | FLAG_PRESSED_BUTTON_ON;
|
||||
}
|
||||
}
|
||||
@ -291,7 +294,6 @@ void ButtonProc(struct ControlButton *button,struct MESSAGE *message)
|
||||
(DWORD*)ControlCheckCallbackEvent(button,(DWORD)BUTTON_PRESSED_EVENT);
|
||||
main_parent->number_callbacks++;
|
||||
}
|
||||
if (button->flags & FLAG_SHOW_CONTROL) DrawPressedButton(button);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -399,7 +401,7 @@ void* CreateButtonWithText(gui_button_data_t *info,char *txt)
|
||||
memmove(txtdata.text,txt,len);
|
||||
text=CreateText(&txtdata);
|
||||
|
||||
if (text->ctrl_sizex>Button->ctrl_sizex) Button->ctrl_sizex=text->ctrl_sizex+6;
|
||||
if (text->ctrl_sizex>Button->ctrl_sizex) Button->ctrl_sizex=text->ctrl_sizex+10;
|
||||
if (text->ctrl_sizey>Button->ctrl_sizey) Button->ctrl_sizey=text->ctrl_sizey+6;
|
||||
|
||||
text->ctrl_x=(Button->ctrl_sizex/2)-(text->ctrl_sizex/2);
|
||||
|
@ -2,7 +2,6 @@
|
||||
control ProgressBar
|
||||
*/
|
||||
|
||||
|
||||
void ProgressBarDrawProgress(struct ControlProgressBar *ProgressBar)
|
||||
{
|
||||
int x;
|
||||
@ -72,11 +71,12 @@ void ProgressBarDrawProgress(struct ControlProgressBar *ProgressBar)
|
||||
|
||||
void DrawProgressBar(struct ControlProgressBar *ProgressBar)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int sizex;
|
||||
int sizey;
|
||||
struct FINITION *fin;
|
||||
int x,y,sizex,sizey;
|
||||
char c;
|
||||
char *save_buf,*buf;
|
||||
int save_size_x,save_size_y;
|
||||
DWORD draw_output,flags;
|
||||
finition_t *fin;
|
||||
|
||||
x=ProgressBar->ctrl_x;
|
||||
y=ProgressBar->ctrl_y;
|
||||
@ -84,10 +84,51 @@ void DrawProgressBar(struct ControlProgressBar *ProgressBar)
|
||||
sizey=ProgressBar->ctrl_sizey;
|
||||
fin=(struct FINITION*)ProgressBar->finition;
|
||||
|
||||
Draw(fin,TOOL_RECTANGLE,x,y,sizex,sizey,COLOR_ABSOLUTE_DARK);
|
||||
Draw(fin,TOOL_GRADIENT_UP_FILLED_RECTANGLE,x+1,y+1,sizex-2,sizey-2,COLOR_MIDDLE_LIGHT,COLOR_LIGHT);
|
||||
//alocate a buffer for draw text
|
||||
c=screen.bits_per_pixel >> 3;
|
||||
buf=malloc(sizex*sizey*c);
|
||||
|
||||
//save current screen parameters
|
||||
save_buf=screen.buffer;
|
||||
save_size_x=screen.size_x;
|
||||
save_size_y=screen.size_y;
|
||||
draw_output=screen.draw_output;
|
||||
|
||||
//load parameters of local buffer
|
||||
screen.buffer=buf;
|
||||
screen.size_x=sizex;
|
||||
screen.size_y=sizey;
|
||||
screen.draw_output=DRAW_OUTPUT_BUFFER;
|
||||
|
||||
//move control
|
||||
SetControlNewPosition(ProgressBar,0,0);
|
||||
//save finition parameters
|
||||
flags=fin->flags;
|
||||
fin->flags &=FINITION_OFF;
|
||||
|
||||
//draw progress bar in buffer
|
||||
Draw(fin,TOOL_RECTANGLE,0,0,sizex,sizey,COLOR_ABSOLUTE_DARK);
|
||||
ProgressBarDrawProgress(ProgressBar);
|
||||
|
||||
//restore last position of control
|
||||
SetControlNewPosition(ProgressBar,x,y);
|
||||
//restore finition
|
||||
fin->flags=flags;
|
||||
|
||||
//restore screen parameters
|
||||
screen.buffer=save_buf;
|
||||
screen.size_x=save_size_x;
|
||||
screen.size_y=save_size_y;
|
||||
screen.draw_output=draw_output;
|
||||
|
||||
//move rendered objects from local buffer to screen
|
||||
if (fin->flags & FINITION_ON)
|
||||
DrawImageFinit(fin,x,y,sizex,sizey,screen.bits_per_pixel,buf);
|
||||
else
|
||||
DrawImage(x,y,sizex,sizey,screen.bits_per_pixel,buf);
|
||||
|
||||
//free local buffer
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void SetProgressBarPulse(struct ControlProgressBar *ProgressBar,int time_tick)
|
||||
@ -100,7 +141,7 @@ void SetProgressBarPulse(struct ControlProgressBar *ProgressBar,int time_tick)
|
||||
{
|
||||
main_parent->number_timers_for_controls++;
|
||||
|
||||
ProgressBar->timer=(DWORD*)SetTimerCallbackForControl(time_tick,&ProgressBarDrawProgress,ProgressBar);
|
||||
ProgressBar->timer=(DWORD*)SetTimerCallbackForControl(time_tick,&DrawProgressBar,ProgressBar);
|
||||
timer=(struct TIMER*)ProgressBar->timer;
|
||||
timer->flags=timer->flags | FLAG_TIMER_ON;
|
||||
}
|
||||
@ -148,6 +189,7 @@ void ProgressBarProc(struct ControlProgressBar *ProgressBar,struct MESSAGE *mess
|
||||
{
|
||||
ProgressBar->ctrl_x=ProgressBar->ctrl_x+message->arg1;
|
||||
ProgressBar->ctrl_y=ProgressBar->ctrl_y+message->arg2;
|
||||
SendMessage((struct HEADER*)ProgressBar,message);
|
||||
break;
|
||||
}
|
||||
case MESSAGE_CALL_TIMER_EVENT:
|
||||
@ -157,25 +199,26 @@ void ProgressBarProc(struct ControlProgressBar *ProgressBar,struct MESSAGE *mess
|
||||
timer=(struct TIMER*)ProgressBar->timer;
|
||||
if (timer->flags & FLAG_TIMER_ON) Timer(timer);
|
||||
}
|
||||
SendMessage((struct HEADER*)ProgressBar,message);
|
||||
break;
|
||||
}
|
||||
case MESSAGE_DESTROY_CONTROL:
|
||||
{
|
||||
if (ProgressBar->timer!=(DWORD*)NULL) free(ProgressBar->timer);
|
||||
free(ProgressBar->finition);
|
||||
SendMessage((struct HEADER*)ProgressBar,message);
|
||||
break;
|
||||
}
|
||||
case MESSAGE_SET_MAIN_PARENT:
|
||||
{
|
||||
SendMessage((struct HEADER*)ProgressBar,message);
|
||||
ProgressBar->main_parent=(DWORD*)message->arg1;
|
||||
SendMessage((struct HEADER*)ProgressBar,message);
|
||||
break;
|
||||
}
|
||||
|
||||
default: break;
|
||||
}
|
||||
//send message to child controls(if there is)
|
||||
SendMessage((struct HEADER*)ProgressBar,message);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
|
@ -103,8 +103,112 @@ void ScrolledWindowPackControls(void *parent,void *Control)
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Draw full Scroll Bar
|
||||
// Draw full Scrolled Window
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ScrollWin_FuncCallback_HVScroll(struct HEADER* control,void *data)
|
||||
{
|
||||
struct ControlScrollBar *Hscrollbar,*Vscrollbar;
|
||||
struct ControlScrolledWindow *ScrolledWindow;
|
||||
struct HEADER *seek_control,*exchange_control;
|
||||
struct MESSAGE local_message;
|
||||
struct FINITION *fin;
|
||||
int i,new_x,new_y,x,y,sizex,sizey;
|
||||
char c;
|
||||
char *save_buf,*buf;
|
||||
int save_size_x,save_size_y;
|
||||
DWORD draw_output;
|
||||
|
||||
ScrolledWindow=(gui_scrolled_window_t*)data;
|
||||
Hscrollbar=(gui_scroll_bar_t*)ScrolledWindow->horizontal_scroll;
|
||||
Vscrollbar=(gui_scroll_bar_t*)ScrolledWindow->vertical_scroll;
|
||||
ScrolledWindow->virtual_x=(ScrolledWindow->virtual_sizex-ScrolledWindow->scroll_arrea_sizex)*Hscrollbar->ruller_pos;
|
||||
ScrolledWindow->virtual_y=(ScrolledWindow->virtual_sizey-ScrolledWindow->scroll_arrea_sizey)*Vscrollbar->ruller_pos;
|
||||
|
||||
x=ScrolledWindow->ctrl_x+1;
|
||||
y=ScrolledWindow->ctrl_y+1;
|
||||
sizex=ScrolledWindow->scroll_arrea_sizex;
|
||||
sizey=ScrolledWindow->scroll_arrea_sizey;
|
||||
|
||||
//alocate a buffer for draw text
|
||||
c=screen.bits_per_pixel >> 3;
|
||||
i=sizex*sizey*c;
|
||||
buf=malloc(i);
|
||||
|
||||
//save current screen parameters
|
||||
save_buf=screen.buffer;
|
||||
save_size_x=screen.size_x;
|
||||
save_size_y=screen.size_y;
|
||||
draw_output=screen.draw_output;
|
||||
|
||||
//load parameters of local buffer
|
||||
screen.buffer=buf;
|
||||
screen.size_x=sizex;
|
||||
screen.size_y=sizey;
|
||||
screen.draw_output=DRAW_OUTPUT_BUFFER;
|
||||
|
||||
//fill buffer by background color
|
||||
FillArrea(buf,i,screen.bits_per_pixel,COLOR_LIGHT);
|
||||
|
||||
local_message.type=MESSAGE_FULL_REDRAW_ALL_WITH_FINITION;
|
||||
local_message.arg1=0;
|
||||
local_message.arg2=0;
|
||||
local_message.arg3=sizex;
|
||||
local_message.arg4=sizey;
|
||||
|
||||
seek_control=(struct HEADER*)Vscrollbar->ctrl_fd;
|
||||
//move controls in new position
|
||||
for(i=0;i<ScrolledWindow->number_virtual_controls;i++)
|
||||
{
|
||||
new_x=ScrolledWindow->virtual_controls_x[i]-ScrolledWindow->virtual_x;
|
||||
new_y=ScrolledWindow->virtual_controls_y[i]-ScrolledWindow->virtual_y;
|
||||
|
||||
SetControlNewPosition(seek_control,new_x,new_y);
|
||||
|
||||
if (CheckCrossRectangles(x,y,sizex,sizey,new_x,new_y,
|
||||
seek_control->ctrl_sizex,
|
||||
seek_control->ctrl_sizey)==TRUE)
|
||||
{
|
||||
seek_control->flags=seek_control->flags | FLAG_SHOW_CONTROL;
|
||||
seek_control->flags=seek_control->flags & FLAG_MOUSE_BLOCKED_OFF;
|
||||
|
||||
//move control
|
||||
SetControlNewPosition(seek_control,new_x-x,new_y-y);
|
||||
//call draw control in buffer
|
||||
ControlProc=(void (*)(void *Control,struct MESSAGE *message))seek_control->ctrl_proc;
|
||||
ControlProc(seek_control,&local_message);
|
||||
//restore last position of control
|
||||
SetControlNewPosition(seek_control,new_x,new_y);
|
||||
//restore coordinates of last finition of control
|
||||
fin=(finition_t*)seek_control->finition;
|
||||
fin->x=x;
|
||||
fin->y=y;
|
||||
}
|
||||
else
|
||||
{
|
||||
seek_control->flags=seek_control->flags & FLAG_HIDE_CONTROL;
|
||||
seek_control->flags=seek_control->flags | FLAG_MOUSE_BLOCKED_ON;
|
||||
}
|
||||
|
||||
exchange_control=(struct HEADER*)seek_control->ctrl_fd;
|
||||
seek_control=exchange_control;
|
||||
}
|
||||
//restore screen parameters
|
||||
screen.buffer=save_buf;
|
||||
screen.size_x=save_size_x;
|
||||
screen.size_y=save_size_y;
|
||||
screen.draw_output=draw_output;
|
||||
|
||||
//move rendered objects from local buffer to screen
|
||||
fin=(finition_t*)ScrolledWindow->finition;
|
||||
if (fin->flags & FINITION_ON)
|
||||
DrawImageFinit(fin,x,y,sizex,sizey,screen.bits_per_pixel,buf);
|
||||
else
|
||||
DrawImage(x,y,sizex,sizey,screen.bits_per_pixel,buf);
|
||||
|
||||
//free local buffer
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void DrawScrolledWindow(struct ControlScrolledWindow *ScrolledWindow)
|
||||
{
|
||||
int x,y,sizex,sizey;
|
||||
@ -116,138 +220,16 @@ void DrawScrolledWindow(struct ControlScrolledWindow *ScrolledWindow)
|
||||
sizey=ScrolledWindow->ctrl_sizey;
|
||||
fin=(struct FINITION*)ScrolledWindow->finition;
|
||||
|
||||
Draw(fin,TOOL_FILLED_RECTANGLE,x+1,y+1,ScrolledWindow->scroll_arrea_sizex,
|
||||
ScrolledWindow->scroll_arrea_sizey,COLOR_LIGHT);
|
||||
|
||||
if ((ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_HORIZONTAL_SCROLL_ON) ||
|
||||
(ScrolledWindow->scw_flags & FLAG_SCROLL_WIN_VERTICAL_SCROLL_ON))
|
||||
{
|
||||
Draw(fin,TOOL_RECTANGLE,x,y,ScrolledWindow->scroll_arrea_sizex+2,
|
||||
ScrolledWindow->scroll_arrea_sizey+2,0xff0000);
|
||||
ScrolledWindow->scroll_arrea_sizey+2,COLOR_ABSOLUTE_DARK);
|
||||
}
|
||||
else
|
||||
Draw(fin,TOOL_RECTANGLE,x,y,sizex,sizey,COLOR_ABSOLUTE_DARK);
|
||||
}
|
||||
|
||||
void ScrollWin_FuncCallback_HScroll(struct HEADER* control,void *data)
|
||||
{
|
||||
struct ControlScrollBar *Hscrollbar,*Vscrollbar;
|
||||
struct ControlScrolledWindow *ScrolledWindow;
|
||||
struct HEADER *seek_control,*exchange_control;
|
||||
struct FINITION *fin;
|
||||
struct MESSAGE local_message;
|
||||
int i,new_x,new_y,x,y,sizex,sizey;
|
||||
|
||||
Hscrollbar=(struct ControlScrollBar*)control;
|
||||
ScrolledWindow=(struct ControlScrolledWindow*)data;
|
||||
|
||||
ScrolledWindow->virtual_x=(ScrolledWindow->virtual_sizex-ScrolledWindow->scroll_arrea_sizex)*Hscrollbar->ruller_pos;
|
||||
|
||||
x=ScrolledWindow->ctrl_x+1;
|
||||
y=ScrolledWindow->ctrl_y+1;
|
||||
sizex=ScrolledWindow->scroll_arrea_sizex;
|
||||
sizey=ScrolledWindow->scroll_arrea_sizey;
|
||||
|
||||
local_message.type=MESSAGE_FULL_REDRAW_ALL_WITH_FINITION;
|
||||
local_message.arg1=x;
|
||||
local_message.arg2=y;
|
||||
local_message.arg3=sizex;
|
||||
local_message.arg4=sizey;
|
||||
|
||||
fin=(finition_t*)ScrolledWindow->finition;
|
||||
Draw(fin,TOOL_FILLED_RECTANGLE,x,y,sizex,sizey,COLOR_LIGHT);
|
||||
|
||||
Vscrollbar=(struct ControlScrollBar*)ScrolledWindow->vertical_scroll;
|
||||
seek_control=(struct HEADER*)Vscrollbar->ctrl_fd;
|
||||
//move controls in new position
|
||||
for(i=0;i<ScrolledWindow->number_virtual_controls;i++)
|
||||
{
|
||||
new_x=ScrolledWindow->virtual_controls_x[i]-ScrolledWindow->virtual_x;
|
||||
new_y=ScrolledWindow->virtual_controls_y[i]-ScrolledWindow->virtual_y;
|
||||
|
||||
SetControlNewPosition(seek_control,new_x,new_y);
|
||||
|
||||
if (CheckCrossRectangles(local_message.arg1,local_message.arg2,local_message.arg3,local_message.arg4,
|
||||
seek_control->ctrl_x,seek_control->ctrl_y,seek_control->ctrl_sizex,seek_control->ctrl_sizey)==TRUE)
|
||||
{
|
||||
seek_control->flags=seek_control->flags | FLAG_SHOW_CONTROL;
|
||||
seek_control->flags=seek_control->flags & FLAG_MOUSE_BLOCKED_OFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
seek_control->flags=seek_control->flags & FLAG_HIDE_CONTROL;
|
||||
seek_control->flags=seek_control->flags | FLAG_MOUSE_BLOCKED_ON;
|
||||
}
|
||||
|
||||
if (seek_control->flags & FLAG_SHOW_CONTROL)
|
||||
{
|
||||
ControlProc=(void (*)(void *Control,struct MESSAGE *message))seek_control->ctrl_proc;
|
||||
ControlProc(seek_control,&local_message);
|
||||
}
|
||||
|
||||
exchange_control=(struct HEADER*)seek_control->ctrl_fd;
|
||||
seek_control=exchange_control;
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollWin_FuncCallback_VScroll(struct HEADER* control,void *data)
|
||||
{
|
||||
struct ControlScrollBar *Hscrollbar,*Vscrollbar;
|
||||
struct ControlScrolledWindow *ScrolledWindow;
|
||||
struct HEADER *seek_control,*exchange_control;
|
||||
struct MESSAGE local_message;
|
||||
struct FINITION *fin;
|
||||
int i,new_x,new_y,x,y,sizex,sizey;
|
||||
|
||||
Vscrollbar=(struct ControlScrollBar*)control;
|
||||
ScrolledWindow=(struct ControlScrolledWindow*)data;
|
||||
|
||||
ScrolledWindow->virtual_y=(ScrolledWindow->virtual_sizey-ScrolledWindow->scroll_arrea_sizey)*Vscrollbar->ruller_pos;
|
||||
|
||||
x=ScrolledWindow->ctrl_x+1;
|
||||
y=ScrolledWindow->ctrl_y+1;
|
||||
sizex=ScrolledWindow->scroll_arrea_sizex;
|
||||
sizey=ScrolledWindow->scroll_arrea_sizey;
|
||||
|
||||
local_message.type=MESSAGE_FULL_REDRAW_ALL_WITH_FINITION;
|
||||
local_message.arg1=x;
|
||||
local_message.arg2=y;
|
||||
local_message.arg3=sizex;
|
||||
local_message.arg4=sizey;
|
||||
|
||||
fin=(finition_t*)ScrolledWindow->finition;
|
||||
Draw(fin,TOOL_FILLED_RECTANGLE,x,y,sizex,sizey,COLOR_LIGHT);
|
||||
|
||||
seek_control=(struct HEADER*)Vscrollbar->ctrl_fd;
|
||||
//move controls in new position
|
||||
for(i=0;i<ScrolledWindow->number_virtual_controls;i++)
|
||||
{
|
||||
new_x=ScrolledWindow->virtual_controls_x[i]-ScrolledWindow->virtual_x;
|
||||
new_y=ScrolledWindow->virtual_controls_y[i]-ScrolledWindow->virtual_y;
|
||||
|
||||
SetControlNewPosition(seek_control,new_x,new_y);
|
||||
|
||||
if (CheckCrossRectangles(local_message.arg1,local_message.arg2,local_message.arg3,local_message.arg4,
|
||||
seek_control->ctrl_x,seek_control->ctrl_y,seek_control->ctrl_sizex,seek_control->ctrl_sizey)==TRUE)
|
||||
{
|
||||
seek_control->flags=seek_control->flags | FLAG_SHOW_CONTROL;
|
||||
seek_control->flags=seek_control->flags & FLAG_MOUSE_BLOCKED_OFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
seek_control->flags=seek_control->flags & FLAG_HIDE_CONTROL;
|
||||
seek_control->flags=seek_control->flags | FLAG_MOUSE_BLOCKED_ON;
|
||||
}
|
||||
|
||||
if (seek_control->flags & FLAG_SHOW_CONTROL)
|
||||
{
|
||||
ControlProc=(void (*)(void *Control,struct MESSAGE *message))seek_control->ctrl_proc;
|
||||
ControlProc(seek_control,&local_message);
|
||||
}
|
||||
|
||||
exchange_control=(struct HEADER*)seek_control->ctrl_fd;
|
||||
seek_control=exchange_control;
|
||||
}
|
||||
ScrollWin_FuncCallback_HVScroll(NULL,ScrolledWindow);
|
||||
}
|
||||
|
||||
void ScrlWinCheckActivatedForKeysControl(struct ControlScrolledWindow *ScrolledWindow)
|
||||
@ -326,46 +308,7 @@ void ScrlWinCheckActivatedForKeysControl(struct ControlScrolledWindow *ScrolledW
|
||||
Vscrollbar->ruller_pos=Vscrollbar->ruller_pos/((float)(ScrolledWindow->virtual_sizey-ScrolledWindow->scroll_arrea_sizey));
|
||||
SpecialRedrawControl(Vscrollbar);
|
||||
}
|
||||
|
||||
local_message.type=MESSAGE_FULL_REDRAW_ALL_WITH_FINITION;
|
||||
local_message.arg1=x;
|
||||
local_message.arg2=y;
|
||||
local_message.arg3=sizex;
|
||||
local_message.arg4=sizey;
|
||||
|
||||
fin=(finition_t*)ScrolledWindow->finition;
|
||||
Draw(fin,TOOL_FILLED_RECTANGLE,x,y,sizex,sizey,COLOR_LIGHT);
|
||||
|
||||
seek_control=(struct HEADER*)Vscrollbar->ctrl_fd;
|
||||
//move controls in new position
|
||||
for(i=0;i<ScrolledWindow->number_virtual_controls;i++)
|
||||
{
|
||||
sx=ScrolledWindow->virtual_controls_x[i]-ScrolledWindow->virtual_x;
|
||||
sy=ScrolledWindow->virtual_controls_y[i]-ScrolledWindow->virtual_y;
|
||||
|
||||
SetControlNewPosition(seek_control,sx,sy);
|
||||
|
||||
if (CheckCrossRectangles(x,y,sizex,sizey,seek_control->ctrl_x,seek_control->ctrl_y,
|
||||
seek_control->ctrl_sizex,seek_control->ctrl_sizey)==TRUE)
|
||||
{
|
||||
seek_control->flags=seek_control->flags | FLAG_SHOW_CONTROL;
|
||||
seek_control->flags=seek_control->flags & FLAG_MOUSE_BLOCKED_OFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
seek_control->flags=seek_control->flags & FLAG_HIDE_CONTROL;
|
||||
seek_control->flags=seek_control->flags | FLAG_MOUSE_BLOCKED_ON;
|
||||
}
|
||||
|
||||
if (seek_control->flags & FLAG_SHOW_CONTROL)
|
||||
{
|
||||
ControlProc=(void (*)(void *Control,struct MESSAGE *message))seek_control->ctrl_proc;
|
||||
ControlProc(seek_control,&local_message);
|
||||
}
|
||||
|
||||
exchange_control=(struct HEADER*)seek_control->ctrl_fd;
|
||||
seek_control=exchange_control;
|
||||
}
|
||||
ScrollWin_FuncCallback_HVScroll(NULL,ScrolledWindow);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -393,35 +336,13 @@ void ScrolledWindowProc(struct ControlScrolledWindow *ScrolledWindow,struct MESS
|
||||
if (ScrolledWindow->flags & FLAG_SHOW_CONTROL)
|
||||
{
|
||||
DrawScrolledWindow(ScrolledWindow);
|
||||
|
||||
//send message to scroll bars
|
||||
Hscrollbar=(struct ControlScrollBar*)ScrolledWindow->horizontal_scroll;
|
||||
Vscrollbar=(struct ControlScrollBar*)ScrolledWindow->vertical_scroll;
|
||||
|
||||
ControlProc=(void (*)(void *Control,struct MESSAGE *message))Hscrollbar->ctrl_proc;
|
||||
ControlProc((struct HEADER*)Hscrollbar,message);
|
||||
|
||||
ControlProc=(void (*)(void *Control,struct MESSAGE *message))Vscrollbar->ctrl_proc;
|
||||
ControlProc((struct HEADER*)Vscrollbar,message);
|
||||
|
||||
//send message finit redraw only to some child controls of ScrolledWondow
|
||||
local_message.type=MESSAGE_FULL_REDRAW_ALL_WITH_FINITION;
|
||||
local_message.arg1=ScrolledWindow->ctrl_x+1;
|
||||
local_message.arg2=ScrolledWindow->ctrl_y+1;
|
||||
local_message.arg3=ScrolledWindow->scroll_arrea_sizex;
|
||||
local_message.arg4=ScrolledWindow->scroll_arrea_sizey;
|
||||
|
||||
seek_control=(struct HEADER *)Vscrollbar->ctrl_fd;
|
||||
while(seek_control!=(struct HEADER*)NULL)
|
||||
{
|
||||
if (seek_control->flags & FLAG_SHOW_CONTROL)
|
||||
{
|
||||
ControlProc=(void (*)(void *Control,struct MESSAGE *message))seek_control->ctrl_proc;
|
||||
ControlProc(seek_control,&local_message);
|
||||
}
|
||||
exchange_control=(struct HEADER*)seek_control->ctrl_fd;
|
||||
seek_control=exchange_control;
|
||||
}
|
||||
Hscrollbar=(gui_scroll_bar_t*)ScrolledWindow->horizontal_scroll;
|
||||
Vscrollbar=(gui_scroll_bar_t*)ScrolledWindow->vertical_scroll;
|
||||
//draw scroll bars
|
||||
ControlProc=(void (*)(void *Control,gui_message_t *message))Hscrollbar->ctrl_proc;
|
||||
ControlProc(Hscrollbar,message);
|
||||
ControlProc=(void (*)(void *Control,gui_message_t *message))Vscrollbar->ctrl_proc;
|
||||
ControlProc(Vscrollbar,message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -590,8 +511,8 @@ void* CreateScrolledWindow(struct ScrolledWindowData *info_for_control)
|
||||
HorizontalScrollBar=CreateHorizontalScrollBar(&HorizontalScrollData);
|
||||
VerticalScrollBar=CreateVerticalScrollBar(&VerticalScrollData);
|
||||
|
||||
SetCallbackFunction(HorizontalScrollBar,SCROLLBAR_CHANGED_EVENT,&ScrollWin_FuncCallback_HScroll,ScrolledWindow);
|
||||
SetCallbackFunction(VerticalScrollBar,SCROLLBAR_CHANGED_EVENT,&ScrollWin_FuncCallback_VScroll,ScrolledWindow);
|
||||
SetCallbackFunction(HorizontalScrollBar,SCROLLBAR_CHANGED_EVENT,&ScrollWin_FuncCallback_HVScroll,ScrolledWindow);
|
||||
SetCallbackFunction(VerticalScrollBar,SCROLLBAR_CHANGED_EVENT,&ScrollWin_FuncCallback_HVScroll,ScrolledWindow);
|
||||
|
||||
PackControls(ScrolledWindow,HorizontalScrollBar);
|
||||
PackControls(ScrolledWindow,VerticalScrollBar);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
function for draw controls
|
||||
functions for draw controls
|
||||
*/
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -1219,8 +1219,11 @@ void DrawImage(int x,int y,int sizex,int sizey,char bits_per_pixel,char *img)
|
||||
switch(screen.bits_per_pixel)
|
||||
{
|
||||
case 32:
|
||||
case 24:
|
||||
{
|
||||
if (bits_per_pixel==32)
|
||||
switch(bits_per_pixel)
|
||||
{//check bits per pixel in picture
|
||||
case 32:
|
||||
{//convert 32 bit image to 24 bit image
|
||||
j=sizex*sizey;
|
||||
ptr_src=img;
|
||||
@ -1237,7 +1240,6 @@ void DrawImage(int x,int y,int sizex,int sizey,char bits_per_pixel,char *img)
|
||||
}
|
||||
gui_ksys_put_image_window(ptr_screen2,x,y,countx,county);
|
||||
free(ptr_screen2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 24:
|
||||
@ -1245,6 +1247,9 @@ void DrawImage(int x,int y,int sizex,int sizey,char bits_per_pixel,char *img)
|
||||
gui_ksys_put_image_window(img,x,y,countx,county);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
@ -1258,42 +1263,38 @@ void DrawImage(int x,int y,int sizex,int sizey,char bits_per_pixel,char *img)
|
||||
switch(bits_per_pixel)
|
||||
{
|
||||
case 32://display 32 bit image in 24 bit mode
|
||||
{
|
||||
pitch_screen=screen.size_x*3;
|
||||
pitch_src=countx << 2;
|
||||
ptr_screen=screen.buffer+pitch_screen*y+x*3;
|
||||
{//convert and draw 32 bit image in 24 bit buffer
|
||||
ptr_screen=screen.buffer+(screen.size_x*y+x)*3;
|
||||
add_screen=(screen.size_x-countx)*3;
|
||||
ptr_src=img;
|
||||
add_screen=pitch_screen-pitch_src;
|
||||
//copy line of byte with size x
|
||||
for(i=0;i<county;i++)
|
||||
{
|
||||
for(j=0;j<pitch_src;j++)
|
||||
for(j=0;j<countx;j++)
|
||||
{
|
||||
*(char*)ptr_screen=*(char*)ptr_src;
|
||||
ptr_src++;
|
||||
ptr_screen++;
|
||||
*((char*)ptr_screen+1)=*((char*)ptr_src+1);
|
||||
*((char*)ptr_screen+2)=*((char*)ptr_src+2);
|
||||
|
||||
ptr_src+=4;
|
||||
ptr_screen+=3;
|
||||
}
|
||||
ptr_screen+=add_screen;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 24://display 24 bit image in 24 bit mode
|
||||
{
|
||||
pitch_screen=screen.size_x*3;
|
||||
pitch_src=countx*3;
|
||||
ptr_screen=screen.buffer+pitch_screen*y+x*3;
|
||||
ptr_src=img;
|
||||
add_screen=pitch_screen-pitch_src;
|
||||
case 24:
|
||||
{//display 24 bit image in 24 bit buffer
|
||||
ptr_screen=screen.buffer+(screen.size_x*y+x)*3;
|
||||
add_screen=screen.size_x*3;
|
||||
add_src=countx*3;
|
||||
|
||||
//copy line of byte with size x
|
||||
for(i=0;i<county;i++)
|
||||
{
|
||||
for(j=0;j<pitch_src;j++)
|
||||
{
|
||||
*(char*)ptr_screen=*(char*)ptr_src;
|
||||
ptr_src++;
|
||||
ptr_screen++;
|
||||
}
|
||||
memmove(ptr_screen,img,add_src);
|
||||
ptr_screen+=add_screen;
|
||||
img+=add_src;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1305,28 +1306,41 @@ void DrawImage(int x,int y,int sizex,int sizey,char bits_per_pixel,char *img)
|
||||
{ //check source image resolution
|
||||
switch(bits_per_pixel)
|
||||
{
|
||||
case 32://display 32 bit image in 32 bit mode
|
||||
{
|
||||
pitch_screen=screen.size_x << 2;
|
||||
pitch_src=countx << 2;
|
||||
ptr_screen=screen.buffer+pitch_screen*y+x*4;
|
||||
ptr_src=img;
|
||||
add_screen=pitch_screen-pitch_src;
|
||||
case 32:
|
||||
{//display 32 bit image in 32 bit mode
|
||||
ptr_screen=screen.buffer+(screen.size_x*y+x)*4;
|
||||
add_screen=screen.size_x*4;
|
||||
add_src=countx*4;
|
||||
|
||||
//copy line of byte with size x
|
||||
for(i=0;i<county;i++)
|
||||
{
|
||||
for(j=0;j<pitch_src;j++)
|
||||
{
|
||||
*(char*)ptr_screen=*(char*)ptr_src;
|
||||
ptr_src++;
|
||||
ptr_screen++;
|
||||
}
|
||||
memmove(ptr_screen,img,add_src);
|
||||
ptr_screen+=add_screen;
|
||||
img+=add_src;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 24://display 24 bit image in 32 bit mode
|
||||
{
|
||||
ptr_screen=screen.buffer+(screen.size_x*y+x)*4;
|
||||
add_screen=(screen.size_x-countx)*4;
|
||||
ptr_src=img;
|
||||
//copy line of byte with size x
|
||||
for(i=0;i<county;i++)
|
||||
{
|
||||
for(j=0;j<countx;j++)
|
||||
{
|
||||
*(char*)ptr_screen=*(char*)ptr_src;
|
||||
*((char*)ptr_screen+1)=*((char*)ptr_src+1);
|
||||
*((char*)ptr_screen+2)=*((char*)ptr_src+2);
|
||||
|
||||
ptr_src+=3;
|
||||
ptr_screen+=4;
|
||||
}
|
||||
ptr_screen+=add_screen;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
@ -1401,32 +1415,28 @@ void DrawImageFinit(finition_t *fin,int x,int y,int sizex,int sizey,char bits_pe
|
||||
county=y2-y1+1;
|
||||
|
||||
//cut finited rectangle from image and move them into buffer
|
||||
switch(bits_per_pixel)
|
||||
{
|
||||
case 32:
|
||||
case 24:
|
||||
case 16:
|
||||
case 8:
|
||||
{ //allocate buffer
|
||||
|
||||
bytes_per_pixel=bits_per_pixel >> 3;
|
||||
buf=malloc(countx*county*bytes_per_pixel);
|
||||
ptr_dest=buf;
|
||||
|
||||
pitch_src=sizex*bytes_per_pixel;
|
||||
ptr_src=img+pitch_src*(y1-y)+(x1-x)*bytes_per_pixel;
|
||||
add_src=(sizex-countx)*bytes_per_pixel;
|
||||
add_src=sizex*bytes_per_pixel;
|
||||
countline=countx*bytes_per_pixel;
|
||||
//copy line of byte with size x
|
||||
|
||||
switch(bits_per_pixel)
|
||||
{
|
||||
case 32:
|
||||
case 24:
|
||||
case 16:
|
||||
case 8:
|
||||
{
|
||||
for(i=0;i<county;i++)
|
||||
{
|
||||
for(j=0;j<countline;j++)
|
||||
{
|
||||
*(char*)ptr_dest=*(char*)ptr_src;
|
||||
ptr_dest++;
|
||||
ptr_src++;
|
||||
}
|
||||
|
||||
memmove(ptr_dest,ptr_src,countline);
|
||||
ptr_src+=add_src;
|
||||
ptr_dest+=countline;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -173,8 +173,8 @@ void MonofontDraw(finition_t *fin,int fx,int fy,
|
||||
unsigned int i,j,k,step,len;
|
||||
int x,y,size_x,save_size_x,save_size_y;
|
||||
unsigned char *p,*buf,*save_buf;
|
||||
unsigned char c,draw_output;
|
||||
|
||||
unsigned char c;
|
||||
DWORD draw_output;
|
||||
|
||||
step=font->sizex*font->sizey;
|
||||
len=strlen(s);
|
||||
|
@ -313,7 +313,7 @@ extern inline int gui_ksys_check_event(void)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
// wait event
|
||||
// wait event while not timeout
|
||||
//------------------------------------------------------------------------------------------
|
||||
extern inline int gui_ksys_wait_event_with_timeout(DWORD timeout)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
service structures of libGUI
|
||||
*/
|
||||
|
||||
DWORD ID;
|
||||
static DWORD ID;
|
||||
|
||||
//screen's parameters
|
||||
#define BYTES_PER_PIXEL 4
|
||||
@ -111,12 +111,12 @@ DWORD ID;
|
||||
#define DRAW_OUTPUT_SCREEN 0
|
||||
#define DRAW_OUTPUT_BUFFER 1
|
||||
|
||||
static struct
|
||||
|
||||
static struct SCREEN
|
||||
{
|
||||
char *buffer;
|
||||
char bits_per_pixel;
|
||||
char bytes_per_pixel;
|
||||
char draw_output;
|
||||
DWORD bits_per_pixel;
|
||||
DWORD bytes_per_pixel;
|
||||
DWORD draw_output;
|
||||
int x;
|
||||
int y;
|
||||
int size_x;
|
||||
@ -124,6 +124,7 @@ static struct
|
||||
int skin_height;
|
||||
int display_size_x;
|
||||
int display_size_y;
|
||||
char *buffer;
|
||||
}screen;
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
@ -1326,12 +1326,13 @@ void SetControlNewPosition(void *Control,int new_x,int new_y)
|
||||
int old_y;
|
||||
|
||||
control=(struct HEADER*)Control;
|
||||
/*
|
||||
main_parent=(parent_t*)control->main_parent;
|
||||
if (control->parent==(DWORD*)main_parent)
|
||||
{//check position of child control of main parent
|
||||
if (new_x+control->ctrl_sizex-1>screen.size_x) return;
|
||||
if (new_y+control->ctrl_sizey-1>screen.size_y) return;
|
||||
}
|
||||
}*/
|
||||
|
||||
message.type=(DWORD)MESSAGE_CHANGE_POSITION_EVENT;
|
||||
message.arg1=(DWORD)(new_x-control->ctrl_x);
|
||||
|
@ -34,8 +34,9 @@ void LibGUImain(parent_t *WindowParent)
|
||||
{
|
||||
//check for timers
|
||||
if ((WindowParent->timer_bk!=(DWORD*)NULL) ||
|
||||
(WindowParent->number_timers_for_controls!=0)) {event=gui_ksys_check_event();}
|
||||
(WindowParent->number_timers_for_controls!=0)) {event=gui_ksys_wait_event_with_timeout(1);}
|
||||
else {event=gui_ksys_wait_event();}
|
||||
|
||||
//get and chack system events
|
||||
switch(event)
|
||||
{
|
||||
|
@ -6,6 +6,8 @@ static void *memmove(void *dst,const void *src,size_t length)
|
||||
{
|
||||
void *value;
|
||||
|
||||
if (length & 3)
|
||||
{//length not aligned in 4 bytes use reb movsb
|
||||
__asm__ __volatile__(
|
||||
"movl %%edi,%%eax\n\t"
|
||||
"cld\n\t"
|
||||
@ -14,7 +16,20 @@ static void *memmove(void *dst,const void *src,size_t length)
|
||||
:"=D"(value)
|
||||
:"c"(length),"S"(src),"D"(dst)
|
||||
:"eax");
|
||||
}
|
||||
else
|
||||
{//length aligned in 4 bytes use rep movsd
|
||||
length=length >> 2;//length=length/4
|
||||
__asm__ __volatile__(
|
||||
"movl %%edi,%%eax\n\t"
|
||||
"cld\n\t"
|
||||
"rep\n\t"
|
||||
"movsd"
|
||||
:"=D"(value)
|
||||
:"c"(length),"S"(src),"D"(dst)
|
||||
:"eax");
|
||||
|
||||
}
|
||||
return(value);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user