moved duplicate code to a common location.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21459 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2007, Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Stefano Ceccherini <[email protected]>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Various private functions and variables for the Interface Kit */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __INTERFACE_MISC_H
|
||||||
|
#define __INTERFACE_MISC_H
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
bool get_mode_parameter(uint32 mode, int32& width, int32& height, uint32& colorSpace);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <input_globals.h>
|
#include <input_globals.h>
|
||||||
#include <InputServerTypes.h> // For IS_SET_MOUSE_POSITION
|
#include <InputServerTypes.h> // For IS_SET_MOUSE_POSITION
|
||||||
|
#include <interface_misc.h>
|
||||||
#include <WindowPrivate.h>
|
#include <WindowPrivate.h>
|
||||||
|
|
||||||
#include <AppServerLink.h>
|
#include <AppServerLink.h>
|
||||||
@@ -167,103 +168,6 @@ draw_rect_32(int32 sx, int32 sy, int32 sw, int32 sh, uint32 color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Fills the \a width, \a height, and \a colorSpace parameters according
|
|
||||||
to the window screen's mode.
|
|
||||||
Returns \c true if the mode is known.
|
|
||||||
*/
|
|
||||||
static bool
|
|
||||||
get_mode_parameter(uint32 mode, int32& width, int32& height, uint32& colorSpace)
|
|
||||||
{
|
|
||||||
switch (mode) {
|
|
||||||
case B_8_BIT_640x480:
|
|
||||||
case B_8_BIT_800x600:
|
|
||||||
case B_8_BIT_1024x768:
|
|
||||||
case B_8_BIT_1152x900:
|
|
||||||
case B_8_BIT_1280x1024:
|
|
||||||
case B_8_BIT_1600x1200:
|
|
||||||
colorSpace = B_CMAP8;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_15_BIT_640x480:
|
|
||||||
case B_15_BIT_800x600:
|
|
||||||
case B_15_BIT_1024x768:
|
|
||||||
case B_15_BIT_1152x900:
|
|
||||||
case B_15_BIT_1280x1024:
|
|
||||||
case B_15_BIT_1600x1200:
|
|
||||||
colorSpace = B_RGB15;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_16_BIT_640x480:
|
|
||||||
case B_16_BIT_800x600:
|
|
||||||
case B_16_BIT_1024x768:
|
|
||||||
case B_16_BIT_1152x900:
|
|
||||||
case B_16_BIT_1280x1024:
|
|
||||||
case B_16_BIT_1600x1200:
|
|
||||||
colorSpace = B_RGB16;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_32_BIT_640x480:
|
|
||||||
case B_32_BIT_800x600:
|
|
||||||
case B_32_BIT_1024x768:
|
|
||||||
case B_32_BIT_1152x900:
|
|
||||||
case B_32_BIT_1280x1024:
|
|
||||||
case B_32_BIT_1600x1200:
|
|
||||||
colorSpace = B_RGB32;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (mode) {
|
|
||||||
case B_8_BIT_640x480:
|
|
||||||
case B_15_BIT_640x480:
|
|
||||||
case B_16_BIT_640x480:
|
|
||||||
case B_32_BIT_640x480:
|
|
||||||
width = 640; height = 480;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_8_BIT_800x600:
|
|
||||||
case B_15_BIT_800x600:
|
|
||||||
case B_16_BIT_800x600:
|
|
||||||
case B_32_BIT_800x600:
|
|
||||||
width = 800; height = 600;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_8_BIT_1024x768:
|
|
||||||
case B_15_BIT_1024x768:
|
|
||||||
case B_16_BIT_1024x768:
|
|
||||||
case B_32_BIT_1024x768:
|
|
||||||
width = 1024; height = 768;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_8_BIT_1152x900:
|
|
||||||
case B_15_BIT_1152x900:
|
|
||||||
case B_16_BIT_1152x900:
|
|
||||||
case B_32_BIT_1152x900:
|
|
||||||
width = 1152; height = 900;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_8_BIT_1280x1024:
|
|
||||||
case B_15_BIT_1280x1024:
|
|
||||||
case B_16_BIT_1280x1024:
|
|
||||||
case B_32_BIT_1280x1024:
|
|
||||||
width = 1280; height = 1024;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_8_BIT_1600x1200:
|
|
||||||
case B_15_BIT_1600x1200:
|
|
||||||
case B_16_BIT_1600x1200:
|
|
||||||
case B_32_BIT_1600x1200:
|
|
||||||
width = 1600; height = 1200;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - public API calls
|
// #pragma mark - public API calls
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,9 @@
|
|||||||
|
|
||||||
/** Global functions and variables for the Interface Kit */
|
/** Global functions and variables for the Interface Kit */
|
||||||
|
|
||||||
#include "truncate_string.h"
|
#include <interface_misc.h>
|
||||||
#include "utf8_functions.h"
|
#include <truncate_string.h>
|
||||||
|
#include <utf8_functions.h>
|
||||||
|
|
||||||
#include <ApplicationPrivate.h>
|
#include <ApplicationPrivate.h>
|
||||||
#include <AppServerLink.h>
|
#include <AppServerLink.h>
|
||||||
@@ -91,114 +92,100 @@ static const rgb_color _kDefaultColors[kNumColors] = {
|
|||||||
const rgb_color* BPrivate::kDefaultColors = &_kDefaultColors[0];
|
const rgb_color* BPrivate::kDefaultColors = &_kDefaultColors[0];
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
/*!
|
||||||
mode2parms(uint32 space, uint32 *out_space, int32 *width, int32 *height)
|
Fills the \a width, \a height, and \a colorSpace parameters according
|
||||||
|
to the window screen's mode.
|
||||||
|
Returns \c true if the mode is known.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
get_mode_parameter(uint32 mode, int32& width, int32& height, uint32& colorSpace)
|
||||||
{
|
{
|
||||||
status_t status = B_OK;
|
switch (mode) {
|
||||||
|
|
||||||
switch (space) {
|
|
||||||
case B_8_BIT_640x480:
|
case B_8_BIT_640x480:
|
||||||
*out_space = B_CMAP8;
|
|
||||||
*width = 640; *height = 480;
|
|
||||||
break;
|
|
||||||
case B_8_BIT_800x600:
|
case B_8_BIT_800x600:
|
||||||
*out_space = B_CMAP8;
|
|
||||||
*width = 800; *height = 600;
|
|
||||||
break;
|
|
||||||
case B_8_BIT_1024x768:
|
case B_8_BIT_1024x768:
|
||||||
*out_space = B_CMAP8;
|
case B_8_BIT_1152x900:
|
||||||
*width = 1024; *height = 768;
|
|
||||||
break;
|
|
||||||
case B_8_BIT_1280x1024:
|
case B_8_BIT_1280x1024:
|
||||||
*out_space = B_CMAP8;
|
|
||||||
*width = 1280; *height = 1024;
|
|
||||||
break;
|
|
||||||
case B_8_BIT_1600x1200:
|
case B_8_BIT_1600x1200:
|
||||||
*out_space = B_CMAP8;
|
colorSpace = B_CMAP8;
|
||||||
*width = 1600; *height = 1200;
|
|
||||||
break;
|
break;
|
||||||
case B_16_BIT_640x480:
|
|
||||||
*out_space = B_RGB16;
|
|
||||||
*width = 640; *height = 480;
|
|
||||||
break;
|
|
||||||
case B_16_BIT_800x600:
|
|
||||||
*out_space = B_RGB16;
|
|
||||||
*width = 800; *height = 600;
|
|
||||||
break;
|
|
||||||
case B_16_BIT_1024x768:
|
|
||||||
*out_space = B_RGB16;
|
|
||||||
*width = 1024; *height = 768;
|
|
||||||
break;
|
|
||||||
case B_16_BIT_1280x1024:
|
|
||||||
*out_space = B_RGB16;
|
|
||||||
*width = 1280; *height = 1024;
|
|
||||||
break;
|
|
||||||
case B_16_BIT_1600x1200:
|
|
||||||
*out_space = B_RGB16;
|
|
||||||
*width = 1600; *height = 1200;
|
|
||||||
break;
|
|
||||||
case B_32_BIT_640x480:
|
|
||||||
*out_space = B_RGB32;
|
|
||||||
*width = 640; *height = 480;
|
|
||||||
break;
|
|
||||||
case B_32_BIT_800x600:
|
|
||||||
*out_space = B_RGB32;
|
|
||||||
*width = 800; *height = 600;
|
|
||||||
break;
|
|
||||||
case B_32_BIT_1024x768:
|
|
||||||
*out_space = B_RGB32;
|
|
||||||
*width = 1024; *height = 768;
|
|
||||||
break;
|
|
||||||
case B_32_BIT_1280x1024:
|
|
||||||
*out_space = B_RGB32;
|
|
||||||
*width = 1280; *height = 1024;
|
|
||||||
break;
|
|
||||||
case B_32_BIT_1600x1200:
|
|
||||||
*out_space = B_RGB32;
|
|
||||||
*width = 1600; *height = 1200;
|
|
||||||
break;
|
|
||||||
case B_8_BIT_1152x900:
|
|
||||||
*out_space = B_CMAP8;
|
|
||||||
*width = 1152; *height = 900;
|
|
||||||
break;
|
|
||||||
case B_16_BIT_1152x900:
|
|
||||||
*out_space = B_RGB16;
|
|
||||||
*width = 1152; *height = 900;
|
|
||||||
break;
|
|
||||||
case B_32_BIT_1152x900:
|
|
||||||
*out_space = B_RGB32;
|
|
||||||
*width = 1152; *height = 900;
|
|
||||||
break;
|
|
||||||
case B_15_BIT_640x480:
|
case B_15_BIT_640x480:
|
||||||
*out_space = B_RGB15;
|
|
||||||
*width = 640; *height = 480;
|
|
||||||
break;
|
|
||||||
case B_15_BIT_800x600:
|
case B_15_BIT_800x600:
|
||||||
*out_space = B_RGB15;
|
|
||||||
*width = 800; *height = 600;
|
|
||||||
break;
|
|
||||||
case B_15_BIT_1024x768:
|
case B_15_BIT_1024x768:
|
||||||
*out_space = B_RGB15;
|
case B_15_BIT_1152x900:
|
||||||
*width = 1024; *height = 768;
|
|
||||||
break;
|
|
||||||
case B_15_BIT_1280x1024:
|
case B_15_BIT_1280x1024:
|
||||||
*out_space = B_RGB15;
|
|
||||||
*width = 1280; *height = 1024;
|
|
||||||
break;
|
|
||||||
case B_15_BIT_1600x1200:
|
case B_15_BIT_1600x1200:
|
||||||
*out_space = B_RGB15;
|
colorSpace = B_RGB15;
|
||||||
*width = 1600; *height = 1200;
|
break;
|
||||||
|
|
||||||
|
case B_16_BIT_640x480:
|
||||||
|
case B_16_BIT_800x600:
|
||||||
|
case B_16_BIT_1024x768:
|
||||||
|
case B_16_BIT_1152x900:
|
||||||
|
case B_16_BIT_1280x1024:
|
||||||
|
case B_16_BIT_1600x1200:
|
||||||
|
colorSpace = B_RGB16;
|
||||||
break;
|
break;
|
||||||
case B_15_BIT_1152x900:
|
|
||||||
*out_space = B_RGB15;
|
case B_32_BIT_640x480:
|
||||||
*width = 1152; *height = 900;
|
case B_32_BIT_800x600:
|
||||||
break;
|
case B_32_BIT_1024x768:
|
||||||
default:
|
case B_32_BIT_1152x900:
|
||||||
status = B_BAD_VALUE;
|
case B_32_BIT_1280x1024:
|
||||||
break;
|
case B_32_BIT_1600x1200:
|
||||||
|
colorSpace = B_RGB32;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
switch (mode) {
|
||||||
|
case B_8_BIT_640x480:
|
||||||
|
case B_15_BIT_640x480:
|
||||||
|
case B_16_BIT_640x480:
|
||||||
|
case B_32_BIT_640x480:
|
||||||
|
width = 640; height = 480;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_8_BIT_800x600:
|
||||||
|
case B_15_BIT_800x600:
|
||||||
|
case B_16_BIT_800x600:
|
||||||
|
case B_32_BIT_800x600:
|
||||||
|
width = 800; height = 600;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_8_BIT_1024x768:
|
||||||
|
case B_15_BIT_1024x768:
|
||||||
|
case B_16_BIT_1024x768:
|
||||||
|
case B_32_BIT_1024x768:
|
||||||
|
width = 1024; height = 768;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_8_BIT_1152x900:
|
||||||
|
case B_15_BIT_1152x900:
|
||||||
|
case B_16_BIT_1152x900:
|
||||||
|
case B_32_BIT_1152x900:
|
||||||
|
width = 1152; height = 900;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_8_BIT_1280x1024:
|
||||||
|
case B_15_BIT_1280x1024:
|
||||||
|
case B_16_BIT_1280x1024:
|
||||||
|
case B_32_BIT_1280x1024:
|
||||||
|
width = 1280; height = 1024;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_8_BIT_1600x1200:
|
||||||
|
case B_15_BIT_1600x1200:
|
||||||
|
case B_16_BIT_1600x1200:
|
||||||
|
case B_32_BIT_1600x1200:
|
||||||
|
width = 1600; height = 1200;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -215,10 +202,8 @@ set_screen_space(int32 index, uint32 space, bool stick)
|
|||||||
int32 width;
|
int32 width;
|
||||||
int32 height;
|
int32 height;
|
||||||
uint32 depth;
|
uint32 depth;
|
||||||
|
if (!get_mode_parameter(space, width, height, depth))
|
||||||
status_t status = mode2parms(space, &depth, &width, &height);
|
return B_BAD_VALUE;
|
||||||
if (status < B_OK)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
BScreen screen(B_MAIN_SCREEN_ID);
|
BScreen screen(B_MAIN_SCREEN_ID);
|
||||||
display_mode mode;
|
display_mode mode;
|
||||||
@@ -226,7 +211,7 @@ set_screen_space(int32 index, uint32 space, bool stick)
|
|||||||
// TODO: What about refresh rate ?
|
// TODO: What about refresh rate ?
|
||||||
// currently we get it from the current video mode, but
|
// currently we get it from the current video mode, but
|
||||||
// this might be not so wise.
|
// this might be not so wise.
|
||||||
status = screen.GetMode(index, &mode);
|
status_t status = screen.GetMode(index, &mode);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user