Subversion Repositories Kolibri OS

Rev

Rev 7806 | Rev 7991 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7806 Rev 7984
Line 17... Line 17...
17
//                                                   //
17
//                                                   //
18
//                       DATA                        //
18
//                       DATA                        //
19
//                                                   //
19
//                                                   //
20
//===================================================//
20
//===================================================//
Line 21... Line 21...
21
 
21
 
22
?define WINDOW_HEADER "Clipboard Viewer v1.03"
22
?define WINDOW_HEADER "Clipboard Viewer"
23
?define T_DELETE_LAST_SLOT "Delete last slot"
23
?define T_DELETE_LAST_SLOT "Delete last slot"
24
?define T_DELETE_ALL_SLOTS "Delete all slots"
24
?define T_DELETE_ALL_SLOTS "Delete all slots"
25
?define T_RESET_BUFFER_LOCK "Reset the lock buffer"
25
?define T_RESET_BUFFER_LOCK "Reset the lock buffer"
26
?define T_COLUMNS_TITLE "# | Data size | Data type | Contents"
26
?define T_COLUMNS_TITLE "# | Data size | Data type | Contents"
Line 48... Line 48...
48
//===================================================//
48
//===================================================//
Line 49... Line 49...
49
 
49
 
50
void main()
50
void main()
51
{   
51
{   
52
	int id;
52
	int id;
-
 
53
	@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
53
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
54
	#define NO_DLL_INIT
54
	load_dll(boxlib, #box_lib_init,0);
-
 
55
	loop() 
-
 
56
	{
55
	load_dll(boxlib, #box_lib_init,0);
57
	  WaitEventTimeout(10);
-
 
58
	  switch(EAX & 0xFF)
56
	loop() switch(@WaitEventTimeout(10))
59
	  {
57
	{
60
	  	case evMouse:
58
	  	case evMouse:
61
			SelectList_ProcessMouse();
59
			SelectList_ProcessMouse();
Line 62... Line 60...
62
	  		break;
60
	  		break;
63
 
61
 
64
		case evButton:
62
		case evButton:
65
			id = GetButtonID();
63
			@GetButtonID();
66
			if (id==1) ExitProcess();
64
			if (id==1) ExitProcess();
67
			if (id==BT_DELETE_LAST_SLOT) EventDeleteLastSlot();
65
			if (id==BT_DELETE_LAST_SLOT) EventDeleteLastSlot();
68
			if (id==BT_DELETE_ALL_SLOTS) EventDeleteAllSlots();
66
			if (id==BT_DELETE_ALL_SLOTS) EventDeleteAllSlots();
69
			if (id==BT_UNLOCK) EventResetBufferLock();
67
			if (id==BT_UNLOCK) EventResetBufferLock();
70
			if (id>=100) && (id<300) EventOpenAsText(id-100);
68
			if (id>=100) && (id<300) EventOpenAsText(id-100);
Line 71... Line 69...
71
			if (id>=300) EventOpenAsHex(id-300);
69
			if (id>=300) EventOpenAsHex(id-300);
72
			break;
70
			break;
73
	  
71
	  
-
 
72
		case evKey:
74
		case evKey:
73
			if (select_list.ProcessKey(@GetKeyScancode())) {
Line 75... Line 74...
75
			GetKeys(); 
74
				ClipViewSelectListDraw();
76
			if (select_list.ProcessKey(key_scancode)) ClipViewSelectListDraw();
75
			}
77
			break;
76
			break;
78
		 
77
		 
79
		case evReDraw:
78
		case evReDraw:
80
			sc.get();			
79
			sc.get();			
81
			DefineAndDrawWindow(screen.width-700/2,80,700,454+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0);
80
			DefineAndDrawWindow(screen.width-700/2,80,700,454+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0);
82
			GetProcessInfo(#Form, SelfInfo);
81
			GetProcessInfo(#Form, SelfInfo);
83
			IF (Form.status_window>=2) break;
82
			IF (Form.status_window>=2) break;
84
			if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; }
83
			IF (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; }
85
			if (Form.width  < 570) { MoveSize(OLD,OLD,570,OLD); break; }
84
			IF (Form.width  < 570) { MoveSize(OLD,OLD,570,OLD); break; }
86
			SelectList_Init(
85
			SelectList_Init(
Line 96... Line 95...
96
		default:
95
		default:
97
			if (Clipboard__GetSlotCount() > select_list.count) ClipViewSelectListDraw();
96
			if (Clipboard__GetSlotCount() > select_list.count) ClipViewSelectListDraw();
98
			break;
97
			break;
99
	  }
98
   }
100
   }
99
}
101
}
-
 
Line 102... Line 100...
102
 
100
 
103
void DrawWindowContent()
101
void DrawWindowContent()
104
{
102
{
105
	int button_x = select_list.x;
103
	int button_x = select_list.x;
106
	DrawBar(0,0, Form.cwidth, PANEL_TOP_H, sc.work);
104
	DrawBar(0,0, Form.cwidth, PANEL_TOP_H, sc.work);
107
	DrawBar(0,Form.cheight-PANEL_BOTTOM_H, Form.cwidth, PANEL_BOTTOM_H, sc.work);
105
	DrawBar(0,Form.cheight-PANEL_BOTTOM_H, Form.cwidth, PANEL_BOTTOM_H, sc.work);
108
	DrawWideRectangle(select_list.x-LIST_PADDING, select_list.y-LIST_PADDING, LIST_PADDING*2+select_list.w+scroll1.size_x, LIST_PADDING*2+select_list.h, LIST_PADDING-2, sc.work);
106
	DrawWideRectangle(select_list.x-LIST_PADDING, select_list.y-LIST_PADDING, LIST_PADDING*2+select_list.w+scroll1.size_x, LIST_PADDING*2+select_list.h, LIST_PADDING-2, sc.work);
109
	button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_DELETE_LAST_SLOT, T_DELETE_LAST_SLOT);
107
	button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_DELETE_LAST_SLOT, T_DELETE_LAST_SLOT);
110
	button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_DELETE_ALL_SLOTS, T_DELETE_ALL_SLOTS);
108
	button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_DELETE_ALL_SLOTS, T_DELETE_ALL_SLOTS);
111
	button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_UNLOCK, T_RESET_BUFFER_LOCK);
109
	button_x += DrawStandartCaptButton(button_x, select_list.y + select_list.h + 8, BT_UNLOCK, T_RESET_BUFFER_LOCK);
112
	WriteText(select_list.x+12, select_list.y - 23, select_list.font_type, sc.work_text, T_COLUMNS_TITLE);
110
	WriteText(select_list.x+12, select_list.y - 23, 0x90, sc.work_text, T_COLUMNS_TITLE);
113
	WriteText(select_list.x+select_list.w - 88-14, select_list.y - 23, select_list.font_type, sc.work_text, T_COLUMN_VIEW);
111
	WriteText(select_list.x+select_list.w - 88-14, select_list.y - 23, 0x90, sc.work_text, T_COLUMN_VIEW);
114
 	ClipViewSelectListDraw();
112
 	ClipViewSelectListDraw();
115
 	SelectList_DrawBorder();
113
 	SelectList_DrawBorder();
Line 116... Line 114...
116
}
114
}
Line 127... Line 125...
127
 
125
 
128
void SelectList_DrawLine(dword i)
126
void SelectList_DrawLine(dword i)
129
{
127
{
130
	int yyy, length, slot_data_type_number;
128
	int yyy, length, slot_data_type_number;
131
	dword line_text[2048];
-
 
132
	dword size_kb;
-
 
133
	dword text_color = 0;
-
 
134
	dword bgcol = 0xFFFfff;
-
 
Line 135... Line 129...
135
	if (i%2) bgcol = 0xF1F1F1;
129
	dword line_text[2048];
136
 
130
 
137
	slot_data = Clipboard__GetSlotData(select_list.first + i);
131
	slot_data = Clipboard__GetSlotData(select_list.first + i);
138
	cdata.size = ESDWORD[slot_data];
132
	cdata.size = ESDWORD[slot_data];
Line 142... Line 136...
142
	else 
136
	else 
143
		cdata.content_offset = 8;
137
		cdata.content_offset = 8;
144
	cdata.content = slot_data + cdata.content_offset; 
138
	cdata.content = slot_data + cdata.content_offset; 
Line 145... Line 139...
145
 
139
 
146
	yyy = i*select_list.item_h+select_list.y;
140
	yyy = i*select_list.item_h+select_list.y;
147
	DrawBar(select_list.x+1, yyy, select_list.w-1, select_list.item_h, bgcol);
141
	DrawBar(select_list.x+1, yyy, select_list.w-1, select_list.item_h, -i%2 * 0x0E0E0E + 0xF1F1f1);
148
	WriteText(select_list.x+12, yyy+select_list.text_y, select_list.font_type, text_color, itoa(select_list.first + i));
142
	WriteText(select_list.x+12, yyy+select_list.text_y, 0x90, 0x000000, itoa(select_list.first + i));
149
	size_kb = ConvertSizeToKb(cdata.size);
143
	EDX = ConvertSizeToKb(cdata.size);
150
	WriteText(select_list.x+44, yyy+select_list.text_y, select_list.font_type, text_color, size_kb);
144
	WriteText(select_list.x+44, yyy+select_list.text_y, 0x90, 0x000000, EDX);
151
	slot_data_type_number = cdata.type;
145
	slot_data_type_number = cdata.type;
152
	WriteText(select_list.x+140, yyy+select_list.text_y, select_list.font_type, text_color, data_type[slot_data_type_number]);
146
	WriteText(select_list.x+140, yyy+select_list.text_y, 0x90, 0x000000, data_type[slot_data_type_number]);
153
	WriteText(select_list.x+select_list.w - 88, yyy+select_list.text_y, select_list.font_type, 0x006597, T_VIEW_OPTIONS);
147
	WriteText(select_list.x+select_list.w - 88, yyy+select_list.text_y, 0x90, 0x006597, T_VIEW_OPTIONS);
154
	DefineButton(select_list.x+select_list.w - 95, yyy, 50, select_list.item_h, 100+i+BT_HIDE, NULL);
148
	DefineButton(select_list.x+select_list.w - 95, yyy, 50, select_list.item_h, 100+i+BT_HIDE, NULL);
Line 155... Line 149...
155
	DefineButton(select_list.x+select_list.w - 95 + 51, yyy, 40, select_list.item_h, 300+i+BT_HIDE, NULL);
149
	DefineButton(select_list.x+select_list.w - 95 + 51, yyy, 40, select_list.item_h, 300+i+BT_HIDE, NULL);
156
 
150
 
157
	length = select_list.w-236 - 95 / select_list.font_w - 2;
151
	length = select_list.w-236 - 95 / select_list.font_w - 2;
158
	if (cdata.size - cdata.content_offset < length) length = cdata.size - cdata.content_offset;
152
	if (cdata.size - cdata.content_offset < length) length = cdata.size - cdata.content_offset;
159
	memmov(#line_text, cdata.content, length);
153
	strlcpy(#line_text, cdata.content, length);
160
	replace_char(#line_text, 0, 31, length); // 31 is a dot
154
	replace_char(#line_text, 0, 31, length); // 31 is a dot
Line 161... Line 155...
161
	WriteText(select_list.x+236, yyy+select_list.text_y, select_list.font_type, text_color, #line_text);
155
	WriteText(select_list.x+236, yyy+select_list.text_y, 0x90, 0x000000, #line_text);
162
}
156
}
163
 
-
 
164
int SaveSlotContents(dword size, off) {
-
 
165
	EAX = CreateFile(size, off, DEFAULT_SAVE_PATH);
157
 
166
	if (!EAX)
-
 
167
	{
158
int SaveSlotContents(dword size, off) {
168
		return true;
159
	if (! CreateFile(size, off, DEFAULT_SAVE_PATH))	{
169
	}
160
		return true;
170
	else {
161
	} else {
171
		notify("'Can not create /tmp0/1/clipview.tmp\nPreview function is not available.' -E");
162
		notify("'Can not create /tmp0/1/clipview.tmp\nPreview function is not available.' -E");